From 32009a0e8c7b9b9c563614be8b832db99cd17112 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 31 Mar 2015 18:58:51 +0900 Subject: [PATCH] Evas masking: Refactor GL code Use the same method as for map masking: - Pass absolute geometry of the mask to the push functions, - Compute absolute position in the shader (like gl_Position) and apply scaling factor + offset to sample the mask. Masking now uses a single vec4 attribute instead of hi-jacking other vertices. This way, all masking shaders share the same code and are way simpler. On the other hand, the vertex shaders have a little bit more work to do. --- .../evas/engines/gl_common/evas_gl_common.h | 20 +- .../evas/engines/gl_common/evas_gl_context.c | 274 ++++++++++----------- src/modules/evas/engines/gl_common/evas_gl_font.c | 32 +-- src/modules/evas/engines/gl_common/evas_gl_image.c | 35 +-- .../evas/engines/gl_common/evas_gl_rectangle.c | 28 +-- .../evas/engines/gl_common/evas_gl_shader.c | 6 +- .../engines/gl_common/shader/evas_gl_shaders.x | 151 +++++++----- .../engines/gl_common/shader/font_mask_vert.shd | 8 +- .../gl_common/shader/img_mask_bgra_frag.shd | 4 +- .../gl_common/shader/img_mask_bgra_nomul_frag.shd | 4 +- .../gl_common/shader/img_mask_bgra_nomul_vert.shd | 10 +- .../gl_common/shader/img_mask_bgra_vert.shd | 10 +- .../engines/gl_common/shader/img_mask_frag.shd | 4 +- .../gl_common/shader/img_mask_nomul_frag.shd | 4 +- .../gl_common/shader/img_mask_nomul_vert.shd | 10 +- .../engines/gl_common/shader/img_mask_vert.shd | 10 +- .../gl_common/shader/map_mask_bgra_nomul_vert.shd | 10 +- .../gl_common/shader/map_mask_bgra_vert.shd | 10 +- .../gl_common/shader/map_mask_nomul_vert.shd | 10 +- .../engines/gl_common/shader/map_mask_vert.shd | 10 +- .../engines/gl_common/shader/nv12_mask_vert.shd | 9 +- .../engines/gl_common/shader/rect_mask_frag.shd | 4 +- .../engines/gl_common/shader/rect_mask_vert.shd | 10 +- .../gl_common/shader/rgb_a_pair_mask_frag.shd | 6 +- .../gl_common/shader/rgb_a_pair_mask_vert.shd | 10 +- .../engines/gl_common/shader/yuv_mask_vert.shd | 9 +- .../engines/gl_common/shader/yuy2_mask_vert.shd | 9 +- 27 files changed, 354 insertions(+), 353 deletions(-) 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 112eb44..4556093 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -289,7 +289,7 @@ #define SHAD_TEXUV3 4 #define SHAD_TEXA 5 #define SHAD_TEXSAM 6 -#define SHAD_TEXM 7 +#define SHAD_MASK 7 typedef struct _Evas_GL_Program Evas_GL_Program; typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source; @@ -490,7 +490,7 @@ struct _Evas_Engine_GL_Context GLfloat *texuv3; GLfloat *texa; GLfloat *texsam; - GLfloat *texm; + GLfloat *mask; Eina_Bool line: 1; Eina_Bool use_vertex : 1; Eina_Bool use_color : 1; @@ -499,7 +499,7 @@ struct _Evas_Engine_GL_Context Eina_Bool use_texuv3 : 1; Eina_Bool use_texa : 1; Eina_Bool use_texsam : 1; - Eina_Bool use_texm : 1; + Eina_Bool use_mask : 1; Eina_Bool anti_alias : 1; Evas_GL_Image *im; GLuint buffer; @@ -720,46 +720,46 @@ void evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc, void evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int r, int g, int b, int a, - Evas_GL_Texture *mtex, double mx, double my, double mw, double mh, Eina_Bool mask_smooth); + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth); 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a); 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth); void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, 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 13ed9bc..d3ef178 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -1008,7 +1008,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc) if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); if (gc->pipe[i].array.texsam) free(gc->pipe[i].array.texsam); - if (gc->pipe[i].array.texm) free(gc->pipe[i].array.texm); + if (gc->pipe[i].array.mask) free(gc->pipe[i].array.mask); } } @@ -1273,6 +1273,11 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, _evas_gl_common_viewport_set(gc); } +#define VERTEX_CNT 3 +#define COLOR_CNT 4 +#define TEX_CNT 2 +#define MASK_CNT 4 + #define PUSH_VERTEX(n, x, y, z) do { \ gc->pipe[n].array.vertex[nv++] = x; \ gc->pipe[n].array.vertex[nv++] = y; \ @@ -1294,9 +1299,11 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, #define PUSH_TEXA(n, u, v) do { \ gc->pipe[n].array.texa[na++] = u; \ gc->pipe[n].array.texa[na++] = v; } while(0) -#define PUSH_TEXM(n, u, v) do { \ - gc->pipe[n].array.texm[nm++] = u; \ - gc->pipe[n].array.texm[nm++] = v; } while(0) +#define PUSH_TEXM(n, u, v, w, z) do { \ + gc->pipe[n].array.mask[nm++] = u; \ + gc->pipe[n].array.mask[nm++] = v; \ + gc->pipe[n].array.mask[nm++] = w; \ + gc->pipe[n].array.mask[nm++] = z; } while(0) #define PUSH_TEXSAM(n, x, y) do { \ gc->pipe[n].array.texsam[ns++] = x; \ gc->pipe[n].array.texsam[ns++] = y; } while(0) @@ -1329,29 +1336,61 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc, #define PUSH_6_COLORS(pn, r, g, b, a) \ do { int i; for (i = 0; i < 6; i++) PUSH_COLOR(pn, r, g, b, a); } while(0) +static inline Eina_Bool +_push_mask(Evas_Engine_GL_Context *gc, int pn, int nm, Evas_GL_Texture *mtex, + int mx, int my, int mw, int mh) +{ + double glmx, glmy, glmw, glmh, yinv = -1.f; + double gw = gc->w, gh = gc->h; + + if (!((gc->pipe[0].shader.surface == gc->def_surface) || + (!gc->pipe[0].shader.surface))) + { + gw = gc->pipe[0].shader.surface->w; + gh = gc->pipe[0].shader.surface->h; + yinv = 1.f; + } + + if (!gw || !gh || !mw || !mh || !mtex->pt->w || !mtex->pt->h) + return EINA_FALSE; + + /* vertex shader: + * vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + * tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; + */ + glmx = (double)((mtex->x * mw) - (mtex->w * mx)) / (double)(mw * mtex->pt->w); + glmy = (double)((mtex->y * mh) - (mtex->h * my)) / (double)(mh * mtex->pt->h); + glmw = (double)(gw * mtex->w) / (double)(mw * mtex->pt->w); + glmh = (double)(gh * mtex->h) / (double)(mh * mtex->pt->h); + glmh *= yinv; + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + PUSH_TEXM(pn, glmx, glmy, glmw, glmh); + + DBG("%d,%d %dx%d --> %f , %f - %f x %f [gc %dx%d, tex %d,%d %dx%d, pt %dx%d]", + mx, my, mw, mh, + glmx, glmy, glmw, glmh, + gc->w, gc->h, mtex->x, mtex->y, mtex->w, mtex->h, mtex->pt->w, mtex->pt->h); + + return EINA_TRUE; +} + #define PUSH_MASK(pn, mtex, mx, my, mw, mh) if (mtex) do { \ - GLfloat tmx1, tmx2, tmy1, tmy2; \ - tmx1 = mx; \ - tmy1 = my; \ - tmx2 = mx + mw; \ - tmy2 = my + mh; \ - PUSH_TEXM(pn, tmx1, tmy1); \ - PUSH_TEXM(pn, tmx2, tmy1); \ - PUSH_TEXM(pn, tmx1, tmy2); \ - PUSH_TEXM(pn, tmx2, tmy1); \ - PUSH_TEXM(pn, tmx2, tmy2); \ - PUSH_TEXM(pn, tmx1, tmy2); \ - } while(0) + _push_mask(gc, pn, nm, mtex, mx, my, mw, mh); \ + } while(0) #define PIPE_GROW(gc, pn, inc) \ - int nv = gc->pipe[pn].array.num * 3; (void) nv; \ - int nc = gc->pipe[pn].array.num * 4; (void) nc; \ - int nu = gc->pipe[pn].array.num * 2; (void) nu; \ - int nu2 = gc->pipe[pn].array.num * 2; (void) nu2; \ - int nu3 = gc->pipe[pn].array.num * 2; (void) nu3; \ - int na = gc->pipe[pn].array.num * 2; (void) na; \ - int ns = gc->pipe[pn].array.num * 2; (void) ns; \ - int nm = gc->pipe[pn].array.num * 2; (void) nm; \ + int nv = gc->pipe[pn].array.num * VERTEX_CNT; (void) nv; \ + int nc = gc->pipe[pn].array.num * COLOR_CNT; (void) nc; \ + int nu = gc->pipe[pn].array.num * TEX_CNT; (void) nu; \ + int nu2 = gc->pipe[pn].array.num * TEX_CNT; (void) nu2; \ + int nu3 = gc->pipe[pn].array.num * TEX_CNT; (void) nu3; \ + int na = gc->pipe[pn].array.num * TEX_CNT; (void) na; \ + int ns = gc->pipe[pn].array.num * TEX_CNT; (void) ns; \ + int nm = gc->pipe[pn].array.num * MASK_CNT; (void) nm; \ gc->pipe[pn].array.num += inc; \ array_alloc(gc, pn); @@ -1365,14 +1404,14 @@ array_alloc(Evas_Engine_GL_Context *gc, int n) if ((gc->pipe[n].array.use_##field) && (!gc->pipe[n].array.field)) \ gc->pipe[n].array.field = \ malloc(gc->pipe[n].array.alloc * sizeof(type) * size) - ALOC(vertex, GLshort, 3); - ALOC(color, GLubyte, 4); - ALOC(texuv, GLfloat, 2); - ALOC(texa, GLfloat, 2); - ALOC(texuv2, GLfloat, 2); - ALOC(texuv3, GLfloat, 2); - ALOC(texsam, GLfloat, 2); - ALOC(texm, GLfloat, 2); + ALOC(vertex, GLshort, VERTEX_CNT); + ALOC(color, GLubyte, COLOR_CNT); + ALOC(texuv, GLfloat, TEX_CNT); + ALOC(texa, GLfloat, TEX_CNT); + ALOC(texuv2, GLfloat, TEX_CNT); + ALOC(texuv3, GLfloat, TEX_CNT); + ALOC(texsam, GLfloat, TEX_CNT); + ALOC(mask, GLfloat, MASK_CNT); return; } gc->pipe[n].array.alloc += 6 * 1024; @@ -1381,14 +1420,14 @@ array_alloc(Evas_Engine_GL_Context *gc, int n) gc->pipe[n].array.field = realloc \ (gc->pipe[n].array.field, \ gc->pipe[n].array.alloc * sizeof(type) * size) - RALOC(vertex, GLshort, 3); - RALOC(color, GLubyte, 4); - RALOC(texuv, GLfloat, 2); - RALOC(texa, GLfloat, 2); - RALOC(texuv2, GLfloat, 2); - RALOC(texuv3, GLfloat, 2); - RALOC(texsam, GLfloat, 2); - RALOC(texm, GLfloat, 2); + RALOC(vertex, GLshort, VERTEX_CNT); + RALOC(color, GLubyte, COLOR_CNT); + RALOC(texuv, GLfloat, TEX_CNT); + RALOC(texa, GLfloat, TEX_CNT); + RALOC(texuv2, GLfloat, TEX_CNT); + RALOC(texuv3, GLfloat, TEX_CNT); + RALOC(texsam, GLfloat, TEX_CNT); + RALOC(mask, GLfloat, MASK_CNT); } #ifdef GLPIPES @@ -1634,7 +1673,7 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv3 = 0; gc->pipe[pn].array.use_texa = 0; gc->pipe[pn].array.use_texsam = 0; - gc->pipe[pn].array.use_texm = 0; + gc->pipe[pn].array.use_mask = 0; PIPE_GROW(gc, pn, 2); PUSH_VERTEX(pn, x1, y1, 0); @@ -1655,7 +1694,7 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv3 = 0; gc->pipe[pn].array.use_texa = 0; gc->pipe[pn].array.use_texsam = 0; - gc->pipe[pn].array.use_texm = 0; + gc->pipe[pn].array.use_mask = 0; } void @@ -1663,7 +1702,7 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int r, int g, int b, int a, Evas_GL_Texture *mtex, - double mx, double my, double mw, double mh, + int mx, int my, int mw, int mh, Eina_Bool mask_smooth) { Eina_Bool blend = EINA_FALSE; @@ -1710,7 +1749,7 @@ again: gc->pipe[pn].array.use_texuv3 = 0; gc->pipe[pn].array.use_texa = 0; gc->pipe[pn].array.use_texsam = 0; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; } else { @@ -1764,7 +1803,7 @@ again: gc->pipe[pn].array.use_texuv3 = 0; gc->pipe[pn].array.use_texa = 0; gc->pipe[pn].array.use_texsam = 0; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; } } #else @@ -1817,7 +1856,7 @@ 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only) { @@ -2049,7 +2088,7 @@ 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_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; gc->pipe[pn].array.use_texsam = sam; pipe_region_expand(gc, pn, x, y, w, h); @@ -2099,7 +2138,7 @@ 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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a) { GLfloat tx1, tx2, ty1, ty2; @@ -2139,7 +2178,7 @@ 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_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); @@ -2171,7 +2210,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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2220,7 +2259,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = 1; gc->pipe[pn].array.use_texuv3 = 1; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); @@ -2249,7 +2288,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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2297,7 +2336,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = 1; gc->pipe[pn].array.use_texuv3 = 0; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); @@ -2325,7 +2364,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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth) { @@ -2375,7 +2414,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = 1; gc->pipe[pn].array.use_texuv3 = 0; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); @@ -2404,7 +2443,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, double mx, double my, double mw, double mh, Eina_Bool mask_smooth, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, Eina_Bool mask_smooth, int r, int g, int b, int a, Eina_Bool smooth) @@ -2460,7 +2499,7 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv3 = 0; gc->pipe[pn].array.use_texa = EINA_TRUE; gc->pipe[pn].array.use_texsam = 0; - gc->pipe[pn].array.use_texm = !!mtex; + gc->pipe[pn].array.use_mask = !!mtex; pipe_region_expand(gc, pn, x, y, w, h); PIPE_GROW(gc, pn, 6); @@ -2689,9 +2728,9 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv = 1; gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0; gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0; - gc->pipe[pn].array.use_texm = !!mtex; - gc->pipe[pn].array.use_texa = !!mtex; - gc->pipe[pn].array.use_texsam = gc->pipe[pn].array.use_texm; + gc->pipe[pn].array.use_mask = !!mtex; + gc->pipe[pn].array.use_texa = 0; + gc->pipe[pn].array.use_texsam = 0; pipe_region_expand(gc, pn, x, y, w, h); PIPE_GROW(gc, pn, 6); @@ -2751,59 +2790,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, A_VAL(&cl)); } - if (mtex) - { - double glmx, glmy, glmw, glmh, yinv = -1.f; - double gw = gc->w, gh = gc->h; + PUSH_MASK(pn, mtex, mx, my, mw, mh); - if (!((gc->pipe[0].shader.surface == gc->def_surface) || - (!gc->pipe[0].shader.surface))) - { - gw = gc->pipe[0].shader.surface->w; - gh = gc->pipe[0].shader.surface->h; - yinv = 1.f; - } - if (!gw || !gh || !mw || !mh || !mtex->pt->w || !mtex->pt->h) - goto mask_error; - - // vertex shader: tex_m = (X,Y) * tex_coordm + tex_sample - // tex_coordm - glmx = (double)((mtex->x * mw) - (mtex->w * mx)) / (double)(mw * mtex->pt->w); - glmy = (double)((mtex->y * mh) - (mtex->h * my)) / (double)(mh * mtex->pt->h); - PUSH_TEXM(pn, glmx, glmy); - PUSH_TEXM(pn, glmx, glmy); - PUSH_TEXM(pn, glmx, glmy); - PUSH_TEXM(pn, glmx, glmy); - PUSH_TEXM(pn, glmx, glmy); - PUSH_TEXM(pn, glmx, glmy); - - // tex_sample - glmw = (double)(gw * mtex->w) / (double)(mw * mtex->pt->w); - glmh = (double)(gh * mtex->h) / (double)(mh * mtex->pt->h); - PUSH_TEXSAM(pn, glmw, glmh); - PUSH_TEXSAM(pn, glmw, glmh); - PUSH_TEXSAM(pn, glmw, glmh); - PUSH_TEXSAM(pn, glmw, glmh); - PUSH_TEXSAM(pn, glmw, glmh); - PUSH_TEXSAM(pn, glmw, glmh); - - // tex_coorda: Y-invert flag - PUSH_TEXA(pn, 1.0, yinv); - PUSH_TEXA(pn, 1.0, yinv); - PUSH_TEXA(pn, 1.0, yinv); - PUSH_TEXA(pn, 1.0, yinv); - PUSH_TEXA(pn, 1.0, yinv); - PUSH_TEXA(pn, 1.0, yinv); - - /* - DBG("Map mask: %d,%d %dx%d --> %f , %f - %f x %f @ %f %f [gc %dx%d, tex %d,%d %dx%d, pt %dx%d]", - mx, my, mw, mh, - glmx, glmy, glmw, glmh, 1.0, yinv, - gc->w, gc->h, mtex->x, mtex->y, mtex->w, mtex->h, mtex->pt->w, mtex->pt->h); - */ - } - -mask_error: if (!flat) { shader_array_flush(gc); @@ -3135,15 +3123,16 @@ shader_array_flush(Evas_Engine_GL_Context *gc) unsigned char *texuv3_ptr = NULL; unsigned char *texa_ptr = NULL; unsigned char *texsam_ptr = NULL; - unsigned char *texm_ptr = NULL; + unsigned char *mask_ptr = NULL; if (glsym_glMapBuffer && glsym_glUnmapBuffer) { unsigned char *x; -# define VERTEX_SIZE (gc->pipe[i].array.num * sizeof(GLshort) * 3) -# define COLOR_SIZE (gc->pipe[i].array.num * sizeof(GLubyte) * 4) -# define TEX_SIZE (gc->pipe[i].array.num * sizeof(GLfloat) * 2) +# define VERTEX_SIZE (gc->pipe[i].array.num * sizeof(GLshort) * VERTEX_CNT) +# define COLOR_SIZE (gc->pipe[i].array.num * sizeof(GLubyte) * COLOR_CNT) +# define TEX_SIZE (gc->pipe[i].array.num * sizeof(GLfloat) * TEX_CNT) +# define MASK_SIZE (gc->pipe[i].array.num * sizeof(GLubyte) * MASK_CNT) vertex_ptr = NULL; color_ptr = vertex_ptr + VERTEX_SIZE; texuv_ptr = color_ptr + COLOR_SIZE; @@ -3151,8 +3140,8 @@ shader_array_flush(Evas_Engine_GL_Context *gc) texuv3_ptr = texuv2_ptr + TEX_SIZE; texa_ptr = texuv3_ptr + TEX_SIZE; texsam_ptr = texa_ptr + TEX_SIZE; - texm_ptr = texsam_ptr + TEX_SIZE; -# define END_POINTER (texm_ptr + TEX_SIZE) + mask_ptr = texsam_ptr + TEX_SIZE; +# define END_POINTER (mask_ptr + TEX_SIZE) glBindBuffer(GL_ARRAY_BUFFER, gc->pipe[i].array.buffer); if ((gc->pipe[i].array.buffer_alloc < (long)END_POINTER) || @@ -3182,8 +3171,8 @@ shader_array_flush(Evas_Engine_GL_Context *gc) memcpy(x + (unsigned long)texa_ptr, gc->pipe[i].array.texa, TEX_SIZE); if (gc->pipe[i].array.use_texsam) memcpy(x + (unsigned long)texsam_ptr, gc->pipe[i].array.texsam, TEX_SIZE); - if (gc->pipe[i].array.use_texm) - memcpy(x + (unsigned long)texm_ptr, gc->pipe[i].array.texm, TEX_SIZE); + if (gc->pipe[i].array.use_mask) + memcpy(x + (unsigned long)mask_ptr, gc->pipe[i].array.mask, MASK_SIZE); /* fprintf(stderr, "copy %i bytes [%i/%i slots] [%i + %i + %i + %i + %i + %i + %i] <%i %i %i %i %i %i %i>\n", (int)((unsigned char *)END_POINTER), @@ -3212,10 +3201,10 @@ shader_array_flush(Evas_Engine_GL_Context *gc) texuv3_ptr = (unsigned char *)gc->pipe[i].array.texuv3; texa_ptr = (unsigned char *)gc->pipe[i].array.texa; texsam_ptr = (unsigned char *)gc->pipe[i].array.texsam; - texm_ptr = (unsigned char *)gc->pipe[i].array.texm; + mask_ptr = (unsigned char *)gc->pipe[i].array.mask; } - glVertexAttribPointer(SHAD_VERTEX, 3, GL_SHORT, GL_FALSE, 0, (void *)vertex_ptr); - glVertexAttribPointer(SHAD_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, (void *)color_ptr); + glVertexAttribPointer(SHAD_VERTEX, VERTEX_CNT, GL_SHORT, GL_FALSE, 0, vertex_ptr); + glVertexAttribPointer(SHAD_COLOR, COLOR_CNT, GL_UNSIGNED_BYTE, GL_TRUE, 0, color_ptr); if (gc->pipe[i].array.line) { @@ -3236,7 +3225,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) glDisableVertexAttribArray(SHAD_TEXUV3); glDisableVertexAttribArray(SHAD_TEXA); glDisableVertexAttribArray(SHAD_TEXSAM); - glDisableVertexAttribArray(SHAD_TEXM); + glDisableVertexAttribArray(SHAD_MASK); glDrawArrays(GL_LINES, 0, gc->pipe[i].array.num); } else @@ -3246,8 +3235,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) if (gc->pipe[i].array.use_texuv) { glEnableVertexAttribArray(SHAD_TEXUV); - glVertexAttribPointer(SHAD_TEXUV, 2, GL_FLOAT, GL_FALSE, 0, - (void *)texuv_ptr); + glVertexAttribPointer(SHAD_TEXUV, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texuv_ptr); MASK_TEXTURE += 1; } @@ -3257,10 +3245,10 @@ shader_array_flush(Evas_Engine_GL_Context *gc) } /* Alpha plane */ - if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type != RTYPE_MAP)) + if (gc->pipe[i].array.use_texa) { glEnableVertexAttribArray(SHAD_TEXA); - glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr); + glVertexAttribPointer(SHAD_TEXA, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texa_ptr); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texa); #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT @@ -3283,14 +3271,6 @@ shader_array_flush(Evas_Engine_GL_Context *gc) MASK_TEXTURE += 1; } - else if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type == RTYPE_MAP)) - { - /* For map masking, we (ab)use 3 texture vertex pointers - * (namely tex_coordm, tex_coorda and tex_sample). - * We could probably pack them into an array or something. */ - glEnableVertexAttribArray(SHAD_TEXA); - glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr); - } else { glDisableVertexAttribArray(SHAD_TEXA); @@ -3299,7 +3279,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) if (gc->pipe[i].array.use_texsam) { glEnableVertexAttribArray(SHAD_TEXSAM); - glVertexAttribPointer(SHAD_TEXSAM, 2, GL_FLOAT, GL_FALSE, 0, (void *)texsam_ptr); + glVertexAttribPointer(SHAD_TEXSAM, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texsam_ptr); } else { @@ -3310,8 +3290,8 @@ shader_array_flush(Evas_Engine_GL_Context *gc) { glEnableVertexAttribArray(SHAD_TEXUV2); glEnableVertexAttribArray(SHAD_TEXUV3); - glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, (void *)texuv2_ptr); - glVertexAttribPointer(SHAD_TEXUV3, 2, GL_FLOAT, GL_FALSE, 0, (void *)texuv3_ptr); + glVertexAttribPointer(SHAD_TEXUV2, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texuv2_ptr); + glVertexAttribPointer(SHAD_TEXUV3, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texuv3_ptr); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu); @@ -3341,7 +3321,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) else if (gc->pipe[i].array.use_texuv2) { glEnableVertexAttribArray(SHAD_TEXUV2); - glVertexAttribPointer(SHAD_TEXUV2, 2, GL_FLOAT, GL_FALSE, 0, (void *)texuv2_ptr); + glVertexAttribPointer(SHAD_TEXUV2, TEX_CNT, GL_FLOAT, GL_FALSE, 0, texuv2_ptr); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texu); @@ -3375,10 +3355,10 @@ shader_array_flush(Evas_Engine_GL_Context *gc) } /* Mask surface */ - if (gc->pipe[i].array.use_texm) + if (gc->pipe[i].array.use_mask) { - glEnableVertexAttribArray(SHAD_TEXM); - glVertexAttribPointer(SHAD_TEXM, 2, GL_FLOAT, GL_FALSE, 0, (void *)texm_ptr); + glEnableVertexAttribArray(SHAD_MASK); + glVertexAttribPointer(SHAD_MASK, MASK_CNT, GL_FLOAT, GL_FALSE, 0, mask_ptr); glActiveTexture(MASK_TEXTURE); glBindTexture(GL_TEXTURE_2D, gc->pipe[i].shader.cur_texm); #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT @@ -3401,7 +3381,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) } else { - glDisableVertexAttribArray(SHAD_TEXM); + glDisableVertexAttribArray(SHAD_MASK); } if (dbgflushnum == 1) @@ -3452,7 +3432,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2); if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3); if (gc->pipe[i].array.texsam) free(gc->pipe[i].array.texsam); - if (gc->pipe[i].array.texm) free(gc->pipe[i].array.texm); + if (gc->pipe[i].array.mask) free(gc->pipe[i].array.mask); gc->pipe[i].array.line = 0; gc->pipe[i].array.use_vertex = 0; @@ -3462,7 +3442,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) gc->pipe[i].array.use_texuv3 = 0; gc->pipe[i].array.use_texa = 0; gc->pipe[i].array.use_texsam = 0; - gc->pipe[i].array.use_texm = 0; + gc->pipe[i].array.use_mask = 0; gc->pipe[i].array.vertex = NULL; gc->pipe[i].array.color = NULL; @@ -3471,7 +3451,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc) gc->pipe[i].array.texuv2 = NULL; gc->pipe[i].array.texuv3 = NULL; gc->pipe[i].array.texsam = NULL; - gc->pipe[i].array.texm = NULL; + gc->pipe[i].array.mask = NULL; gc->pipe[i].array.num = 0; gc->pipe[i].array.alloc = 0; 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 ca6eae9..95ac669 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_font.c +++ b/src/modules/evas/engines/gl_common/evas_gl_font.c @@ -82,30 +82,15 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c b = (dc->col.col ) & 0xff; sx = 0; sy = 0; sw = tex->w, sh = tex->h; - if (gc->dc->clip.mask && (sw > 0) && (sh > 0)) + if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h) { - double nx, ny, nw, nh, dx, dy, dw, dh; - const double mask_x = gc->dc->clip.mask_x; - const double mask_y = gc->dc->clip.mask_y; - const double tmw = mtex->pt->w; - const double tmh = mtex->pt->h; - double scalex = 1.0; - double scaley = 1.0; - // canvas coords - 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; - dx = x; dy = y; dw = sw; dh = sh; - mx = mask_x; my = mask_y; - if (mask->scaled.origin && mask->scaled.w && mask->scaled.h) + mx = dc->clip.mask_x; + my = dc->clip.mask_y; + if (mask->scaled.origin) { mw = mask->scaled.w; mh = mask->scaled.h; - scalex = mask->w / (double)mask->scaled.w; - scaley = mask->h / (double)mask->scaled.h; mask_smooth = mask->scaled.smooth; } else @@ -113,15 +98,8 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c 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); - - // convert to tex coords - mx = (mtex->x / tmw) + ((mx - mask_x + (mw * (nx - dx)) / dw) * scalex / tmw); - my = (mtex->y / tmh) + ((my - mask_y + (mh * (ny - dy)) / dy) * scaley / tmh); - mw = (mw * nw * scalex / dw) / tmw; - mh = (mh * nh * scaley / dh) / tmh; } + else mtex = NULL; if ((!gc->dc->cutout.rects) || ((gc->shared->info.tune.cutout.max > 0) && 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 ff415ba..24b156b 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -979,6 +979,7 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, //mx = mx - dc->clip.mask_x; //my = my - dc->clip.mask_y; } + else mtex = NULL; evas_gl_common_context_image_map_push(gc, im->tex, npoints, p, c, cx, cy, cw, ch, @@ -993,12 +994,12 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int cx, int cy, int cw, int ch, int r, int g, int b, int a, - Evas_GL_Image *mask, int mask_x, int mask_y, + Evas_GL_Image *mask, Eina_Bool smooth, Eina_Bool yuv, Eina_Bool yuy2, Eina_Bool nv12, Eina_Bool rgb_a_pair) { - double mx = 0, my = 0, mw = 0, mh = 0; + int mx = 0, my = 0, mw = 0, mh = 0; double ssx, ssy, ssw, ssh; Evas_GL_Texture *mtex = mask ? mask->tex : NULL; Eina_Bool mask_smooth = EINA_FALSE; @@ -1012,19 +1013,13 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h) { - const double tmw = mtex->pt->w; - const double tmh = mtex->pt->h; - double scalex = 1.0; - double scaley = 1.0; - // canvas coords - mx = mask_x; my = mask_y; + mx = gc->dc->clip.mask_x; + my = gc->dc->clip.mask_y; if (mask->scaled.origin) { mw = mask->scaled.w; mh = mask->scaled.h; - scalex = mask->w / (double)mask->scaled.w; - scaley = mask->h / (double)mask->scaled.h; mask_smooth = mask->scaled.smooth; } else @@ -1032,15 +1027,8 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, 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); - - // convert to tex coords - mx = (mtex->x / tmw) + ((mx - mask_x) * scalex / tmw); - my = (mtex->y / tmh) + ((my - mask_y) * scaley / tmh); - mw = mw * scalex / tmw; - mh = mh * scaley / tmh; } + else mtex = NULL; if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh)) { @@ -1147,7 +1135,6 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, Eina_Bool nv12 = EINA_FALSE; Eina_Bool rgb_a_pair = EINA_FALSE; Evas_GL_Image *mask; - int mask_x, mask_y; if (sw < 1) sw = 1; if (sh < 1) sh = 1; @@ -1166,8 +1153,6 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, // Prepare mask image, if there is one mask = dc->clip.mask; - mask_x = dc->clip.mask_x; - mask_y = dc->clip.mask_y; if (mask) { evas_gl_common_image_update(gc, mask); @@ -1175,8 +1160,6 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, { ERR("Failed to apply mask image"); mask = NULL; - mask_x = 0; - mask_y = 0; } } @@ -1221,7 +1204,7 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, gc->dc->clip.x, gc->dc->clip.y, gc->dc->clip.w, gc->dc->clip.h, r, g, b, a, - mask, mask_x, mask_y, + mask, smooth, yuv, yuy2, nv12, rgb_a_pair); } @@ -1232,7 +1215,7 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, sx, sy, sw, sh, dx, dy, dw, dh, r, g, b, a, - mask, mask_x, mask_y, + mask, smooth, yuv, yuy2, nv12, rgb_a_pair); } @@ -1259,7 +1242,7 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, sx, sy, sw, sh, rct->x, rct->y, rct->w, rct->h, r, g, b, a, - mask, mask_x, mask_y, + mask, smooth, yuv, yuy2, nv12, rgb_a_pair); } diff --git a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c index 39c0c00..c13252a 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c +++ b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c @@ -5,7 +5,7 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h) { Cutout_Rect *r; int c, cx, cy, cw, ch, cr, cg, cb, ca, i; - double mx = 0, my = 0, mw = 0, mh = 0; + int mx = 0, my = 0, mw = 0, mh = 0; Eina_Bool mask_smooth = EINA_FALSE; Evas_GL_Image *mask = gc->dc->clip.mask; Evas_GL_Texture *mtex = mask ? mask->tex : NULL; @@ -30,23 +30,15 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h) gc->dc->clip.w, gc->dc->clip.h); } - if (mtex) + if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h) { - const double mask_x = gc->dc->clip.mask_x; - const double mask_y = gc->dc->clip.mask_y; - const double tmw = mtex->pt->w; - const double tmh = mtex->pt->h; - double scalex = 1.0; - double scaley = 1.0; - // canvas coords - mx = mask_x; my = mask_y; - if (mask->scaled.origin && mask->scaled.w && mask->scaled.h) + mx = gc->dc->clip.mask_x; + my = gc->dc->clip.mask_y; + if (mask->scaled.origin) { mw = mask->scaled.w; mh = mask->scaled.h; - scalex = mask->w / (double)mask->scaled.w; - scaley = mask->h / (double)mask->scaled.h; mask_smooth = mask->scaled.smooth; } else @@ -54,16 +46,8 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h) mw = mask->w; mh = mask->h; } - RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); - mx -= gc->dc->clip.mask_x; - my -= gc->dc->clip.mask_y; - - // convert to tex coords - mx = (mtex->x / tmw) + ((mx - mask_x) * scalex / tmw); - my = (mtex->y / tmh) + ((my - mask_y) * scaley / tmh); - mw = mw * scalex / tmw; - mh = mh * scaley / tmh; } + else mtex = NULL; if (!gc->dc->cutout.rects) { diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c index ff5e79a..96a70e5 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_shader.c +++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c @@ -79,7 +79,7 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p, glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3"); glBindAttribLocation(p->prog, SHAD_TEXA, "tex_coorda"); glBindAttribLocation(p->prog, SHAD_TEXSAM, "tex_sample"); - glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm"); + glBindAttribLocation(p->prog, SHAD_MASK, "mask_coord"); glGetProgramiv(p->prog, GL_LINK_STATUS, &ok); if (!ok) @@ -189,9 +189,9 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p, glBindAttribLocation(p->prog, SHAD_TEXUV, "tex_coord"); glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2"); glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3"); - glBindAttribLocation(p->prog, SHAD_TEXA, "tex_coorda"); + glBindAttribLocation(p->prog, SHAD_TEXA, "tex_coorda"); glBindAttribLocation(p->prog, SHAD_TEXSAM, "tex_sample"); - glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm"); + glBindAttribLocation(p->prog, SHAD_MASK, "mask_coord"); glLinkProgram(p->prog); ok = 0; 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 5abc028..d047c3f 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 @@ -80,7 +80,7 @@ static const char const font_mask_vert_glsl[] = "attribute vec4 vertex;\n" "attribute vec4 color;\n" "attribute vec2 tex_coord;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 tex_c;\n" @@ -90,7 +90,10 @@ static const char const font_mask_vert_glsl[] = " gl_Position = mvp * vertex;\n" " col = color;\n" " tex_c = tex_coord;\n" - " tex_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_font_mask_vert_src = { @@ -2244,10 +2247,10 @@ static const char const img_mask_frag_glsl[] = "uniform sampler2D texm;\n" "varying vec4 col;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy).bgra * col;\n" + " gl_FragColor = texture2D(texm, tex_m.xy).a * texture2D(tex, coord_c.xy).bgra * col;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_frag_src = { @@ -2263,17 +2266,20 @@ static const char const img_mask_vert_glsl[] = "attribute vec4 vertex;\n" "attribute vec4 color;\n" "attribute vec2 tex_coord;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " col = color;\n" " coord_c = tex_coord;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_vert_src = { @@ -2293,10 +2299,10 @@ static const char const img_mask_nomul_frag_glsl[] = "uniform sampler2D tex;\n" "uniform sampler2D texm;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texm, coord_m).a;\n" + " gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texm, tex_m).a;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_nomul_frag_src = { @@ -2311,15 +2317,18 @@ static const char const img_mask_nomul_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec2 tex_coord;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " coord_c = tex_coord;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_nomul_vert_src = { @@ -2340,10 +2349,10 @@ static const char const img_mask_bgra_frag_glsl[] = "uniform sampler2D texm;\n" "varying vec4 col;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy) * col;\n" + " gl_FragColor = texture2D(texm, tex_m.xy).a * texture2D(tex, coord_c.xy) * col;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_bgra_frag_src = { @@ -2359,17 +2368,20 @@ static const char const img_mask_bgra_vert_glsl[] = "attribute vec4 vertex;\n" "attribute vec4 color;\n" "attribute vec2 tex_coord;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " col = color;\n" " coord_c = tex_coord;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_bgra_vert_src = { @@ -2389,10 +2401,10 @@ static const char const img_mask_bgra_nomul_frag_glsl[] = "uniform sampler2D tex;\n" "uniform sampler2D texm;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy);\n" + " gl_FragColor = texture2D(texm, tex_m.xy).a * texture2D(tex, coord_c.xy);\n" "}\n"; Evas_GL_Program_Source shader_img_mask_bgra_nomul_frag_src = { @@ -2407,15 +2419,18 @@ static const char const img_mask_bgra_nomul_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec2 tex_coord;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec2 coord_c;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " coord_c = tex_coord;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_img_mask_bgra_nomul_vert_src = { @@ -2462,7 +2477,8 @@ static const char const yuv_mask_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec4 color;\n" - "attribute vec2 tex_coord, tex_coord2, tex_coord3, tex_coordm;\n" + "attribute vec4 mask_coord;\n" + "attribute vec2 tex_coord, tex_coord2, tex_coord3;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 tex_c, tex_c2, tex_c3, tex_m;\n" @@ -2473,7 +2489,10 @@ static const char const yuv_mask_vert_glsl[] = " tex_c = tex_coord;\n" " tex_c2 = tex_coord2;\n" " tex_c3 = tex_coord3;\n" - " tex_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_yuv_mask_vert_src = { @@ -2523,7 +2542,8 @@ static const char const nv12_mask_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec4 color;\n" - "attribute vec2 tex_coord, tex_coord2, tex_coordm;\n" + "attribute vec4 mask_coord;\n" + "attribute vec2 tex_coord, tex_coord2;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 tex_c, tex_cuv, tex_m;\n" @@ -2533,7 +2553,10 @@ static const char const nv12_mask_vert_glsl[] = " col = color;\n" " tex_c = tex_coord;\n" " tex_cuv = tex_coord2 * 0.5;\n" - " tex_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_nv12_mask_vert_src = { @@ -2582,7 +2605,8 @@ static const char const yuy2_mask_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec4 color;\n" - "attribute vec2 tex_coord, tex_coord2, tex_coordm;\n" + "attribute vec4 mask_coord;\n" + "attribute vec2 tex_coord, tex_coord2;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 tex_c, tex_cuv, tex_m;\n" @@ -2592,7 +2616,10 @@ static const char const yuy2_mask_vert_glsl[] = " col = color;\n" " tex_c = tex_coord;\n" " tex_cuv = vec2(tex_coord2.x * 0.5, tex_coord2.y);\n" - " tex_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_yuy2_mask_vert_src = { @@ -2615,11 +2642,11 @@ static const char const rgb_a_pair_mask_frag_glsl[] = "varying vec4 col;\n" "varying vec2 coord_c;\n" "varying vec2 coord_a;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;\n" - " gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;\n" + " gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, tex_m.xy).a;\n" + " gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, tex_m.xy).a;\n" "}\n"; Evas_GL_Program_Source shader_rgb_a_pair_mask_frag_src = { @@ -2636,19 +2663,22 @@ static const char const rgb_a_pair_mask_vert_glsl[] = "attribute vec4 color;\n" "attribute vec2 tex_coord;\n" "attribute vec2 tex_coorda;\n" - "attribute vec2 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" "varying vec2 coord_c;\n" "varying vec2 coord_a;\n" - "varying vec2 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " col = color;\n" " coord_c = tex_coord;\n" " coord_a = tex_coorda;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_rgb_a_pair_mask_vert_src = { @@ -2667,10 +2697,10 @@ static const char const rect_mask_frag_glsl[] = "#endif\n" "uniform sampler2D texm;\n" "varying vec4 col;\n" - "varying vec4 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" - " gl_FragColor = texture2D(texm, coord_m.xy).a * col;\n" + " gl_FragColor = texture2D(texm, tex_m.xy).a * col;\n" "}\n"; Evas_GL_Program_Source shader_rect_mask_frag_src = { @@ -2685,15 +2715,18 @@ static const char const rect_mask_vert_glsl[] = "#endif\n" "attribute vec4 vertex;\n" "attribute vec4 color;\n" - "attribute vec4 tex_coordm;\n" + "attribute vec4 mask_coord;\n" "uniform mat4 mvp;\n" "varying vec4 col;\n" - "varying vec4 coord_m;\n" + "varying vec2 tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " col = color;\n" - " coord_m = tex_coordm;\n" + " // mask_coord.w contains the Y-invert flag\n" + " // position on screen in [0..1] range of current pixel\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_rect_mask_vert_src = { @@ -2729,8 +2762,8 @@ static const char const map_mask_vert_glsl[] = "#ifdef GL_ES\n" "precision highp float;\n" "#endif\n" - "attribute vec4 vertex, color;\n" - "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" + "attribute vec4 vertex, color, mask_coord;\n" + "attribute vec2 tex_coord;\n" "uniform mat4 mvp;\n" "varying vec2 tex_c, tex_m;\n" "varying vec4 col;\n" @@ -2739,10 +2772,10 @@ static const char const map_mask_vert_glsl[] = " gl_Position = mvp * vertex;\n" " tex_c = tex_coord;\n" " col = color;\n" - " // tex_coorda contains the Y-invert flag\n" + " // mask_coord.w contains the Y-invert flag\n" " // position on screen in [0..1] range of current pixel\n" - " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" - " tex_m = mask_Position.xy * tex_sample + tex_coordm;\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_map_mask_vert_src = { @@ -2776,18 +2809,18 @@ static const char const map_mask_nomul_vert_glsl[] = "#ifdef GL_ES\n" "precision highp float;\n" "#endif\n" - "attribute vec4 vertex;\n" - "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" + "attribute vec4 vertex, mask_coord;\n" + "attribute vec2 tex_coord;\n" "uniform mat4 mvp;\n" "varying vec2 tex_c, tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " tex_c = tex_coord;\n" - " // tex_coorda contains the Y-invert flag\n" + " // mask_coord.w contains the Y-invert flag\n" " // position on screen in [0..1] range of current pixel\n" - " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" - " tex_m = mask_Position.xy * tex_sample + tex_coordm;\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_map_mask_nomul_vert_src = { @@ -2823,8 +2856,8 @@ static const char const map_mask_bgra_vert_glsl[] = "#ifdef GL_ES\n" "precision highp float;\n" "#endif\n" - "attribute vec4 vertex, color;\n" - "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" + "attribute vec4 vertex, color, mask_coord;\n" + "attribute vec2 tex_coord;\n" "uniform mat4 mvp;\n" "varying vec2 tex_c, tex_m;\n" "varying vec4 col;\n" @@ -2833,10 +2866,10 @@ static const char const map_mask_bgra_vert_glsl[] = " gl_Position = mvp * vertex;\n" " tex_c = tex_coord;\n" " col = color;\n" - " // tex_coorda contains the Y-invert flag\n" + " // mask_coord.w contains the Y-invert flag\n" " // position on screen in [0..1] range of current pixel\n" - " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" - " tex_m = mask_Position.xy * tex_sample + tex_coordm;\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_map_mask_bgra_vert_src = { @@ -2870,18 +2903,18 @@ static const char const map_mask_bgra_nomul_vert_glsl[] = "#ifdef GL_ES\n" "precision highp float;\n" "#endif\n" - "attribute vec4 vertex;\n" - "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" + "attribute vec4 vertex, mask_coord;\n" + "attribute vec2 tex_coord;\n" "uniform mat4 mvp;\n" "varying vec2 tex_c, tex_m;\n" "void main()\n" "{\n" " gl_Position = mvp * vertex;\n" " tex_c = tex_coord;\n" - " // tex_coorda contains the Y-invert flag\n" + " // mask_coord.w contains the Y-invert flag\n" " // position on screen in [0..1] range of current pixel\n" - " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" - " tex_m = mask_Position.xy * tex_sample + tex_coordm;\n" + " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" + " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" "}\n"; Evas_GL_Program_Source shader_map_mask_bgra_nomul_vert_src = { diff --git a/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd index 2651689..f1c9c7b 100644 --- a/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/font_mask_vert.shd @@ -4,7 +4,7 @@ precision highp float; attribute vec4 vertex; attribute vec4 color; attribute vec2 tex_coord; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec4 col; varying vec2 tex_c; @@ -14,6 +14,10 @@ void main() gl_Position = mvp * vertex; col = color; tex_c = tex_coord; - tex_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } 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 index ad56737..5412d69 100644 --- 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 @@ -9,9 +9,9 @@ uniform sampler2D tex; uniform sampler2D texm; varying vec4 col; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy) * col; + gl_FragColor = texture2D(texm, tex_m.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 index 5fc393b..f2f3ff1 100644 --- 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 @@ -8,9 +8,9 @@ precision mediump float; uniform sampler2D tex; uniform sampler2D texm; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy); + gl_FragColor = texture2D(texm, tex_m.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 index 973402f..0804133 100644 --- 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 @@ -3,14 +3,18 @@ precision highp float; #endif attribute vec4 vertex; attribute vec2 tex_coord; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; coord_c = tex_coord; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } 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 index 04da2aa..456e01f 100644 --- 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 @@ -4,16 +4,20 @@ precision highp float; attribute vec4 vertex; attribute vec4 color; attribute vec2 tex_coord; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec4 col; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; col = color; coord_c = tex_coord; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } 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 34b1af9..d0c9f0a 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 @@ -9,9 +9,9 @@ uniform sampler2D tex; uniform sampler2D texm; varying vec4 col; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor = texture2D(texm, coord_m.xy).a * texture2D(tex, coord_c.xy).bgra * col; + gl_FragColor = texture2D(texm, tex_m.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 e172ebe..cb309ad 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 @@ -8,9 +8,9 @@ precision mediump float; uniform sampler2D tex; uniform sampler2D texm; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texm, coord_m).a; + gl_FragColor = texture2D(tex, coord_c.xy) * texture2D(texm, tex_m).a; } diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd index 973402f..0804133 100644 --- a/src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd @@ -3,14 +3,18 @@ precision highp float; #endif attribute vec4 vertex; attribute vec2 tex_coord; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; coord_c = tex_coord; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/img_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/img_mask_vert.shd index 04da2aa..456e01f 100644 --- a/src/modules/evas/engines/gl_common/shader/img_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/img_mask_vert.shd @@ -4,16 +4,20 @@ precision highp float; attribute vec4 vertex; attribute vec4 color; attribute vec2 tex_coord; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec4 col; varying vec2 coord_c; -varying vec2 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; col = color; coord_c = tex_coord; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd index 49da5bc..c04a5a4 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd @@ -1,8 +1,8 @@ #ifdef GL_ES precision highp float; #endif -attribute vec4 vertex; -attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; +attribute vec4 vertex, mask_coord; +attribute vec2 tex_coord; uniform mat4 mvp; varying vec2 tex_c, tex_m; void main() @@ -10,8 +10,8 @@ void main() gl_Position = mvp * vertex; tex_c = tex_coord; - // tex_coorda contains the Y-invert flag + // mask_coord.w contains the Y-invert flag // position on screen in [0..1] range of current pixel - vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); - tex_m = mask_Position.xy * tex_sample + tex_coordm; + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd index 2d2afa9..6bc3697 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd @@ -1,8 +1,8 @@ #ifdef GL_ES precision highp float; #endif -attribute vec4 vertex, color; -attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; +attribute vec4 vertex, color, mask_coord; +attribute vec2 tex_coord; uniform mat4 mvp; varying vec2 tex_c, tex_m; varying vec4 col; @@ -12,8 +12,8 @@ void main() tex_c = tex_coord; col = color; - // tex_coorda contains the Y-invert flag + // mask_coord.w contains the Y-invert flag // position on screen in [0..1] range of current pixel - vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); - tex_m = mask_Position.xy * tex_sample + tex_coordm; + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd index 49da5bc..c04a5a4 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd @@ -1,8 +1,8 @@ #ifdef GL_ES precision highp float; #endif -attribute vec4 vertex; -attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; +attribute vec4 vertex, mask_coord; +attribute vec2 tex_coord; uniform mat4 mvp; varying vec2 tex_c, tex_m; void main() @@ -10,8 +10,8 @@ void main() gl_Position = mvp * vertex; tex_c = tex_coord; - // tex_coorda contains the Y-invert flag + // mask_coord.w contains the Y-invert flag // position on screen in [0..1] range of current pixel - vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); - tex_m = mask_Position.xy * tex_sample + tex_coordm; + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/map_mask_vert.shd index 2d2afa9..6bc3697 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_vert.shd @@ -1,8 +1,8 @@ #ifdef GL_ES precision highp float; #endif -attribute vec4 vertex, color; -attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; +attribute vec4 vertex, color, mask_coord; +attribute vec2 tex_coord; uniform mat4 mvp; varying vec2 tex_c, tex_m; varying vec4 col; @@ -12,8 +12,8 @@ void main() tex_c = tex_coord; col = color; - // tex_coorda contains the Y-invert flag + // mask_coord.w contains the Y-invert flag // position on screen in [0..1] range of current pixel - vec4 mask_Position = mvp * vertex * vec4(0.5, sign(tex_coorda.y) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); - tex_m = mask_Position.xy * tex_sample + tex_coordm; + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd index b77a0a5..d17555a 100644 --- a/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd @@ -3,7 +3,8 @@ precision highp float; #endif attribute vec4 vertex; attribute vec4 color; -attribute vec2 tex_coord, tex_coord2, tex_coordm; +attribute vec4 mask_coord; +attribute vec2 tex_coord, tex_coord2; uniform mat4 mvp; varying vec4 col; varying vec2 tex_c, tex_cuv, tex_m; @@ -13,5 +14,9 @@ void main() col = color; tex_c = tex_coord; tex_cuv = tex_coord2 * 0.5; - tex_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/rect_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/rect_mask_frag.shd index e278ea6..9af029d 100644 --- a/src/modules/evas/engines/gl_common/shader/rect_mask_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/rect_mask_frag.shd @@ -7,8 +7,8 @@ precision mediump float; #endif uniform sampler2D texm; varying vec4 col; -varying vec4 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor = texture2D(texm, coord_m.xy).a * col; + gl_FragColor = texture2D(texm, tex_m.xy).a * col; } diff --git a/src/modules/evas/engines/gl_common/shader/rect_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/rect_mask_vert.shd index 4a1dd2c..5065209 100644 --- a/src/modules/evas/engines/gl_common/shader/rect_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/rect_mask_vert.shd @@ -3,13 +3,17 @@ precision highp float; #endif attribute vec4 vertex; attribute vec4 color; -attribute vec4 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec4 col; -varying vec4 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; col = color; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd index 2c2ddef..daa185a 100644 --- a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd @@ -11,9 +11,9 @@ uniform sampler2D texm; varying vec4 col; varying vec2 coord_c; varying vec2 coord_a; -varying vec2 coord_m; +varying vec2 tex_m; void main() { - gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a; - gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a; + gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, tex_m.xy).a; + gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, tex_m.xy).a; } diff --git a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd index 03f7055..ba575d6 100644 --- a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd @@ -5,17 +5,21 @@ attribute vec4 vertex; attribute vec4 color; attribute vec2 tex_coord; attribute vec2 tex_coorda; -attribute vec2 tex_coordm; +attribute vec4 mask_coord; uniform mat4 mvp; varying vec4 col; varying vec2 coord_c; varying vec2 coord_a; -varying vec2 coord_m; +varying vec2 tex_m; void main() { gl_Position = mvp * vertex; col = color; coord_c = tex_coord; coord_a = tex_coorda; - coord_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd index 8a074d0..8962d9b 100644 --- a/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd @@ -3,7 +3,8 @@ precision highp float; #endif attribute vec4 vertex; attribute vec4 color; -attribute vec2 tex_coord, tex_coord2, tex_coord3, tex_coordm; +attribute vec4 mask_coord; +attribute vec2 tex_coord, tex_coord2, tex_coord3; uniform mat4 mvp; varying vec4 col; varying vec2 tex_c, tex_c2, tex_c3, tex_m; @@ -14,5 +15,9 @@ void main() tex_c = tex_coord; tex_c2 = tex_coord2; tex_c3 = tex_coord3; - tex_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } diff --git a/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd index c40a07e..a4c5cb6 100644 --- a/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd +++ b/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd @@ -3,7 +3,8 @@ precision highp float; #endif attribute vec4 vertex; attribute vec4 color; -attribute vec2 tex_coord, tex_coord2, tex_coordm; +attribute vec4 mask_coord; +attribute vec2 tex_coord, tex_coord2; uniform mat4 mvp; varying vec4 col; varying vec2 tex_c, tex_cuv, tex_m; @@ -13,5 +14,9 @@ void main() col = color; tex_c = tex_coord; tex_cuv = vec2(tex_coord2.x * 0.5, tex_coord2.y); - tex_m = tex_coordm; + + // mask_coord.w contains the Y-invert flag + // position on screen in [0..1] range of current pixel + vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); + tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; } -- 2.7.4