jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b815f570788a4b643a6a499e421d7d49975e1cca

commit b815f570788a4b643a6a499e421d7d49975e1cca
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Thu Feb 26 17:19:07 2015 +0900

    Evas masking: Simplify map masking shaders.
    
    Use vertex shader for all coordinates computations.
    This reduces the number of varyings used.
---
 .../engines/gl_common/shader/evas_gl_shaders.x     | 70 ++++++++++------------
 .../gl_common/shader/map_mask_bgra_frag.shd        |  7 +--
 .../gl_common/shader/map_mask_bgra_nomul_frag.shd  |  7 +--
 .../gl_common/shader/map_mask_bgra_nomul_vert.shd  | 14 +++--
 .../gl_common/shader/map_mask_bgra_vert.shd        |  8 +--
 .../engines/gl_common/shader/map_mask_frag.shd     |  7 +--
 .../gl_common/shader/map_mask_nomul_frag.shd       |  7 +--
 .../gl_common/shader/map_mask_nomul_vert.shd       | 14 +++--
 .../engines/gl_common/shader/map_mask_vert.shd     |  8 +--
 9 files changed, 66 insertions(+), 76 deletions(-)

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 bedfbd2..4789e40 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,14 +2711,13 @@ static const char const map_mask_frag_glsl[] =
    "#endif\n"
    "#endif\n"
    "uniform sampler2D tex, texm;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, col, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
+   "varying vec4 col;\n"
    "void main()\n"
    "{\n"
    "   // FIXME: Use mask coordinates within its texture\n"
    "   // FIXME: Fix Mach band effect using proper 4-point color 
interpolation\n"
-   "   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * 
mask_Absolute.zw;\n"
-   "   gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a 
*  col;\n"
+   "   gl_FragColor = texture2D(tex, tex_c).bgra * texture2D(texm, tex_m).a *  
col;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_frag_src =
 {
@@ -2734,8 +2733,8 @@ static const char const map_mask_vert_glsl[] =
    "attribute vec4 vertex, color;\n"
    "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n"
    "uniform mat4 mvp;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, col, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
+   "varying vec4 col;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = mvp * vertex;\n"
@@ -2744,8 +2743,8 @@ static const char const map_mask_vert_glsl[] =
    "   // tex_coorda contains the Y-invert flag\n"
    "   // tex_coordm contains the X,Y position of the mask\n"
    "   // tex_sample contains the W,H size of the mask (inverted)\n"
-   "   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"
-   "   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on 
canvas in GL coords\n"
+   "   vec4 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"
+   "   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_vert_src =
 {
@@ -2763,13 +2762,10 @@ static const char const map_mask_nomul_frag_glsl[] =
    "#endif\n"
    "#endif\n"
    "uniform sampler2D tex, texm;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
    "void main()\n"
    "{\n"
-   "   // FIXME: Use mask coordinates within its texture\n"
-   "   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * 
mask_Absolute.zw;\n"
-   "   gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, 
mpos).a;\n"
+   "   gl_FragColor = texture2D(tex, tex_c).bgra * texture2D(texm, tex_m).a;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_nomul_frag_src =
 {
@@ -2783,17 +2779,18 @@ static const char const map_mask_nomul_vert_glsl[] =
    "precision highp float;\n"
    "#endif\n"
    "attribute vec4 vertex;\n"
-   "attribute vec2 tex_coord, tex_coordm, tex_sample;\n"
+   "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n"
    "uniform mat4 mvp;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = mvp * vertex;\n"
    "   tex_c = tex_coord;\n"
-   "   // Assume Y-invert on mask, normalize (screen to texture mode 
coordinates)\n"
-   "   mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 
0.5, 0, 0);\n"
-   "   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on 
canvas in GL coords\n"
+   "   // tex_coorda contains the Y-invert flag\n"
+   "   // tex_coordm contains the X,Y position of the mask\n"
+   "   // tex_sample contains the W,H size of the mask (inverted)\n"
+   "   vec4 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"
+   "   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_nomul_vert_src =
 {
@@ -2811,14 +2808,13 @@ static const char const map_mask_bgra_frag_glsl[] =
    "#endif\n"
    "#endif\n"
    "uniform sampler2D tex, texm;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, col, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
+   "varying vec4 col;\n"
    "void main()\n"
    "{\n"
    "   // FIXME: Use mask coordinates within its texture\n"
    "   // FIXME: Fix Mach band effect using proper 4-point color 
interpolation\n"
-   "   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * 
mask_Absolute.zw;\n"
-   "   gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a *  
col;\n"
+   "   gl_FragColor = texture2D(tex, tex_c) * texture2D(texm, tex_m).a *  
col;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_bgra_frag_src =
 {
@@ -2834,8 +2830,8 @@ static const char const map_mask_bgra_vert_glsl[] =
    "attribute vec4 vertex, color;\n"
    "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n"
    "uniform mat4 mvp;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, col, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
+   "varying vec4 col;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = mvp * vertex;\n"
@@ -2844,8 +2840,8 @@ static const char const map_mask_bgra_vert_glsl[] =
    "   // tex_coorda contains the Y-invert flag\n"
    "   // tex_coordm contains the X,Y position of the mask\n"
    "   // tex_sample contains the W,H size of the mask (inverted)\n"
-   "   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"
-   "   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on 
canvas in GL coords\n"
+   "   vec4 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"
+   "   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_bgra_vert_src =
 {
@@ -2863,13 +2859,10 @@ static const char const map_mask_bgra_nomul_frag_glsl[] 
=
    "#endif\n"
    "#endif\n"
    "uniform sampler2D tex, texm;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
    "void main()\n"
    "{\n"
-   "   // FIXME: Use mask coordinates within its texture\n"
-   "   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * 
mask_Absolute.zw;\n"
-   "   gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a;\n"
+   "   gl_FragColor = texture2D(tex, tex_c) * texture2D(texm, tex_m).a;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_bgra_nomul_frag_src =
 {
@@ -2883,17 +2876,18 @@ static const char const map_mask_bgra_nomul_vert_glsl[] 
=
    "precision highp float;\n"
    "#endif\n"
    "attribute vec4 vertex;\n"
-   "attribute vec2 tex_coord, tex_coordm, tex_sample;\n"
+   "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n"
    "uniform mat4 mvp;\n"
-   "varying vec2 tex_c;\n"
-   "varying vec4 mask_Position, mask_Absolute;\n"
+   "varying vec2 tex_c, tex_m;\n"
    "void main()\n"
    "{\n"
    "   gl_Position = mvp * vertex;\n"
    "   tex_c = tex_coord;\n"
-   "   // Assume Y-invert on mask, normalize (screen to texture mode 
coordinates)\n"
-   "   mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 
0.5, 0, 0);\n"
-   "   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on 
canvas in GL coords\n"
+   "   // tex_coorda contains the Y-invert flag\n"
+   "   // tex_coordm contains the X,Y position of the mask\n"
+   "   // tex_sample contains the W,H size of the mask (inverted)\n"
+   "   vec4 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"
+   "   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;\n"
    "}\n";
 Evas_GL_Program_Source shader_map_mask_bgra_nomul_vert_src =
 {
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 e267142..ed4fdf0 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,12 +6,11 @@ precision mediump float;
 #endif
 #endif
 uniform sampler2D tex, texm;
-varying vec2 tex_c;
-varying vec4 mask_Position, col, mask_Absolute;
+varying vec2 tex_c, tex_m;
+varying vec4 col;
 void main()
 {
    // FIXME: Use mask coordinates within its texture
    // FIXME: Fix Mach band effect using proper 4-point color interpolation
-   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
-   gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a *  col;
+   gl_FragColor = texture2D(tex, tex_c) * texture2D(texm, tex_m).a *  col;
 }
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 98aa2f4..a1ce622 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
@@ -6,11 +6,8 @@ precision mediump float;
 #endif
 #endif
 uniform sampler2D tex, texm;
-varying vec2 tex_c;
-varying vec4 mask_Position, mask_Absolute;
+varying vec2 tex_c, tex_m;
 void main()
 {
-   // FIXME: Use mask coordinates within its texture
-   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
-   gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).a;
+   gl_FragColor = texture2D(tex, tex_c) * texture2D(texm, tex_m).a;
 }
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 8457372..7e2b02e 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
@@ -2,16 +2,18 @@
 precision highp float;
 #endif
 attribute vec4 vertex;
-attribute vec2 tex_coord, tex_coordm, tex_sample;
+attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;
 uniform mat4 mvp;
-varying vec2 tex_c;
-varying vec4 mask_Position, mask_Absolute;
+varying vec2 tex_c, tex_m;
 void main()
 {
    gl_Position = mvp * vertex;
    tex_c = tex_coord;
 
-   // Assume Y-invert on mask, normalize (screen to texture mode coordinates)
-   mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 0.5, 
0, 0);
-   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas 
in GL coords
+   // tex_coorda contains the Y-invert flag
+   // tex_coordm contains the X,Y position of the mask
+   // tex_sample contains the W,H size of the mask (inverted)
+
+   vec4 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);
+   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;
 }
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 7b0c968..c1c132b 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
@@ -4,8 +4,8 @@ precision highp float;
 attribute vec4 vertex, color;
 attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;
 uniform mat4 mvp;
-varying vec2 tex_c;
-varying vec4 mask_Position, col, mask_Absolute;
+varying vec2 tex_c, tex_m;
+varying vec4 col;
 void main()
 {
    gl_Position = mvp * vertex;
@@ -16,6 +16,6 @@ void main()
    // tex_coordm contains the X,Y position of the mask
    // tex_sample contains the W,H size of the mask (inverted)
 
-   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);
-   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas 
in GL coords
+   vec4 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);
+   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;
 }
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 fdc066b..7a7579a 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,12 +6,11 @@ precision mediump float;
 #endif
 #endif
 uniform sampler2D tex, texm;
-varying vec2 tex_c;
-varying vec4 mask_Position, col, mask_Absolute;
+varying vec2 tex_c, tex_m;
+varying vec4 col;
 void main()
 {
    // FIXME: Use mask coordinates within its texture
    // FIXME: Fix Mach band effect using proper 4-point color interpolation
-   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
-   gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a *  
col;
+   gl_FragColor = texture2D(tex, tex_c).bgra * texture2D(texm, tex_m).a *  col;
 }
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 021d091..0720d58 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
@@ -6,11 +6,8 @@ precision mediump float;
 #endif
 #endif
 uniform sampler2D tex, texm;
-varying vec2 tex_c;
-varying vec4 mask_Position, mask_Absolute;
+varying vec2 tex_c, tex_m;
 void main()
 {
-   // FIXME: Use mask coordinates within its texture
-   vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw;
-   gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).a;
+   gl_FragColor = texture2D(tex, tex_c).bgra * texture2D(texm, tex_m).a;
 }
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 8457372..7e2b02e 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
@@ -2,16 +2,18 @@
 precision highp float;
 #endif
 attribute vec4 vertex;
-attribute vec2 tex_coord, tex_coordm, tex_sample;
+attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;
 uniform mat4 mvp;
-varying vec2 tex_c;
-varying vec4 mask_Position, mask_Absolute;
+varying vec2 tex_c, tex_m;
 void main()
 {
    gl_Position = mvp * vertex;
    tex_c = tex_coord;
 
-   // Assume Y-invert on mask, normalize (screen to texture mode coordinates)
-   mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 0.5, 
0, 0);
-   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas 
in GL coords
+   // tex_coorda contains the Y-invert flag
+   // tex_coordm contains the X,Y position of the mask
+   // tex_sample contains the W,H size of the mask (inverted)
+
+   vec4 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);
+   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;
 }
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 7b0c968..c1c132b 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
@@ -4,8 +4,8 @@ precision highp float;
 attribute vec4 vertex, color;
 attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;
 uniform mat4 mvp;
-varying vec2 tex_c;
-varying vec4 mask_Position, col, mask_Absolute;
+varying vec2 tex_c, tex_m;
+varying vec4 col;
 void main()
 {
    gl_Position = mvp * vertex;
@@ -16,6 +16,6 @@ void main()
    // tex_coordm contains the X,Y position of the mask
    // tex_sample contains the W,H size of the mask (inverted)
 
-   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);
-   mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas 
in GL coords
+   vec4 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);
+   tex_m = vec2(mask_Position.xy - tex_coordm) * tex_sample;
 }

-- 


Reply via email to