From: raster Date: Fri, 6 Nov 2009 11:32:23 +0000 (+0000) Subject: better text perf - less geometry data for complex text drawing. X-Git-Tag: accepted/2.0/20130306.225542~242^2~2208 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=714de2e050d4757e96189711a7e6df70dbe2621b;p=profile%2Fivi%2Fevas.git better text perf - less geometry data for complex text drawing. simpler yuv with matrix. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@43487 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/modules/engines/gl_common/Makefile.am b/src/modules/engines/gl_common/Makefile.am index 49c4e15..adb3e30 100644 --- a/src/modules/engines/gl_common/Makefile.am +++ b/src/modules/engines/gl_common/Makefile.am @@ -62,4 +62,5 @@ shader/font_frag.shd \ shader/font_frag_s3c6410.asm \ shader/font_vert.shd \ shader/yuv_frag.shd \ +shader/yuv_frag_s3c6410.asm \ shader/yuv_vert.shd diff --git a/src/modules/engines/gl_common/evas_gl_common.h b/src/modules/engines/gl_common/evas_gl_common.h index e16df6f..5b6a259 100644 --- a/src/modules/engines/gl_common/evas_gl_common.h +++ b/src/modules/engines/gl_common/evas_gl_common.h @@ -104,26 +104,11 @@ struct _Evas_GL_Context RGBA_Draw_Context *dc; Evas_GL_Shared *shared; -/* - Eina_List *images; - - struct { - Eina_List *whole; - Eina_List *atlas[33][3]; - } tex; - struct { - GLint max_texture_units; - GLint max_texture_size; - Eina_Bool tex_npo2 : 1; - Eina_Bool tex_rect : 1; - } info; - */ struct { int x, y, w, h; Eina_Bool active : 1; } clip; struct { -/* Evas_GL_Program rect, img, font, yuv;*/ GLuint cur_prog; GLuint cur_tex, cur_texu, cur_texv; Eina_Bool smooth : 1; @@ -138,8 +123,8 @@ struct _Evas_GL_Context struct { int num; int alloc; - GLint *vertex; - GLfloat *color; + GLshort *vertex; + GLubyte *color; GLfloat *texuv; GLfloat *texuv2; GLfloat *texuv3; @@ -153,7 +138,7 @@ struct _Evas_GL_Texture_Pool { Evas_GL_Context *gc; GLuint texture; - GLuint format; + GLuint intformat, format, dataformat; int w, h; int references; int slot, fslot; diff --git a/src/modules/engines/gl_common/evas_gl_context.c b/src/modules/engines/gl_common/evas_gl_context.c index 57a3a5b..44ffbd9 100644 --- a/src/modules/engines/gl_common/evas_gl_context.c +++ b/src/modules/engines/gl_common/evas_gl_context.c @@ -177,12 +177,6 @@ evas_gl_common_context_new(void) &(shader_font_vert_src), &(shader_font_frag_src), "font"); -//#if defined (GLES_VARIETY_S3C6410) -// evas_gl_common_shader_program_init(&(shared->shader.yuv), -// &(shader_img_vert_src), -// &(shader_img_frag_src), -// "yuv"); -//#else evas_gl_common_shader_program_init(&(shared->shader.yuv), &(shader_yuv_vert_src), &(shader_yuv_frag_src), @@ -191,7 +185,6 @@ evas_gl_common_context_new(void) glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "tex"), 0); glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texu"), 1); glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texv"), 2); -//#endif // in shader: // uniform sampler2D tex[8]; // @@ -235,7 +228,6 @@ evas_gl_common_context_free(Evas_GL_Context *gc) } free(gc->shared); shared = NULL; - // FIXME: free shader.rect.prog etc. etc. } free(gc->array.vertex); @@ -284,11 +276,6 @@ evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h) #define PUSH_TEXUV3(u, v) \ gc->array.texuv3[nu3++] = u; \ gc->array.texuv3[nu3++] = v -#define COLOR_FLOAT(r, g, b, a, fr, fg, fb, fa) \ - fr = ((GLfloat)(r)) / 255.0; \ - fg = ((GLfloat)(g)) / 255.0; \ - fb = ((GLfloat)(b)) / 255.0; \ - fa = ((GLfloat)(a)) / 255.0 static inline void _evas_gl_common_context_array_alloc(Evas_GL_Context *gc) @@ -296,9 +283,9 @@ _evas_gl_common_context_array_alloc(Evas_GL_Context *gc) if (gc->array.num <= gc->array.alloc) return; gc->array.alloc += 6 * 1024; gc->array.vertex = realloc(gc->array.vertex, - gc->array.alloc * sizeof(GLint) * 3); + gc->array.alloc * sizeof(GLshort) * 3); gc->array.color = realloc(gc->array.color, - gc->array.alloc * sizeof(GLfloat) * 4); + gc->array.alloc * sizeof(GLubyte) * 4); gc->array.texuv = realloc(gc->array.texuv, gc->array.alloc * sizeof(GLfloat) * 2); gc->array.texuv2 = realloc(gc->array.texuv2, @@ -313,7 +300,6 @@ evas_gl_common_context_rectangle_push(Evas_GL_Context *gc, int r, int g, int b, int a) { int pnum, nv, nc, nu, nt, i; - GLfloat rr, gg, bb, aa; Eina_Bool blend = 0; if (a < 255) blend = 1; @@ -345,10 +331,9 @@ evas_gl_common_context_rectangle_push(Evas_GL_Context *gc, { PUSH_TEXUV(0.0, 0.0); } - COLOR_FLOAT(r, g, b, a, rr, gg, bb, aa); for (i = 0; i < 6; i++) { - PUSH_COLOR(rr, gg, bb, aa); + PUSH_COLOR(r, g, b, a); } } @@ -361,7 +346,7 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc, Eina_Bool smooth) { int pnum, nv, nc, nu, nt, i; - GLfloat rr, gg, bb, aa, tx1, tx2, ty1, ty2; + GLfloat tx1, tx2, ty1, ty2; Eina_Bool blend = 1; if (tex->pt->format == GL_RGB) blend = 0; @@ -406,10 +391,9 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc, PUSH_TEXUV(tx2, ty2); PUSH_TEXUV(tx1, ty2); - COLOR_FLOAT(r, g, b, a, rr, gg, bb, aa); for (i = 0; i < 6; i++) { - PUSH_COLOR(rr, gg, bb, aa); + PUSH_COLOR(r, g, b, a); } } @@ -421,7 +405,7 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc, int r, int g, int b, int a) { int pnum, nv, nc, nu, nt, i; - GLfloat rr, gg, bb, aa, tx1, tx2, ty1, ty2; + GLfloat tx1, tx2, ty1, ty2; if ((gc->shader.cur_tex != tex->pt->texture) || (gc->shader.cur_prog != gc->shared->shader.font.prog) @@ -472,10 +456,9 @@ evas_gl_common_context_font_push(Evas_GL_Context *gc, PUSH_TEXUV(tx2, ty2); PUSH_TEXUV(tx1, ty2); - COLOR_FLOAT(r, g, b, a, rr, gg, bb, aa); for (i = 0; i < 6; i++) { - PUSH_COLOR(rr, gg, bb, aa); + PUSH_COLOR(r, g, b, a); } } @@ -488,7 +471,7 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc, Eina_Bool smooth) { int pnum, nv, nc, nu, nu2, nu3, nt, i; - GLfloat rr, gg, bb, aa, tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; + GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; Eina_Bool blend = 0; if (a < 255) blend = 1; @@ -556,10 +539,9 @@ evas_gl_common_context_yuv_push(Evas_GL_Context *gc, PUSH_TEXUV3(t2x2, t2y2); PUSH_TEXUV3(t2x1, t2y2); - COLOR_FLOAT(r, g, b, a, rr, gg, bb, aa); for (i = 0; i < 6; i++) { - PUSH_COLOR(rr, gg, bb, aa); + PUSH_COLOR(r, g, b, a); } } @@ -612,13 +594,11 @@ shader_array_flush(Evas_GL_Context *gc) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 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_WRAP_S, GL_REPEAT); -// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } } - glVertexAttribPointer(SHAD_VERTEX, 3, GL_INT, GL_FALSE, 0, gc->array.vertex); - glVertexAttribPointer(SHAD_COLOR, 4, GL_FLOAT, GL_FALSE, 0, gc->array.color); + glVertexAttribPointer(SHAD_VERTEX, 3, GL_SHORT, GL_FALSE, 0, gc->array.vertex); + glVertexAttribPointer(SHAD_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, gc->array.color); glVertexAttribPointer(SHAD_TEXUV, 2, GL_FLOAT, GL_FALSE, 0, gc->array.texuv); if ((gc->array.texuv2) && (gc->array.texuv3)) { diff --git a/src/modules/engines/gl_common/evas_gl_texture.c b/src/modules/engines/gl_common/evas_gl_texture.c index 5427a99..e80d67c 100644 --- a/src/modules/engines/gl_common/evas_gl_texture.c +++ b/src/modules/engines/gl_common/evas_gl_texture.c @@ -1,5 +1,25 @@ #include "evas_gl_private.h" +#if 1 +static const GLenum rgba_fmt = GL_RGBA; +static const GLenum rgba_ifmt = GL_RGBA; +//static const GLenum rgb_fmt = GL_RGBA; +//static const GLenum rgb_ifmt = GL_RGBA; +static const GLenum alpha_fmt = GL_ALPHA; +static const GLenum alpha_ifmt = GL_ALPHA; +static const GLenum lum_fmt = GL_LUMINANCE; +static const GLenum lum_ifmt = GL_LUMINANCE; +#else +static const GLenum rgba_fmt = GL_RGBA; +static const GLenum rgba_ifmt = GL_COMPRESSED_RGBA; +//static const GLenum rgb_fmt = GL_RGBA; +//static const GLenum rgb_ifmt = GL_COMPRESSED_RGBA; +static const GLenum alpha_fmt = GL_ALPHA; +static const GLenum alpha_ifmt = GL_COMPRESSED_ALPHA; +static const GLenum lum_fmt = GL_LUMINANCE; +static const GLenum lum_ifmt = GL_COMPRESSED_LUMINANCE; +#endif + static int _nearest_pow2(int num) { @@ -37,12 +57,24 @@ _tex_format_index(GLuint format) switch (format) { case GL_RGBA: +#ifdef GL_COMPRESSED_RGBA + case GL_COMPRESSED_RGBA: +#endif return 0; case GL_RGB: +#ifdef GL_COMPRESSED_RGB + case GL_COMPRESSED_RGB: +#endif return 1; case GL_ALPHA: +#ifdef GL_COMPRESSED_ALPHA + case GL_COMPRESSED_ALPHA: +#endif return 2; case GL_LUMINANCE: +#ifdef GL_COMPRESSED_LUMINANCE + case GL_COMPRESSED_LUMINANCE: +#endif return 3; default: break; @@ -50,8 +82,33 @@ _tex_format_index(GLuint format) return 0; } +static void +_tex_2d(GLint internalformat, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type) +{ + glTexImage2D(GL_TEXTURE_2D, 0, internalformat, + width, height, 0, format, type, NULL); +} + +static void +_tex_sub_2d(GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid *pixels) +{ + glTexSubImage2D(GL_TEXTURE_2D, 0, + xoffset, yoffset, width, height, format, type, pixels); +} + static Evas_GL_Texture_Pool * -_pool_tex_new(Evas_GL_Context *gc, int w, int h, GLuint format) +_pool_tex_new(Evas_GL_Context *gc, int w, int h, + GLenum intformat, GLenum format) { Evas_GL_Texture_Pool *pt; @@ -62,7 +119,9 @@ _pool_tex_new(Evas_GL_Context *gc, int w, int h, GLuint format) pt->gc = gc; pt->w = w; pt->h = h; + pt->intformat = intformat; pt->format = format; + pt->dataformat = GL_UNSIGNED_BYTE; pt->references = 0; glGenTextures(1, &(pt->texture)); glBindTexture(GL_TEXTURE_2D, pt->texture); @@ -70,14 +129,13 @@ _pool_tex_new(Evas_GL_Context *gc, int w, int h, GLuint format) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, - format, GL_UNSIGNED_BYTE/* fixme - pass this in */, NULL); + _tex_2d(pt->intformat, w, h, pt->format, pt->dataformat); glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); return pt; } static int -_pool_tex_alloc(Evas_GL_Texture_Pool *pt, GLuint format, int w, int h, int *u, int *v, Eina_List **l_after) +_pool_tex_alloc(Evas_GL_Texture_Pool *pt, int w, int h, int *u, int *v, Eina_List **l_after) { Eina_List *l; Evas_GL_Texture *tex, *tex2; @@ -122,7 +180,9 @@ _pool_tex_alloc(Evas_GL_Texture_Pool *pt, GLuint format, int w, int h, int *u, i } static Evas_GL_Texture_Pool * -_pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v, Eina_List **l_after, int atlas_w) +_pool_tex_find(Evas_GL_Context *gc, int w, int h, + GLuint intformat, GLuint format, int *u, int *v, + Eina_List **l_after, int atlas_w) { Evas_GL_Texture_Pool *pt = NULL; Eina_List *l; @@ -130,7 +190,7 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v, if ((w > 512) || (h > 512)) { - pt = _pool_tex_new(gc, w, h, format); + pt = _pool_tex_new(gc, w, h, intformat, format); gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, pt); pt->slot = -1; pt->fslot = -1; @@ -145,7 +205,7 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v, th2 = _tex_format_index(format); EINA_LIST_FOREACH(gc->shared->tex.atlas[th][th2], l, pt) { - if (_pool_tex_alloc(pt, format, w, h, u, v, l_after)) + if (_pool_tex_alloc(pt, w, h, u, v, l_after)) { gc->shared->tex.atlas[th][th2] = eina_list_remove_list(gc->shared->tex.atlas[th][th2], l); @@ -154,7 +214,7 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h, GLuint format, int *u, int *v, return pt; } } - pt = _pool_tex_new(gc, atlas_w, h, format); + pt = _pool_tex_new(gc, atlas_w, h, intformat, format); gc->shared->tex.atlas[th][th2] = eina_list_prepend(gc->shared->tex.atlas[th][th2], pt); pt->slot = th; @@ -179,11 +239,11 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im) tex->references = 1; // if (im->cache_entry.flags.alpha) tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2, - im->cache_entry.h + 1, GL_RGBA, + im->cache_entry.h + 1, rgba_ifmt, rgba_fmt, &u, &v, &l_after, 1024); // else // tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3, -// im->cache_entry.h + 1, GL_RGB, +// im->cache_entry.h + 1, rgb_ifmt, rgb_fmt, // &u, &v, &l_after, 1024); if (!tex->pt) { @@ -208,16 +268,6 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im) void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im) { -#if defined(GL_UNSIGNED_INT_8_8_8_8_REV) && defined(GL_BGRA) -#define COLOR_FORMAT GL_RGBA -#define PIXEL_FORMAT GL_UNSIGNED_BYTE -// FIXME: need to change shader for this to work -//#define COLOR_FORMAT GL_BGRA -//#define PIXEL_FORMAT GL_UNSIGNED_INT_8_8_8_8_REV -#else -#define COLOR_FORMAT GL_RGBA -#define PIXEL_FORMAT GL_UNSIGNED_BYTE -#endif glBindTexture(GL_TEXTURE_2D, tex->pt->texture); #ifdef GL_UNPACK_ROW_LENGTH glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -226,55 +276,47 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im) // +-+ // +-+ // - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x, tex->y, - im->cache_entry.w, im->cache_entry.h, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data); + _tex_sub_2d(tex->x, tex->y, + im->cache_entry.w, im->cache_entry.h, + tex->pt->format, tex->pt->dataformat, + im->image.data); // |xxx // |xxx // - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x - 1, tex->y, - 1, im->cache_entry.h, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data); + _tex_sub_2d(tex->x - 1, tex->y, + 1, im->cache_entry.h, + tex->pt->format, tex->pt->dataformat, + im->image.data); // xxx| // xxx| // - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x + im->cache_entry.w, tex->y, - 1, im->cache_entry.h, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data + (im->cache_entry.w - 1)); + _tex_sub_2d(tex->x + im->cache_entry.w, tex->y, + 1, im->cache_entry.h, + tex->pt->format, tex->pt->dataformat, + im->image.data + (im->cache_entry.w - 1)); // xxx // xxx // --- - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x, tex->y + im->cache_entry.h, - im->cache_entry.w, 1, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w)); + _tex_sub_2d(tex->x, tex->y + im->cache_entry.h, + im->cache_entry.w, 1, + tex->pt->format, tex->pt->dataformat, + im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w)); // xxx // xxx // o - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x - 1, tex->y + im->cache_entry.h, - 1, 1, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w)); + _tex_sub_2d(tex->x - 1, tex->y + im->cache_entry.h, + 1, 1, + tex->pt->format, tex->pt->dataformat, + im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w)); // xxx // xxx // o - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x + im->cache_entry.w, tex->y + im->cache_entry.h, - 1, 1, - COLOR_FORMAT, PIXEL_FORMAT, - im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w) + (im->cache_entry.w - 1)); + _tex_sub_2d(tex->x + im->cache_entry.w, tex->y + im->cache_entry.h, + 1, 1, + tex->pt->format, tex->pt->dataformat, + im->image.data + ((im->cache_entry.h - 1) * im->cache_entry.w) + (im->cache_entry.w - 1)); if (tex->pt->texture != tex->gc->shader.cur_tex) - { - glBindTexture(GL_TEXTURE_2D, tex->gc->shader.cur_tex); - } + glBindTexture(GL_TEXTURE_2D, tex->gc->shader.cur_tex); } static void @@ -323,8 +365,7 @@ evas_gl_common_texture_alpha_new(Evas_GL_Context *gc, DATA8 *pixels, int w, int tex->references = 1; if (tw > gc->shared->info.max_texture_size) tw = gc->shared->info.max_texture_size; - tex->pt = _pool_tex_find(gc, w + 3, fh, GL_ALPHA, - &u, &v, &l_after, tw); + tex->pt = _pool_tex_find(gc, w + 3, fh, alpha_ifmt, alpha_fmt, &u, &v, &l_after, tw); if (!tex->pt) { free(tex); @@ -351,10 +392,7 @@ evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels, int w, glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #endif glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glTexSubImage2D(GL_TEXTURE_2D, 0, - tex->x, tex->y, w, h, - GL_ALPHA, GL_UNSIGNED_BYTE, - pixels); + _tex_sub_2d(tex->x, tex->y, w, h, tex->pt->format, tex->pt->dataformat, pixels); if (tex->pt->texture != tex->gc->shader.cur_tex) glBindTexture(GL_TEXTURE_2D, tex->gc->shader.cur_tex); } @@ -371,17 +409,17 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h) tex->gc = gc; tex->references = 1; - tex->pt = _pool_tex_new(gc, w + 1, h + 1, GL_LUMINANCE); + tex->pt = _pool_tex_new(gc, w + 1, h + 1, lum_ifmt, lum_fmt); gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->pt); tex->pt->slot = -1; tex->pt->fslot = -1; tex->pt->whole = 1; - tex->ptu = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, GL_LUMINANCE); + tex->ptu = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt); gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->ptu); tex->ptu->slot = -1; tex->ptu->fslot = -1; tex->ptu->whole = 1; - tex->ptv = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, GL_LUMINANCE); + tex->ptv = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt); gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->ptv); tex->ptv->slot = -1; tex->ptv->fslot = -1; @@ -403,82 +441,49 @@ evas_gl_common_texture_yuv_new(Evas_GL_Context *gc, DATA8 **rows, int w, int h) void evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, int w, int h) { + int y; + // FIXME: works on lowest size 4 pixel high buffers. must also be multiple of 2 #ifdef GL_UNPACK_ROW_LENGTH glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[1] - rows[0]); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, tex->pt->texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w, h, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[0]); + _tex_sub_2d(0, 0, w, h, tex->pt->format, tex->pt->dataformat, rows[0]); glBindTexture(GL_TEXTURE_2D, tex->ptu->texture); glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + 1] - rows[h]); - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w / 2, h / 2, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h]); + _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptu->format, tex->ptu->dataformat, rows[h]); glBindTexture(GL_TEXTURE_2D, tex->ptv->texture); glPixelStorei(GL_UNPACK_ROW_LENGTH, rows[h + (h / 2) + 1] - rows[h + (h / 2)]); - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w / 2, h / 2, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h + (h / 2)]); + _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptv->format, tex->ptv->dataformat, rows[h + (h / 2)]); #else glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, tex->pt->texture); if ((rows[1] - rows[0]) == w) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w, h, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[0]); + _tex_sub_2d(0, 0, w, h, tex->pt->format, tex->pt->dataformat, rows[0]); else { - int y; - for (y = 0; y < h; y++) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, y, w, 1, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[y]); + _tex_sub_2d(0, y, w, 1, tex->pt->format, tex->pt->dataformat, rows[y]); } glBindTexture(GL_TEXTURE_2D, tex->ptu->texture); if ((rows[h + 1] - rows[h]) == (w / 2)) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w / 2, h / 2, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h]); + _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptu->format, tex->ptu->dataformat, rows[h]); else { - int y; - for (y = 0; y < (h / 2); y++) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, y, w / 2, 1, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h + y]); + _tex_sub_2d(0, y, w / 2, 1, tex->ptu->format, tex->ptu->dataformat, rows[h + y]); } glBindTexture(GL_TEXTURE_2D, tex->ptv->texture); if ((rows[h + (h / 2) + 1] - rows[h + (h / 2)]) == (w / 2)) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, 0, w / 2, h / 2, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h + (h / 2)]); + _tex_sub_2d(0, 0, w / 2, h / 2, tex->ptv->format, tex->ptv->dataformat, rows[h + (h / 2)]); else { - int y; - for (y = 0; y < (h / 2); y++) - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, y, w / 2, 1, - GL_LUMINANCE, GL_UNSIGNED_BYTE, - rows[h + (h / 2) + y]); + _tex_sub_2d(0, y, w / 2, 1, tex->ptv->format, tex->ptv->dataformat, rows[h + (h / 2) + y]); } #endif if (tex->pt->texture != tex->gc->shader.cur_tex) - { - glBindTexture(GL_TEXTURE_2D, tex->gc->shader.cur_tex); - } + glBindTexture(GL_TEXTURE_2D, tex->gc->shader.cur_tex); } diff --git a/src/modules/engines/gl_common/shader/yuv_frag.h b/src/modules/engines/gl_common/shader/yuv_frag.h index f14c7ab..af1aa48 100644 --- a/src/modules/engines/gl_common/shader/yuv_frag.h +++ b/src/modules/engines/gl_common/shader/yuv_frag.h @@ -8,15 +8,12 @@ "varying vec2 tex_c3;\n" "void main()\n" "{\n" -" float r, g, b, y, u, v;\n" -" y = texture2D(tex, tex_c.xy).r;\n" -" u = texture2D(texu, tex_c2.xy).r;\n" -" v = texture2D(texv, tex_c3.xy).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) * col;\n" +" mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000,\n" +" 0.00000, -0.34410, 1.77200, 0.00000,\n" +" 1.40200, -0.71410, 0.00000, 0.00000,\n" +" -0.77380, 0.45630, -0.95880, 1.00000);\n" +" vec4 yuv = vec4(texture2D(tex, tex_c.xy).r,\n" +" texture2D(texu, tex_c2.xy).r,\n" +" texture2D(texv, tex_c3.xy).r, 1.0);\n" +" gl_FragColor = (yuv2rgb * yuv) * col;\n" "}\n" diff --git a/src/modules/engines/gl_common/shader/yuv_frag.shd b/src/modules/engines/gl_common/shader/yuv_frag.shd index 95bbd82..7da2546 100644 --- a/src/modules/engines/gl_common/shader/yuv_frag.shd +++ b/src/modules/engines/gl_common/shader/yuv_frag.shd @@ -8,15 +8,12 @@ varying vec2 tex_c2; varying vec2 tex_c3; void main() { - float r, g, b, y, u, v; - y = texture2D(tex, tex_c.xy).r; - u = texture2D(texu, tex_c2.xy).r; - v = texture2D(texv, tex_c3.xy).r; - y = (y - 0.0625) * 1.164; - u = u - 0.5; - v = v - 0.5; - r = y + (1.402 * v); - g = y - (0.34414 * u) - (0.71414 * v); - b = y + (1.772 * u); - gl_FragColor = vec4(r, g, b, 1.0) * col; + mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000, + 0.00000, -0.34410, 1.77200, 0.00000, + 1.40200, -0.71410, 0.00000, 0.00000, + -0.77380, 0.45630, -0.95880, 1.00000); + vec4 yuv = vec4(texture2D(tex, tex_c.xy).r, + texture2D(texu, tex_c2.xy).r, + texture2D(texv, tex_c3.xy).r, 1.0); + gl_FragColor = (yuv2rgb * yuv) * col; } diff --git a/src/modules/engines/gl_common/shader/yuv_frag_bin_s3c6410.h b/src/modules/engines/gl_common/shader/yuv_frag_bin_s3c6410.h index db8d76a..cd301dc 100644 --- a/src/modules/engines/gl_common/shader/yuv_frag_bin_s3c6410.h +++ b/src/modules/engines/gl_common/shader/yuv_frag_bin_s3c6410.h @@ -1,31 +1,24 @@ -0x20205350, 0xffff0008, 0x00000048, 0x01020000, 0x00000014, 0x0000000a, +0x20205350, 0xffff0008, 0x00000048, 0x01020000, 0x0000000d, 0x00000007, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000026, 0x00000000, -0x00000000, 0x02025400, 0x23782050, 0x00000000, 0x00000000, 0x0100e407, -0x307820e4, 0x00000000, 0x01000000, 0x02025400, 0x23782150, 0x00000000, -0x01000000, 0x0101e407, 0x307821e4, 0x00000000, 0x02000000, 0x02025400, +0x00000000, 0x02065400, 0x23782050, 0x00000000, 0x00000000, 0x0100e407, +0x307820e4, 0x00000000, 0x01000000, 0x02065400, 0x23782150, 0x00000000, +0x01000000, 0x0101e407, 0x307821e4, 0x00000000, 0x02000000, 0x02065400, 0x23782250, 0x00000000, 0x02000000, 0x0102e407, 0x307822e4, 0x00000000, -0x03000000, 0x01000042, 0x22082300, 0x00000000, 0x04000000, 0x01030002, -0x23082300, 0x00000000, 0x05000000, 0x01010042, 0x22102300, 0x00000000, -0x05000000, 0x01020042, 0x22202300, 0x00000000, 0x03000103, 0x0206aa01, -0x2ec02300, 0x00000000, 0x03000103, 0x42075501, 0x2e882400, 0x00000000, -0x03000104, 0x4208aa01, 0x2e882400, 0x00000000, 0x03000103, 0x02095501, -0x2e882300, 0x00000000, 0x00000000, 0x01030000, 0x208825ff, 0x00000000, -0x00000000, 0x01040000, 0x20902500, 0x00000000, 0x00000000, 0x01030000, -0x20a02500, 0x00000000, 0x00000000, 0x02020000, 0x20c02500, 0x00000000, -0x03000000, 0x0105e400, 0x237a10e4, 0x00000000, 0x00000000, 0x00000000, -0x1e000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x00000000, -0x00000000, 0x00000000, 0x3d800000, 0x00000000, 0x00000000, 0x00000000, -0x3f94fdf4, 0x00000000, 0x00000000, 0x00000000, 0x3f000000, 0x00000000, -0x00000000, 0x00000000, 0x3fb374bc, 0x00000000, 0x00000000, 0x00000000, -0x3eb0331e, 0x00000000, 0x00000000, 0x00000000, 0x3f36d1e1, 0x00000000, -0x00000000, 0x00000000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x00000000, -0x0000000e, 0x00000003, 0x00000009, 0x00000000, 0x0000000c, 0x00000012, -0x00000005, 0x00000003, 0x00000000, 0x00000000, 0x00000018, 0x00000006, -0x00000003, 0x00000000, 0x00000004, 0x0000001f, 0x00000006, 0x00000003, -0x00000000, 0x00000008, 0x00000000, 0x00000003, 0x0000000f, 0x00030005, -0x00000000, 0x00000004, 0x00000004, 0x0000000f, 0x00030005, 0x00000004, -0x00000009, 0x00000004, 0x0000000f, 0x00030005, 0x00000008, 0x00786574, -0x75786574, 0x78657400, 0x6f630076, 0x6574006c, 0x00635f78, 0x5f786574, -0x74003263, 0x635f7865, 0x00000033, \ No newline at end of file +0x00000000, 0x02020001, 0x237823e4, 0x00000000, 0x01e40103, 0x02030001, +0x2ef823e4, 0x00000000, 0x02e40103, 0x02040001, 0x2ef823e4, 0x00000000, +0x00000000, 0x02050000, 0x20f824e4, 0x00000000, 0x06e40103, 0x01040002, +0x2ef823e4, 0x00000000, 0x03000000, 0x0103e400, 0x237a10e4, 0x00000000, +0x00000000, 0x00000000, 0x1e000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x3f94fdf4, 0x3f94fdf4, 0x3f94fdf4, 0x00000000, 0x00000000, 0xbeb02de0, +0x3fe2d0e5, 0x00000000, 0x3fb374bc, 0xbf36cf42, 0x00000000, 0x00000000, +0xbf4617c2, 0x3ee9a027, 0xbf7573eb, 0x3f800000, 0x3f800000, 0x00000000, +0x00000000, 0x00000000, 0x0000000e, 0x00000003, 0x00000009, 0x00000000, +0x0000000c, 0x00000012, 0x00000005, 0x00000003, 0x00000000, 0x00000000, +0x00000018, 0x00000006, 0x00000003, 0x00000000, 0x00000004, 0x0000001f, +0x00000006, 0x00000003, 0x00000000, 0x00000008, 0x00000000, 0x00000003, +0x0000000f, 0x00030005, 0x00000000, 0x00000004, 0x00000004, 0x0000000f, +0x00030005, 0x00000004, 0x00000009, 0x00000004, 0x0000000f, 0x00030005, +0x00000008, 0x00786574, 0x75786574, 0x78657400, 0x6f630076, 0x6574006c, +0x00635f78, 0x5f786574, 0x74003263, 0x635f7865, 0x00000033, diff --git a/src/modules/engines/gl_common/shader/yuv_frag_s3c6410.asm b/src/modules/engines/gl_common/shader/yuv_frag_s3c6410.asm new file mode 100644 index 0000000..9a10bf0 --- /dev/null +++ b/src/modules/engines/gl_common/shader/yuv_frag_s3c6410.asm @@ -0,0 +1,46 @@ + +#------------------------------------------------- +# ORION - OpenGL ES 2.0 Shading Language Compiler +# SAMSUNG INDIA SOFTWARE OPERATIONS PVT. LTD. +# Compiler Version : v04.00.09 +# Release Date : 19.01.2009 +# FIMG VERSION : FIMGv1.5 +# Optimizer Options : -O --nolodcalc +#------------------------------------------------- + +# hand optimised - removed useless ops + +ps_3_0 + +fimg_version 0x01020000 + +dcl_s2_tex s0 +dcl_s2_texu s1 +dcl_s2_texv s2 +dcl_f4_col v3.x +dcl_f2_tex_c v0.x +dcl_f2_tex_c2 v1.x +dcl_f2_tex_c3 v2.x + +def c2, 1.164000, 1.164000, 1.164000, 0.000000 +def c3, 0.000000, -0.344100, 1.772000, 0.000000 +def c4, 1.402000, -0.714100, 0.000000, 0.000000 +def c5, -0.773800, 0.456300, -0.958800, 1.000000 +def c6, 1.000000, 0.000000, 0.000000, 0.000000 + +label start +label main_ +mul r0.xyzw, c6.xxyy, v0.xyyy # tex_c=v0.xyyy +texld r0.xyzw, r0.xyzw, s0 # tex=s0 +mul r1.xyzw, c6.xxyy, v1.xyyy # tex_c2=v1.xyyy +texld r1.xyzw, r1.xyzw, s1 # texu=s1 +mul r2.xyzw, c6.xxyy, v2.xyyy # tex_c3=v2.xyyy +texld r2.xyzw, r2.xyzw, s2 # texv=s2 +mul r3.xyzw, c2.xyzw, r0.xxxx # yuv=r0.xxxx +mad r3.xyzw, c3.xyzw, r1.xxxx, r3.xyzw # yuv=r1.xxxx +mad r3.xyzw, c4.xyzw, r2.xxxx, r3.xyzw # yuv=r2.xxxx +mov r4.xyzw, c5.xyzw +mad r3.xyzw, r4.xyzw, c6.xxxx, r3.xyzw # yuv=c6.xxxx +mul_sat oColor.xyzw, r3.xyzw, v3.xyzw # gl_FragColor=oColor.xyzw, col=v3.xyzw +label main_end +ret diff --git a/src/modules/engines/gl_x11/evas_engine.c b/src/modules/engines/gl_x11/evas_engine.c index eb1f436..b6e4c17 100644 --- a/src/modules/engines/gl_x11/evas_engine.c +++ b/src/modules/engines/gl_x11/evas_engine.c @@ -1028,6 +1028,25 @@ eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint) { } +static void +eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *image, RGBA_Map_Point *p, int smooth, int level) +{ + // XXX +} + +static void * +eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha) +{ + // XXX + return NULL; +} + +static void +eng_image_map_surface_free(void *data __UNUSED__, void *surface) +{ + // XXX +} + static int eng_image_scale_hint_get(void *data __UNUSED__, void *image) { @@ -1175,9 +1194,9 @@ module_open(Evas_Module *em) ORD(image_scale_hint_set); ORD(image_scale_hint_get); - //ODR(image_map4_draw); - //ODR(image_map_surface_new); - //ODR(image_map_surface_free); + ORD(image_map4_draw); + ORD(image_map_surface_new); + ORD(image_map_surface_free); /* now advertise out own api */ em->functions = (void *)(&func);