Evas masking: Add support for YUV, YUY2, NV12 masking in GL
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 1 Dec 2014 10:52:13 +0000 (19:52 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 7 Jan 2015 06:06:03 +0000 (15:06 +0900)
RGB+A masking needs to be implemented, because there's a
clash (only one texture name "texa" is available).

12 files changed:
src/Makefile_Evas.am
src/modules/evas/engines/gl_common/evas_gl_context.c
src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
src/modules/evas/engines/gl_common/shader/nv12_mask_frag.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/yuv_mask_frag.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/yuy2_mask_frag.shd [new file with mode: 0644]
src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd [new file with mode: 0644]

index 7b175f1..78515ad 100644 (file)
@@ -691,6 +691,14 @@ modules/evas/engines/gl_common/shader/img_mask_bgra_frag.shd \
 modules/evas/engines/gl_common/shader/img_mask_bgra_vert.shd \
 modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_frag.shd \
 modules/evas/engines/gl_common/shader/img_mask_bgra_nomul_vert.shd \
+modules/evas/engines/gl_common/shader/yuv_mask_frag.shd \
+modules/evas/engines/gl_common/shader/yuv_mask_vert.shd \
+modules/evas/engines/gl_common/shader/nv12_mask_frag.shd \
+modules/evas/engines/gl_common/shader/nv12_mask_vert.shd \
+modules/evas/engines/gl_common/shader/yuy2_mask_frag.shd \
+modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd \
+modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd \
+modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd \
 $(NULL)
 
 EXTRA_DIST += \
index 00e4489..170581f 100644 (file)
@@ -2068,7 +2068,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
                                 int r, int g, int b, int a,
                                 Eina_Bool smooth)
 {
-   int pnum, nv, nc, nu, nu2, nu3, i;
+   int pnum, nv, nc, nu, nu2, nu3, na, i;
    GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
    Eina_Bool blend = 0;
    GLuint prog;
@@ -2076,10 +2076,9 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
 
    if (a < 255) blend = 1;
 
-#warning YUV+mask
    prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex,
                                                           SHADER_YUV_NOMUL, SHADER_YUV,
-                                                          SHADER_YUV_NOMUL, SHADER_YUV)].prog;
+                                                          SHADER_YUV_MASK, SHADER_YUV_MASK)].prog;
 
    pn = _evas_gl_common_context_push(RTYPE_YUV,
                                      gc, tex,
@@ -2093,6 +2092,7 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].shader.cur_tex = tex->pt->texture;
    gc->pipe[pn].shader.cur_texu = tex->ptu->texture;
    gc->pipe[pn].shader.cur_texv = tex->ptv->texture;
+   gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0;
    gc->pipe[pn].shader.cur_prog = prog;
    gc->pipe[pn].shader.smooth = smooth;
    gc->pipe[pn].shader.blend = blend;
@@ -2108,13 +2108,13 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].array.use_texuv = 1;
    gc->pipe[pn].array.use_texuv2 = 1;
    gc->pipe[pn].array.use_texuv3 = 1;
-   gc->pipe[pn].array.use_texa = 0;
+   gc->pipe[pn].array.use_texa = !!mtex;
    gc->pipe[pn].array.use_texsam = 0;
 
    pipe_region_expand(gc, pn, x, y, w, h);
 
    pnum = gc->pipe[pn].array.num;
-   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2;
+   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2;
    nu2 = pnum * 2; nu3 = pnum * 2;
    gc->pipe[pn].array.num += 6;
    array_alloc(gc, pn);
@@ -2161,6 +2161,22 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
    PUSH_TEXUV3(pn, t2x2, t2y2);
    PUSH_TEXUV3(pn, t2x1, t2y2);
 
