Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/modules/engines/gl_common Modified Files: evas_gl_common.h evas_gl_context.c evas_gl_image.c evas_gl_texture.c Log Message: fix color modulation for gl surfaces. also fix segvs tat can happen. xrender engine is behind now though. can't do yuv surfaces (yet) =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_common/evas_gl_common.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- evas_gl_common.h 18 Dec 2006 14:55:47 -0000 1.8 +++ evas_gl_common.h 19 Dec 2006 14:12:40 -0000 1.9 @@ -188,7 +188,9 @@ void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth); void evas_gl_common_texture_free(Evas_GL_Texture *tex); void evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int smooth); - +Evas_GL_Texture *evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, unsigned char **rows, int w, int h, int smooth); +void evas_gl_common_ycbcr601pl_texture_update(Evas_GL_Texture *tex, unsigned char **rows, int w, int h, int smooth); + Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key, Evas_Image_Load_Opts *lo); Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace); Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace); =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_common/evas_gl_context.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- evas_gl_context.c 18 Dec 2006 14:55:47 -0000 1.5 +++ evas_gl_context.c 19 Dec 2006 14:12:40 -0000 1.6 @@ -67,9 +67,9 @@ // 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; - 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); +// 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); // this causes at least nvidia's drivers to go into pathological pain when // changing textures a lot (doing video). so we wont do anything with this // for now, but it does work. @@ -78,7 +78,7 @@ } else { - printf("GL EXT supported: No extensions!!!!!\n"); +// printf("GL EXT supported: No extensions!!!!!\n"); } gc->ext.checked = 1; } @@ -330,12 +330,14 @@ } if (gc->font_texture_rectangle) { + glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_RECTANGLE_NV); glBindTexture(GL_TEXTURE_RECTANGLE_NV, gc->font_texture); } else { + glActiveTexture(GL_TEXTURE0); if (gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV); glEnable(GL_TEXTURE_2D); @@ -346,6 +348,7 @@ { if (gc->texture->rectangle) { + glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_RECTANGLE_NV); glBindTexture(GL_TEXTURE_RECTANGLE_NV, gc->texture->texture); =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_common/evas_gl_image.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- evas_gl_image.c 17 Dec 2006 15:48:51 -0000 1.4 +++ evas_gl_image.c 19 Dec 2006 14:12:40 -0000 1.5 @@ -246,11 +246,11 @@ case EVAS_COLORSPACE_YCBCR422P709_PL: if ((im->tex) && (im->dirty)) { - evas_gl_common_ycbcr601pl_texture_update(im->tex, im->cs.data, im->im->image->w, im->im->image->h); + evas_gl_common_ycbcr601pl_texture_update(im->tex, im->cs.data, im->im->image->w, im->im->image->h, smooth); im->dirty = 0; } if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data))) - im->tex = evas_gl_common_ycbcr601pl_texture_new(gc, im->cs.data, im->im->image->w, im->im->image->h); + im->tex = evas_gl_common_ycbcr601pl_texture_new(gc, im->cs.data, im->im->image->w, im->im->image->h, smooth); if (!im->tex) return; ow = (dw * im->tex->tw) / sw; oh = (dh * im->tex->th) / sh; =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_common/evas_gl_texture.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- evas_gl_texture.c 18 Dec 2006 14:56:46 -0000 1.4 +++ evas_gl_texture.c 19 Dec 2006 14:12:40 -0000 1.5 @@ -413,12 +413,11 @@ } Evas_GL_Texture * -evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, unsigned char **rows, int w, int h) +evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, unsigned char **rows, int w, int h, int smooth) { Evas_GL_Texture *tex; - int im_w, im_h; - int tw, th; - GLenum pixfmt, texfmt; + int im_w, im_h, tw, th, y; + GLenum texfmt; GLhandleARB fshad; if (!gc->ext.arb_texture_non_power_of_two) return NULL; @@ -444,23 +443,17 @@ 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, g, b, 1.0);\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(fshad, 1, &code, NULL); } @@ -482,33 +475,69 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } glTexImage2D(GL_TEXTURE_2D, 0, texfmt, tw, th, 0, - texfmt, GL_UNSIGNED_BYTE, rows[0]); + texfmt, GL_UNSIGNED_BYTE, NULL); + for (y = 0; y < tex->h; y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w, tex->h, + texfmt, GL_UNSIGNED_BYTE, rows[y]); glGenTextures(1, &(tex->texture2)); glBindTexture(GL_TEXTURE_2D, tex->texture2); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } glTexImage2D(GL_TEXTURE_2D, 0, texfmt, tw / 2, th / 2, 0, - texfmt, GL_UNSIGNED_BYTE, rows[th]); + texfmt, GL_UNSIGNED_BYTE, NULL); + for (y = 0; y < (tex->h / 2); y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w / 2, tex->h / 2, + texfmt, GL_UNSIGNED_BYTE, rows[tex->h + y]); glGenTextures(1, &(tex->texture3)); glBindTexture(GL_TEXTURE_2D, tex->texture3); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } glTexImage2D(GL_TEXTURE_2D, 0, texfmt, tw / 2, th / 2, 0, - texfmt, GL_UNSIGNED_BYTE, rows[th + (th / 2)]); + texfmt, GL_UNSIGNED_BYTE, NULL); + for (y = 0; y < (tex->h / 2); y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w / 2, tex->h / 2, + texfmt, GL_UNSIGNED_BYTE, rows[tex->h + (tex->h / 2) + y]); glUseProgramObjectARB(0); @@ -517,39 +546,66 @@ gc->change.texture = 1; tex->references++; - /* FIXME: should use subimage */ -/* - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, im_w, im_h, - pixfmt, NATIVE_PIX_UNIT, - im_data); - */ return tex; } void -evas_gl_common_ycbcr601pl_texture_update(Evas_GL_Texture *tex, unsigned char **rows, int w, int h) +evas_gl_common_ycbcr601pl_texture_update(Evas_GL_Texture *tex, unsigned char **rows, int w, int h, int smooth) { int texfmt; + int y; /* FIXME: should use subimage */ glEnable(GL_TEXTURE_2D); texfmt = GL_LUMINANCE; glBindTexture(GL_TEXTURE_2D, tex->texture); - glTexImage2D(GL_TEXTURE_2D, 0, - texfmt, tex->w, tex->h, 0, - texfmt, GL_UNSIGNED_BYTE, rows[0]); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + for (y = 0; y < tex->h; y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w, tex->h, + texfmt, GL_UNSIGNED_BYTE, rows[y]); glBindTexture(GL_TEXTURE_2D, tex->texture2); - glTexImage2D(GL_TEXTURE_2D, 0, - texfmt, tex->w / 2, tex->h / 2, 0, - texfmt, GL_UNSIGNED_BYTE, rows[tex->h]); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + for (y = 0; y < (tex->h / 2); y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w / 2, tex->h / 2, + texfmt, GL_UNSIGNED_BYTE, rows[tex->h + y]); glBindTexture(GL_TEXTURE_2D, tex->texture3); - glTexImage2D(GL_TEXTURE_2D, 0, - texfmt, tex->w / 2, tex->h / 2, 0, - texfmt, GL_UNSIGNED_BYTE, rows[tex->h + (tex->h / 2)]); + if (smooth) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + for (y = 0; y < (tex->h / 2); y++) + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, y, tex->w / 2, tex->h / 2, + texfmt, GL_UNSIGNED_BYTE, rows[tex->h + (tex->h / 2) + y]); if (tex->gc->texture) tex->gc->texture->references--; tex->gc->texture = tex; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs