summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-02-26 17:19:07 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-26 17:49:21 +0900
commitb815f570788a4b643a6a499e421d7d49975e1cca (patch)
tree950595a218a170eb236f72d4efa645e20060d67c
parent053430739e147c7af84a5c768f074bb7fb095cb7 (diff)
downloadefl-b815f570788a4b643a6a499e421d7d49975e1cca.tar.gz
Evas masking: Simplify map masking shaders.
Use vertex shader for all coordinates computations. This reduces the number of varyings used.
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x70
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd7
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd7
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd14
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd8
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_frag.shd7
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd7
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd14
-rw-r--r--src/modules/evas/engines/gl_common/shader/map_mask_vert.shd8
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 bedfbd2338..4789e40424 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 e267142ac4..ed4fdf0f1c 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 98aa2f4319..a1ce62291c 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 8457372d5b..7e2b02e5e5 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 7b0c9684e7..c1c132b929 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 fdc066bdf5..7a7579a357 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 021d091ceb..0720d580bd 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 8457372d5b..7e2b02e5e5 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 7b0c9684e7..c1c132b929 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;
}