+   if (mtex)
+     {
+        t2x1 = (mtex->x + mx) / (double)mtex->pt->w;
+        t2y1 = (mtex->y + my) / (double)mtex->pt->h;
+        t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w;
+        t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h;
+
+        PUSH_TEXA(pn, t2x1, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x1, t2y2);
+
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y2);
+        PUSH_TEXA(pn, t2x1, t2y2);
+     }
+
    for (i = 0; i < 6; i++)
      {
         PUSH_COLOR(pn, r, g, b, a);
@@ -2176,7 +2192,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
                                  int r, int g, int b, int a,
                                  Eina_Bool smooth)
 {
-   int pnum, nv, nc, nu, nu2, i;
+   int pnum, nv, nc, nu, nu2, na, i;
    GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
    Eina_Bool blend = 0;
    GLuint prog;
@@ -2184,10 +2200,9 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
 
    if (a < 255) blend = 1;
 
-#warning mask
    prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex,
                                                           SHADER_YUY2_NOMUL, SHADER_YUY2,
-                                                          SHADER_YUY2_NOMUL, SHADER_YUY2)].prog;
+                                                          SHADER_YUY2_MASK, SHADER_YUY2_MASK)].prog;
 
    pn = _evas_gl_common_context_push(RTYPE_YUY2,
                                      gc, tex,
@@ -2200,6 +2215,7 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].region.type = RTYPE_YUY2;
    gc->pipe[pn].shader.cur_tex = tex->pt->texture;
    gc->pipe[pn].shader.cur_texu = tex->ptuv->texture;
+   gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0;
    gc->pipe[pn].shader.cur_prog = prog;
    gc->pipe[pn].shader.smooth = smooth;
    gc->pipe[pn].shader.blend = blend;
@@ -2215,13 +2231,13 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].array.use_texuv = 1;
    gc->pipe[pn].array.use_texuv2 = 1;
    gc->pipe[pn].array.use_texuv3 = 0;
-   gc->pipe[pn].array.use_texa = 0;
+   gc->pipe[pn].array.use_texa = !!mtex;
    gc->pipe[pn].array.use_texsam = 0;
 
    pipe_region_expand(gc, pn, x, y, w, h);
 
    pnum = gc->pipe[pn].array.num;
-   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2;
+   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2;
    nu2 = pnum * 2;
    gc->pipe[pn].array.num += 6;
    array_alloc(gc, pn);
@@ -2260,6 +2276,22 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
    PUSH_TEXUV2(pn, t2x2, t2y2);
    PUSH_TEXUV2(pn, t2x1, t2y2);
 
+   if (mtex)
+     {
+        t2x1 = (mtex->x + mx) / (double)mtex->pt->w;
+        t2y1 = (mtex->y + my) / (double)mtex->pt->h;
+        t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w;
+        t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h;
+
+        PUSH_TEXA(pn, t2x1, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x1, t2y2);
+
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y2);
+        PUSH_TEXA(pn, t2x1, t2y2);
+     }
+
    for (i = 0; i < 6; i++)
      {
         PUSH_COLOR(pn, r, g, b, a);
@@ -2275,7 +2307,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
                                  int r, int g, int b, int a,
                                  Eina_Bool smooth)
 {
-   int pnum, nv, nc, nu, nu2, i;
+   int pnum, nv, nc, nu, nu2, na, i;
    GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
    Eina_Bool blend = 0;
    GLuint prog;
@@ -2283,10 +2315,9 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
 
    if (a < 255) blend = 1;
 
-#warning mask
    prog = gc->shared->shader[evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex,
                                                           SHADER_NV12_NOMUL, SHADER_NV12,
-                                                          SHADER_NV12_NOMUL, SHADER_NV12)].prog;
+                                                          SHADER_NV12_MASK, SHADER_NV12_MASK)].prog;
 
    pn = _evas_gl_common_context_push(RTYPE_NV12,
                                      gc, tex,
@@ -2301,6 +2332,7 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].shader.cur_tex_dyn = tex->pt->dyn.img;
    gc->pipe[pn].shader.cur_texu = tex->ptuv->texture;
    gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img;
+   gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0;
    gc->pipe[pn].shader.cur_prog = prog;
    gc->pipe[pn].shader.smooth = smooth;
    gc->pipe[pn].shader.blend = blend;
@@ -2316,13 +2348,13 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].array.use_texuv = 1;
    gc->pipe[pn].array.use_texuv2 = 1;
    gc->pipe[pn].array.use_texuv3 = 0;
-   gc->pipe[pn].array.use_texa = 0;
+   gc->pipe[pn].array.use_texa = !!mtex;
    gc->pipe[pn].array.use_texsam = 0;
 
    pipe_region_expand(gc, pn, x, y, w, h);
 
    pnum = gc->pipe[pn].array.num;
-   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2;
+   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; na = pnum * 2;
    nu2 = pnum * 2;
    gc->pipe[pn].array.num += 6;
    array_alloc(gc, pn);
