Rev 6115 | Rev 6142 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6115 | Rev 6137 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | #include "pxgl.h" |
8 | #include "pxgl.h" |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | #define WIN_STATE_MINIMIZED 0x02 |
10 | #define WIN_STATE_MINIMIZED 0x02 |
Line -... | Line 11... | ||
- | 11 | #define WIN_STATE_ROLLED 0x04 |
|
- | 12 | ||
11 | #define WIN_STATE_ROLLED 0x04 |
13 | #define LINE() printf("%s line %d\n", __FUNCTION__,__LINE__) |
12 | 14 | ||
13 | static int drm_ioctl(int fd, unsigned long request, void *arg) |
15 | static int drm_ioctl(int fd, unsigned long request, void *arg) |
Line 14... | Line 16... | ||
14 | { |
16 | { |
Line 123... | Line 125... | ||
123 | DBG("%s %s\n", __FUNCTION__, errmsg); |
125 | DBG("%s %s\n", __FUNCTION__, errmsg); |
Line 124... | Line 126... | ||
124 | 126 | ||
125 | return -1; |
127 | return -1; |
Line 126... | Line -... | ||
126 | }; |
- | |
127 | - | ||
128 | static GLint create_shader(GLenum type, const char *source) |
- | |
129 | { |
- | |
130 | GLint ok; |
- | |
131 | GLint shader; |
- | |
132 | - | ||
133 | shader = glCreateShader(type); |
- | |
134 | if(shader == 0) |
- | |
135 | goto err; |
- | |
136 | - | ||
137 | glShaderSource(shader, 1, (const GLchar **) &source, NULL); |
- | |
138 | glCompileShader(shader); |
- | |
139 | glGetShaderiv(shader, GL_COMPILE_STATUS, &ok); |
- | |
140 | if (!ok) { |
- | |
141 | GLchar *info; |
- | |
142 | GLint size; |
- | |
143 | - | ||
144 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &size); |
- | |
145 | info = malloc(size); |
- | |
146 | - | ||
147 | glGetShaderInfoLog(shader, size, NULL, info); |
- | |
148 | DBG("Failed to compile %s: %s\n", |
- | |
149 | type == GL_FRAGMENT_SHADER ? "FS" : "VS",info); |
- | |
150 | DBG("Program source:\n%s", source); |
- | |
151 | DBG("GLSL compile failure\n"); |
- | |
152 | free(info); |
- | |
153 | glDeleteShader(shader); |
- | |
154 | shader = 0; |
- | |
155 | }; |
- | |
156 | - | ||
157 | DBG("create shader %d\n", shader); |
- | |
158 | err: |
- | |
Line 159... | Line 128... | ||
159 | return shader; |
128 | }; |
160 | } |
129 | |
161 | 130 | ||
Line 345... | Line 314... | ||
345 | drm_ioctl(px->fd, DRM_IOCTL_GEM_CLOSE, &close); |
314 | drm_ioctl(px->fd, DRM_IOCTL_GEM_CLOSE, &close); |
346 | err_0: |
315 | err_0: |
347 | return -1; |
316 | return -1; |
348 | }; |
317 | }; |
Line 349... | Line 318... | ||
349 | 318 | ||
- | 319 | static GLint create_shader(GLenum type, const char *source) |
|
- | 320 | { |
|
- | 321 | GLint ok; |
|
- | 322 | GLint shader; |
|
- | 323 | ||
- | 324 | shader = glCreateShader(type); |
|
- | 325 | if(shader == 0) |
|
- | 326 | goto err; |
|
- | 327 | ||
- | 328 | glShaderSource(shader, 1, (const GLchar **) &source, NULL); |
|
- | 329 | glCompileShader(shader); |
|
- | 330 | glGetShaderiv(shader, GL_COMPILE_STATUS, &ok); |
|
- | 331 | if (!ok) { |
|
- | 332 | GLchar *info; |
|
- | 333 | GLint size; |
|
- | 334 | ||
- | 335 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &size); |
|
- | 336 | info = malloc(size); |
|
- | 337 | ||
- | 338 | glGetShaderInfoLog(shader, size, NULL, info); |
|
- | 339 | DBG("Failed to compile %s: %s\n", |
|
- | 340 | type == GL_FRAGMENT_SHADER ? "FS" : "VS",info); |
|
- | 341 | DBG("Program source:\n%s", source); |
|
- | 342 | DBG("GLSL compile failure\n"); |
|
- | 343 | free(info); |
|
- | 344 | glDeleteShader(shader); |
|
- | 345 | shader = 0; |
|
- | 346 | }; |
|
- | 347 | ||
- | 348 | DBG("create shader %d\n", shader); |
|
- | 349 | err: |
|
- | 350 | return shader; |
|
- | 351 | } |
|
- | 352 | ||
- | 353 | static GLuint create_rgba_shader(struct shader *shader) |
|
- | 354 | { |
|
- | 355 | const char *vs_src = |
|
- | 356 | "attribute vec4 v_position;\n" |
|
- | 357 | "attribute vec4 v_texcoord0;\n" |
|
- | 358 | "varying vec2 tex_coord;\n" |
|
- | 359 | "void main()\n" |
|
- | 360 | "{\n" |
|
- | 361 | " gl_Position = v_position;\n" |
|
- | 362 | " tex_coord = v_texcoord0.xy;\n" |
|
- | 363 | "}\n"; |
|
- | 364 | ||
- | 365 | const char *fs_rgba = |
|
- | 366 | "uniform sampler2D tex_rgba;\n" |
|
- | 367 | "uniform sampler2D tex_mask;\n" |
|
- | 368 | "varying vec2 tex_coord;\n" |
|
- | 369 | "void main()\n" |
|
- | 370 | "{\n" |
|
- | 371 | " float ca = texture2D(tex_mask, tex_coord).r;\n" |
|
- | 372 | " gl_FragColor = vec4(texture2D(tex_rgba, tex_coord).rgb, ca);\n" |
|
- | 373 | "}\n"; |
|
- | 374 | ||
- | 375 | GLuint prog; |
|
- | 376 | GLint vs_shader, fs_shader; |
|
- | 377 | int ret; |
|
- | 378 | ||
- | 379 | prog = glCreateProgram(); |
|
- | 380 | if(prog == 0) |
|
- | 381 | goto err; |
|
- | 382 | ||
- | 383 | vs_shader = create_shader(GL_VERTEX_SHADER, vs_src); |
|
- | 384 | if(vs_shader == 0) |
|
- | 385 | goto err; |
|
- | 386 | ||
- | 387 | fs_shader = create_shader(GL_FRAGMENT_SHADER, fs_rgba); |
|
- | 388 | if(fs_shader == 0) |
|
- | 389 | goto err; |
|
- | 390 | ||
- | 391 | glAttachShader(prog, vs_shader); |
|
- | 392 | glAttachShader(prog, fs_shader); |
|
- | 393 | glBindAttribLocation(prog, 0, "v_position"); |
|
- | 394 | glBindAttribLocation(prog, 1, "v_texcoord0"); |
|
- | 395 | ||
- | 396 | glLinkProgram(prog); |
|
- | 397 | glGetProgramiv(prog, GL_LINK_STATUS, &ret); |
|
- | 398 | if (!ret) |
|
- | 399 | { |
|
- | 400 | GLchar *info; |
|
- | 401 | GLint size; |
|
- | 402 | ||
- | 403 | glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size); |
|
- | 404 | info = malloc(size); |
|
- | 405 | ||
- | 406 | glGetProgramInfoLog(prog, size, NULL, info); |
|
- | 407 | DBG("Failed to link: %s\n", info); |
|
- | 408 | DBG("GLSL link failure\n"); |
|
- | 409 | free(info); |
|
- | 410 | goto err; |
|
- | 411 | } |
|
- | 412 | ||
- | 413 | shader->sampler0 = glGetUniformLocation(prog,"tex_rgba"); |
|
- | 414 | shader->sm_mask = glGetUniformLocation(prog,"tex_mask"); |
|
- | 415 | shader->blit_prog = prog; |
|
- | 416 | return prog; |
|
- | 417 | err: |
|
- | 418 | return 0; |
|
- | 419 | } |
|
- | 420 | ||
350 | static struct render* create_render(EGLDisplay dpy, EGLContext context, int dx, int dy, int w, int h) |
421 | static GLuint create_y_uv_shader(struct shader *shader) |
351 | { |
422 | { |
352 | const char *vs_src = |
423 | const char *vs_src = |
353 | "attribute vec4 v_position;\n" |
424 | "attribute vec4 v_position;\n" |
354 | "attribute vec4 v_texcoord0;\n" |
425 | "attribute vec4 v_texcoord0;\n" |
355 | "varying vec2 source_texture;\n" |
426 | "varying vec2 tex_coord;\n" |
356 | "void main()\n" |
427 | "void main()\n" |
357 | "{\n" |
428 | "{\n" |
358 | " gl_Position = v_position;\n" |
429 | " gl_Position = v_position;\n" |
359 | " source_texture = v_texcoord0.xy;\n" |
430 | " tex_coord = v_texcoord0.xy;\n" |
Line 360... | Line 431... | ||
360 | "}\n"; |
431 | "}\n"; |
361 | 432 | ||
362 | const char *fs_i965 = |
433 | const char *fs_y_uv = |
363 | "varying vec2 source_texture;\n" |
434 | "uniform sampler2D tex_src_y;\n" |
- | 435 | "uniform sampler2D tex_src_uv;\n" |
|
364 | "uniform sampler2D sampler_src;\n" |
436 | "uniform sampler2D tex_mask;\n" |
365 | "uniform sampler2D sampler_mask;\n" |
437 | "varying vec2 tex_coord;\n" |
- | 438 | "void main()\n" |
|
- | 439 | "{\n" |
|
366 | "void main()\n" |
440 | " float y = 1.16438356 * (texture2D(tex_src_y, tex_coord).x - 0.0625);\n" |
- | 441 | " float u = texture2D(tex_src_uv, tex_coord).r - 0.5;\n" |
|
- | 442 | " float v = texture2D(tex_src_uv, tex_coord).g - 0.5;\n" |
|
- | 443 | " gl_FragColor.r = y + 1.59602678 * v;\n" \ |
|
367 | "{\n" |
444 | " gl_FragColor.g = y - 0.39176229 * u - 0.81296764 * v;\n" \ |
368 | " float ca = texture2D(sampler_mask, source_texture).r;\n" |
445 | " gl_FragColor.b = y + 2.01723214 * u;\n" \ |
Line -... | Line 446... | ||
- | 446 | " gl_FragColor.a = texture2D(tex_mask, tex_coord).r;\n" |
|
- | 447 | "}\n"; |
|
- | 448 | ||
- | 449 | GLuint prog; |
|
- | 450 | GLint vs_shader, fs_shader; |
|
- | 451 | int ret; |
|
- | 452 | ||
- | 453 | prog = glCreateProgram(); |
|
- | 454 | if(prog == 0) |
|
- | 455 | goto err; |
|
- | 456 | ||
- | 457 | vs_shader = create_shader(GL_VERTEX_SHADER, vs_src); |
|
- | 458 | if(vs_shader == 0) |
|
- | 459 | goto err; |
|
- | 460 | ||
- | 461 | fs_shader = create_shader(GL_FRAGMENT_SHADER, fs_y_uv); |
|
- | 462 | if(fs_shader == 0) |
|
- | 463 | goto err; |
|
- | 464 | ||
- | 465 | glAttachShader(prog, vs_shader); |
|
- | 466 | glAttachShader(prog, fs_shader); |
|
- | 467 | glBindAttribLocation(prog, 0, "v_position"); |
|
- | 468 | glBindAttribLocation(prog, 1, "v_texcoord0"); |
|
- | 469 | ||
- | 470 | glLinkProgram(prog); |
|
- | 471 | glGetProgramiv(prog, GL_LINK_STATUS, &ret); |
|
- | 472 | if (!ret) |
|
- | 473 | { |
|
- | 474 | GLchar *info; |
|
- | 475 | GLint size; |
|
- | 476 | ||
- | 477 | glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size); |
|
- | 478 | info = malloc(size); |
|
- | 479 | ||
- | 480 | glGetProgramInfoLog(prog, size, NULL, info); |
|
- | 481 | DBG("Failed to link: %s\n", info); |
|
- | 482 | DBG("GLSL link failure\n"); |
|
- | 483 | free(info); |
|
- | 484 | goto err; |
|
- | 485 | } |
|
- | 486 | ||
- | 487 | shader->sampler0 = glGetUniformLocation(prog,"tex_src_y"); |
|
- | 488 | shader->sampler1 = glGetUniformLocation(prog,"tex_src_uv"); |
|
- | 489 | shader->sm_mask = glGetUniformLocation(prog,"tex_mask"); |
|
- | 490 | shader->blit_prog = prog; |
|
- | 491 | return prog; |
|
- | 492 | err: |
|
- | 493 | return 0; |
|
- | 494 | } |
|
- | 495 | ||
369 | " gl_FragColor = vec4(texture2D(sampler_src, source_texture).rgb, ca);\n" |
496 | static struct render* create_render(EGLDisplay dpy, EGLContext context, int dx, int dy, int w, int h) |
370 | "}\n"; |
497 | { |
371 | - | ||
- | 498 | ||
372 | struct drm_i915_fb_info fb; |
499 | struct drm_i915_fb_info fb; |
Line 373... | Line 500... | ||
373 | struct render *px; |
500 | struct render *px; |
374 | GLint vs_shader, fs_shader; |
501 | |
375 | int ret; |
502 | int ret; |
Line 416... | Line 543... | ||
416 | glLoadIdentity(); |
543 | glLoadIdentity(); |
Line 417... | Line 544... | ||
417 | 544 | ||
418 | if(create_mask(px)) |
545 | if(create_mask(px)) |
Line 419... | Line -... | ||
419 | goto err_4; |
- | |
420 | - | ||
421 | px->blit_prog = glCreateProgram(); |
- | |
422 | if(px->blit_prog == 0) |
- | |
423 | goto err_4; |
- | |
424 | - | ||
425 | vs_shader = create_shader(GL_VERTEX_SHADER, vs_src); |
- | |
426 | if(vs_shader == 0) |
- | |
427 | goto err_4; |
- | |
428 | - | ||
429 | fs_shader = create_shader(GL_FRAGMENT_SHADER, fs_i965); |
- | |
430 | if(fs_shader == 0) |
- | |
431 | goto err_4; |
- | |
432 | 546 | goto err_4; |
|
433 | glAttachShader(px->blit_prog, vs_shader); |
- | |
434 | glAttachShader(px->blit_prog, fs_shader); |
- | |
435 | glBindAttribLocation(px->blit_prog, 0, "v_position"); |
- | |
436 | glBindAttribLocation(px->blit_prog, 1, "v_texcoord0"); |
- | |
437 | - | ||
438 | glLinkProgram(px->blit_prog); |
- | |
439 | glGetProgramiv(px->blit_prog, GL_LINK_STATUS, &ret); |
- | |
440 | if (!ret) |
- | |
441 | { |
- | |
442 | GLchar *info; |
- | |
443 | GLint size; |
- | |
444 | - | ||
445 | glGetProgramiv(px->blit_prog, GL_INFO_LOG_LENGTH, &size); |
- | |
446 | info = malloc(size); |
- | |
447 | - | ||
448 | glGetProgramInfoLog(px->blit_prog, size, NULL, info); |
- | |
449 | DBG("Failed to link: %s\n", info); |
- | |
450 | DBG("GLSL link failure\n"); |
- | |
451 | free(info); |
- | |
452 | goto err_4; |
- | |
453 | } |
- | |
454 | - | ||
455 | px->sampler = glGetUniformLocation(px->blit_prog,"sampler_src"); |
- | |
456 | px->sm_mask = glGetUniformLocation(px->blit_prog,"sampler_mask"); |
- | |
457 | 547 | ||
458 | glUseProgram(px->blit_prog); |
- | |
Line 459... | Line 548... | ||
459 | glUniform1i(px->sampler, 0); |
548 | create_y_uv_shader(&px->shader_y_uv); |
Line 460... | Line 549... | ||
460 | glUniform1i(px->sm_mask, 1); |
549 | create_rgba_shader(&px->shader_rgba); |
461 | 550 | ||
Line 550... | Line 639... | ||
550 | EGL_NONE, EGL_NONE |
639 | EGL_NONE, EGL_NONE |
551 | }; |
640 | }; |
Line 552... | Line 641... | ||
552 | 641 | ||
553 | switch (format) |
642 | switch (format) |
554 | { |
643 | { |
555 | case EGL_TEXTURE_Y_UV_WL: |
644 | case WL_DRM_FORMAT_NV12: |
556 | num_planes = 2; |
645 | num_planes = 2; |
557 | break; |
646 | break; |
558 | case EGL_TEXTURE_Y_U_V_WL: |
647 | case EGL_TEXTURE_Y_U_V_WL: |
559 | num_planes = 3; |
648 | num_planes = 3; |
Line 563... | Line 652... | ||
563 | break; |
652 | break; |
564 | default: |
653 | default: |
565 | num_planes = 0; |
654 | num_planes = 0; |
566 | } |
655 | } |
Line -... | Line 656... | ||
- | 656 | ||
- | 657 | // printf("%s num_planes %d\n", __FUNCTION__, num_planes); |
|
567 | 658 | ||
568 | if(num_planes == 0) |
659 | if(num_planes == 0) |
Line 569... | Line 660... | ||
569 | return NULL; |
660 | goto fail; |
570 | 661 | ||
571 | planar = calloc(1, sizeof(struct planar)); |
662 | planar = calloc(1, sizeof(struct planar)); |
Line 572... | Line 663... | ||
572 | if(planar == NULL) |
663 | if(planar == NULL) |
573 | return NULL; |
664 | goto fail; |
574 | 665 | ||
Line 591... | Line 682... | ||
591 | 682 | ||
Line 592... | Line 683... | ||
592 | glGenTextures(num_planes, &planar->tex[0]); |
683 | glGenTextures(num_planes, &planar->tex[0]); |
593 | 684 | ||
- | 685 | for(i = 0; i < num_planes; i++) |
|
594 | for(i = 0; i < num_planes; i++) |
686 | { |
595 | { |
687 | EGLImageKHR image; |
596 | EGLint attr[3]; |
688 | EGLint attr[3]; |
597 | attr[0] = EGL_WAYLAND_PLANE_WL; |
689 | attr[0] = EGL_WAYLAND_PLANE_WL; |
Line 598... | Line 690... | ||
598 | attr[1] = i; |
690 | attr[1] = i; |
599 | attr[2] = EGL_NONE; |
691 | attr[2] = EGL_NONE; |
Line -... | Line 692... | ||
- | 692 | ||
600 | 693 | image = eglCreateImageKHR(px->dpy, px->context, |
|
Line -... | Line 694... | ||
- | 694 | EGL_WAYLAND_BUFFER_WL,(EGLClientBuffer)img, attr); |
|
- | 695 | ||
- | 696 | planar->image[i] = image; |
|
- | 697 | glBindTexture(GL_TEXTURE_2D, planar->tex[i]); |
|
- | 698 | ||
601 | planar->image[i] = eglCreateImageKHR(px->dpy, px->context, |
699 | if(glGetError() != GL_NO_ERROR) |
- | 700 | { |
|
- | 701 | goto fail; |
|
- | 702 | }; |
|
- | 703 | ||
Line 602... | Line 704... | ||
602 | EGL_WAYLAND_BUFFER_WL,(EGLClientBuffer)name, attr); |
704 | glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); |
603 | 705 | if(glGetError() != GL_NO_ERROR) |
|
604 | glBindTexture(GL_TEXTURE_2D, planar->tex[i]); |
706 | { |
Line 605... | Line 707... | ||
605 | 707 | goto fail; |
|
Line 606... | Line 708... | ||
606 | glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, planar->image[i]); |
708 | } |
607 | 709 | ||
- | 710 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); |
|
Line 608... | Line 711... | ||
608 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); |
711 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); |
609 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); |
712 | }; |
Line 721... | Line 824... | ||
721 | vertices[1] = t1 = 2*(winy+px->dy)*yscale - 1.0; |
824 | vertices[1] = t1 = 2*(winy+px->dy)*yscale - 1.0; |
722 | vertices[2*2+1] = t5 = 2*b*yscale - 1.0; |
825 | vertices[2*2+1] = t5 = 2*b*yscale - 1.0; |
723 | vertices[1*2+1] = t1; |
826 | vertices[1*2+1] = t1; |
724 | vertices[3*2+1] = t5; |
827 | vertices[3*2+1] = t5; |
Line -... | Line 828... | ||
- | 828 | ||
- | 829 | struct shader *shader = &px->shader_rgba; |
|
- | 830 | ||
- | 831 | glUseProgram(shader->blit_prog); |
|
- | 832 | glUniform1i(shader->sampler0, 0); |
|
- | 833 | glUniform1i(shader->sm_mask, 1); |
|
725 | 834 | ||
726 | glActiveTexture(GL_TEXTURE0); |
835 | glActiveTexture(GL_TEXTURE0); |
Line 727... | Line 836... | ||
727 | glBindTexture(GL_TEXTURE_2D, bitmap->tex); |
836 | glBindTexture(GL_TEXTURE_2D, bitmap->tex); |
728 | 837 | ||
Line 734... | Line 843... | ||
734 | glFlush(); |
843 | glFlush(); |
Line 735... | Line 844... | ||
735 | 844 | ||
736 | return; |
845 | return; |
Line -... | Line 846... | ||
- | 846 | }; |
|
- | 847 | ||
- | 848 | static int hw_blit_planar(planar_t *planar, int dst_x, int dst_y, |
|
- | 849 | uint32_t w, uint32_t h, int src_x, int src_y) |
|
- | 850 | { |
|
- | 851 | struct drm_i915_mask_update update; |
|
- | 852 | struct drm_i915_fb_info fb; |
|
- | 853 | ||
- | 854 | uint32_t winx, winy, winw, winh; |
|
- | 855 | uint8_t state; |
|
- | 856 | float xscale, yscale; |
|
- | 857 | int r, b; |
|
- | 858 | float *vertices = px->vertices; |
|
- | 859 | ||
- | 860 | get_proc_info(proc_info); |
|
- | 861 | ||
- | 862 | state = *(uint8_t*)(proc_info+70); |
|
- | 863 | if(state & (WIN_STATE_MINIMIZED|WIN_STATE_ROLLED)) |
|
- | 864 | return; |
|
- | 865 | ||
- | 866 | winx = *(uint32_t*)(proc_info+34); |
|
- | 867 | winy = *(uint32_t*)(proc_info+38); |
|
- | 868 | winw = *(uint32_t*)(proc_info+42)+1; |
|
- | 869 | winh = *(uint32_t*)(proc_info+46)+1; |
|
- | 870 | ||
- | 871 | __builtin_memset(&fb, 0, sizeof(fb)); |
|
- | 872 | if( 0 != drm_ioctl(px->fd, SRV_FBINFO, &fb)) |
|
- | 873 | { |
|
- | 874 | DBG("failed to get framebuffer info\n"); |
|
- | 875 | return; |
|
- | 876 | }; |
|
- | 877 | ||
- | 878 | if( fb.width != px->scr_width || |
|
- | 879 | fb.height != px->scr_height ) |
|
- | 880 | { |
|
- | 881 | px->scr_width = fb.width; |
|
- | 882 | px->scr_height = fb.height; |
|
- | 883 | ||
- | 884 | eglDestroyImageKHR(px->dpy, px->screen); |
|
- | 885 | ||
- | 886 | if(update_fb(px, fb.name, fb.pitch)) |
|
- | 887 | return; |
|
- | 888 | }; |
|
- | 889 | ||
- | 890 | update.handle = px->mask.handle; |
|
- | 891 | update.dx = px->dx; |
|
- | 892 | update.dy = px->dy; |
|
- | 893 | update.width = px->width; |
|
- | 894 | update.height = px->height; |
|
- | 895 | update.bo_pitch = (px->width+15) & ~15; |
|
- | 896 | update.bo_map = (int)px->mask.buffer; |
|
- | 897 | ||
- | 898 | if(drm_ioctl(px->fd, SRV_MASK_UPDATE_EX, &update)) |
|
- | 899 | { |
|
- | 900 | return; |
|
- | 901 | } |
|
- | 902 | ||
- | 903 | xscale = 1.0/px->scr_width; |
|
- | 904 | yscale = 1.0/px->scr_height; |
|
- | 905 | ||
- | 906 | r = winx + px->dx + px->width; |
|
- | 907 | b = winy + px->dy + px->height; |
|
- | 908 | ||
- | 909 | float t0, t1, t2, t5; |
|
- | 910 | ||
- | 911 | // render->tc_src[1*2] = 1.0; |
|
- | 912 | // render->tc_src[2*2] = 1.0; |
|
- | 913 | // render->tc_src[2*2+1]= 1.0; |
|
- | 914 | // render->tc_src[3*2+1]= 1.0; |
|
- | 915 | ||
- | 916 | vertices[0] = t0 = 2*(winx+px->dx)*xscale - 1.0; |
|
- | 917 | vertices[1 * 2] = t2 = 2*r*xscale - 1.0; |
|
- | 918 | ||
- | 919 | vertices[2 * 2] = t2; |
|
- | 920 | vertices[3 * 2] = t0; |
|
- | 921 | ||
- | 922 | vertices[1] = t1 = 2*(winy+px->dy)*yscale - 1.0; |
|
- | 923 | vertices[2*2+1] = t5 = 2*b*yscale - 1.0; |
|
- | 924 | vertices[1*2+1] = t1; |
|
- | 925 | vertices[3*2+1] = t5; |
|
- | 926 | ||
- | 927 | struct shader *shader = &px->shader_y_uv; |
|
- | 928 | ||
- | 929 | glUseProgram(shader->blit_prog); |
|
- | 930 | glUniform1i(shader->sampler0, 0); |
|
- | 931 | glUniform1i(shader->sampler1, 1); |
|
- | 932 | glUniform1i(shader->sm_mask, 2); |
|
- | 933 | ||
- | 934 | glActiveTexture(GL_TEXTURE0); |
|
- | 935 | glBindTexture(GL_TEXTURE_2D, planar->tex[0]); |
|
- | 936 | ||
- | 937 | glActiveTexture(GL_TEXTURE1); |
|
- | 938 | glBindTexture(GL_TEXTURE_2D, planar->tex[1]); |
|
- | 939 | ||
- | 940 | glActiveTexture(GL_TEXTURE2); |
|
- | 941 | glBindTexture(GL_TEXTURE_2D, px->texture[TEX_MASK]); |
|
- | 942 | ||
- | 943 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
|
- | 944 | ||
- | 945 | glFlush(); |
|
- | 946 | ||
- | 947 | return; |
|
737 | }; |
948 | }; |
738 | 949 | ||
739 | static int hw_create_client(int x, int y, uint32_t width, uint32_t height) |
950 | static int hw_create_client(int x, int y, uint32_t width, uint32_t height) |
Line 740... | Line 951... | ||
740 | { |
951 | { |
Line 801... | Line 1012... | ||
801 | hw_resize_bitmap, |
1012 | hw_resize_bitmap, |
802 | hw_blit, |
1013 | hw_blit, |
803 | hw_create_client, |
1014 | hw_create_client, |
804 | hw_resize_client, |
1015 | hw_resize_client, |
805 | hw_fini, |
1016 | hw_fini, |
806 | hw_create_planar |
1017 | hw_create_planar, |
- | 1018 | hw_blit_planar |
|
807 | }; |
1019 | }; |
Line 808... | Line 1020... | ||
808 | 1020 | ||
809 | struct pix_driver *DrvInit(uint32_t service) |
1021 | struct pix_driver *DrvInit(uint32_t service) |
810 | { |
1022 | { |