jpeg pushed a commit to branch master.

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

commit 4071af438a447479f15fc3d979058a889b2aa911
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Fri Nov 4 11:59:59 2016 +0900

    Revert "evas: Simplify GL masking and fix window rotation"
    
    This reverts commit 562528d28c376d5ff941f9db3ea5c4924c07e75f.
    
    This patch did not work with mapped images.
---
 .../evas/engines/gl_common/evas_gl_context.c       | 66 +++++++++++++---------
 .../engines/gl_common/shader/evas_gl_shaders.x     |  5 +-
 .../evas/engines/gl_common/shader/vertex.glsl      |  5 +-
 3 files changed, 46 insertions(+), 30 deletions(-)

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 8e14150..a13b8b5 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -1357,7 +1357,7 @@ 
evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
 #define COLOR_CNT  4
 #define TEX_CNT    2
 #define SAM_CNT    2
-#define MASK_CNT   2
+#define MASK_CNT   4
 
 #define PUSH_VERTEX(n, x, y, z) do { \
    gc->pipe[n].array.vertex[nv++] = x; \
@@ -1380,9 +1380,11 @@ 
evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
 #define PUSH_TEXA(n, u, v) do { \
    gc->pipe[n].array.texa[na++] = u; \
    gc->pipe[n].array.texa[na++] = v; } while(0)
-#define PUSH_TEXM(n, u, v) do { \
+#define PUSH_TEXM(n, u, v, w, z) do { \
    gc->pipe[n].array.mask[nm++] = u; \
-   gc->pipe[n].array.mask[nm++] = v; } while(0)
+   gc->pipe[n].array.mask[nm++] = v; \
+   gc->pipe[n].array.mask[nm++] = w; \
+   gc->pipe[n].array.mask[nm++] = z; } while(0)
 #define PUSH_TEXSAM(n, x, y) do { \
    gc->pipe[n].array.texsam[ns++] = x; \
    gc->pipe[n].array.texsam[ns++] = y; } while(0)
@@ -1396,12 +1398,6 @@ 
evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
   PUSH_TEXUV(pn, x1, y1); PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x4, y4);\
   PUSH_TEXUV(pn, x2, y2); PUSH_TEXUV(pn, x3, y3); PUSH_TEXUV(pn, x4, y4);
 
-#define PUSH_6_TEXM(pn, x, y, w, h) do { \
-   PUSH_TEXM(pn, x    , y    ); PUSH_TEXM(pn, x + w, y    ); \
-   PUSH_TEXM(pn, x    , y + h); PUSH_TEXM(pn, x + w, y    ); \
-   PUSH_TEXM(pn, x + w, y + h); PUSH_TEXM(pn, x    , y + h); \
-   } while (0)
-
 #define PUSH_6_TEXUV(pn, x1, y1, x2, y2)                \
   PUSH_6_QUAD(pn, x1, y1, x2, y1, x2, y2, x1, y2);
 
