diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-02-12 15:10:53 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-02-12 15:18:19 +0900 |
commit | 6b48c106d3261dc3c03c8add24d5d8cad3705bd9 (patch) | |
tree | 9a22b0943ed60b2ffd2bcb934a6a030029bcfdc1 /src | |
parent | cfd337a758ab379ebb6b89c6d8d8f8f8c8786c87 (diff) |
Revert "Evas GL: Add support for uniforms in the shaders"
This reverts commit 21d08f86e6087f7e30ff2015c7551c06e359bba9.
Diffstat (limited to 'src')
9 files changed, 76 insertions, 145 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 8bb414bca4..f2f816198f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h | |||
@@ -481,7 +481,6 @@ struct _Evas_Engine_GL_Context | |||
481 | GLfloat *texa; | 481 | GLfloat *texa; |
482 | GLfloat *texsam; | 482 | GLfloat *texsam; |
483 | GLfloat *texm; | 483 | GLfloat *texm; |
484 | Eina_List *uniforms; /* Evas_GL_Uniform */ | ||
485 | Eina_Bool line: 1; | 484 | Eina_Bool line: 1; |
486 | Eina_Bool use_vertex : 1; | 485 | Eina_Bool use_vertex : 1; |
487 | Eina_Bool use_color : 1; | 486 | 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 2b4e267515..9ab866395a 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c | |||
@@ -1311,107 +1311,6 @@ array_alloc(Evas_Engine_GL_Context *gc, int n) | |||
1311 | RALOC(texm, GLfloat, 2); | 1311 | RALOC(texm, GLfloat, 2); |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | |||
1315 | /* Very basic uniform upload support. | ||
1316 | * TODO: Optimize out call to glGetUniformLocation(). */ | ||
1317 | |||
1318 | typedef enum _Evas_GL_Uniform_Type Evas_GL_Uniform_Type; | ||
1319 | typedef struct _Evas_GL_Uniform Evas_GL_Uniform; | ||
1320 | |||
1321 | enum _Evas_GL_Uniform_Type { | ||
1322 | EVAS_GL_UNIFORM_FLOAT, | ||
1323 | EVAS_GL_UNIFORM_VEC2, | ||
1324 | EVAS_GL_UNIFORM_VEC4, | ||
1325 | // Add more types if needed. | ||
1326 | }; | ||
1327 | |||
1328 | struct _Evas_GL_Uniform { | ||
1329 | Evas_GL_Uniform_Type type; | ||
1330 | Eina_Stringshare *name; // May be NULL if location was found at link time | ||
1331 | GLint location; | ||
1332 | union { | ||
1333 | GLfloat f; | ||
1334 | GLfloat vec2[2]; | ||
1335 | GLfloat vec4[4]; | ||
1336 | } value; | ||
1337 | }; | ||
1338 | |||
1339 | static inline void | ||
1340 | push_uniform(Evas_Engine_GL_Context *gc, int n, Evas_GL_Uniform_Type type, | ||
1341 | const char *name, GLint loc, ...) | ||
1342 | { | ||
1343 | Evas_GL_Uniform *u = calloc(1, sizeof(Evas_GL_Uniform)); | ||
1344 | va_list args; | ||
1345 | va_start(args, loc); | ||
1346 | |||
1347 | if (!gc || !u) return; | ||
1348 | u->type = type; | ||
1349 | u->location = loc; | ||
1350 | if (loc < 0) u->name = eina_stringshare_add(name); | ||
1351 | |||
1352 | switch (type) | ||
1353 | { | ||
1354 | case EVAS_GL_UNIFORM_FLOAT: | ||
1355 | u->value.f = (GLfloat) va_arg(args, double); | ||
1356 | break; | ||
1357 | case EVAS_GL_UNIFORM_VEC2: | ||
1358 | u->value.vec2[0] = (GLfloat) va_arg(args, double); | ||
1359 | u->value.vec2[1] = (GLfloat) va_arg(args, double); | ||
1360 | break; | ||
1361 | case EVAS_GL_UNIFORM_VEC4: | ||
1362 | u->value.vec4[0] = (GLfloat) va_arg(args, double); | ||
1363 | u->value.vec4[1] = (GLfloat) va_arg(args, double); | ||
1364 | u->value.vec4[2] = (GLfloat) va_arg(args, double); | ||
1365 | u->value.vec4[3] = (GLfloat) va_arg(args, double); | ||
1366 | break; | ||
1367 | default: | ||
1368 | eina_stringshare_del(u->name); | ||
1369 | free(u); | ||
1370 | va_end(args); | ||
1371 | return; | ||
1372 | } | ||
1373 | |||
1374 | va_end(args); | ||
1375 | gc->pipe[n].array.uniforms = eina_list_append(gc->pipe[n].array.uniforms, u); | ||
1376 | } | ||
1377 | |||
1378 | static inline void | ||
1379 | shader_array_uniforms_set(Evas_Engine_GL_Context *gc, int n) | ||
1380 | { | ||
1381 | Evas_GL_Uniform *u; | ||
1382 | GLint loc; | ||
1383 | |||
1384 | if (!gc || !gc->pipe[n].array.uniforms) return; | ||
1385 | EINA_LIST_FREE(gc->pipe[n].array.uniforms, u) | ||
1386 | { | ||
1387 | if (u->location >= 0) | ||
1388 | loc = u->location; | ||
1389 | else | ||
1390 | loc = glGetUniformLocation(gc->pipe[n].shader.cur_prog, u->name); | ||
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 | } | ||
1407 | eina_stringshare_del(u->name); | ||
1408 | free(u); | ||
1409 | } | ||
1410 | } | ||
1411 | |||
1412 | #define PUSH_UNIFORM(pn, shader, type, name, ...) \ | ||
1413 | push_uniform(gc, pn, type, #name, gc->shared->shader[shader].uniforms.loc_##name, __VA_ARGS__) | ||
1414 | |||
1415 | #ifdef GLPIPES | 1314 | #ifdef GLPIPES |
1416 | static int | 1315 | static int |
1417 | pipe_region_intersects(Evas_Engine_GL_Context *gc, int n, | 1316 | pipe_region_intersects(Evas_Engine_GL_Context *gc, int n, |
@@ -2688,8 +2587,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, | |||
2688 | gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0; | 2587 | gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0; |
2689 | gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0; | 2588 | gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0; |
2690 | gc->pipe[pn].array.use_texm = !!mtex; | 2589 | gc->pipe[pn].array.use_texm = !!mtex; |
2691 | gc->pipe[pn].array.use_texa = 0; | 2590 | gc->pipe[pn].array.use_texa = !!mtex; |
2692 | gc->pipe[pn].array.use_texsam = 0; | 2591 | gc->pipe[pn].array.use_texsam = gc->pipe[pn].array.use_texm; |
2693 | 2592 | ||
2694 | pipe_region_expand(gc, pn, x, y, w, h); | 2593 | pipe_region_expand(gc, pn, x, y, w, h); |
2695 | PIPE_GROW(gc, pn, 6); | 2594 | PIPE_GROW(gc, pn, 6); |
@@ -2751,8 +2650,8 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, | |||
2751 | 2650 | ||
2752 | if (mtex) | 2651 | if (mtex) |
2753 | { | 2652 | { |
2754 | double glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f, yinv = -1.f; | 2653 | GLfloat glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f, yinv = -1.f; |
2755 | double gw = gc->w, gh = gc->h; | 2654 | GLfloat gw = gc->w, gh = gc->h; |
2756 | 2655 | ||
2757 | // Note: I couldn't write any test case where it was necessary | 2656 | // Note: I couldn't write any test case where it was necessary |
2758 | // to know the mask position in its texture. Thus these unused vars. | 2657 | // to know the mask position in its texture. Thus these unused vars. |
@@ -2766,13 +2665,34 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, | |||
2766 | yinv = 1.f; | 2665 | yinv = 1.f; |
2767 | } | 2666 | } |
2768 | 2667 | ||
2769 | if (gw) glmdx = (double) mdx / (double) gw; | 2668 | if (gw) glmdx = (GLfloat) mdx / (GLfloat) gw; |
2770 | if (gh) glmdy = (double) mdy / (double) gh; | 2669 | if (gh) glmdy = (GLfloat) mdy / (GLfloat) gh; |
2771 | if (mdw) glmdw = (double) gw / (double) mdw; | 2670 | if (mdw) glmdw = (GLfloat) gw / (GLfloat) mdw; |
2772 | if (mdh) glmdh = (double) gh / (double) mdh; | 2671 | if (mdh) glmdh = (GLfloat) gh / (GLfloat) mdh; |
2773 | 2672 | ||
2774 | PUSH_UNIFORM(pn, shader, EVAS_GL_UNIFORM_VEC4, mask_Absolute, glmdx, glmdy, glmdw, glmdh); | 2673 | // tex_coordm: mask x,y (on canvas) |
2775 | PUSH_UNIFORM(pn, shader, EVAS_GL_UNIFORM_FLOAT, yinvert, yinv); | 2674 | PUSH_TEXM(pn, glmdx, glmdy); |
2675 | PUSH_TEXM(pn, glmdx, glmdy); | ||
2676 | PUSH_TEXM(pn, glmdx, glmdy); | ||
2677 | PUSH_TEXM(pn, glmdx, glmdy); | ||
2678 | PUSH_TEXM(pn, glmdx, glmdy); | ||
2679 | PUSH_TEXM(pn, glmdx, glmdy); | ||
2680 | |||
2681 | // tex_sample: mask 1/w, 1/h | ||
2682 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2683 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2684 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2685 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2686 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2687 | PUSH_TEXSAM(pn, glmdw, glmdh); | ||
2688 | |||
2689 | // tex_coorda: mask Y-invert flag | ||
2690 | PUSH_TEXA(pn, 1.f, yinv); | ||
2691 | PUSH_TEXA(pn, 1.f, yinv); | ||
2692 | PUSH_TEXA(pn, 1.f, yinv); | ||
2693 | PUSH_TEXA(pn, 1.f, yinv); | ||
2694 | PUSH_TEXA(pn, 1.f, yinv); | ||
2695 | PUSH_TEXA(pn, 1.f, yinv); | ||
2776 | 2696 | ||
2777 | //DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh, | 2697 | //DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh, |
2778 | // glmdx, glmdy, glmdw, glmdh); | 2698 | // glmdx, glmdy, glmdw, glmdh); |
@@ -3257,6 +3177,16 @@ shader_array_flush(Evas_Engine_GL_Context *gc) | |||
3257 | 3177 | ||
3258 | MASK_TEXTURE += 1; | 3178 | MASK_TEXTURE += 1; |
3259 | } | 3179 | } |
3180 | else if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type == RTYPE_MAP)) | ||
3181 | { | ||
3182 | /* FIXME: | ||
3183 | * This is a workaround as we hijack some tex ids | ||
3184 | * (namely tex_coordm, tex_coorda and tex_sample) for map masking. | ||
3185 | * These masking shaders should definitely use uniforms. | ||
3186 | */ | ||
3187 | glEnableVertexAttribArray(SHAD_TEXA); | ||
3188 | glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr); | ||
3189 | } | ||
3260 | else | 3190 | else |
3261 | { | 3191 | { |
3262 | glDisableVertexAttribArray(SHAD_TEXA); | 3192 | glDisableVertexAttribArray(SHAD_TEXA); |
@@ -3370,10 +3300,6 @@ shader_array_flush(Evas_Engine_GL_Context *gc) | |||
3370 | glDisableVertexAttribArray(SHAD_TEXM); | 3300 | glDisableVertexAttribArray(SHAD_TEXM); |
3371 | } | 3301 | } |
3372 | 3302 | ||
3373 | // Push all uniforms | ||
3374 | if (gc->pipe[i].array.uniforms) | ||
3375 | shader_array_uniforms_set(gc, i); | ||
3376 | |||
3377 | if (dbgflushnum == 1) | 3303 | if (dbgflushnum == 1) |
3378 | { | 3304 | { |
3379 | const char *types[6] = | 3305 | 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 712a84924e..bedfbd2338 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,9 +2711,8 @@ 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" | ||
2715 | "varying vec2 tex_c;\n" | 2714 | "varying vec2 tex_c;\n" |
2716 | "varying vec4 mask_Position, col;\n" | 2715 | "varying vec4 mask_Position, col, mask_Absolute;\n" |
2717 | "void main()\n" | 2716 | "void main()\n" |
2718 | "{\n" | 2717 | "{\n" |
2719 | " // FIXME: Use mask coordinates within its texture\n" | 2718 | " // FIXME: Use mask coordinates within its texture\n" |
@@ -2733,17 +2732,20 @@ static const char const map_mask_vert_glsl[] = | |||
2733 | "precision highp float;\n" | 2732 | "precision highp float;\n" |
2734 | "#endif\n" | 2733 | "#endif\n" |
2735 | "attribute vec4 vertex, color;\n" | 2734 | "attribute vec4 vertex, color;\n" |
2736 | "attribute vec2 tex_coord;\n" | 2735 | "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" |
2737 | "uniform float yinvert;\n" | ||
2738 | "uniform mat4 mvp;\n" | 2736 | "uniform mat4 mvp;\n" |
2739 | "varying vec2 tex_c;\n" | 2737 | "varying vec2 tex_c;\n" |
2740 | "varying vec4 mask_Position, col;\n" | 2738 | "varying vec4 mask_Position, col, mask_Absolute;\n" |
2741 | "void main()\n" | 2739 | "void main()\n" |
2742 | "{\n" | 2740 | "{\n" |
2743 | " gl_Position = mvp * vertex;\n" | 2741 | " gl_Position = mvp * vertex;\n" |
2744 | " tex_c = tex_coord;\n" | 2742 | " tex_c = tex_coord;\n" |
2745 | " col = color;\n" | 2743 | " col = color;\n" |
2746 | " mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" | 2744 | " // tex_coorda contains the Y-invert flag\n" |
2745 | " // tex_coordm contains the X,Y position of the mask\n" | ||
2746 | " // tex_sample contains the W,H size of the mask (inverted)\n" | ||
2747 | " 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" | ||
2748 | " mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords\n" | ||
2747 | "}\n"; | 2749 | "}\n"; |
2748 | Evas_GL_Program_Source shader_map_mask_vert_src = | 2750 | Evas_GL_Program_Source shader_map_mask_vert_src = |
2749 | { | 2751 | { |
@@ -2766,7 +2768,6 @@ static const char const map_mask_nomul_frag_glsl[] = | |||
2766 | "void main()\n" | 2768 | "void main()\n" |
2767 | "{\n" | 2769 | "{\n" |
2768 | " // FIXME: Use mask coordinates within its texture\n" | 2770 | " // FIXME: Use mask coordinates within its texture\n" |
2769 | " // FIXME: We're abusing varying where we should have uniforms\n" | ||
2770 | " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" | 2771 | " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" |
2771 | " gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a;\n" | 2772 | " gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a;\n" |
2772 | "}\n"; | 2773 | "}\n"; |
@@ -2810,9 +2811,8 @@ static const char const map_mask_bgra_frag_glsl[] = | |||
2810 | "#endif\n" | 2811 | "#endif\n" |
2811 | "#endif\n" | 2812 | "#endif\n" |
2812 | "uniform sampler2D tex, texm;\n" | 2813 | "uniform sampler2D tex, texm;\n" |
2813 | "uniform vec4 mask_Absolute;\n" | ||
2814 | "varying vec2 tex_c;\n" | 2814 | "varying vec2 tex_c;\n" |
2815 | "varying vec4 mask_Position, col;\n" | 2815 | "varying vec4 mask_Position, col, mask_Absolute;\n" |
2816 | "void main()\n" | 2816 | "void main()\n" |
2817 | "{\n" | 2817 | "{\n" |
2818 | " // FIXME: Use mask coordinates within its texture\n" | 2818 | " // FIXME: Use mask coordinates within its texture\n" |
@@ -2832,17 +2832,20 @@ static const char const map_mask_bgra_vert_glsl[] = | |||
2832 | "precision highp float;\n" | 2832 | "precision highp float;\n" |
2833 | "#endif\n" | 2833 | "#endif\n" |
2834 | "attribute vec4 vertex, color;\n" | 2834 | "attribute vec4 vertex, color;\n" |
2835 | "attribute vec2 tex_coord;\n" | 2835 | "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n" |
2836 | "uniform float yinvert;\n" | ||
2837 | "uniform mat4 mvp;\n" | 2836 | "uniform mat4 mvp;\n" |
2838 | "varying vec2 tex_c;\n" | 2837 | "varying vec2 tex_c;\n" |
2839 | "varying vec4 mask_Position, col;\n" | 2838 | "varying vec4 mask_Position, col, mask_Absolute;\n" |
2840 | "void main()\n" | 2839 | "void main()\n" |
2841 | "{\n" | 2840 | "{\n" |
2842 | " gl_Position = mvp * vertex;\n" | 2841 | " gl_Position = mvp * vertex;\n" |
2843 | " tex_c = tex_coord;\n" | 2842 | " tex_c = tex_coord;\n" |
2844 | " col = color;\n" | 2843 | " col = color;\n" |
2845 | " mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n" | 2844 | " // tex_coorda contains the Y-invert flag\n" |
2845 | " // tex_coordm contains the X,Y position of the mask\n" | ||
2846 | " // tex_sample contains the W,H size of the mask (inverted)\n" | ||
2847 | " 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" | ||
2848 | " mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords\n" | ||
2846 | "}\n"; | 2849 | "}\n"; |
2847 | Evas_GL_Program_Source shader_map_mask_bgra_vert_src = | 2850 | Evas_GL_Program_Source shader_map_mask_bgra_vert_src = |
2848 | { | 2851 | { |
@@ -2865,7 +2868,6 @@ static const char const map_mask_bgra_nomul_frag_glsl[] = | |||
2865 | "void main()\n" | 2868 | "void main()\n" |
2866 | "{\n" | 2869 | "{\n" |
2867 | " // FIXME: Use mask coordinates within its texture\n" | 2870 | " // FIXME: Use mask coordinates within its texture\n" |
2868 | " // FIXME: We're abusing varying where we should have uniforms\n" | ||
2869 | " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" | 2871 | " vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;\n" |
2870 | " gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a;\n" | 2872 | " gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a;\n" |
2871 | "}\n"; | 2873 | "}\n"; |
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 10c01451f9..e267142ac4 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,9 +6,8 @@ precision mediump float; | |||
6 | #endif | 6 | #endif |
7 | #endif | 7 | #endif |
8 | uniform sampler2D tex, texm; | 8 | uniform sampler2D tex, texm; |
9 | uniform vec4 mask_Absolute; | ||
10 | varying vec2 tex_c; | 9 | varying vec2 tex_c; |
11 | varying vec4 mask_Position, col; | 10 | varying vec4 mask_Position, col, mask_Absolute; |
12 | void main() | 11 | void main() |
13 | { | 12 | { |
14 | // FIXME: Use mask coordinates within its texture | 13 | // FIXME: Use mask coordinates within its texture |
diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd index b790efa1ce..98aa2f4319 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd | |||
@@ -11,7 +11,6 @@ varying vec4 mask_Position, mask_Absolute; | |||
11 | void main() | 11 | void main() |
12 | { | 12 | { |
13 | // FIXME: Use mask coordinates within its texture | 13 | // FIXME: Use mask coordinates within its texture |
14 | // FIXME: We're abusing varying where we should have uniforms | ||
15 | vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; | 14 | vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; |
16 | gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a; | 15 | gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a; |
17 | } | 16 | } |
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 726a0f5dd0..7b0c9684e7 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,16 +2,20 @@ | |||
2 | precision highp float; | 2 | precision highp float; |
3 | #endif | 3 | #endif |
4 | attribute vec4 vertex, color; | 4 | attribute vec4 vertex, color; |
5 | attribute vec2 tex_coord; | 5 | attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; |
6 | uniform float yinvert; | ||
7 | uniform mat4 mvp; | 6 | uniform mat4 mvp; |
8 | varying vec2 tex_c; | 7 | varying vec2 tex_c; |
9 | varying vec4 mask_Position, col; | 8 | varying vec4 mask_Position, col, mask_Absolute; |
10 | void main() | 9 | void main() |
11 | { | 10 | { |
12 | gl_Position = mvp * vertex; | 11 | gl_Position = mvp * vertex; |
13 | tex_c = tex_coord; | 12 | tex_c = tex_coord; |
14 | col = color; | 13 | col = color; |
15 | 14 | ||
16 | mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); | 15 | // tex_coorda contains the Y-invert flag |
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 | ||
17 | } | 21 | } |
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 bbed95ba18..fdc066bdf5 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,9 +6,8 @@ precision mediump float; | |||
6 | #endif | 6 | #endif |
7 | #endif | 7 | #endif |
8 | uniform sampler2D tex, texm; | 8 | uniform sampler2D tex, texm; |
9 | uniform vec4 mask_Absolute; | ||
10 | varying vec2 tex_c; | 9 | varying vec2 tex_c; |
11 | varying vec4 mask_Position, col; | 10 | varying vec4 mask_Position, col, mask_Absolute; |
12 | void main() | 11 | void main() |
13 | { | 12 | { |
14 | // FIXME: Use mask coordinates within its texture | 13 | // FIXME: Use mask coordinates within its texture |
diff --git a/src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd index 2340f50c29..021d091ceb 100644 --- a/src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd +++ b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd | |||
@@ -11,7 +11,6 @@ varying vec4 mask_Position, mask_Absolute; | |||
11 | void main() | 11 | void main() |
12 | { | 12 | { |
13 | // FIXME: Use mask coordinates within its texture | 13 | // FIXME: Use mask coordinates within its texture |
14 | // FIXME: We're abusing varying where we should have uniforms | ||
15 | vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; | 14 | vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; |
16 | gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a; | 15 | gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a; |
17 | } | 16 | } |
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 726a0f5dd0..7b0c9684e7 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,16 +2,20 @@ | |||
2 | precision highp float; | 2 | precision highp float; |
3 | #endif | 3 | #endif |
4 | attribute vec4 vertex, color; | 4 | attribute vec4 vertex, color; |
5 | attribute vec2 tex_coord; | 5 | attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda; |
6 | uniform float yinvert; | ||
7 | uniform mat4 mvp; | 6 | uniform mat4 mvp; |
8 | varying vec2 tex_c; | 7 | varying vec2 tex_c; |
9 | varying vec4 mask_Position, col; | 8 | varying vec4 mask_Position, col, mask_Absolute; |
10 | void main() | 9 | void main() |
11 | { | 10 | { |
12 | gl_Position = mvp * vertex; | 11 | gl_Position = mvp * vertex; |
13 | tex_c = tex_coord; | 12 | tex_c = tex_coord; |
14 | col = color; | 13 | col = color; |
15 | 14 | ||
16 | mask_Position = mvp * vertex * vec4(0.5, yinvert * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0); | 15 | // tex_coorda contains the Y-invert flag |
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 | ||
17 | } | 21 | } |