diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index a2f7431701..7b175f12db 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -687,6 +687,10 @@ modules/evas/engines/gl_common/shader/img_mask_frag.shd \ modules/evas/engines/gl_common/shader/img_mask_vert.shd \ modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd \ modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd \ +modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd \ +modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd \ +modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd \ +modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd \ $(NULL) EXTRA_DIST += \ diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index c314e4d88e..b201183f64 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -722,42 +722,41 @@ void evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only); void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a); -void evas_gl_common_context_masked_font_push(Evas_Engine_GL_Context *gc, - Evas_GL_Texture *tex, - double sx, double sy, double sw, double sh, - int x, int y, int w, int h, - int r, int g, int b, int a, - Evas_GL_Texture *texa, - int mx, int my, int mw, int mh); void evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth); void evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth); void evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth); void evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth); void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, @@ -765,19 +764,11 @@ void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *g int npoints, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only, Evas_Colorspace cspace); -void evas_gl_common_context_masked_image_push(Evas_Engine_GL_Context *gc, - Evas_GL_Texture *tex, - Evas_GL_Texture *mask_tex, - double sx, double sy, - double sw, double sh, - int x, int y, int w, int h, - int mx, int my, int mw, int mh, - int r, int g, int b, int a, - Eina_Bool smooth, Eina_Bool tex_only); int evas_gl_common_shader_program_init(Evas_GL_Shared *shared); void evas_gl_common_shader_program_init_done(void); diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c index abe448e21b..00e4489560 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -856,6 +856,11 @@ evas_gl_common_context_new(void) SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, tex); SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, texa); + SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA, tex); + SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA, texa); + SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA_NOMUL, tex); + SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA_NOMUL, texa); + SHADER_TEXTURE_ADD(shared, FONT_MASK, tex); SHADER_TEXTURE_ADD(shared, FONT_MASK, texa); @@ -1331,18 +1336,21 @@ static inline Evas_GL_Shader evas_gl_common_shader_choice(int npoints EINA_UNUSED, RGBA_Map_Point *p, int r, int g, int b, int a, + Eina_Bool has_mask, Evas_GL_Shader nomul, - Evas_GL_Shader mul) + Evas_GL_Shader mul, + Evas_GL_Shader mask_nomul, + Evas_GL_Shader mask_mul) { if ((a == 255) && (r == 255) && (g == 255) && (b == 255)) { - if (!p) return nomul; + if (!p) return (has_mask ? mask_nomul : nomul); if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) && (p[2].col == 0xffffffff) && (p[3].col == 0xffffffff)) - return nomul; + return (has_mask ? mask_nomul : nomul); } - return mul; + return (has_mask ? mask_mul : mul); } static int @@ -1650,11 +1658,12 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only) { Evas_GL_Texture_Pool *pt; - int pnum, nv, nc, nu, ns, i; + int pnum, nv, nc, nu, ns, na, i; GLfloat tx1, tx2, ty1, ty2; GLfloat offsetx, offsety; Eina_Bool blend = EINA_FALSE; @@ -1662,7 +1671,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, int pn = 0, sam = 0; if (!(gc->dc->render_op == EVAS_RENDER_COPY) && - ((a < 255) || (tex->alpha))) blend = EINA_TRUE; + ((a < 255) || (tex->alpha) || (!!mtex))) blend = EINA_TRUE; if (gc->filter_prog) { @@ -1674,26 +1683,30 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, { if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2)))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_22_BGRA_NOMUL, SHADER_IMG_22_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_22_BGRA_NOMUL, SHADER_IMG_22_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else if ((smooth) && (sw >= (w * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_21_BGRA_NOMUL, SHADER_IMG_21_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_21_BGRA_NOMUL, SHADER_IMG_21_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else if ((smooth) && (sh >= (h * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_12_BGRA_NOMUL, SHADER_IMG_12_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_12_BGRA_NOMUL, SHADER_IMG_12_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; } } else @@ -1701,41 +1714,49 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2)))) { if ((!tex->alpha) && (tex->pt->native)) - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_22_NOMUL_AFILL, SHADER_TEX_22_AFILL)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_22_NOMUL_AFILL, SHADER_TEX_22_AFILL, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; else - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_22_NOMUL, SHADER_TEX_22)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_22_NOMUL, SHADER_TEX_22, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else if ((smooth) && (sw >= (w * 2))) { if ((!tex->alpha) && (tex->pt->native)) - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_21_NOMUL_AFILL, SHADER_TEX_21_AFILL)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_21_NOMUL_AFILL, SHADER_TEX_21_AFILL, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; else - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_21_NOMUL, SHADER_TEX_21)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_21_NOMUL, SHADER_TEX_21, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else if ((smooth) && (sh >= (h * 2))) { if ((!tex->alpha) && (tex->pt->native)) - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_12_NOMUL_AFILL, SHADER_TEX_12_AFILL)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_12_NOMUL_AFILL, SHADER_TEX_12_AFILL, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; else - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_12_NOMUL, SHADER_TEX_12)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_12_NOMUL, SHADER_TEX_12, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else { if ((!tex->alpha) && (tex->pt->native)) - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_NOMUL_AFILL, SHADER_TEX_AFILL)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_NOMUL_AFILL, SHADER_TEX_AFILL, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; else - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_TEX_NOMUL, SHADER_TEX)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_TEX_NOMUL, SHADER_TEX, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; } } } @@ -1745,52 +1766,60 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, { if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2)))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_22_BGRA_NOMUL, SHADER_IMG_22_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_22_BGRA_NOMUL, SHADER_IMG_22_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else if ((smooth) && (sw >= (w * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_21_BGRA_NOMUL, SHADER_IMG_21_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_21_BGRA_NOMUL, SHADER_IMG_21_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else if ((smooth) && (sh >= (h * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_12_BGRA_NOMUL, SHADER_IMG_12_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_12_BGRA_NOMUL, SHADER_IMG_12_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; sam = 1; } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; } } else { if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2)))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_22_NOMUL, SHADER_IMG_22)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_22_NOMUL, SHADER_IMG_22, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else if ((smooth) && (sw >= (w * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_21_NOMUL, SHADER_IMG_21)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_21_NOMUL, SHADER_IMG_21, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else if ((smooth) && (sh >= (h * 2))) { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_12_NOMUL, SHADER_IMG_12)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_12_NOMUL, SHADER_IMG_12, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; sam = 1; } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, - SHADER_IMG_NOMUL, SHADER_IMG)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_IMG_NOMUL, SHADER_IMG, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; } } } @@ -1824,6 +1853,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].region.type = RTYPE_IMAGE; gc->pipe[pn].shader.cur_tex = pt->texture; + gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0; gc->pipe[pn].shader.cur_prog = prog; gc->pipe[pn].shader.smooth = smooth; gc->pipe[pn].shader.blend = blend; @@ -1840,13 +1870,13 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = 0; gc->pipe[pn].array.use_texuv3 = 0; - gc->pipe[pn].array.use_texa = 0; + gc->pipe[pn].array.use_texa = !!mtex; gc->pipe[pn].array.use_texsam = sam; pipe_region_expand(gc, pn, x, y, w, h); pnum = gc->pipe[pn].array.num; - nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; ns = pnum * 2; + nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; ns = pnum * 2; na = pnum * 2; gc->pipe[pn].array.num += 6; array_alloc(gc, pn); @@ -1894,6 +1924,24 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, PUSH_TEXSAM(pn, samx, samy); PUSH_TEXSAM(pn, samx, samy); } + + if (mtex) + { + GLfloat t2x1, t2x2, t2y1, t2y2; + + t2x1 = (mtex->x + mx) / (double)mtex->pt->w; + t2y1 = (mtex->y + my) / (double)mtex->pt->h; + t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w; + t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h; + + PUSH_TEXA(pn, t2x1, t2y1); + PUSH_TEXA(pn, t2x2, t2y1); + PUSH_TEXA(pn, t2x1, t2y2); + + PUSH_TEXA(pn, t2x2, t2y1); + PUSH_TEXA(pn, t2x2, t2y2); + PUSH_TEXA(pn, t2x1, t2y2); + } // if nomul... dont need this for (i = 0; i < 6; i++) @@ -1902,118 +1950,24 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc, } } -void -evas_gl_common_context_masked_font_push(Evas_Engine_GL_Context *gc, - Evas_GL_Texture *tex, - double sx, double sy, double sw, double sh, - int x, int y, int w, int h, - int r, int g, int b, int a, - Evas_GL_Texture *texa, - int mx, int my, int mw, int mh) -{ - int pnum, nv, nc, nu, na, i; - GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; - GLuint prog = gc->shared->shader[SHADER_FONT_MASK].prog; - int pn = 0; - - pn = _evas_gl_common_context_push(RTYPE_FONT, - gc, tex, - prog, - x, y, w, h, - 1, - 0, - 0, 0, 0, 0, 0); - - gc->pipe[pn].region.type = RTYPE_FONT; - gc->pipe[pn].shader.cur_tex = tex->pt->texture; - gc->pipe[pn].shader.cur_texa = texa->pt->texture; - gc->pipe[pn].shader.cur_prog = prog; - gc->pipe[pn].shader.smooth = 0; - gc->pipe[pn].shader.blend = 1; - gc->pipe[pn].shader.render_op = gc->dc->render_op; - gc->pipe[pn].shader.clip = 0; - gc->pipe[pn].shader.cx = 0; - gc->pipe[pn].shader.cy = 0; - gc->pipe[pn].shader.cw = 0; - gc->pipe[pn].shader.ch = 0; - gc->pipe[pn].array.line = 0; - gc->pipe[pn].array.use_vertex = 1; - gc->pipe[pn].array.use_color = 1; - gc->pipe[pn].array.use_texuv = 1; - gc->pipe[pn].array.use_texuv2 = 0; - gc->pipe[pn].array.use_texuv3 = 0; - gc->pipe[pn].array.use_texa = 1; // - gc->pipe[pn].array.use_texsam = 0; - - pipe_region_expand(gc, pn, x, y, w, h); - - pnum = gc->pipe[pn].array.num; - nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2; - gc->pipe[pn].array.num += 6; - array_alloc(gc, pn); - - if (sw == 0.0) - { - tx1 = tex->sx1; - ty1 = tex->sy1; - tx2 = tex->sx2; - ty2 = tex->sy2; - } - else - { - tx1 = ((double)(tex->x) + sx) / (double)tex->pt->w; - ty1 = ((double)(tex->y) + sy) / (double)tex->pt->h; - tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w; - ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h; - } - - t2x1 = (texa->x + mx) / (double)texa->pt->w; - t2y1 = (texa->y + my) / (double)texa->pt->h; - t2x2 = (texa->x + mx + mw) / (double)texa->pt->w; - t2y2 = (texa->y + my + mh) / (double)texa->pt->h; - - PUSH_VERTEX(pn, x , y , 0); - PUSH_VERTEX(pn, x + w, y , 0); - PUSH_VERTEX(pn, x , y + h, 0); - - PUSH_TEXUV(pn, tx1, ty1); - PUSH_TEXUV(pn, tx2, ty1); - PUSH_TEXUV(pn, tx1, ty2); - - PUSH_TEXA(pn, t2x1, t2y1); - PUSH_TEXA(pn, t2x2, t2y1); - PUSH_TEXA(pn, t2x1, t2y2); - - PUSH_VERTEX(pn, x + w, y , 0); - PUSH_VERTEX(pn, x + w, y + h, 0); - PUSH_VERTEX(pn, x , y + h, 0); - - PUSH_TEXUV(pn, tx2, ty1); - PUSH_TEXUV(pn, tx2, ty2); - PUSH_TEXUV(pn, tx1, ty2); - - PUSH_TEXA(pn, t2x2, t2y1); - PUSH_TEXA(pn, t2x2, t2y2); - PUSH_TEXA(pn, t2x1, t2y2); - - for (i = 0; i < 6; i++) - { - PUSH_COLOR(pn, r, g, b, a); - } -} - void evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a) { - int pnum, nv, nc, nu, i; + int pnum, nv, nc, nu, na, i; GLfloat tx1, tx2, ty1, ty2; - GLuint prog = gc->shared->shader[SHADER_FONT].prog; + GLuint prog; int pn = 0; + if (!mtex) + prog = gc->shared->shader[SHADER_FONT].prog; + else + prog = gc->shared->shader[SHADER_FONT_MASK].prog; + pn = _evas_gl_common_context_push(RTYPE_FONT, gc, tex, prog, @@ -2024,6 +1978,7 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].region.type = RTYPE_FONT; gc->pipe[pn].shader.cur_tex = tex->pt->texture; + gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0; gc->pipe[pn].shader.cur_prog = prog; gc->pipe[pn].shader.smooth = 0; gc->pipe[pn].shader.blend = 1; @@ -2039,13 +1994,13 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = 0; gc->pipe[pn].array.use_texuv3 = 0; - gc->pipe[pn].array.use_texa = 0; + gc->pipe[pn].array.use_texa = !!mtex; gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); pnum = gc->pipe[pn].array.num; - nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; + nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = 2 * pnum; gc->pipe[pn].array.num += 6; array_alloc(gc, pn); @@ -2080,6 +2035,24 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc, PUSH_TEXUV(pn, tx2, ty2); PUSH_TEXUV(pn, tx1, ty2); + if (mtex) + { + GLfloat t2x1, t2x2, t2y1, t2y2; + + t2x1 = (mtex->x + mx) / (double)mtex->pt->w; + t2y1 = (mtex->y + my) / (double)mtex->pt->h; + t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w; + t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h; + + PUSH_TEXA(pn, t2x1, t2y1); + PUSH_TEXA(pn, t2x2, t2y1); + PUSH_TEXA(pn, t2x1, t2y2); + + PUSH_TEXA(pn, t2x2, t2y1); + PUSH_TEXA(pn, t2x2, t2y2); + PUSH_TEXA(pn, t2x1, t2y2); + } + for (i = 0; i < 6; i++) { PUSH_COLOR(pn, r, g, b, a); @@ -2091,6 +2064,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2102,7 +2076,9 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc, if (a < 255) blend = 1; - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, +#warning YUV+mask + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_YUV_NOMUL, SHADER_YUV, SHADER_YUV_NOMUL, SHADER_YUV)].prog; pn = _evas_gl_common_context_push(RTYPE_YUV, @@ -2196,6 +2172,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2207,7 +2184,9 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc, if (a < 255) blend = 1; - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, +#warning mask + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_YUY2_NOMUL, SHADER_YUY2, SHADER_YUY2_NOMUL, SHADER_YUY2)].prog; pn = _evas_gl_common_context_push(RTYPE_YUY2, @@ -2292,6 +2271,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc, Evas_GL_Texture *tex, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2303,7 +2283,9 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc, if (a < 255) blend = 1; - prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, +#warning mask + prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex, + SHADER_NV12_NOMUL, SHADER_NV12, SHADER_NV12_NOMUL, SHADER_NV12)].prog; pn = _evas_gl_common_context_push(RTYPE_NV12, @@ -2391,6 +2373,7 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc, double sx, double sy, double sw, double sh, int x, int y, int w, int h, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth) @@ -2407,8 +2390,11 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc, GLuint prog; int pn; +#warning rgba+a+mask prog = gc->shared->shader[evas_gl_common_shader_choice - (0, NULL, r, g, b, a, SHADER_RGB_A_PAIR_NOMUL, SHADER_RGB_A_PAIR)].prog; + (0, NULL, r, g, b, a, !!mtex, + SHADER_RGB_A_PAIR_NOMUL, SHADER_RGB_A_PAIR, + SHADER_RGB_A_PAIR_NOMUL, SHADER_RGB_A_PAIR)].prog; pn = _evas_gl_common_context_push(RTYPE_IMAGE, gc, tex, @@ -2494,6 +2480,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, int npoints, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only, Evas_Colorspace cspace) @@ -2531,18 +2518,21 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, { case EVAS_COLORSPACE_YCBCR422P601_PL: case EVAS_COLORSPACE_YCBCR422P709_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_YUV_NOMUL, SHADER_YUV, SHADER_YUV_NOMUL, SHADER_YUV)].prog; utexture = EINA_TRUE; break; case EVAS_COLORSPACE_YCBCR422601_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_YUY2_NOMUL, SHADER_YUY2, SHADER_YUY2_NOMUL, SHADER_YUY2)].prog; uvtexture = EINA_TRUE; break; case EVAS_COLORSPACE_YCBCR420NV12601_PL: case EVAS_COLORSPACE_YCBCR420TM12601_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_NV12_NOMUL, SHADER_NV12, SHADER_NV12_NOMUL, SHADER_NV12)].prog; uvtexture = EINA_TRUE; break; @@ -2552,28 +2542,30 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, { if (tex->pt->dyn.img) { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, - SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, - SHADER_TEX_NOMUL, SHADER_TEX)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_TEX_NOMUL, SHADER_TEX, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; } } else { if (tex->gc->shared->info.bgra) { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, - SHADER_IMG_BGRA_NOMUL, - SHADER_IMG_BGRA)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, - SHADER_IMG_NOMUL, - SHADER_IMG)].prog; + prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_NOMUL, SHADER_IMG, + SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; } } } @@ -2753,109 +2745,6 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, } } -void -evas_gl_common_context_masked_image_push(Evas_Engine_GL_Context *gc, - Evas_GL_Texture *tex, - Evas_GL_Texture *mask_tex, - double sx, double sy, - double sw, double sh, - int x, int y, int w, int h, - int mx, int my, int mw, int mh, - int r, int g, int b, int a, - Eina_Bool smooth, Eina_Bool tex_only) -{ - // FIXME: How to implement support for yuv, rgb_a_pair & map stuff? - // NOTE: If image (tex) has no alpha this is very similar to RGB+A pair - - // FIXME: Optimize for image vs. texture? - (void)tex_only; - - int pnum, nv, nc, nu, na, i; - GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; - GLuint prog; - int pn; - - // TODO: Big IF here (image type, etc --> needs tons of new shaders!) - prog = gc->shared->shader[evas_gl_common_shader_choice - (0, NULL, r, g, b, a, SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; - - pn = _evas_gl_common_context_push(RTYPE_IMAGE, - gc, tex, - prog, - x, y, w, h, - EINA_TRUE, - smooth, - EINA_FALSE, 0, 0, 0, 0); - - gc->pipe[pn].region.type = RTYPE_IMAGE; - gc->pipe[pn].shader.cur_tex = tex->pt->texture; - gc->pipe[pn].shader.cur_texa = mask_tex->pt->texture; - gc->pipe[pn].shader.cur_prog = prog; - gc->pipe[pn].shader.smooth = smooth; - gc->pipe[pn].shader.blend = EINA_TRUE; - gc->pipe[pn].shader.render_op = gc->dc->render_op; - gc->pipe[pn].shader.clip = 0; - gc->pipe[pn].shader.cx = 0; - gc->pipe[pn].shader.cy = 0; - gc->pipe[pn].shader.cw = 0; - gc->pipe[pn].shader.ch = 0; - gc->pipe[pn].array.line = 0; - gc->pipe[pn].array.use_vertex = EINA_TRUE; - // if nomul... dont need this - gc->pipe[pn].array.use_color = EINA_TRUE; - gc->pipe[pn].array.use_texuv = EINA_TRUE; - gc->pipe[pn].array.use_texuv2 = EINA_FALSE; - gc->pipe[pn].array.use_texuv3 = EINA_FALSE; - gc->pipe[pn].array.use_texa = EINA_TRUE; - gc->pipe[pn].array.use_texsam = EINA_FALSE; - - pipe_region_expand(gc, pn, x, y, w, h); - - pnum = gc->pipe[pn].array.num; - nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2; - gc->pipe[pn].array.num += 6; - array_alloc(gc, pn); - - tx1 = (tex->x + sx) / (double)tex->pt->w; - ty1 = (tex->y + sy) / (double)tex->pt->h; - tx2 = (tex->x + sx + sw) / (double)tex->pt->w; - ty2 = (tex->y + sy + sh) / (double)tex->pt->h; - - t2x1 = (mask_tex->x + mx) / (double)mask_tex->pt->w; - t2y1 = (mask_tex->y + my) / (double)mask_tex->pt->h; - t2x2 = (mask_tex->x + mx + mw) / (double)mask_tex->pt->w; - t2y2 = (mask_tex->y + my + mh) / (double)mask_tex->pt->h; - - PUSH_VERTEX(pn, x , y , 0); - PUSH_VERTEX(pn, x + w, y , 0); - PUSH_VERTEX(pn, x , y + h, 0); - - PUSH_TEXUV(pn, tx1, ty1); - PUSH_TEXUV(pn, tx2, ty1); - PUSH_TEXUV(pn, tx1, ty2); - - PUSH_TEXA(pn, t2x1, t2y1); - PUSH_TEXA(pn, t2x2, t2y1); - PUSH_TEXA(pn, t2x1, t2y2); - - PUSH_VERTEX(pn, x + w, y , 0); - PUSH_VERTEX(pn, x + w, y + h, 0); - PUSH_VERTEX(pn, x , y + h, 0); - - PUSH_TEXUV(pn, tx2, ty1); - PUSH_TEXUV(pn, tx2, ty2); - PUSH_TEXUV(pn, tx1, ty2); - - PUSH_TEXA(pn, t2x2, t2y1); - PUSH_TEXA(pn, t2x2, t2y2); - PUSH_TEXA(pn, t2x1, t2y2); - - for (i = 0; i < 6; i++) - { - PUSH_COLOR(pn, r, g, b, a); - } -} - EAPI void evas_gl_common_context_flush(Evas_Engine_GL_Context *gc) { diff --git a/src/modules/evas/engines/gl_common/evas_gl_font.c b/src/modules/evas/engines/gl_common/evas_gl_font.c index b7663a2b44..e43318a5f3 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_font.c +++ b/src/modules/evas/engines/gl_common/evas_gl_font.c @@ -61,14 +61,14 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c { Evas_Engine_GL_Context *gc = context; RGBA_Draw_Context *dc = draw_context; - Evas_GL_Texture *tex; + Evas_GL_Texture *tex, *mtex = NULL; Cutout_Rect *rct; int r, g, b, a; double ssx, ssy, ssw, ssh; int c, cx, cy, cw, ch; int i; int sx, sy, sw, sh; - double mx, my, mw, mh, mmx, mmy, mmw, mmh; + double mmx, mmy, mmw, mmh; if (dc != gc->dc) return; tex = fg->ext_dat; @@ -85,34 +85,33 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c // FIXME: This code path does not handle half the stuff the other path does... Evas_GL_Image *mask = gc->dc->clip.mask; int nx, ny, nw, nh, dx, dy, dw, dh; + double mx, my, mw, mh; - nx = x; ny = y; nw = tex->w; nh = tex->h; - RECTS_CLIP_TO_RECT(nx, ny, nw, nh, - gc->dc->clip.x, gc->dc->clip.y, - gc->dc->clip.w, gc->dc->clip.h); - if ((nw < 1) || (nh < 1)) return; + if (mask->tex) + { + nx = x; ny = y; nw = tex->w; nh = tex->h; + RECTS_CLIP_TO_RECT(nx, ny, nw, nh, + gc->dc->clip.x, gc->dc->clip.y, + gc->dc->clip.w, gc->dc->clip.h); + if ((nw < 1) || (nh < 1)) return; - ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w)); - ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h)); - ssw = ((double)sw * (double)(nw)) / (double)(tex->w); - ssh = ((double)sh * (double)(nh)) / (double)(tex->h); + ssx = (double)sx + ((double)(sw * (nx - x)) / (double)(tex->w)); + ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h)); + ssw = ((double)sw * (double)(nw)) / (double)(tex->w); + ssh = ((double)sh * (double)(nh)) / (double)(tex->h); - dx = x; dy = y; dw = sw; dh = sh; - mx = gc->dc->clip.mask_x; my = gc->dc->clip.mask_y; mw = mask->w; mh = mask->h; - //RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); - RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); + dx = x; dy = y; dw = sw; dh = sh; + mx = gc->dc->clip.mask_x; my = gc->dc->clip.mask_y; mw = mask->w; mh = mask->h; + //RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); + RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); - mmx = (double)(mx - gc->dc->clip.mask_x) + ((double)(mw * (nx - dx)) / (double)(dw)); - mmy = (double)(my - gc->dc->clip.mask_y) + ((double)(mh * (ny - dy)) / (double)(dh)); - mmw = ((double)mw * (double)(nw)) / (double)(dw); - mmh = ((double)mh * (double)(nh)) / (double)(dh); + mmx = (double)(mx - gc->dc->clip.mask_x) + ((double)(mw * (nx - dx)) / (double)(dw)); + mmy = (double)(my - gc->dc->clip.mask_y) + ((double)(mh * (ny - dy)) / (double)(dh)); + mmw = ((double)mw * (double)(nw)) / (double)(dw); + mmh = ((double)mh * (double)(nh)) / (double)(dh); - evas_gl_common_context_masked_font_push(gc, tex, - ssx, ssy, ssw, ssh, - nx, ny, nw, nh, - r, g, b, a, - mask->tex, mmx, mmy, mmw, mmh); - return; + mtex = mask->tex; + } } if ((!gc->dc->cutout.rects) || @@ -134,6 +133,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c 0.0, 0.0, 0.0, 0.0, // sx, sy, sw, sh, x, y, tex->w, tex->h, + mtex, mmx, mmy, mmw, mmh, r, g, b, a); return; } @@ -144,6 +144,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c evas_gl_common_context_font_push(gc, tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a); } else @@ -152,6 +153,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c 0.0, 0.0, 0.0, 0.0, // sx, sy, sw, sh, x, y, tex->w, tex->h, + mtex, mmx, mmy, mmw, mmh, r, g, b, a); } return; @@ -181,6 +183,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c 0.0, 0.0, 0.0, 0.0, // sx, sy, sw, sh, x, y, tex->w, tex->h, + mtex, mmx, mmy, mmw, mmh, r, g, b, a); continue; } @@ -191,6 +194,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c evas_gl_common_context_font_push(gc, tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a); } evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c index 583a6a6baf..05965803c0 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -948,6 +948,7 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, evas_gl_common_context_image_map_push(gc, im->tex, npoints, p, c, cx, cy, cw, ch, + NULL, 0, 0, 0, 0, r, g, b, a, smooth, im->tex_only, im->cs.space); } @@ -963,8 +964,9 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, Eina_Bool yuv, Eina_Bool yuy2, Eina_Bool nv12, Eina_Bool rgb_a_pair) { - double mx, my, mw, mh, mmx, mmy, mmw, mmh; + double mmx = 0, mmy = 0, mmw = 0, mmh = 0; double ssx, ssy, ssw, ssh; + Evas_GL_Texture *mtex = NULL; int nx, ny, nw, nh; nx = dx; ny = dy; nw = dw; nh = dh; @@ -973,33 +975,29 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, if ((nw < 1) || (nh < 1)) return; if (!im->tex) return; + if (mask && mask->tex) + { + double mx, my, mw, mh; + + mtex = mask->tex; + mx = mask_x; my = mask_y; mw = mask->w; mh = mask->h; + RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); + RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); + + mmx = (double)(mx - mask_x) + ((double)(mw * (nx - dx)) / (double)(dw)); + mmy = (double)(my - mask_y) + ((double)(mh * (ny - dy)) / (double)(dh)); + mmw = ((double)mw * (double)(nw)) / (double)(dw); + mmh = ((double)mh * (double)(nh)) / (double)(dh); + } + if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh)) { - /* Apply mask on image */ - if (mask) - { - // FIXME/TODO: support for yuv, yuy2, nv12, rgb_a with masks - mx = mask_x; my = mask_y; mw = mask->w; mh = mask->h; - RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); - RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); - - mmx = (double)(mx - mask_x) + ((double)(mw * (nx - dx)) / (double)(dw)); - mmy = (double)(my - mask_y) + ((double)(mh * (ny - dy)) / (double)(dh)); - mmw = ((double)mw * (double)(nw)) / (double)(dw); - mmh = ((double)mh * (double)(nh)) / (double)(dh); - - evas_gl_common_context_masked_image_push(gc, im->tex, mask->tex, - sx, sy, sw, sh, - dx, dy, dw, dh, - mmx, mmy, mmw, mmh, - r, g, b, a, - smooth, im->tex_only); - } - else if (yuv) + if (yuv) evas_gl_common_context_yuv_push(gc, im->tex, sx, sy, sw, sh, dx, dy, dw, dh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (yuy2) @@ -1007,6 +1005,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, sx, sy, sw, sh, dx, dy, dw, dh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (nv12) @@ -1014,6 +1013,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, sx, sy, sw, sh, dx, dy, dw, dh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (rgb_a_pair) @@ -1021,6 +1021,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, sx, sy, sw, sh, dx, dy, dw, dh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else @@ -1028,6 +1029,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, sx, sy, sw, sh, dx, dy, dw, dh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth, im->tex_only); return; @@ -1038,31 +1040,12 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, ssw = ((double)sw * (double)(nw)) / (double)(dw); ssh = ((double)sh * (double)(nh)) / (double)(dh); - /* Apply mask on image */ - if (mask) - { - // FIXME/TODO: support for yuv, yuy2, nv12, rgb_a with masks - mx = mask_x; my = mask_y; mw = mask->w; mh = mask->h; - RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); - RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); - - mmx = (double)(mx - mask_x) + ((double)(mw * (nx - dx)) / (double)(dw)); - mmy = (double)(my - mask_y) + ((double)(mh * (ny - dy)) / (double)(dh)); - mmw = ((double)mw * (double)(nw)) / (double)(dw); - mmh = ((double)mh * (double)(nh)) / (double)(dh); - - evas_gl_common_context_masked_image_push(gc, im->tex, mask->tex, - ssx, ssy, ssw, ssh, - nx, ny, nw, nh, - mmx, mmy, mmw, mmh, - r, g, b, a, - smooth, im->tex_only); - } - else if (yuv) + if (yuv) evas_gl_common_context_yuv_push(gc, im->tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (yuy2) @@ -1070,6 +1053,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (nv12) @@ -1077,6 +1061,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else if (rgb_a_pair) @@ -1084,6 +1069,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth); else @@ -1091,6 +1077,7 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, im->tex, ssx, ssy, ssw, ssh, nx, ny, nw, nh, + mtex, mmx, mmy, mmw, mmh, r, g, b, a, smooth, im->tex_only); } diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x index 04614ac134..29f2e8a182 100644 --- a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x +++ b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x @@ -47,5 +47,7 @@ typedef enum { SHADER_YUY2, SHADER_IMG_MASK, SHADER_IMG_MASK_NOMUL, + SHADER_IMG_MASK_BGRA, + SHADER_IMG_MASK_BGRA_NOMUL, SHADER_LAST } Evas_GL_Shader; diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x index 9916ef0f0f..690328a2c7 100644 --- a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x +++ b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x @@ -2247,8 +2247,7 @@ static const char const img_mask_frag_glsl[] = "varying vec2 coord_a;\n" "void main()\n" "{\n" - " gl_FragColor.rgb = col.rgb * texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;\n" - " gl_FragColor.a = col.a * texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;\n" + " gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy).bgra * col;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_frag_src = { @@ -2297,8 +2296,7 @@ static const char const img_mask_nomul_frag_glsl[] = "varying vec2 coord_a;\n" "void main()\n" "{\n" - " gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;\n" - " gl_FragColor.a = texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;\n" + " gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texa, coord_a).a;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_nomul_frag_src = { @@ -2329,6 +2327,102 @@ Evas_GL_Program_Source shader_img_mask_nomul_vert_src = NULL, 0 }; +/* Source: modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd */ +static const char const img_mask_bgra_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex;\n" + "uniform sampler2D texa;\n" + "varying vec4 col;\n" + "varying vec2 coord_c;\n" + "varying vec2 coord_a;\n" + "void main()\n" + "{\n" + " gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy) * col;\n" + "}\n"; +Evas_GL_Program_Source shader_img_mask_bgra_frag_src = +{ + img_mask_bgra_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd */ +static const char const img_mask_bgra_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex;\n" + "attribute vec4 color;\n" + "attribute vec2 tex_coord;\n" + "attribute vec2 tex_coorda;\n" + "uniform mat4 mvp;\n" + "varying vec4 col;\n" + "varying vec2 coord_c;\n" + "varying vec2 coord_a;\n" + "void main()\n" + "{\n" + " gl_Position = mvp * vertex;\n" + " col = color;\n" + " coord_c = tex_coord;\n" + " coord_a = tex_coorda;\n" + "}\n"; +Evas_GL_Program_Source shader_img_mask_bgra_vert_src = +{ + img_mask_bgra_vert_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd */ +static const char const img_mask_bgra_nomul_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex;\n" + "uniform sampler2D texa;\n" + "varying vec2 coord_c;\n" + "varying vec2 coord_a;\n" + "void main()\n" + "{\n" + " gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy);\n" + "}\n"; +Evas_GL_Program_Source shader_img_mask_bgra_nomul_frag_src = +{ + img_mask_bgra_nomul_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd */ +static const char const img_mask_bgra_nomul_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex;\n" + "attribute vec2 tex_coord;\n" + "attribute vec2 tex_coorda;\n" + "uniform mat4 mvp;\n" + "varying vec2 coord_c;\n" + "varying vec2 coord_a;\n" + "void main()\n" + "{\n" + " gl_Position = mvp * vertex;\n" + " coord_c = tex_coord;\n" + " coord_a = tex_coorda;\n" + "}\n"; +Evas_GL_Program_Source shader_img_mask_bgra_nomul_vert_src = +{ + img_mask_bgra_nomul_vert_glsl, + NULL, 0 +}; + static const struct { Evas_GL_Shader id; Evas_GL_Program_Source *vert; @@ -2380,5 +2474,7 @@ static const struct { { SHADER_YUY2, &(shader_yuy2_vert_src), &(shader_yuy2_frag_src), "yuy2" }, { SHADER_IMG_MASK, &(shader_img_mask_vert_src), &(shader_img_mask_frag_src), "img_mask" }, { SHADER_IMG_MASK_NOMUL, &(shader_img_mask_nomul_vert_src), &(shader_img_mask_nomul_frag_src), "img_mask_nomul" }, + { SHADER_IMG_MASK_BGRA, &(shader_img_mask_bgra_vert_src), &(shader_img_mask_bgra_frag_src), "img_mask_bgra" }, + { SHADER_IMG_MASK_BGRA_NOMUL, &(shader_img_mask_bgra_nomul_vert_src), &(shader_img_mask_bgra_nomul_frag_src), "img_mask_bgra_nomul" }, }; diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd new file mode 100644 index 0000000000..8583474f58 --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd @@ -0,0 +1,17 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex; +uniform sampler2D texa; +varying vec4 col; +varying vec2 coord_c; +varying vec2 coord_a; +void main() +{ + gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy) * col; +} + diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd new file mode 100644 index 0000000000..4556cde3d1 --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd @@ -0,0 +1,16 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex; +uniform sampler2D texa; +varying vec2 coord_c; +varying vec2 coord_a; +void main() +{ + gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy); +} + diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd new file mode 100644 index 0000000000..a1debf63f2 --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd @@ -0,0 +1,16 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex; +attribute vec2 tex_coord; +attribute vec2 tex_coorda; +uniform mat4 mvp; +varying vec2 coord_c; +varying vec2 coord_a; +void main() +{ + gl_Position = mvp * vertex; + coord_c = tex_coord; + coord_a = tex_coorda; +} + diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd new file mode 100644 index 0000000000..3cd1740771 --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd @@ -0,0 +1,19 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex; +attribute vec4 color; +attribute vec2 tex_coord; +attribute vec2 tex_coorda; +uniform mat4 mvp; +varying vec4 col; +varying vec2 coord_c; +varying vec2 coord_a; +void main() +{ + gl_Position = mvp * vertex; + col = color; + coord_c = tex_coord; + coord_a = tex_coorda; +} + diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/img_mask_frag.shd index 2d1612a38e..fadbd281d0 100644 --- a/src/modules/evas/engines/gl_common/shader/img_mask_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/img_mask_frag.shd @@ -12,7 +12,6 @@ varying vec2 coord_c; varying vec2 coord_a; void main() { - gl_FragColor.rgb = col.rgb * texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g; - gl_FragColor.a = col.a * texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g; + gl_FragColor = texture2D(texa, coord_a.xy).a * texture2D(tex, coord_c.xy).bgra * col; } diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd index e5336f4246..b93d6fb6d5 100644 --- a/src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd @@ -11,7 +11,6 @@ varying vec2 coord_c; varying vec2 coord_a; void main() { - gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g; - gl_FragColor.a = texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g; + gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texa, coord_a).a; }