diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 1d8344f701..2b7eab4c74 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -701,6 +701,14 @@ modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd \ modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd \ modules/evas/engines/gl_common/shader/rect_mask_frag.shd \ modules/evas/engines/gl_common/shader/rect_mask_vert.shd \ +modules/evas/engines/gl_common/shader/map_mask_frag.shd \ +modules/evas/engines/gl_common/shader/map_mask_vert.shd \ +modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd \ +modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd \ +modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd \ +modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd \ +modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd \ +modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd \ $(NULL) EXTRA_DIST += \ 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 456d42d86b..b5a72c9568 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -446,6 +446,7 @@ struct _Evas_Engine_GL_Context Eina_Bool active : 1; } clip; struct { + Evas_GL_Shader id; Evas_GL_Image *surface; GLuint cur_prog; GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm; @@ -735,7 +736,7 @@ void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *g int npoints, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, - Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, + Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, int mdx, int mdy, int mdw, int mdh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only, 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 7141920d64..381872f3cc 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -880,6 +880,11 @@ evas_gl_common_context_new(void) SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA_NOMUL, tex); SHADER_TEXTURE_ADD(shared, IMG_MASK_BGRA_NOMUL, texm); + SHADER_TEXTURE_ADD(shared, MAP_MASK_BGRA, tex); + SHADER_TEXTURE_ADD(shared, MAP_MASK_BGRA, texm); + SHADER_TEXTURE_ADD(shared, MAP_MASK_BGRA_NOMUL, tex); + SHADER_TEXTURE_ADD(shared, MAP_MASK_BGRA_NOMUL, texm); + SHADER_TEXTURE_ADD(shared, FONT_MASK, tex); SHADER_TEXTURE_ADD(shared, FONT_MASK, texm); @@ -2481,6 +2486,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, RGBA_Map_Point *p, int clip, int cx, int cy, int cw, int ch, Evas_GL_Texture *mtex, int mx, int my, int mw, int mh, + int mdx, int mdy, int mdw, int mdh, int r, int g, int b, int a, Eina_Bool smooth, Eina_Bool tex_only, Evas_Colorspace cspace) @@ -2490,11 +2496,12 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, GLfloat tx[4], ty[4], t2x[4], t2y[4]; Eina_Bool blend = EINA_FALSE; DATA32 cmul; - GLuint prog = gc->shared->shader[SHADER_IMG].prog; + Evas_GL_Shader shader = SHADER_IMG; Eina_Bool utexture = EINA_FALSE; Eina_Bool uvtexture = EINA_FALSE; int pn = 0, i; int flat = 0; + GLuint prog; if (!(gc->dc->render_op == EVAS_RENDER_COPY) && ((a < 255) || (tex->alpha) || (!!mtex))) blend = EINA_TRUE; @@ -2517,59 +2524,65 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, { case EVAS_COLORSPACE_YCBCR422P601_PL: case EVAS_COLORSPACE_YCBCR422P709_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_YUV_NOMUL, SHADER_YUV, - SHADER_YUV_MASK, SHADER_YUV_MASK)].prog; - utexture = EINA_TRUE; - break; + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_YUV_NOMUL, SHADER_YUV, + SHADER_YUV_MASK, SHADER_YUV_MASK); + utexture = EINA_TRUE; + break; case EVAS_COLORSPACE_YCBCR422601_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_YUY2_NOMUL, SHADER_YUY2, - SHADER_YUY2_MASK, SHADER_YUY2_MASK)].prog; - uvtexture = EINA_TRUE; - break; + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_YUY2_NOMUL, SHADER_YUY2, + SHADER_YUY2_MASK, SHADER_YUY2_MASK); + uvtexture = EINA_TRUE; + break; case EVAS_COLORSPACE_YCBCR420NV12601_PL: case EVAS_COLORSPACE_YCBCR420TM12601_PL: - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_NV12_NOMUL, SHADER_NV12, - SHADER_NV12_MASK, SHADER_NV12_MASK)].prog; - uvtexture = EINA_TRUE; - break; - - // FIXME: Add RGB+A support + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_NV12_NOMUL, SHADER_NV12, + SHADER_NV12_MASK, SHADER_NV12_MASK); + uvtexture = EINA_TRUE; + break; default: - if (tex_only) - { - if (tex->pt->dyn.img) - { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, - SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; - } - else - { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_TEX_NOMUL, SHADER_TEX, - SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; - } - } - else - { - if (tex->gc->shared->info.bgra) - { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, - SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA)].prog; - } + if (tex_only) + { + if (tex->pt->dyn.img) + { + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_MAP_MASK_BGRA_NOMUL, SHADER_MAP_MASK_BGRA); + } else { - prog = gc->shared->shader[evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, - SHADER_IMG_NOMUL, SHADER_IMG, - SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK)].prog; + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_TEX_NOMUL, SHADER_TEX, + SHADER_MAP_MASK_BGRA_NOMUL, SHADER_MAP_MASK_BGRA); + } + } + else + { + if (tex->gc->shared->info.bgra) + { + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_BGRA_NOMUL, SHADER_IMG_BGRA, + SHADER_MAP_MASK_BGRA_NOMUL, SHADER_MAP_MASK_BGRA); + } + else + { + shader = evas_gl_common_shader_choice(npoints, p, r, g, b, a, !!mtex, + SHADER_IMG_NOMUL, SHADER_IMG, + SHADER_MAP_MASK_NOMUL, SHADER_MAP_MASK); } } } + prog = gc->shared->shader[shader].prog; + + /* FIXME: Add RGB+A support, as well as YUV map masking + * Print error messages for easier debugging... */ + if (cspace == EVAS_COLORSPACE_ETC1_ALPHA) + ERR("Proper support for ETC1+Alpha maps is not implemented!"); + else if (mtex && (utexture || uvtexture)) + ERR("Support for YUV or ETC1+Alpha map masking is not implemented!"); x = w = (p[0].x >> FP); y = h = (p[0].y >> FP); @@ -2641,6 +2654,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, smooth, clip, cx, cy, cw, ch); gc->pipe[pn].region.type = RTYPE_MAP; + gc->pipe[pn].shader.id = shader; gc->pipe[pn].shader.cur_tex = tex->pt->texture; if (utexture) { @@ -2671,7 +2685,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0; gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0; gc->pipe[pn].array.use_texm = !!mtex; - gc->pipe[pn].array.use_texsam = 0; + gc->pipe[pn].array.use_texsam = gc->pipe[pn].array.use_texm; pipe_region_expand(gc, pn, x, y, w, h); PIPE_GROW(gc, pn, 6); @@ -2731,7 +2745,39 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc, A_VAL(&cl)); } - PUSH_MASK(pn, mtex, mx, my, mw, mh); + if (mtex) + { + GLfloat glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f; + + // Note: I couldn't write any test case where it was necessary + // to know the mask position in its texture. Thus these unused vars. + (void) mx; (void) my; (void) mw; (void) mh; + + if (gc->w) glmdx = (GLfloat) mdx / (GLfloat) gc->w; + if (gc->h) glmdy = (GLfloat) mdy / (GLfloat) gc->h; + if (mdw) glmdw = (GLfloat) gc->w / (GLfloat) mdw; + if (mdh) glmdh = (GLfloat) gc->h / (GLfloat) mdh ; + + // We seriously need uniforms here. Abusing tex_coordm for storage. + // Passing mask x,y (on canvas) to the fragment shader + PUSH_TEXM(pn, glmdx, glmdy); + PUSH_TEXM(pn, glmdx, glmdy); + PUSH_TEXM(pn, glmdx, glmdy); + PUSH_TEXM(pn, glmdx, glmdy); + PUSH_TEXM(pn, glmdx, glmdy); + PUSH_TEXM(pn, glmdx, glmdy); + + // Abusing tex_sample to pass mask 1/w, 1/h as well + PUSH_TEXSAM(pn, glmdw, glmdh); + PUSH_TEXSAM(pn, glmdw, glmdh); + PUSH_TEXSAM(pn, glmdw, glmdh); + PUSH_TEXSAM(pn, glmdw, glmdh); + PUSH_TEXSAM(pn, glmdw, glmdh); + PUSH_TEXSAM(pn, glmdw, glmdh); + + //DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh, + // glmdx, glmdy, glmdw, glmdh); + } if (!flat) { 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 6478ab0604..0bd990a641 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -920,6 +920,8 @@ void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED) { + int mmx = 0, mmy = 0, mmw = 0, mmh = 0, mdx = 0, mdy = 0, mdw = 0, mdh = 0; + Evas_GL_Texture *mtex = NULL; RGBA_Draw_Context *dc; int r, g, b, a; int c, cx, cy, cw, ch; @@ -946,9 +948,27 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, if (!im->tex) return; im->tex->im = im; + if (dc->clip.mask) + { + Evas_GL_Image *mask = dc->clip.mask; + double mx, my, mw, mh; + + mdx = mx = dc->clip.mask_x; + mdy = my = dc->clip.mask_y; + mdw = mw = mask->w; + mdh = mh = mask->h; + if (c) RECTS_CLIP_TO_RECT(mx, my, mw, mh, cx, cy, cw, ch); + //RECTS_CLIP_TO_RECT(mx, my, mw, mh, dx, dy, dw, dh); + mmx = mx - dc->clip.mask_x; + mmy = my - dc->clip.mask_y; + mmw = mw; + mmh = mh; + mtex = mask->tex; + } + evas_gl_common_context_image_map_push(gc, im->tex, npoints, p, c, cx, cy, cw, ch, - NULL, 0, 0, 0, 0, + mtex, mmx, mmy, mmw, mmh, mdx, mdy, mdw, mdh, r, g, b, a, smooth, im->tex_only, im->cs.space); } 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 6f0fb93d1d..6a543bb1c0 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 @@ -54,5 +54,9 @@ typedef enum { SHADER_YUY2_MASK, SHADER_RGB_A_PAIR_MASK, SHADER_RECT_MASK, + SHADER_MAP_MASK, + SHADER_MAP_MASK_NOMUL, + SHADER_MAP_MASK_BGRA, + SHADER_MAP_MASK_BGRA_NOMUL, SHADER_LAST } 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 555bfa8335..cffc70b636 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 @@ -2701,6 +2701,206 @@ Evas_GL_Program_Source shader_rect_mask_vert_src = NULL, 0 }; +/* Source: modules/evas/engines/gl_common/shader/map_mask_frag.shd */ +static const char const map_mask_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex, texm;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, col, mask_Absolute;\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" + " // FIXME: We're abusing varying where we should have uniforms\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_frag_src = +{ + map_mask_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_vert.shd */ +static const char const map_mask_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex, color;\n" + "attribute vec2 tex_coord, tex_coordm, tex_sample;\n" + "uniform mat4 mvp;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, col, mask_Absolute;\n" + "void main()\n" + "{\n" + " gl_Position = mvp * vertex;\n" + " tex_c = tex_coord;\n" + " col = color;\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_vert_src = +{ + map_mask_vert_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd */ +static const char const map_mask_nomul_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex, texm;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, mask_Absolute;\n" + "void main()\n" + "{\n" + " // FIXME: Use mask coordinates within its texture\n" + " // FIXME: We're abusing varying where we should have uniforms\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_nomul_frag_src = +{ + map_mask_nomul_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd */ +static const char const map_mask_nomul_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex;\n" + "attribute vec2 tex_coord, tex_coordm, tex_sample;\n" + "uniform mat4 mvp;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, mask_Absolute;\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_nomul_vert_src = +{ + map_mask_nomul_vert_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd */ +static const char const map_mask_bgra_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex, texm;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, col, mask_Absolute;\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" + " // FIXME: We're abusing varying where we should have uniforms\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_bgra_frag_src = +{ + map_mask_bgra_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd */ +static const char const map_mask_bgra_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex, color;\n" + "attribute vec2 tex_coord, tex_coordm, tex_sample;\n" + "uniform mat4 mvp;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, col, mask_Absolute;\n" + "void main()\n" + "{\n" + " gl_Position = mvp * vertex;\n" + " tex_c = tex_coord;\n" + " col = color;\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_bgra_vert_src = +{ + map_mask_bgra_vert_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd */ +static const char const map_mask_bgra_nomul_frag_glsl[] = + "#ifdef GL_ES\n" + "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" + "precision highp float;\n" + "#else\n" + "precision mediump float;\n" + "#endif\n" + "#endif\n" + "uniform sampler2D tex, texm;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, mask_Absolute;\n" + "void main()\n" + "{\n" + " // FIXME: Use mask coordinates within its texture\n" + " // FIXME: We're abusing varying where we should have uniforms\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_bgra_nomul_frag_src = +{ + map_mask_bgra_nomul_frag_glsl, + NULL, 0 +}; + +/* Source: modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd */ +static const char const map_mask_bgra_nomul_vert_glsl[] = + "#ifdef GL_ES\n" + "precision highp float;\n" + "#endif\n" + "attribute vec4 vertex;\n" + "attribute vec2 tex_coord, tex_coordm, tex_sample;\n" + "uniform mat4 mvp;\n" + "varying vec2 tex_c;\n" + "varying vec4 mask_Position, mask_Absolute;\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" + "}\n"; +Evas_GL_Program_Source shader_map_mask_bgra_nomul_vert_src = +{ + map_mask_bgra_nomul_vert_glsl, + NULL, 0 +}; + static const struct { Evas_GL_Shader id; Evas_GL_Program_Source *vert; @@ -2759,5 +2959,9 @@ static const struct { { SHADER_YUY2_MASK, &(shader_yuy2_mask_vert_src), &(shader_yuy2_mask_frag_src), "yuy2_mask" }, { SHADER_RGB_A_PAIR_MASK, &(shader_rgb_a_pair_mask_vert_src), &(shader_rgb_a_pair_mask_frag_src), "rgb_a_pair_mask" }, { SHADER_RECT_MASK, &(shader_rect_mask_vert_src), &(shader_rect_mask_frag_src), "rect_mask" }, + { SHADER_MAP_MASK, &(shader_map_mask_vert_src), &(shader_map_mask_frag_src), "map_mask" }, + { SHADER_MAP_MASK_NOMUL, &(shader_map_mask_nomul_vert_src), &(shader_map_mask_nomul_frag_src), "map_mask_nomul" }, + { SHADER_MAP_MASK_BGRA, &(shader_map_mask_bgra_vert_src), &(shader_map_mask_bgra_frag_src), "map_mask_bgra" }, + { SHADER_MAP_MASK_BGRA_NOMUL, &(shader_map_mask_bgra_nomul_vert_src), &(shader_map_mask_bgra_nomul_frag_src), "map_mask_bgra_nomul" }, }; 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 new file mode 100644 index 0000000000..d6922f04ba --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_frag.shd @@ -0,0 +1,18 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex, texm; +varying vec2 tex_c; +varying vec4 mask_Position, col, mask_Absolute; +void main() +{ + // FIXME: Use mask coordinates within its texture + // FIXME: Fix Mach band effect using proper 4-point color interpolation + // FIXME: We're abusing varying where we should have uniforms + vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; + gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).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 new file mode 100644 index 0000000000..b790efa1ce --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_frag.shd @@ -0,0 +1,17 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex, texm; +varying vec2 tex_c; +varying vec4 mask_Position, mask_Absolute; +void main() +{ + // FIXME: Use mask coordinates within its texture + // FIXME: We're abusing varying where we should have uniforms + vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; + gl_FragColor = texture2D(tex, tex_c.xy) * texture2D(texm, mpos).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 new file mode 100644 index 0000000000..8457372d5b --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_nomul_vert.shd @@ -0,0 +1,17 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex; +attribute vec2 tex_coord, tex_coordm, tex_sample; +uniform mat4 mvp; +varying vec2 tex_c; +varying vec4 mask_Position, mask_Absolute; +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 +} 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 new file mode 100644 index 0000000000..a7a537d26b --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_bgra_vert.shd @@ -0,0 +1,18 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex, color; +attribute vec2 tex_coord, tex_coordm, tex_sample; +uniform mat4 mvp; +varying vec2 tex_c; +varying vec4 mask_Position, col, mask_Absolute; +void main() +{ + gl_Position = mvp * vertex; + tex_c = tex_coord; + col = color; + + // 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 +} 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 new file mode 100644 index 0000000000..189807bffd --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_frag.shd @@ -0,0 +1,18 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex, texm; +varying vec2 tex_c; +varying vec4 mask_Position, col, mask_Absolute; +void main() +{ + // FIXME: Use mask coordinates within its texture + // FIXME: Fix Mach band effect using proper 4-point color interpolation + // FIXME: We're abusing varying where we should have uniforms + 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; +} 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 new file mode 100644 index 0000000000..2340f50c29 --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_frag.shd @@ -0,0 +1,17 @@ +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +uniform sampler2D tex, texm; +varying vec2 tex_c; +varying vec4 mask_Position, mask_Absolute; +void main() +{ + // FIXME: Use mask coordinates within its texture + // FIXME: We're abusing varying where we should have uniforms + vec2 mpos = vec2(mask_Position.xy - mask_Absolute.xy) * mask_Absolute.zw; + gl_FragColor = texture2D(tex, tex_c.xy).bgra * texture2D(texm, mpos).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 new file mode 100644 index 0000000000..8457372d5b --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_nomul_vert.shd @@ -0,0 +1,17 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex; +attribute vec2 tex_coord, tex_coordm, tex_sample; +uniform mat4 mvp; +varying vec2 tex_c; +varying vec4 mask_Position, mask_Absolute; +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 +} 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 new file mode 100644 index 0000000000..a7a537d26b --- /dev/null +++ b/src/modules/evas/engines/gl_common/shader/map_mask_vert.shd @@ -0,0 +1,18 @@ +#ifdef GL_ES +precision highp float; +#endif +attribute vec4 vertex, color; +attribute vec2 tex_coord, tex_coordm, tex_sample; +uniform mat4 mvp; +varying vec2 tex_c; +varying vec4 mask_Position, col, mask_Absolute; +void main() +{ + gl_Position = mvp * vertex; + tex_c = tex_coord; + col = color; + + // 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 +}