summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-02-06 12:21:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 12:00:37 +0900
commit21d08f86e6087f7e30ff2015c7551c06e359bba9 (patch)
tree6aff15745ee5d90d3ec80be873c9b2c3f2c64235 /src/modules
parent888fc6e93f8261666fe9c40addbc40bcd720decc (diff)
Evas GL: Add support for uniforms in the shaders
This will simplify greatly the code for map masking.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h1
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c155
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x30
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd4
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd12
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_frag.shd4
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_vert.shd12
7 files changed, 134 insertions, 84 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 382c3bcacf..4f2a552458 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -468,6 +468,7 @@ struct _Evas_Engine_GL_Context
468 GLfloat *texa; 468 GLfloat *texa;
469 GLfloat *texsam; 469 GLfloat *texsam;
470 GLfloat *texm; 470 GLfloat *texm;
471 Eina_List *uniforms; /* Evas_GL_Uniform */
471 Eina_Bool line: 1; 472 Eina_Bool line: 1;
472 Eina_Bool use_vertex : 1; 473 Eina_Bool use_vertex : 1;
473 Eina_Bool use_color : 1; 474 Eina_Bool use_color : 1;
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 4a06a5609a..bd683bdf6b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1318,6 +1318,100 @@ array_alloc(Evas_Engine_GL_Context *gc, int n)
1318 RALOC(texm, GLfloat, 2); 1318 RALOC(texm, GLfloat, 2);
1319} 1319}
1320 1320
1321
1322/* Very basic uniform upload support.
1323 * TODO: Optimize out call to glGetUniformLocation(). */
1324
1325typedef enum _Evas_GL_Uniform_Type Evas_GL_Uniform_Type;
1326typedef struct _Evas_GL_Uniform Evas_GL_Uniform;
1327
1328enum _Evas_GL_Uniform_Type {
1329 EVAS_GL_UNIFORM_FLOAT,
1330 EVAS_GL_UNIFORM_VEC2,
1331 EVAS_GL_UNIFORM_VEC4,
1332 // Add more types if needed.
1333};
1334
1335struct _Evas_GL_Uniform {
1336 Eina_Stringshare *name;
1337 Evas_GL_Uniform_Type type;
1338 union {
1339 GLfloat f;
1340 GLfloat vec2[2];
1341 GLfloat vec4[4];
1342 } value;
1343};
1344
1345static inline void
1346push_uniform(Evas_Engine_GL_Context *gc, int n, Evas_GL_Uniform_Type type, const char *name, ...)
1347{
1348 Evas_GL_Uniform *u = calloc(1, sizeof(Evas_GL_Uniform));
1349 va_list args;
1350 va_start(args, name);
1351
1352 if (!gc || !u) return;
1353 u->name = eina_stringshare_add(name);
1354 u->type = type;
1355
1356 switch (type)
1357 {
1358 case EVAS_GL_UNIFORM_FLOAT:
1359 u->value.f = (GLfloat) va_arg(args, double);
1360 break;
1361 case EVAS_GL_UNIFORM_VEC2:
1362 u->value.vec2[0] = (GLfloat) va_arg(args, double);
1363 u->value.vec2[1] = (GLfloat) va_arg(args, double);
1364 break;
1365 case EVAS_GL_UNIFORM_VEC4:
1366 u->value.vec4[0] = (GLfloat) va_arg(args, double);
1367 u->value.vec4[1] = (GLfloat) va_arg(args, double);
1368 u->value.vec4[2] = (GLfloat) va_arg(args, double);
1369 u->value.vec4[3] = (GLfloat) va_arg(args, double);
1370 break;
1371 default:
1372 free(u);
1373 va_end(args);
1374 return;
1375 }
1376
1377 va_end(args);
1378 gc->pipe[n].array.uniforms = eina_list_append(gc->pipe[n].array.uniforms, u);
1379}
1380
1381static inline void
1382shader_array_uniforms_set(Evas_Engine_GL_Context *gc, int n)
1383{
1384 Evas_GL_Uniform *u;
1385
1386 if (!gc || !gc->pipe[n].array.uniforms) return;
1387 EINA_LIST_FREE(gc->pipe[n].array.uniforms, u)
1388 {
1389 GLint loc = glGetUniformLocation(gc->pipe[n].shader.cur_prog, u->name);
1390 GLERR(__FUNCTION__, __FILE__, __LINE__, "glUniform");
1391 if (loc >= 0)
1392 {
1393 switch (u->type)
1394 {
1395 case EVAS_GL_UNIFORM_FLOAT:
1396 glUniform1f(loc, u->value.f);
1397 break;
1398 case EVAS_GL_UNIFORM_VEC2:
1399 glUniform2fv(loc, 1, u->value.vec2);
1400 break;
1401 case EVAS_GL_UNIFORM_VEC4:
1402 glUniform4fv(loc, 1, u->value.vec4);
1403 break;
1404 default: ERR("Unhandled uniform type"); break;
1405 }
1406 GLERR(__FUNCTION__, __FILE__, __LINE__, "glUniform");
1407 }
1408 eina_stringshare_del(u->name);
1409 free(u);
1410 }
1411}
1412
1413#define PUSH_UNIFORM(pn, type, name, ...) push_uniform(gc, pn, type, name, __VA_ARGS__)
1414
1321#ifdef GLPIPES 1415#ifdef GLPIPES
1322static int 1416static int
1323pipe_region_intersects(Evas_Engine_GL_Context *gc, int n, 1417pipe_region_intersects(Evas_Engine_GL_Context *gc, int n,
@@ -2706,8 +2800,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2706 gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0; 2800 gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0;
2707 gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0; 2801 gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0;
2708 gc->pipe[pn].array.use_texm = !!mtex; 2802 gc->pipe[pn].array.use_texm = !!mtex;
2709 gc->pipe[pn].array.use_texa = !!mtex; 2803 gc->pipe[pn].array.use_texa = 0;
2710 gc->pipe[pn].array.use_texsam = gc->pipe[pn].array.use_texm; 2804 gc->pipe[pn].array.use_texsam = 0;
2711 2805
2712 pipe_region_expand(gc, pn, x, y, w, h); 2806 pipe_region_expand(gc, pn, x, y, w, h);
2713 PIPE_GROW(gc, pn, 6); 2807 PIPE_GROW(gc, pn, 6);
@@ -2769,8 +2863,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2769 2863
2770 if (mtex) 2864 if (mtex)
2771 { 2865 {
2772 GLfloat glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f, yinv = -1.f; 2866 double glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f, yinv = -1.f;
2773 GLfloat gw = gc->w, gh = gc->h; 2867 double gw = gc->w, gh = gc->h;
2774 2868
2775 // Note: I couldn't write any test case where it was necessary 2869 // Note: I couldn't write any test case where it was necessary
2776 // to know the mask position in its texture. Thus these unused vars. 2870 // to know the mask position in its texture. Thus these unused vars.
@@ -2784,36 +2878,13 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2784 yinv = 1.f; 2878 yinv = 1.f;
2785 } 2879 }
2786 2880
2787 if (gw) glmdx = (GLfloat) mdx / (GLfloat) gw; 2881 if (gw) glmdx = (double) mdx / (double) gw;
2788 if (gh) glmdy = (GLfloat) mdy / (GLfloat) gh; 2882 if (gh) glmdy = (double) mdy / (double) gh;
2789 if (mdw) glmdw = (GLfloat) gw / (GLfloat) mdw; 2883 if (mdw) glmdw = (double) gw / (double) mdw;
2790 if (mdh) glmdh = (GLfloat) gh / (GLfloat) mdh; 2884 if (mdh) glmdh = (double) gh / (double) mdh;
2791 2885
2792 // FIXME!!! 2886 PUSH_UNIFORM(pn, EVAS_GL_UNIFORM_VEC4, "mask_Absolute", glmdx, glmdy, glmdw, glmdh);
2793 // We seriously need uniforms here. Abusing tex_coordm for storage. 2887 PUSH_UNIFORM(pn, EVAS_GL_UNIFORM_FLOAT, "yinvert", yinv);
2794 // Passing mask x,y (on canvas) to the fragment shader
2795 PUSH_TEXM(pn, glmdx, glmdy);
2796 PUSH_TEXM(pn, glmdx, glmdy);
2797 PUSH_TEXM(pn, glmdx, glmdy);
2798 PUSH_TEXM(pn, glmdx, glmdy);
2799 PUSH_TEXM(pn, glmdx, glmdy);
2800 PUSH_TEXM(pn, glmdx, glmdy);
2801
2802 // Abusing tex_sample to pass mask 1/w, 1/h as well
2803 PUSH_TEXSAM(pn, glmdw, glmdh);
2804 PUSH_TEXSAM(pn, glmdw, glmdh);
2805 PUSH_TEXSAM(pn, glmdw, glmdh);
2806 PUSH_TEXSAM(pn, glmdw, glmdh);
2807 PUSH_TEXSAM(pn, glmdw, glmdh);
2808 PUSH_TEXSAM(pn, glmdw, glmdh);
2809
2810 // Abusing tex_coorda to pass Y-invert flag
2811 PUSH_TEXA(pn, 1.f, yinv);
2812 PUSH_TEXA(pn, 1.f, yinv);
2813 PUSH_TEXA(pn, 1.f, yinv);
2814 PUSH_TEXA(pn, 1.f, yinv);
2815 PUSH_TEXA(pn, 1.f, yinv);
2816 PUSH_TEXA(pn, 1.f, yinv);
2817 2888
2818 //DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh, 2889 //DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh,
2819 // glmdx, glmdy, glmdw, glmdh); 2890 // glmdx, glmdy, glmdw, glmdh);
@@ -3347,18 +3418,6 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3347 3418
3348 MASK_TEXTURE += 1; 3419 MASK_TEXTURE += 1;
3349 } 3420 }
3350 else if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type == RTYPE_MAP))
3351 {
3352 /* FIXME:
3353 * This is a workaround as we hijack some tex ids
3354 * (namely tex_coordm, tex_coorda and tex_sample) for map masking.
3355 * These masking shaders should definitely use uniforms.
3356 */
3357 glEnableVertexAttribArray(SHAD_TEXA);
3358 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3359 glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr);
3360 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3361 }
3362 else 3421 else
3363 { 3422 {
3364 glDisableVertexAttribArray(SHAD_TEXA); 3423 glDisableVertexAttribArray(SHAD_TEXA);
@@ -3520,6 +3579,10 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3520 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 3579 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3521 } 3580 }
3522 3581
3582 // Push all uniforms
3583 if (gc->pipe[i].array.uniforms)
3584 shader_array_uniforms_set(gc, i);
3585
3523 if (dbgflushnum == 1) 3586 if (dbgflushnum == 1)
3524 { 3587 {
3525 const char *types[6] = 3588 const char *types[6] =
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 09ea4074f0..1aa4b27be1 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
@@ -2711,13 +2711,13 @@ static const char const map_mask_frag_glsl[] =
2711 "#endif\n" 2711 "#endif\n"
2712 "#endif\n" 2712 "#endif\n"
2713 "uniform sampler2D tex, texm;\n" 2713 "uniform sampler2D tex, texm;\n"
2714 "uniform vec4 mask_Absolute;\n"
2714 "varying vec2 tex_c;\n" 2715 "varying vec2 tex_c;\n"
2715 "varying vec4 mask_Position, col, mask_Absolute;\n" 2716 "varying vec4 mask_Position, col;\n"
2716 "void main()\n" 2717 "void main()\n"
2717 "{\n" 2718 "{\n"
2718 " // FIXME: Use mask coordinates within its texture\n" 2719 " // FIXME: Use mask coordinates within its texture\n"
2719 " // FIXME: Fix Mach band effect using proper 4-point color interpolation\n" 2720 " // FIXME: Fix Mach band effect using proper 4-point color interpolation\n"
2720 " // FIXME: We're abusing varying where we should have uniforms\n"
2721 " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" 2721 " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n"
2722 " gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a * col;\n" 2722 " gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a * col;\n"
2723 "}\n"; 2723 "}\n";
@@ -2733,20 +2733,17 @@ static const char const map_mask_vert_glsl[] =
2733 "precision highp float;\n" 2733 "precision highp float;\n"
2734 "#endif\n" 2734 "#endif\n"
2735 "attribute vec4 vertex, color;\n" 2735 "attribute vec4 vertex, color;\n"
2736 "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" 2736 "attribute vec2 tex_coord;\n"
2737 "uniform float yinvert;\n"
2737 "uniform mat4 mvp;\n" 2738 "uniform mat4 mvp;\n"
2738 "varying vec2 tex_c;\n" 2739 "varying vec2 tex_c;\n"
2739 "varying vec4 mask_Position, col, mask_Absolute;\n" 2740 "varying vec4 mask_Position, col;\n"
2740 "void main()\n" 2741 "void main()\n"
2741 "{\n" 2742 "{\n"
2742 " gl_Position = mvp * vertex;\n" 2743 " gl_Position = mvp * vertex;\n"
2743 " tex_c = tex_coord;\n" 2744 " tex_c = tex_coord;\n"
2744 " col = color;\n" 2745 " col = color;\n"
2745 " // tex_coorda contains the Y-invert flag\n" 2746 " mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
2746 " // tex_coordm contains the X,Y position of the mask\n"
2747 " // tex_sample contains the W,H size of the mask (inverted)\n"
2748 " mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
2749 " mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords\n"
2750 "}\n"; 2747 "}\n";
2751Evas_GL_Program_Source shader_map_mask_vert_src = 2748Evas_GL_Program_Source shader_map_mask_vert_src =
2752{ 2749{
@@ -2813,13 +2810,13 @@ static const char const map_mask_bgra_frag_glsl[] =
2813 "#endif\n" 2810 "#endif\n"
2814 "#endif\n" 2811 "#endif\n"
2815 "uniform sampler2D tex, texm;\n" 2812 "uniform sampler2D tex, texm;\n"
2813 "uniform vec4 mask_Absolute;\n"
2816 "varying vec2 tex_c;\n" 2814 "varying vec2 tex_c;\n"
2817 "varying vec4 mask_Position, col, mask_Absolute;\n" 2815 "varying vec4 mask_Position, col;\n"
2818 "void main()\n" 2816 "void main()\n"
2819 "{\n" 2817 "{\n"
2820 " // FIXME: Use mask coordinates within its texture\n" 2818 " // FIXME: Use mask coordinates within its texture\n"
2821 " // FIXME: Fix Mach band effect using proper 4-point color interpolation\n" 2819 " // FIXME: Fix Mach band effect using proper 4-point color interpolation\n"
2822 " // FIXME: We're abusing varying where we should have uniforms\n"
2823 " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" 2820 " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n"
2824 " gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a * col;\n" 2821 " gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a * col;\n"
2825 "}\n"; 2822 "}\n";
@@ -2835,20 +2832,17 @@ static const char const map_mask_bgra_vert_glsl[] =
2835 "precision highp float;\n" 2832 "precision highp float;\n"
2836 "#endif\n" 2833 "#endif\n"
2837 "attribute vec4 vertex, color;\n" 2834 "attribute vec4 vertex, color;\n"
2838 "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" 2835 "attribute vec2 tex_coord;\n"
2836 "uniform float yinvert;\n"
2839 "uniform mat4 mvp;\n" 2837 "uniform mat4 mvp;\n"
2840 "varying vec2 tex_c;\n" 2838 "varying vec2 tex_c;\n"
2841 "varying vec4 mask_Position, col, mask_Absolute;\n" 2839 "varying vec4 mask_Position, col;\n"
2842 "void main()\n" 2840 "void main()\n"
2843 "{\n" 2841 "{\n"
2844 " gl_Position = mvp * vertex;\n" 2842 " gl_Position = mvp * vertex;\n"
2845 " tex_c = tex_coord;\n" 2843 " tex_c = tex_coord;\n"
2846 " col = color;\n" 2844 " col = color;\n"
2847 " // tex_coorda contains the Y-invert flag\n" 2845 " mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
2848 " // tex_coordm contains the X,Y position of the mask\n"
2849 " // tex_sample contains the W,H size of the mask (inverted)\n"
2850 " mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
2851 " mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords\n"
2852 "}\n"; 2846 "}\n";
2853Evas_GL_Program_Source shader_map_mask_bgra_vert_src = 2847Evas_GL_Program_Source shader_map_mask_bgra_vert_src =
2854{ 2848{
diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd
index d6922f04ba..10c01451f9 100644
--- a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd
+++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd
@@ -6,13 +6,13 @@ precision mediump float;
6#endif 6#endif
7#endif 7#endif
8uniform sampler2D tex, texm; 8uniform sampler2D tex, texm;
9uniform vec4 mask_Absolute;
9varying vec2 tex_c; 10varying vec2 tex_c;
10varying vec4 mask_Position, col, mask_Absolute; 11varying vec4 mask_Position, col;
11void main() 12void main()
12{ 13{
13 // FIXME: Use mask coordinates within its texture 14 // FIXME: Use mask coordinates within its texture
14 // FIXME: Fix Mach band effect using proper 4-point color interpolation 15 // FIXME: Fix Mach band effect using proper 4-point color interpolation
15 // FIXME: We're abusing varying where we should have uniforms
16 vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; 16 vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
17 gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a * col; 17 gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a * col;
18} 18}
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 7b0c9684e7..726a0f5dd0 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
@@ -2,20 +2,16 @@
2precision highp float; 2precision highp float;
3#endif 3#endif
4attribute vec4 vertex, color; 4attribute vec4 vertex, color;
5attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; 5attribute vec2 tex_coord;
6uniform float yinvert;
6uniform mat4 mvp; 7uniform mat4 mvp;
7varying vec2 tex_c; 8varying vec2 tex_c;
8varying vec4 mask_Position, col, mask_Absolute; 9varying vec4 mask_Position, col;
9void main() 10void main()
10{ 11{
11 gl_Position = mvp * vertex; 12 gl_Position = mvp * vertex;
12 tex_c = tex_coord; 13 tex_c = tex_coord;
13 col = color; 14 col = color;
14 15
15 // tex_coorda contains the Y-invert flag 16 mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
16 // tex_coordm contains the X,Y position of the mask
17 // tex_sample contains the W,H size of the mask (inverted)
18
19 mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
20 mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords
21} 17}
diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/map_mask_frag.shd
index 189807bffd..bbed95ba18 100644
--- a/src/modules/evas/engines/gl_common/shader/map_mask_frag.shd
+++ b/src/modules/evas/engines/gl_common/shader/map_mask_frag.shd
@@ -6,13 +6,13 @@ precision mediump float;
6#endif 6#endif
7#endif 7#endif
8uniform sampler2D tex, texm; 8uniform sampler2D tex, texm;
9uniform vec4 mask_Absolute;
9varying vec2 tex_c; 10varying vec2 tex_c;
10varying vec4 mask_Position, col, mask_Absolute; 11varying vec4 mask_Position, col;
11void main() 12void main()
12{ 13{
13 // FIXME: Use mask coordinates within its texture 14 // FIXME: Use mask coordinates within its texture
14 // FIXME: Fix Mach band effect using proper 4-point color interpolation 15 // FIXME: Fix Mach band effect using proper 4-point color interpolation
15 // FIXME: We're abusing varying where we should have uniforms
16 vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; 16 vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
17 gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a * col; 17 gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a * col;
18} 18}
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 7b0c9684e7..726a0f5dd0 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
@@ -2,20 +2,16 @@
2precision highp float; 2precision highp float;
3#endif 3#endif
4attribute vec4 vertex, color; 4attribute vec4 vertex, color;
5attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; 5attribute vec2 tex_coord;
6uniform float yinvert;
6uniform mat4 mvp; 7uniform mat4 mvp;
7varying vec2 tex_c; 8varying vec2 tex_c;
8varying vec4 mask_Position, col, mask_Absolute; 9varying vec4 mask_Position, col;
9void main() 10void main()
10{ 11{
11 gl_Position = mvp * vertex; 12 gl_Position = mvp * vertex;
12 tex_c = tex_coord; 13 tex_c = tex_coord;
13 col = color; 14 col = color;
14 15
15 // tex_coorda contains the Y-invert flag 16 mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
16 // tex_coordm contains the X,Y position of the mask
17 // tex_sample contains the W,H size of the mask (inverted)
18
19 mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
20 mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords
21} 17}