@@ -2361,6 +2393,22 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
    PUSH_TEXUV2(pn, t2x2, t2y2);
    PUSH_TEXUV2(pn, t2x1, t2y2);
 
+   if (mtex)
+     {
+        t2x1 = (mtex->x + mx) / (double)mtex->pt->w;
+        t2y1 = (mtex->y + my) / (double)mtex->pt->h;
+        t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w;
+        t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h;
+
+        PUSH_TEXA(pn, t2x1, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x1, t2y2);
+
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y2);
+        PUSH_TEXA(pn, t2x1, t2y2);
+     }
+
    for (i = 0; i < 6; i++)
      {
         PUSH_COLOR(pn, r, g, b, a);
@@ -2390,11 +2438,10 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
    GLuint prog;
    int pn;
 
-#warning rgba+a+mask
    prog = gc->shared->shader[evas_gl_common_shader_choice
      (0, NULL, r, g, b, a, !!mtex,
       SHADER_RGB_A_PAIR_NOMUL, SHADER_RGB_A_PAIR,
-      SHADER_RGB_A_PAIR_NOMUL, SHADER_RGB_A_PAIR)].prog;
+      SHADER_RGB_A_PAIR_MASK, SHADER_RGB_A_PAIR_MASK)].prog;
 
    pn = _evas_gl_common_context_push(RTYPE_IMAGE,
                                      gc, tex,
@@ -2407,6 +2454,8 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].region.type = RTYPE_IMAGE;
    gc->pipe[pn].shader.cur_tex = tex->pt->texture;
    gc->pipe[pn].shader.cur_texa = tex->pta->texture;
+#warning FIXME: must add texm instead
+   //gc->pipe[pn].shader.cur_texu = mtex ? mtex->pt->texture : 0;
    gc->pipe[pn].shader.cur_prog = prog;
    gc->pipe[pn].shader.smooth = smooth;
    gc->pipe[pn].shader.blend = EINA_TRUE;
@@ -2468,6 +2517,24 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
    PUSH_TEXA(pn, t2x2, t2y2);
    PUSH_TEXA(pn, t2x1, t2y2);
 
+   /*
+   if (mtex)
+     {
+        t2x1 = (mtex->x + mx) / (double)mtex->pt->w;
+        t2y1 = (mtex->y + my) / (double)mtex->pt->h;
+        t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w;
+        t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h;
+
+        PUSH_TEXM(pn, t2x1, t2y1);
+        PUSH_TEXM(pn, t2x2, t2y1);
+        PUSH_TEXM(pn, t2x1, t2y2);
+
+        PUSH_TEXM(pn, t2x2, t2y1);
+        PUSH_TEXM(pn, t2x2, t2y2);
+        PUSH_TEXM(pn, t2x1, t2y2);
+     }
+   */
+
    for (i = 0; i < 6; i++)
      {
         PUSH_COLOR(pn, r, g, b, a);
@@ -2485,7 +2552,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                                       Eina_Bool smooth, Eina_Bool tex_only,
                                       Evas_Colorspace cspace)
 {
-   int pnum, nv, nc, nu, nu2, nu3, i;
+   int pnum, nv, nc, nu, nu2, nu3, na, i;
    const int points[6] = { 0, 1, 2, 0, 2, 3 };
    int x = 0, y = 0, w = 0, h = 0, px = 0, py = 0;
    GLfloat tx[4], ty[4], t2x[4], t2y[4];
@@ -2520,23 +2587,25 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
       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_NOMUL, SHADER_YUV)].prog;
+                                                                SHADER_YUV_MASK, SHADER_YUV_MASK)].prog;
          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_NOMUL, SHADER_YUY2)].prog;
+                                                                SHADER_YUY2_MASK, SHADER_YUY2_MASK)].prog;
          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_NOMUL, SHADER_NV12)].prog;
+                                                                SHADER_NV12_MASK, SHADER_NV12_MASK)].prog;
          uvtexture = EINA_TRUE;
          break;
 
+      // FIXME: Add RGB+A support
+
       default:
          if (tex_only)
            {
@@ -2653,6 +2722,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
        gc->pipe[pn].shader.cur_texu = tex->ptuv->texture;
        gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img;
      }
