diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h index 67372fc5ab..5f98fb0a70 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h @@ -67,6 +67,7 @@ struct _Evas_GL_Context int sgis_generate_mipmap : 1; int nv_texture_rectangle : 1; int arb_texture_non_power_of_two : 1; + int arb_program : 1; } ext; GLenum read_buf; diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c index f4708b0108..cca8fd8b14 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c @@ -40,40 +40,6 @@ evas_gl_common_context_new(void) gc->change.buf = 1; gc->change.other = 1; - gc->yuv422p.prog = glCreateProgramObjectARB(); -// on an nv 6600gt this is fast - but on a 5500fx its DEAD SLOW!!!!! -// if (!gc->ext.arb_texture_non_power_of_two) return NULL; - /* BEGIN LEAK */ - gc->yuv422p.fshad = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); - { - const char *code = - "uniform sampler2D ytex, utex, vtex;\n" - "void main(void) {\n" - " float r, g, b, y, u, v;\n" - " y = texture2D(ytex, gl_TexCoord[0].st).r;\n" - " u = texture2D(utex, gl_TexCoord[0].st).r;\n" - " v = texture2D(vtex, gl_TexCoord[0].st).r;\n" - " y = (y - 0.0625) * 1.164;\n" - " u = u - 0.5;\n" - " v = v - 0.5;\n" - " r = y + (1.402 * v);\n" - " g = y - (0.34414 * u) - (0.71414 * v);\n" - " b = y + (1.772 * u);\n" - " gl_FragColor = vec4(r * gl_Color.r * gl_Color.a, g * gl_Color.g * gl_Color.a, b * gl_Color.b * gl_Color.a, gl_Color.a);\n" - "}\n"; - glShaderSourceARB(gc->yuv422p.fshad, 1, &code, NULL); - } - glCompileShaderARB(gc->yuv422p.fshad); - glAttachObjectARB(gc->yuv422p.prog, gc->yuv422p.fshad); - /* END LEAK - something in the above leaks... beats me what. */ - glLinkProgramARB(gc->yuv422p.prog); - - glUseProgramObjectARB(gc->yuv422p.prog); - glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "ytex"), 0); - glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "utex"), 1); - glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "vtex"), 2); - glUseProgramObjectARB(0); - return gc; } @@ -110,6 +76,9 @@ evas_gl_common_context_use(Evas_GL_Context *gc) // if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1; // if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1; if (strstr(ext, "GL_ARB_texture_non_power_of_two")) gc->ext.arb_texture_non_power_of_two = 1; + if (strstr(ext, "GL_ARB_shader_objects") && strstr(ext, "GL_ARB_vertex_shader") + && strstr(ext, "GL_ARB_fragment_shader") && strstr(ext, "GL_ARB_shading_language")) + gc->ext.arb_program = 1; // printf("GL EXT supported: GL_SGIS_generate_mipmap = %x\n", gc->ext.sgis_generate_mipmap); // printf("GL EXT supported: GL_NV_texture_rectangle = %x\n", gc->ext.nv_texture_rectangle); // printf("GL EXT supported: GL_ARB_texture_non_power_of_two = %x\n", gc->ext.arb_texture_non_power_of_two); @@ -123,7 +92,45 @@ evas_gl_common_context_use(Evas_GL_Context *gc) { // printf("GL EXT supported: No extensions!!!!!\n"); } - gc->ext.checked = 1; + + if (gc->ext.arb_program) + { + gc->yuv422p.prog = glCreateProgramObjectARB(); + // on an nv 6600gt this is fast - but on a 5500fx its DEAD SLOW!!!!! + // if (!gc->ext.arb_texture_non_power_of_two) return NULL; + /* BEGIN LEAK */ + gc->yuv422p.fshad = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + { + const char *code = + "uniform sampler2D ytex, utex, vtex;\n" + "void main(void) {\n" + " float r, g, b, y, u, v;\n" + " y = texture2D(ytex, gl_TexCoord[0].st).r;\n" + " u = texture2D(utex, gl_TexCoord[0].st).r;\n" + " v = texture2D(vtex, gl_TexCoord[0].st).r;\n" + " y = (y - 0.0625) * 1.164;\n" + " u = u - 0.5;\n" + " v = v - 0.5;\n" + " r = y + (1.402 * v);\n" + " g = y - (0.34414 * u) - (0.71414 * v);\n" + " b = y + (1.772 * u);\n" + " gl_FragColor = vec4(r * gl_Color.r * gl_Color.a, g * gl_Color.g * gl_Color.a, b * gl_Color.b * gl_Color.a, gl_Color.a);\n" + "}\n"; + glShaderSourceARB(gc->yuv422p.fshad, 1, &code, NULL); + } + glCompileShaderARB(gc->yuv422p.fshad); + glAttachObjectARB(gc->yuv422p.prog, gc->yuv422p.fshad); + /* END LEAK - something in the above leaks... beats me what. */ + glLinkProgramARB(gc->yuv422p.prog); + + glUseProgramObjectARB(gc->yuv422p.prog); + glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "ytex"), 0); + glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "utex"), 1); + glUniform1iARB(glGetUniformLocationARB(gc->yuv422p.prog, "vtex"), 2); + glUseProgramObjectARB(0); + } + + gc->ext.checked = 1; } _evas_gl_common_context = gc; _evas_gl_common_viewport_set(gc); diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c index e2df893c9d..2b0a5d859e 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c @@ -224,6 +224,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy int r, g, b, a; double tx1, ty1, tx2, ty2; int ow, oh; + int space; if (sw < 1) sw = 1; if (sh < 1) sh = 1; @@ -239,8 +240,29 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy { r = g = b = a = 255; } + + if (!gc->ext.arb_program && (im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL + || im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL)) + { + if ((im->cs.data) && (*((unsigned char **)im->cs.data))) + { + if (im->dirty || !im->im->image->data) + { + free(im->im->image->data); + im->im->image->data = malloc(im->im->image->w * im->im->image->h * sizeof(DATA32)); + if (im->im->image->data) + evas_common_convert_yuv_420p_601_rgba(im->cs.data, + (void *)im->im->image->data, + im->im->image->w, im->im->image->h); + } + } + space = EVAS_COLORSPACE_ARGB8888; + } + else + space = im->cs.space; + /* leak in this switch */ - switch (im->cs.space) + switch (space) { case EVAS_COLORSPACE_ARGB8888: evas_cache_image_load_data(im->im);