Evas masking: Simplify ref/unref code
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 22 Jan 2015 09:21:44 +0000 (18:21 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Thu, 22 Jan 2015 09:22:17 +0000 (18:22 +0900)
Those masks are always render surfaces so we should
treat them as such. Plus, there are proper functions
to ref/unref GL images.

src/modules/evas/engines/gl_generic/evas_engine.c

index 198b638..e280fdd 100644 (file)
@@ -1696,34 +1696,19 @@ eng_context_flush(void *data)
 }
 
 static void
-eng_context_clip_image_unset(void *data, void *context)
+eng_context_clip_image_unset(void *data EINA_UNUSED, void *context)
 {
    RGBA_Draw_Context *ctx = context;
    Evas_GL_Image *im = ctx->clip.mask;
 
-   if (EINA_UNLIKELY(im && im->im))
-     {
-#ifdef EVAS_CSERVE2
-        if (evas_cserve2_use_get())
-          evas_cache2_image_close(&im->im->cache_entry);
-        else
-#endif
-          evas_cache_image_drop(&im->im->cache_entry);
-        // Is the above code safe? Hmmm...
-        //evas_unref_queue_image_put(EVAS???, &ctx->clip.ie->cache_entry);
-     }
-   else if (im)
-     {
-        im->references--;
-        if (!im->references)
-          eng_image_free(data, im);
-     }
+   if (im)
+     evas_gl_common_image_free(im);
 
    ctx->clip.mask = NULL;
 }
 
 static void
-eng_context_clip_image_set(void *data EINA_UNUSED, void *context, void *surface, int x, int y)
+eng_context_clip_image_set(void *data, void *context, void *surface, int x, int y)
 {
    RGBA_Draw_Context *ctx = context;
    Evas_GL_Image *im = surface;
@@ -1741,24 +1726,9 @@ eng_context_clip_image_set(void *data EINA_UNUSED, void *context, void *surface,
    ctx->clip.mask_x = x;
    ctx->clip.mask_y = y;
 
-   if (EINA_UNLIKELY(im && im->im))
-     {
-        // Unlikely to happen because masks are render surfaces.
-        if (!noinc)
-          {
-#ifdef EVAS_CSERVE2
-             if (evas_cserve2_use_get())
-               evas_cache2_image_ref(&im->im->cache_entry);
-             else
-#endif
-               evas_cache_image_ref(&im->im->cache_entry);
-          }
-        RECTS_CLIP_TO_RECT(ctx->clip.x, ctx->clip.y, ctx->clip.w, ctx->clip.h,
-                           x, y, im->im->cache_entry.w, im->im->cache_entry.h);
-     }
-   else if (im)
+   if (im)
      {
-        if (!noinc) im->references++;
+        if (!noinc) evas_gl_common_image_ref(im);
         RECTS_CLIP_TO_RECT(ctx->clip.x, ctx->clip.y, ctx->clip.w, ctx->clip.h,
                            x, y, im->w, im->h);
      }