Evas masking: Simplify previous commit
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 26 Feb 2015 06:36:09 +0000 (15:36 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Fri, 27 Feb 2015 04:06:09 +0000 (13:06 +0900)
Call object's function to get the private engine_data (here, the
image object). Thanks Dongyeon for your patch which inspired me to
do that instead of forcing pre_render.

src/lib/evas/canvas/evas_object_image.c
src/lib/evas/canvas/evas_render.c
src/lib/evas/include/evas_private.h
src/modules/evas/engines/gl_common/evas_gl_context.c

index 2faf393..63f777f 100644 (file)
@@ -3541,18 +3541,6 @@ state_write:
      }
 }
 
-static inline void
-_image_mask_image_set(Evas_Object_Protected_Data *obj, Eina_Bool smooth, void *image)
-{
-   if ((obj->mask->image != image) || (obj->mask->smooth_scale != smooth))
-     {
-        EINA_COW_WRITE_BEGIN(evas_object_mask_cow, obj->mask, Evas_Object_Mask_Data, mask)
-          mask->image = image;
-          mask->smooth_scale = smooth;
-        EINA_COW_WRITE_END(evas_object_mask_cow, obj->mask, mask);
-     }
-}
-
 static void
 evas_object_image_render_pre(Evas_Object *eo_obj,
                             Evas_Object_Protected_Data *obj,
@@ -3573,15 +3561,6 @@ evas_object_image_render_pre(Evas_Object *eo_obj,
 
    if ((o->cur->fill.w < 1) || (o->cur->fill.h < 1)) return;
 
-   /* plain mask images */
-   if (obj->mask->is_mask && !o->cur->scene && !o->cur->source)
-     {
-        DBG("Setting image pointer in mask data.");
-        _image_mask_image_set(obj, o->cur->smooth_scale, o->engine_data);
-     }
-   else
-     _image_mask_image_set(obj, EINA_FALSE, NULL);
-
    /* if someone is clipping this obj - go calculate the clipper */
    if (obj->cur->clipper)
      {
index 27c9ef9..c0a9e17 100644 (file)
@@ -368,10 +368,7 @@ _evas_render_phase1_direct(Evas_Public_Data *e,
           {
              /* is image clipper */
              if (_evas_render_object_changed_get(obj))
-               {
-                  obj->func->render_pre(obj->object, obj, obj->private_data);
-                  _evas_mask_redraw_set(e, obj);
-               }
+               _evas_mask_redraw_set(e, obj);
           }
      }
    for (i = 0; i < render_objects->count; i++)
@@ -1827,13 +1824,15 @@ evas_render_mask_subrender(Evas_Public_Data *evas,
    EINA_COW_WRITE_BEGIN(evas_object_mask_cow, mask->mask, Evas_Object_Mask_Data, mdata)
      mdata->redraw = EINA_FALSE;
 
-     if (is_image && !prev_mask && mdata->image && ENFN->image_scaled_update)
+     if (is_image && !prev_mask && mask->func->engine_data_get &&
+         ENFN->image_scaled_update)
        {
           /* Fast path (for GL) that avoids creating a map surface, render the
            * scaled image in it, when the shaders can just scale on the fly. */
+          Eina_Bool smooth = evas_object_image_smooth_scale_get(mask->object);
+          void *original = mask->func->engine_data_get(mask->object);
           void *scaled = ENFN->image_scaled_update
-                (ENDT, mdata->surface, mdata->image, w, h,
-                 mdata->smooth_scale, EINA_TRUE, EVAS_COLORSPACE_GRY8);
+            (ENDT, mdata->surface, original, w, h, smooth, EINA_TRUE, EVAS_COLORSPACE_GRY8);
           if (scaled)
             {
                done = EINA_TRUE;
index f71d26e..e01eb38 100644 (file)
@@ -911,12 +911,10 @@ struct _Evas_Object_3D_Data
 struct _Evas_Object_Mask_Data
 {
    void          *surface;
-   void          *image; // original image
    int            w, h;
    Eina_Bool      is_mask : 1;
    Eina_Bool      redraw : 1;
    Eina_Bool      is_alpha : 1;
-   Eina_Bool      smooth_scale : 1;
 };
 
 struct _Evas_Object_Protected_State
index 04f248f..2c756db 100644 (file)
@@ -1586,7 +1586,8 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
                                       int x, int y, int w, int h,
                                       int r, int g, int b, int a,
                                       Evas_GL_Texture *mtex,
-                                      double mx, double my, double mw, double mh, Eina_Bool mask_smooth)
+                                      double mx, double my, double mw, double mh,
+                                      Eina_Bool mask_smooth)
 {
    Eina_Bool blend = EINA_FALSE;
    Evas_GL_Shader shader = SHADER_RECT;
@@ -1632,6 +1633,7 @@ again:
         gc->pipe[pn].array.use_texa = 0;
         gc->pipe[pn].array.use_texsam = 0;
         gc->pipe[pn].array.use_texm = !!mtex;
+        gc->pipe[pn].array.mask_smooth = mask_smooth;
      }
    else
      {
@@ -1646,6 +1648,7 @@ again:
                  && (gc->pipe[i].shader.blend == blend)
                  && (gc->pipe[i].shader.render_op == gc->dc->render_op)
                  && (gc->pipe[i].shader.clip == 0)
+                 // todo: save & compare mask_smooth
                 )
                {
                   found = 1;
@@ -1684,6 +1687,7 @@ again:
              gc->pipe[pn].array.use_texa = 0;
              gc->pipe[pn].array.use_texsam = 0;
              gc->pipe[pn].array.use_texm = !!mtex;
+             gc->pipe[pn].array.mask_smooth = mask_smooth;
          }
      }
 #else
@@ -1720,6 +1724,7 @@ again:
    gc->pipe[pn].array.use_texa = 0;
    gc->pipe[pn].array.use_texsam = 0;
    gc->pipe[pn].array.use_texm = !!mtex;
+   gc->pipe[pn].array.mask_smooth = mask_smooth;
 #endif
 
    pipe_region_expand(gc, pn, x, y, w, h);
@@ -3192,11 +3197,9 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
                }
              else if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type == RTYPE_MAP))
                {
-                  /* FIXME:
-                   * This is a workaround as we hijack some tex ids
-                   * (namely tex_coordm, tex_coorda and tex_sample) for map masking.
-                   * These masking shaders should definitely use uniforms.
-                   */
+                  /* For map masking, we (ab)use 3 texture vertex pointers
+                   * (namely tex_coordm, tex_coorda and tex_sample).
+                   * We could probably pack them into an array or something. */
                   glEnableVertexAttribArray(SHAD_TEXA);
                   glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr);
                }