summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-24 20:24:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-01-07 15:06:02 +0900
commit124ab102b7b3f5a2696fca5f797ce2001122c9a5 (patch)
tree450047572edd764577ffe8e69e0f737f1804e97d /src/modules
parent62f3170874c30194c78ab75248b2a45e400f237f (diff)
Evas masking: Implement image masking for GL engines
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h9
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c110
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c94
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_enum.x2
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x100
-rw-r--r--src/modules/evas/engines/gl_common/shader/img_mask_frag.shd18
-rw-r--r--src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd17
-rw-r--r--src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd16
-rw-r--r--src/modules/evas/engines/gl_common/shader/img_mask_vert.shd19
9 files changed, 377 insertions, 8 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 87ea366ac5..eda2b8bc98 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -762,6 +762,15 @@ void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *g
762 Eina_Bool smooth, 762 Eina_Bool smooth,
763 Eina_Bool tex_only, 763 Eina_Bool tex_only,
764 Evas_Colorspace cspace); 764 Evas_Colorspace cspace);
765void evas_gl_common_context_masked_image_push(Evas_Engine_GL_Context *gc,
766 Evas_GL_Texture *tex,
767 Evas_GL_Texture *mask_tex,
768 double sx, double sy,
769 double sw, double sh,
770 int x, int y, int w, int h,
771 int mx, int my, int mw, int mh,
772 int r, int g, int b, int a,
773 Eina_Bool smooth, Eina_Bool tex_only);
765 774
766int evas_gl_common_shader_program_init(Evas_GL_Shared *shared); 775int evas_gl_common_shader_program_init(Evas_GL_Shared *shared);
767void evas_gl_common_shader_program_init_done(void); 776void evas_gl_common_shader_program_init_done(void);
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 32f10b8e10..08ccbb6ec9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -851,6 +851,11 @@ evas_gl_common_context_new(void)
851 SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, tex); 851 SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, tex);
852 SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, texa); 852 SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, texa);
853 853
854 SHADER_TEXTURE_ADD(shared, IMG_MASK, tex);
855 SHADER_TEXTURE_ADD(shared, IMG_MASK, texa);
856 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, tex);
857 SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, texa);
858
854 if (gc->state.current.cur_prog == PRG_INVALID) 859 if (gc->state.current.cur_prog == PRG_INVALID)
855 glUseProgram(shared->shader[0].prog); 860 glUseProgram(shared->shader[0].prog);
856 else glUseProgram(gc->state.current.cur_prog); 861 else glUseProgram(gc->state.current.cur_prog);
@@ -2645,6 +2650,109 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2645 } 2650 }
2646} 2651}
2647 2652
2653void
2654evas_gl_common_context_masked_image_push(Evas_Engine_GL_Context *gc,
2655 Evas_GL_Texture *tex,
2656 Evas_GL_Texture *mask_tex,
2657 double sx, double sy,
2658 double sw, double sh,
2659 int x, int y, int w, int h,
2660 int mx, int my, int mw, int mh,
2661 int r, int g, int b, int a,
2662 Eina_Bool smooth, Eina_Bool tex_only)
2663{
2664 // FIXME: How to implement support for yuv, rgb_a_pair & map stuff?
2665 // NOTE: If image (tex) has no alpha this is very similar to RGB+A pair
2666
2667 // FIXME: Optimize for image vs. texture?
2668 (void)tex_only;
2669
2670 int pnum, nv, nc, nu, na, i;
2671 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2672 GLuint prog;
2673 int pn;
2674
2675 // TODO: Big IF here (image type, etc --> needs tons of new shaders!)
2676 prog = gc->shared->shader[evas_gl_common_shader_choice
2677 (0, NULL, r, g, b, a, SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog;
2678
2679 pn = _evas_gl_common_context_push(RTYPE_IMAGE,
2680 gc, tex,
2681 prog,
2682 x, y, w, h,
2683 EINA_TRUE,
2684 smooth,
2685 EINA_FALSE, 0, 0, 0, 0);
2686
2687 gc->pipe[pn].region.type = RTYPE_IMAGE;
2688 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2689 gc->pipe[pn].shader.cur_texa = mask_tex->pt->texture;
2690 gc->pipe[pn].shader.cur_prog = prog;
2691 gc->pipe[pn].shader.smooth = smooth;
2692 gc->pipe[pn].shader.blend = EINA_TRUE;
2693 gc->pipe[pn].shader.render_op = gc->dc->render_op;
2694 gc->pipe[pn].shader.clip = 0;
2695 gc->pipe[pn].shader.cx = 0;
2696 gc->pipe[pn].shader.cy = 0;
2697 gc->pipe[pn].shader.cw = 0;
2698 gc->pipe[pn].shader.ch = 0;
2699 gc->pipe[pn].array.line = 0;
2700 gc->pipe[pn].array.use_vertex = EINA_TRUE;
2701 // if nomul... dont need this
2702 gc->pipe[pn].array.use_color = EINA_TRUE;
2703 gc->pipe[pn].array.use_texuv = EINA_TRUE;
2704 gc->pipe[pn].array.use_texuv2 = EINA_FALSE;
2705 gc->pipe[pn].array.use_texuv3 = EINA_FALSE;
2706 gc->pipe[pn].array.use_texa = EINA_TRUE;
2707 gc->pipe[pn].array.use_texsam = EINA_FALSE;
2708
2709 pipe_region_expand(gc, pn, x, y, w, h);
2710
2711 pnum = gc->pipe[pn].array.num;
2712 nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2;
2713 gc->pipe[pn].array.num += 6;
2714 array_alloc(gc, pn);
2715
2716 tx1 = (tex->x + sx) / (double)tex->pt->w;
2717 ty1 = (tex->y + sy) / (double)tex->pt->h;
2718 tx2 = (tex->x + sx + sw) / (double)tex->pt->w;
2719 ty2 = (tex->y + sy + sh) / (double)tex->pt->h;
2720
2721 t2x1 = (mask_tex->x + mx) / (double)mask_tex->pt->w;
2722 t2y1 = (mask_tex->y + my) / (double)mask_tex->pt->h;
2723 t2x2 = (mask_tex->x + mx + mw) / (double)mask_tex->pt->w;
2724 t2y2 = (mask_tex->y + my + mh) / (double)mask_tex->pt->h;
2725
2726 PUSH_VERTEX(pn, x , y , 0);
2727 PUSH_VERTEX(pn, x + w, y , 0);
2728 PUSH_VERTEX(pn, x , y + h, 0);
2729
2730 PUSH_TEXUV(pn, tx1, ty1);
2731 PUSH_TEXUV(pn, tx2, ty1);
2732 PUSH_TEXUV(pn, tx1, ty2);
2733
2734 PUSH_TEXA(pn, t2x1, t2y1);
2735 PUSH_TEXA(pn, t2x2, t2y1);
2736 PUSH_TEXA(pn, t2x1, t2y2);
2737
2738 PUSH_VERTEX(pn, x + w, y , 0);
2739 PUSH_VERTEX(pn, x + w, y + h, 0);
2740 PUSH_VERTEX(pn, x , y + h, 0);
2741
2742 PUSH_TEXUV(pn, tx2, ty1);
2743 PUSH_TEXUV(pn, tx2, ty2);
2744 PUSH_TEXUV(pn, tx1, ty2);
2745
2746 PUSH_TEXA(pn, t2x2, t2y1);
2747 PUSH_TEXA(pn, t2x2, t2y2);
2748 PUSH_TEXA(pn, t2x1, t2y2);
2749
2750 for (i = 0; i < 6; i++)
2751 {
2752 PUSH_COLOR(pn, r, g, b, a);
2753 }
2754}
2755
2648EAPI void 2756EAPI void
2649evas_gl_common_context_flush(Evas_Engine_GL_Context *gc) 2757evas_gl_common_context_flush(Evas_Engine_GL_Context *gc)
2650{ 2758{
@@ -3103,7 +3211,6 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3103 glDisableVertexAttribArray(SHAD_TEXUV); 3211 glDisableVertexAttribArray(SHAD_TEXUV);
3104 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 3212 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3105 } 3213 }
3106
3107 if (gc->pipe[i].array.use_texa) 3214 if (gc->pipe[i].array.use_texa)
3108 { 3215 {
3109 glEnableVertexAttribArray(SHAD_TEXA); 3216 glEnableVertexAttribArray(SHAD_TEXA);
@@ -3145,6 +3252,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3145 else 3252 else
3146 { 3253 {
3147 glDisableVertexAttribArray(SHAD_TEXA); 3254 glDisableVertexAttribArray(SHAD_TEXA);
3255
3148 } 3256 }
3149 if (gc->pipe[i].array.use_texsam) 3257 if (gc->pipe[i].array.use_texsam)
3150 { 3258 {
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 88692ba177..583a6a6baf 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -957,10 +957,13 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
957 int dx, int dy, int dw, int dh, 957 int dx, int dy, int dw, int dh,
958 int sx, int sy, int sw, int sh, 958 int sx, int sy, int sw, int sh,
959 int cx, int cy, int cw, int ch, 959 int cx, int cy, int cw, int ch,
960 int r, int g, int b, int a, Eina_Bool smooth, 960 int r, int g, int b, int a,
961 Evas_GL_Image *mask, int mask_x, int mask_y,
962 Eina_Bool smooth,
961 Eina_Bool yuv, Eina_Bool yuy2, Eina_Bool nv12, 963 Eina_Bool yuv, Eina_Bool yuy2, Eina_Bool nv12,
962 Eina_Bool rgb_a_pair) 964 Eina_Bool rgb_a_pair)
963{ 965{
966 double mx, my, mw, mh, mmx, mmy, mmw, mmh;
964 double ssx, ssy, ssw, ssh; 967 double ssx, ssy, ssw, ssh;
965 int nx, ny, nw, nh; 968 int nx, ny, nw, nh;
966 969
@@ -969,9 +972,30 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
969 cx, cy, cw, ch); 972 cx, cy, cw, ch);
970 if ((nw < 1) || (nh < 1)) return; 973 if ((nw < 1) || (nh < 1)) return;
971 if (!im->tex) return; 974 if (!im->tex) return;
975
972 if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh)) 976 if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
973 { 977 {
974 if (yuv) 978 /* Apply mask on image */
979 if (mask)
980 {
981 // FIXME/TODO: support for yuv, yuy2, nv12, rgb_a with masks
982 mx = mask_x; my = mask_y; mw = mask->w; mh = mask->h;
983 RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch);
984 RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh);
985
986 mmx = (double)(mx - mask_x) + ((double)(mw * (nx - dx)) / (double)(dw));
987 mmy = (double)(my - mask_y) + ((double)(mh * (ny - dy)) / (double)(dh));
988 mmw = ((double)mw * (double)(nw)) / (double)(dw);
989 mmh = ((double)mh * (double)(nh)) / (double)(dh);
990
991 evas_gl_common_context_masked_image_push(gc, im->tex, mask->tex,
992 sx, sy, sw, sh,
993 dx, dy, dw, dh,
994 mmx, mmy, mmw, mmh,
995 r, g, b, a,
996 smooth, im->tex_only);
997 }
998 else if (yuv)
975 evas_gl_common_context_yuv_push(gc, 999 evas_gl_common_context_yuv_push(gc,
976 im->tex, 1000 im->tex,
977 sx, sy, sw, sh, 1001 sx, sy, sw, sh,
@@ -1014,7 +1038,27 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
1014 ssw = ((double)sw * (double)(nw)) / (double)(dw); 1038 ssw = ((double)sw * (double)(nw)) / (double)(dw);
1015 ssh = ((double)sh * (double)(nh)) / (double)(dh); 1039 ssh = ((double)sh * (double)(nh)) / (double)(dh);
1016 1040
1017 if (yuv) 1041 /* Apply mask on image */
1042 if (mask)
1043 {
1044 // FIXME/TODO: support for yuv, yuy2, nv12, rgb_a with masks
1045 mx = mask_x; my = mask_y; mw = mask->w; mh = mask->h;
1046 RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch);
1047 RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh);
1048
1049 mmx = (double)(mx - mask_x) + ((double)(mw * (nx - dx)) / (double)(dw));
1050 mmy = (double)(my - mask_y) + ((double)(mh * (ny - dy)) / (double)(dh));
1051 mmw = ((double)mw * (double)(nw)) / (double)(dw);
1052 mmh = ((double)mh * (double)(nh)) / (double)(dh);
1053
1054 evas_gl_common_context_masked_image_push(gc, im->tex, mask->tex,
1055 ssx, ssy, ssw, ssh,
1056 nx, ny, nw, nh,
1057 mmx, mmy, mmw, mmh,
1058 r, g, b, a,
1059 smooth, im->tex_only);
1060 }
1061 else if (yuv)
1018 evas_gl_common_context_yuv_push(gc, 1062 evas_gl_common_context_yuv_push(gc,
1019 im->tex, 1063 im->tex,
1020 ssx, ssy, ssw, ssh, 1064 ssx, ssy, ssw, ssh,
@@ -1063,6 +1107,8 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
1063 Eina_Bool yuy2 = EINA_FALSE; 1107 Eina_Bool yuy2 = EINA_FALSE;
1064 Eina_Bool nv12 = EINA_FALSE; 1108 Eina_Bool nv12 = EINA_FALSE;
1065 Eina_Bool rgb_a_pair = EINA_FALSE; 1109 Eina_Bool rgb_a_pair = EINA_FALSE;
1110 Evas_GL_Image *mask;
1111 int mask_x, mask_y;
1066 1112
1067 if (sw < 1) sw = 1; 1113 if (sw < 1) sw = 1;
1068 if (sh < 1) sh = 1; 1114 if (sh < 1) sh = 1;
@@ -1079,6 +1125,22 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
1079 r = g = b = a = 255; 1125 r = g = b = a = 255;
1080 } 1126 }
1081 1127
1128 // Prepare mask image, if there is one
1129 mask = dc->clip.mask;
1130 mask_x = dc->clip.mask_x;
1131 mask_y = dc->clip.mask_y;
1132 if (mask)
1133 {
1134 evas_gl_common_image_update(gc, im);
1135 if (!mask->tex)
1136 {
1137 ERR("Failed to apply mask image");
1138 mask = NULL;
1139 mask_x = 0;
1140 mask_y = 0;
1141 }
1142 }
1143
1082 evas_gl_common_image_update(gc, im); 1144 evas_gl_common_image_update(gc, im);
1083 if (!im->tex) 1145 if (!im->tex)
1084 { 1146 {
@@ -1112,14 +1174,28 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
1112 ((gc->shared->info.tune.cutout.max > 0) && 1174 ((gc->shared->info.tune.cutout.max > 0) &&
1113 (gc->dc->cutout.active > gc->shared->info.tune.cutout.max))) 1175 (gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
1114 { 1176 {
1115 if (gc->dc->clip.use) 1177 if (mask)
1178 {
1179 _evas_gl_common_image_push(gc, im,
1180 dx, dy, dw, dh,
1181 sx, sy, sw, sh,
1182 gc->dc->clip.x, gc->dc->clip.y,
1183 gc->dc->clip.w, gc->dc->clip.h,
1184 r, g, b, a,
1185 mask, mask_x, mask_y,
1186 smooth,
1187 yuv, yuy2, nv12, rgb_a_pair);
1188 }
1189 else if (gc->dc->clip.use)
1116 { 1190 {
1117 _evas_gl_common_image_push(gc, im, 1191 _evas_gl_common_image_push(gc, im,
1118 dx, dy, dw, dh, 1192 dx, dy, dw, dh,
1119 sx, sy, sw, sh, 1193 sx, sy, sw, sh,
1120 gc->dc->clip.x, gc->dc->clip.y, 1194 gc->dc->clip.x, gc->dc->clip.y,
1121 gc->dc->clip.w, gc->dc->clip.h, 1195 gc->dc->clip.w, gc->dc->clip.h,
1122 r, g, b, a, smooth, 1196 r, g, b, a,
1197 mask, mask_x, mask_y,
1198 smooth,
1123 yuv, yuy2, nv12, rgb_a_pair); 1199 yuv, yuy2, nv12, rgb_a_pair);
1124 } 1200 }
1125 else 1201 else
@@ -1128,7 +1204,9 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
1128 dx, dy, dw, dh, 1204 dx, dy, dw, dh,
1129 sx, sy, sw, sh, 1205 sx, sy, sw, sh,
1130 dx, dy, dw, dh, 1206 dx, dy, dw, dh,
1131 r, g, b, a, smooth, 1207 r, g, b, a,
1208 mask, mask_x, mask_y,
1209 smooth,
1132 yuv, yuy2, nv12, rgb_a_pair); 1210 yuv, yuy2, nv12, rgb_a_pair);
1133 } 1211 }
1134 return; 1212 return;
@@ -1153,7 +1231,9 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
1153 dx, dy, dw, dh, 1231 dx, dy, dw, dh,
1154 sx, sy, sw, sh, 1232 sx, sy, sw, sh,
1155 rct->x, rct->y, rct->w, rct->h, 1233 rct->x, rct->y, rct->w, rct->h,
1156 r, g, b, a, smooth, 1234 r, g, b, a,
1235 mask, mask_x, mask_y,
1236 smooth,
1157 yuv, yuy2, nv12, rgb_a_pair); 1237 yuv, yuy2, nv12, rgb_a_pair);
1158 } 1238 }
1159 evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); 1239 evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
index d2eea835b8..74af14d6d9 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
@@ -44,5 +44,7 @@ typedef enum {
44 SHADER_YUV, 44 SHADER_YUV,
45 SHADER_YUY2_NOMUL, 45 SHADER_YUY2_NOMUL,
46 SHADER_YUY2, 46 SHADER_YUY2,
47 SHADER_IMG_MASK,
48 SHADER_IMG_MASK_NOMUL,
47 SHADER_LAST 49 SHADER_LAST
48} Evas_GL_Shader; 50} Evas_GL_Shader;
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 17c1359166..8ee9ea920f 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
@@ -2181,6 +2181,104 @@ Evas_GL_Program_Source shader_yuy2_vert_src =
2181 NULL, 0 2181 NULL, 0
2182}; 2182};
2183 2183
2184/* Source: modules/evas/engines/gl_common/shader/img_mask_frag.shd */
2185static const char img_mask_frag_glsl[] =
2186 "#ifdef GL_ES\n"
2187 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2188 "precision highp float;\n"
2189 "#else\n"
2190 "precision mediump float;\n"
2191 "#endif\n"
2192 "#endif\n"
2193 "uniform sampler2D tex;\n"
2194 "uniform sampler2D texa;\n"
2195 "varying vec4 col;\n"
2196 "varying vec2 coord_c;\n"
2197 "varying vec2 coord_a;\n"
2198 "void main()\n"
2199 "{\n"
2200 " gl_FragColor.rgb = col.rgb * texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;\n"
2201 " gl_FragColor.a = col.a * texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;\n"
2202 "}\n";
2203Evas_GL_Program_Source shader_img_mask_frag_src =
2204{
2205 img_mask_frag_glsl,
2206 NULL, 0
2207};
2208
2209/* Source: modules/evas/engines/gl_common/shader/img_mask_vert.shd */
2210static const char img_mask_vert_glsl[] =
2211 "#ifdef GL_ES\n"
2212 "precision highp float;\n"
2213 "#endif\n"
2214 "attribute vec4 vertex;\n"
2215 "attribute vec4 color;\n"
2216 "attribute vec2 tex_coord;\n"
2217 "attribute vec2 tex_coorda;\n"
2218 "uniform mat4 mvp;\n"
2219 "varying vec4 col;\n"
2220 "varying vec2 coord_c;\n"
2221 "varying vec2 coord_a;\n"
2222 "void main()\n"
2223 "{\n"
2224 " gl_Position = mvp * vertex;\n"
2225 " col = color;\n"
2226 " coord_c = tex_coord;\n"
2227 " coord_a = tex_coorda;\n"
2228 "}\n";
2229Evas_GL_Program_Source shader_img_mask_vert_src =
2230{
2231 img_mask_vert_glsl,
2232 NULL, 0
2233};
2234
2235/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd */
2236static const char img_mask_nomul_frag_glsl[] =
2237 "#ifdef GL_ES\n"
2238 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2239 "precision highp float;\n"
2240 "#else\n"
2241 "precision mediump float;\n"
2242 "#endif\n"
2243 "#endif\n"
2244 "uniform sampler2D tex;\n"
2245 "uniform sampler2D texa;\n"
2246 "varying vec2 coord_c;\n"
2247 "varying vec2 coord_a;\n"
2248 "void main()\n"
2249 "{\n"
2250 " gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;\n"
2251 " gl_FragColor.a = texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;\n"
2252 "}\n";
2253Evas_GL_Program_Source shader_img_mask_nomul_frag_src =
2254{
2255 img_mask_nomul_frag_glsl,
2256 NULL, 0
2257};
2258
2259/* Source: modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd */
2260static const char img_mask_nomul_vert_glsl[] =
2261 "#ifdef GL_ES\n"
2262 "precision highp float;\n"
2263 "#endif\n"
2264 "attribute vec4 vertex;\n"
2265 "attribute vec2 tex_coord;\n"
2266 "attribute vec2 tex_coorda;\n"
2267 "uniform mat4 mvp;\n"
2268 "varying vec2 coord_c;\n"
2269 "varying vec2 coord_a;\n"
2270 "void main()\n"
2271 "{\n"
2272 " gl_Position = mvp * vertex;\n"
2273 " coord_c = tex_coord;\n"
2274 " coord_a = tex_coorda;\n"
2275 "}\n";
2276Evas_GL_Program_Source shader_img_mask_nomul_vert_src =
2277{
2278 img_mask_nomul_vert_glsl,
2279 NULL, 0
2280};
2281
2184static const struct { 2282static const struct {
2185 Evas_GL_Shader id; 2283 Evas_GL_Shader id;
2186 Evas_GL_Program_Source *vert; 2284 Evas_GL_Program_Source *vert;
@@ -2229,5 +2327,7 @@ static const struct {
2229 { SHADER_YUV, &(shader_yuv_vert_src), &(shader_yuv_frag_src), "yuv" }, 2327 { SHADER_YUV, &(shader_yuv_vert_src), &(shader_yuv_frag_src), "yuv" },
2230 { SHADER_YUY2_NOMUL, &(shader_yuy2_nomul_vert_src), &(shader_yuy2_nomul_frag_src), "yuy2_nomul" }, 2328 { SHADER_YUY2_NOMUL, &(shader_yuy2_nomul_vert_src), &(shader_yuy2_nomul_frag_src), "yuy2_nomul" },
2231 { SHADER_YUY2, &(shader_yuy2_vert_src), &(shader_yuy2_frag_src), "yuy2" }, 2329 { SHADER_YUY2, &(shader_yuy2_vert_src), &(shader_yuy2_frag_src), "yuy2" },
2330 { SHADER_IMG_MASK, &(shader_img_mask_vert_src), &(shader_img_mask_frag_src), "img_mask" },
2331 { SHADER_IMG_MASK_NOMUL, &(shader_img_mask_nomul_vert_src), &(shader_img_mask_nomul_frag_src), "img_mask_nomul" },
2232}; 2332};
2233 2333
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
new file mode 100644
index 0000000000..2d1612a38e
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/img_mask_frag.shd
@@ -0,0 +1,18 @@
1#ifdef GL_ES
2#ifdef GL_FRAGMENT_PRECISION_HIGH
3precision highp float;
4#else
5precision mediump float;
6#endif
7#endif
8uniform sampler2D tex;
9uniform sampler2D texa;
10varying vec4 col;
11varying vec2 coord_c;
12varying vec2 coord_a;
13void main()
14{
15 gl_FragColor.rgb = col.rgb * texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;
16 gl_FragColor.a = col.a * texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;
17}
18
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
new file mode 100644
index 0000000000..e5336f4246
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_frag.shd
@@ -0,0 +1,17 @@
1#ifdef GL_ES
2#ifdef GL_FRAGMENT_PRECISION_HIGH
3precision highp float;
4#else
5precision mediump float;
6#endif
7#endif
8uniform sampler2D tex;
9uniform sampler2D texa;
10varying vec2 coord_c;
11varying vec2 coord_a;
12void main()
13{
14 gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * texture2D(texa, coord_a).g;
15 gl_FragColor.a = texture2D(tex, coord_c.xy).a * texture2D(texa, coord_a).g;
16}
17
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
new file mode 100644
index 0000000000..a1debf63f2
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/img_mask_nomul_vert.shd
@@ -0,0 +1,16 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec2 tex_coord;
6attribute vec2 tex_coorda;
7uniform mat4 mvp;
8varying vec2 coord_c;
9varying vec2 coord_a;
10void main()
11{
12 gl_Position = mvp * vertex;
13 coord_c = tex_coord;
14 coord_a = tex_coorda;
15}
16
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
new file mode 100644
index 0000000000..3cd1740771
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/img_mask_vert.shd
@@ -0,0 +1,19 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec4 color;
6attribute vec2 tex_coord;
7attribute vec2 tex_coorda;
8uniform mat4 mvp;
9varying vec4 col;
10varying vec2 coord_c;
11varying vec2 coord_a;
12void main()
13{
14 gl_Position = mvp * vertex;
15 col = color;
16 coord_c = tex_coord;
17 coord_a = tex_coorda;
18}
19