@@ -1429,31 +1425,38 @@ 
evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
 
 static inline Eina_Bool
 _push_mask(Evas_Engine_GL_Context *gc, const int pn, int nm, Evas_GL_Texture 
*mtex,
-           int mx, int my, int mw, int mh, int x, int y, int w, int h,
-           Shader_Sampling msam, int nms)
+           int mx, int my, int mw, int mh, Shader_Sampling msam, int nms)
 {
-   double glmx, glmy, glmw, glmh;
+   double glmx, glmy, glmw, glmh, yinv = -1.f;
    double gw = gc->w, gh = gc->h;
-   int cnt = 6;
+   int i, cnt = 6;
+
+   if (!((gc->pipe[0].shader.surface == gc->def_surface) ||
+         (!gc->pipe[0].shader.surface)))
+     {
+        gw = gc->pipe[0].shader.surface->w;
+        gh = gc->pipe[0].shader.surface->h;
+        yinv = 1.f;
+     }
 
    if (!gw || !gh || !mw || !mh || !mtex->pt->w || !mtex->pt->h)
      return EINA_FALSE;
 
-   glmx = ((double) (x - mx) / mw) * mtex->w / mtex->pt->w + (double) mtex->x 
/ mtex->pt->w;
-   glmy = ((double) (y - my) / mh) * mtex->h / mtex->pt->h + (double) mtex->y 
/ mtex->pt->h;
-   glmw = (double) (w * mtex->w) / (mw * mtex->pt->w);
-   glmh = (double) (h * mtex->h) / (mh * mtex->pt->h);
+   /* vertex shader:
+    * vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 
0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
+    * tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;
+    */
+   glmx = (double)((mtex->x * mw) - (mtex->w * mx)) / (double)(mw * 
mtex->pt->w);
+   glmy = (double)((mtex->y * mh) - (mtex->h * my)) / (double)(mh * 
mtex->pt->h);
+   glmw = (double)(gw * mtex->w) / (double)(mw * mtex->pt->w);
+   glmh = (double)(gh * mtex->h) / (double)(mh * mtex->pt->h);
+   glmh *= yinv;
 
-   if (EINA_UNLIKELY(gc->pipe[pn].array.line))
-     {
-        PUSH_TEXM(pn, glmx, glmy);
-        PUSH_TEXM(pn, glmx + glmy, glmy + glmh);
-        cnt = 2;
-     }
-   else
-     {
-        PUSH_6_TEXM(pn, glmx, glmy, glmw, glmh);
-     }
+   if (gc->pipe[pn].array.line)
+     cnt = 2;
+
+   for (i = 0; i < cnt; i++)
+     PUSH_TEXM(pn, glmx, glmy, glmw, glmh);
 
    if (msam)
      {
@@ -1462,11 +1465,18 @@ _push_mask(Evas_Engine_GL_Context *gc, const int pn, 
int nm, Evas_GL_Texture *mt
         PUSH_MASKSAM(pn, samx, samy, cnt);
      }
 
+   /*
+   DBG("%d,%d %dx%d --> %f , %f - %f x %f [gc %dx%d, tex %d,%d %dx%d, pt 
%dx%d]",
+       mx, my, mw, mh,
+       glmx, glmy, glmw, glmh,
+       gc->w, gc->h, mtex->x, mtex->y, mtex->w, mtex->h, mtex->pt->w, 
mtex->pt->h);
+   */
+
    return EINA_TRUE;
 }
 
 #define PUSH_MASK(pn, mtex, mx, my, mw, mh, msam) if (mtex) do { \
-   _push_mask(gc, pn, nm, mtex, mx, my, mw, mh, x, y, w, h, msam, nms); \
+   _push_mask(gc, pn, nm, mtex, mx, my, mw, mh, msam, nms); \
    } while(0)
 
 #define PIPE_GROW(gc, pn, inc) \
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 1c09e65..558531a 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
@@ -276,7 +276,10 @@ static const char vertex_glsl[] =
    "   maskdiv_s = 4.0;\n"
    "#endif\n"
    "#ifdef SHD_MASK\n"
-   "   tex_m = mask_coord.xy;\n"
+   "   // mask_coord.w contains the Y-invert flag\n"
+   "   // position on screen in [0..1] range of current pixel\n"
+   "   vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 
0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
+   "   tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
    "#endif\n"
    "}\n";
 
diff --git a/src/modules/evas/engines/gl_common/shader/vertex.glsl 
b/src/modules/evas/engines/gl_common/shader/vertex.glsl
index 81c9281..d67eb06 100644
--- a/src/modules/evas/engines/gl_common/shader/vertex.glsl
+++ b/src/modules/evas/engines/gl_common/shader/vertex.glsl
@@ -128,7 +128,10 @@ void main()
 #endif
 
 #ifdef SHD_MASK
-   tex_m = mask_coord.xy;
+   // mask_coord.w contains the Y-invert flag
+   // position on screen in [0..1] range of current pixel
+   vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 
0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
+   tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;
 #endif
 }
 

-- 


Reply via email to