+   gc->pipe[pn].shader.cur_texa = mtex ? mtex->pt->texture : 0;
    gc->pipe[pn].shader.cur_prog = prog;
    gc->pipe[pn].shader.smooth = smooth;
    gc->pipe[pn].shader.blend = blend;
@@ -2668,13 +2738,13 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
    gc->pipe[pn].array.use_texuv = 1;
    gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0;
    gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0;
-   gc->pipe[pn].array.use_texa = 0;
+   gc->pipe[pn].array.use_texa = !!mtex;
    gc->pipe[pn].array.use_texsam = 0;
 
    pipe_region_expand(gc, pn, x, y, w, h);
 
    pnum = gc->pipe[pn].array.num;
-   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2;
+   nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2; na = pnum * 2;
    nu2 = pnum * 2; nu3 = pnum * 2;
    gc->pipe[pn].array.num += 6;
    array_alloc(gc, pn);
@@ -2733,6 +2803,25 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
                    B_VAL(&cl),
                    A_VAL(&cl));
      }
+
+   if (mtex)
+     {
+        GLfloat t2x1, t2y1, t2x2, t2y2;
+
+        t2x1 = (mtex->x + mx) / (double)mtex->pt->w;
+        t2y1 = (mtex->y + my) / (double)mtex->pt->h;
+        t2x2 = (mtex->x + mx + mw) / (double)mtex->pt->w;
+        t2y2 = (mtex->y + my + mh) / (double)mtex->pt->h;
+
+        PUSH_TEXA(pn, t2x1, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x1, t2y2);
+
+        PUSH_TEXA(pn, t2x2, t2y1);
+        PUSH_TEXA(pn, t2x2, t2y2);
+        PUSH_TEXA(pn, t2x1, t2y2);
+     }
+
    if (!flat)
      {
         shader_array_flush(gc);
index 29f2e8a..d1227ef 100644 (file)
@@ -49,5 +49,9 @@ typedef enum {
    SHADER_IMG_MASK_NOMUL,
    SHADER_IMG_MASK_BGRA,
    SHADER_IMG_MASK_BGRA_NOMUL,
+   SHADER_YUV_MASK,
+   SHADER_NV12_MASK,
+   SHADER_YUY2_MASK,
+   SHADER_RGB_A_PAIR_MASK,
    SHADER_LAST
 } Evas_GL_Shader;
index 690328a..7f3f536 100644 (file)
@@ -2423,6 +2423,239 @@ Evas_GL_Program_Source shader_img_mask_bgra_nomul_vert_src =
    NULL, 0
 };
 
+/* Source: modules/evas/engines/gl_common/shader/yuv_mask_frag.shd */
+static const char const yuv_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, texu, texv, texa;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_c2, tex_c3, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "   float r, g, b, y, u, v;\n"
+   "   y = texture2D(tex, tex_c.xy).r;\n"
+   "   u = texture2D(texu, tex_c2.xy).r;\n"
+   "   v = texture2D(texv, tex_c3.xy).r;\n"
+   "   y = (y - 0.0625) * 1.164;\n"
+   "   u = u - 0.5;\n"
+   "   v = v - 0.5;\n"
+   "   r = y + (1.402   * v);\n"
+   "   g = y - (0.34414 * u) - (0.71414 * v);\n"
+   "   b = y + (1.772   * u);\n"
+   "   gl_FragColor = vec4(r, g, b, 1.0) * texture2D(texa, tex_a.xy).a * col;\n"
+   "}\n";
+Evas_GL_Program_Source shader_yuv_mask_frag_src =
+{
+   yuv_mask_frag_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/yuv_mask_vert.shd */
+static const char const yuv_mask_vert_glsl[] =
+   "#ifdef GL_ES\n"
+   "precision highp float;\n"
+   "#endif\n"
+   "attribute vec4 vertex;\n"
+   "attribute vec4 color;\n"
+   "attribute vec2 tex_coord, tex_coord2, tex_coord3, tex_coorda;\n"
+   "uniform mat4 mvp;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_c2, tex_c3, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = mvp * vertex;\n"
+   "   col = color;\n"
+   "   tex_c = tex_coord;\n"
+   "   tex_c2 = tex_coord2;\n"
+   "   tex_c3 = tex_coord3;\n"
+   "   tex_a = tex_coorda;\n"
+   "}\n";
+Evas_GL_Program_Source shader_yuv_mask_vert_src =
+{
+   yuv_mask_vert_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/nv12_mask_frag.shd */
+static const char const nv12_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, texuv, texa;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_cuv, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "  float y,u,v,vmu,r,g,b;\n"
+   "  y=texture2D(tex,tex_c).g;\n"
+   "  u=texture2D(texuv,tex_cuv).g;\n"
+   "  v=texture2D(texuv,tex_cuv).a;\n"
+   "  u=u-0.5;\n"
+   "  v=v-0.5;\n"
+   "  vmu=v*0.813+u*0.391;\n"
+   "  u=u*2.018;\n"
+   "  v=v*1.596;\n"
+   "  y=(y-0.062)*1.164;\n"
+   "  r=y+v;\n"
+   "  g=y-vmu;\n"
+   "  b=y+u;\n"
+   "  gl_FragColor = vec4(r,g,b,1.0) * texture2D(texa, tex_a.xy).a * col;\n"
+   "}\n";
+Evas_GL_Program_Source shader_nv12_mask_frag_src =
+{
+   nv12_mask_frag_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/nv12_mask_vert.shd */
+static const char const nv12_mask_vert_glsl[] =
+   "#ifdef GL_ES\n"
+   "precision highp float;\n"
+   "#endif\n"
+   "attribute vec4 vertex;\n"
+   "attribute vec4 color;\n"
+   "attribute vec2 tex_coord, tex_coord2, tex_coorda;\n"
+   "uniform mat4 mvp;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_cuv, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = mvp * vertex;\n"
+   "   col = color;\n"
+   "   tex_c = tex_coord;\n"
+   "   tex_cuv = tex_coord2 * 0.5;\n"
+   "   tex_a = tex_coorda;\n"
+   "}\n";
+Evas_GL_Program_Source shader_nv12_mask_vert_src =
+{
+   nv12_mask_vert_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/yuy2_mask_frag.shd */
+static const char const yuy2_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, texuv, texa;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_cuv, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "  float y,u,v,vmu,r,g,b;\n"
+   "  y=texture2D(tex,tex_c).r;\n"
+   "  u=texture2D(texuv,tex_cuv).g;\n"
+   "  v=texture2D(texuv,tex_cuv).a;\n"
+   "  u=u-0.5;\n"
+   "  v=v-0.5;\n"
+   "  vmu=v*0.813+u*0.391;\n"
+   "  u=u*2.018;\n"
+   "  v=v*1.596;\n"
+   "  r=y+v;\n"
+   "  g=y-vmu;\n"
+   "  b=y+u;\n"
+   "  gl_FragColor = vec4(r,g,b,1.0) * texture2D(texa, tex_a.xy).a * col;\n"
+   "}\n";
+Evas_GL_Program_Source shader_yuy2_mask_frag_src =
+{
+   yuy2_mask_frag_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd */
+static const char const yuy2_mask_vert_glsl[] =
+   "#ifdef GL_ES\n"
+   "precision highp float;\n"
+   "#endif\n"
+   "attribute vec4 vertex;\n"
+   "attribute vec4 color;\n"
+   "attribute vec2 tex_coord, tex_coord2, tex_coorda;\n"
+   "uniform mat4 mvp;\n"
+   "varying vec4 col;\n"
+   "varying vec2 tex_c, tex_cuv, tex_a;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = mvp * vertex;\n"
+   "   col = color;\n"
+   "   tex_c = tex_coord;\n"
+   "   tex_cuv = vec2(tex_coord2.x * 0.5, tex_coord2.y);\n"
+   "   tex_a = tex_coorda;\n"
+   "}\n";
+Evas_GL_Program_Source shader_yuy2_mask_vert_src =
+{
+   yuy2_mask_vert_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd */
+static const char const rgb_a_pair_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;\n"
+   "uniform sampler2D texa;\n"
+   "uniform sampler2D texm;\n"
+   "varying vec4 col;\n"
+   "varying vec2 coord_c;\n"
+   "varying vec2 coord_a;\n"
+   "varying vec2 coord_m;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;\n"
+   "   gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;\n"
+   "}\n";
+Evas_GL_Program_Source shader_rgb_a_pair_mask_frag_src =
+{
+   rgb_a_pair_mask_frag_glsl,
+   NULL, 0
+};
+
+/* Source: modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd */
+static const char const rgb_a_pair_mask_vert_glsl[] =
+   "#ifdef GL_ES\n"
+   "precision highp float;\n"
+   "#endif\n"
+   "attribute vec4 vertex;\n"
+   "attribute vec4 color;\n"
+   "attribute vec2 tex_coord;\n"
+   "attribute vec2 tex_coorda;\n"
+   "attribute vec2 tex_coordm;\n"
+   "uniform mat4 mvp;\n"
+   "varying vec4 col;\n"
+   "varying vec2 coord_c;\n"
+   "varying vec2 coord_a;\n"
+   "varying vec2 coord_m;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = mvp * vertex;\n"
+   "   col = color;\n"
+   "   coord_c = tex_coord;\n"
+   "   coord_a = tex_coorda;\n"
+   "   coord_m = tex_coordm;\n"
+   "}\n";
+Evas_GL_Program_Source shader_rgb_a_pair_mask_vert_src =
+{
+   rgb_a_pair_mask_vert_glsl,
+   NULL, 0
+};
+
 static const struct {
    Evas_GL_Shader id;
    Evas_GL_Program_Source *vert;
@@ -2476,5 +2709,9 @@ static const struct {
    { SHADER_IMG_MASK_NOMUL, &(shader_img_mask_nomul_vert_src), &(shader_img_mask_nomul_frag_src), "img_mask_nomul" },
    { SHADER_IMG_MASK_BGRA, &(shader_img_mask_bgra_vert_src), &(shader_img_mask_bgra_frag_src), "img_mask_bgra" },
    { SHADER_IMG_MASK_BGRA_NOMUL, &(shader_img_mask_bgra_nomul_vert_src), &(shader_img_mask_bgra_nomul_frag_src), "img_mask_bgra_nomul" },
+   { SHADER_YUV_MASK, &(shader_yuv_mask_vert_src), &(shader_yuv_mask_frag_src), "yuv_mask" },
+   { SHADER_NV12_MASK, &(shader_nv12_mask_vert_src), &(shader_nv12_mask_frag_src), "nv12_mask" },
+   { 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" },
 };
 
diff --git a/src/modules/evas/engines/gl_common/shader/nv12_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/nv12_mask_frag.shd
new file mode 100644 (file)
index 0000000..f78416e
--- /dev/null
@@ -0,0 +1,31 @@
+#ifdef GL_ES
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif
+uniform sampler2D tex, texuv, texa;
+varying vec4 col;
+varying vec2 tex_c, tex_cuv, tex_a;
+void main()
+{
+  float y,u,v,vmu,r,g,b;
+  y=texture2D(tex,tex_c).g;
+  u=texture2D(texuv,tex_cuv).g;
+  v=texture2D(texuv,tex_cuv).a;
+
+  u=u-0.5;
+  v=v-0.5;
+  vmu=v*0.813+u*0.391;
+  u=u*2.018;
+  v=v*1.596;
+  y=(y-0.062)*1.164;
+
+  r=y+v;
+  g=y-vmu;
+  b=y+u;
+
+  gl_FragColor = vec4(r,g,b,1.0) * texture2D(texa, tex_a.xy).a * col;
+}
+
diff --git a/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/nv12_mask_vert.shd
new file mode 100644 (file)
index 0000000..bce12af
--- /dev/null
@@ -0,0 +1,17 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+attribute vec4 vertex;
+attribute vec4 color;
+attribute vec2 tex_coord, tex_coord2, tex_coorda;
+uniform mat4 mvp;
+varying vec4 col;
+varying vec2 tex_c, tex_cuv, tex_a;
+void main()
+{
+   gl_Position = mvp * vertex;
+   col = color;
+   tex_c = tex_coord;
+   tex_cuv = tex_coord2 * 0.5;
+   tex_a = tex_coorda;
+}
diff --git a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_frag.shd
new file mode 100644 (file)
index 0000000..2c2ddef
--- /dev/null
@@ -0,0 +1,19 @@
+#ifdef GL_ES
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif
+uniform sampler2D tex;
+uniform sampler2D texa;
+uniform sampler2D texm;
+varying vec4 col;
+varying vec2 coord_c;
+varying vec2 coord_a;
+varying vec2 coord_m;
+void main()
+{
+   gl_FragColor.rgb = texture2D(tex, coord_c.xy).rgb * col.rgb * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;
+   gl_FragColor.a = col.a * texture2D(texa, coord_a).g * texture2D(texm, coord_m.xy).a;
+}
diff --git a/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/rgb_a_pair_mask_vert.shd
new file mode 100644 (file)
index 0000000..03f7055
--- /dev/null
@@ -0,0 +1,21 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+attribute vec4 vertex;
+attribute vec4 color;
+attribute vec2 tex_coord;
+attribute vec2 tex_coorda;
+attribute vec2 tex_coordm;
+uniform mat4 mvp;
+varying vec4 col;
+varying vec2 coord_c;
+varying vec2 coord_a;
+varying vec2 coord_m;
+void main()
+{
+   gl_Position = mvp * vertex;
+   col = color;
+   coord_c = tex_coord;
+   coord_a = tex_coorda;
+   coord_m = tex_coordm;
+}
diff --git a/src/modules/evas/engines/gl_common/shader/yuv_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/yuv_mask_frag.shd
new file mode 100644 (file)
index 0000000..e9e32f5
--- /dev/null
@@ -0,0 +1,25 @@
+#ifdef GL_ES
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif
+uniform sampler2D tex, texu, texv, texa;
+varying vec4 col;
+varying vec2 tex_c, tex_c2, tex_c3, tex_a;
+void main()
+{
+   float r, g, b, y, u, v;
+   y = texture2D(tex, tex_c.xy).r;
+   u = texture2D(texu, tex_c2.xy).r;
+   v = texture2D(texv, tex_c3.xy).r;
+   y = (y - 0.0625) * 1.164;
+   u = u - 0.5;
+   v = v - 0.5;
+   r = y + (1.402   * v);
+   g = y - (0.34414 * u) - (0.71414 * v);
+   b = y + (1.772   * u);
+   gl_FragColor = vec4(r, g, b, 1.0) * texture2D(texa, tex_a.xy).a * col;
+}
+
diff --git a/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/yuv_mask_vert.shd
new file mode 100644 (file)
index 0000000..b398515
--- /dev/null
@@ -0,0 +1,18 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+attribute vec4 vertex;
+attribute vec4 color;
+attribute vec2 tex_coord, tex_coord2, tex_coord3, tex_coorda;
+uniform mat4 mvp;
+varying vec4 col;
+varying vec2 tex_c, tex_c2, tex_c3, tex_a;
+void main()
+{
+   gl_Position = mvp * vertex;
+   col = color;
+   tex_c = tex_coord;
+   tex_c2 = tex_coord2;
+   tex_c3 = tex_coord3;
+   tex_a = tex_coorda;
+}
diff --git a/src/modules/evas/engines/gl_common/shader/yuy2_mask_frag.shd b/src/modules/evas/engines/gl_common/shader/yuy2_mask_frag.shd
new file mode 100644 (file)
index 0000000..1b295b7
--- /dev/null
@@ -0,0 +1,30 @@
+#ifdef GL_ES
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif
+uniform sampler2D tex, texuv, texa;
+varying vec4 col;
+varying vec2 tex_c, tex_cuv, tex_a;
+void main()
+{
+  float y,u,v,vmu,r,g,b;
+  y=texture2D(tex,tex_c).r;
+  u=texture2D(texuv,tex_cuv).g;
+  v=texture2D(texuv,tex_cuv).a;
+
+  u=u-0.5;
+  v=v-0.5;
+  vmu=v*0.813+u*0.391;
+  u=u*2.018;
+  v=v*1.596;
+
+  r=y+v;
+  g=y-vmu;
+  b=y+u;
+
+  gl_FragColor = vec4(r,g,b,1.0) * texture2D(texa, tex_a.xy).a * col;
+}
+
diff --git a/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd b/src/modules/evas/engines/gl_common/shader/yuy2_mask_vert.shd
new file mode 100644 (file)
index 0000000..7cafa14
--- /dev/null
@@ -0,0 +1,17 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+attribute vec4 vertex;
+attribute vec4 color;
+attribute vec2 tex_coord, tex_coord2, tex_coorda;
+uniform mat4 mvp;
+varying vec4 col;
+varying vec2 tex_c, tex_cuv, tex_a;
+void main()
+{
+   gl_Position = mvp * vertex;
+   col = color;
+   tex_c = tex_coord;
+   tex_cuv = vec2(tex_coord2.x * 0.5, tex_coord2.y);
+   tex_a = tex_coorda;
+}