jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=69cbbc2184050330c4a70b2432001be717e20a4b

commit 69cbbc2184050330c4a70b2432001be717e20a4b
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Thu Sep 3 12:03:23 2015 +0900

    evas: Add internal context_dup function
    
    This will simplify some code related to clipping and masking.
---
 src/lib/evas/common/evas_draw.h                    |  1 +
 src/lib/evas/common/evas_draw_main.c               | 26 ++++++++++++++++++++++
 src/lib/evas/include/evas_private.h                |  1 +
 src/modules/evas/engines/gl_generic/evas_engine.c  | 13 +++++++++++
 .../evas/engines/software_generic/evas_engine.c    | 21 +++++++++++++++++
 5 files changed, 62 insertions(+)

diff --git a/src/lib/evas/common/evas_draw.h b/src/lib/evas/common/evas_draw.h
index 10cb26f..0beb84c 100644
--- a/src/lib/evas/common/evas_draw.h
+++ b/src/lib/evas/common/evas_draw.h
@@ -5,6 +5,7 @@
 EAPI void               evas_common_draw_init                            
(void);
 
 EAPI RGBA_Draw_Context *evas_common_draw_context_new                     
(void);
+EAPI RGBA_Draw_Context *evas_common_draw_context_dup                     
(RGBA_Draw_Context *dc);
 EAPI void               evas_common_draw_context_free                    
(RGBA_Draw_Context *dc);
 EAPI void               evas_common_draw_context_font_ext_set            
(RGBA_Draw_Context *dc,
                                                                           void 
*data,
diff --git a/src/lib/evas/common/evas_draw_main.c 
b/src/lib/evas/common/evas_draw_main.c
index 01ba20c..5830d70 100644
--- a/src/lib/evas/common/evas_draw_main.c
+++ b/src/lib/evas/common/evas_draw_main.c
@@ -11,6 +11,20 @@ evas_common_draw_context_cutouts_new(void)
    return rects;
 }
 
+static void
+evas_common_draw_context_cutouts_dup(Cutout_Rects *rects2, const Cutout_Rects 
*rects)
+{
+   if (!rects) return;
+   rects2->active = rects->active;
+   rects2->max = rects->max;
+   if (rects->max > 0)
+     {
+        const size_t sz = sizeof(Cutout_Rect) * rects->max;
+        rects2->rects = malloc(sz);
+        memcpy(rects2->rects, rects->rects, sz);
+     }
+}
+
 EAPI void
 evas_common_draw_context_cutouts_free(Cutout_Rects* rects)
 {
@@ -81,6 +95,18 @@ evas_common_draw_context_new(void)
    return dc;
 }
 
+EAPI RGBA_Draw_Context *
+evas_common_draw_context_dup(RGBA_Draw_Context *dc)
+{
+   RGBA_Draw_Context *dc2;
+
+   if (!dc) return evas_common_draw_context_new();
+   dc2 = calloc(1, sizeof(RGBA_Draw_Context));
+   memcpy(dc2, dc, sizeof(RGBA_Draw_Context));
+   evas_common_draw_context_cutouts_dup(&dc2->cutout, &dc->cutout);
+   return dc2;
+}
+
 EAPI void
 evas_common_draw_context_free(RGBA_Draw_Context *dc)
 {
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index f513be4..80c04a0 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1263,6 +1263,7 @@ struct _Evas_Func
    void (*output_dump)                     (void *data);
 
    void *(*context_new)                    (void *data);
+   void *(*context_dup)                    (void *data, void *context);
    Eina_Bool (*canvas_alpha_get)           (void *data, void *context);
    void (*context_free)                    (void *data, void *context);
    void (*context_clip_set)                (void *data, void *context, int x, 
int y, int w, int h);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c 
b/src/modules/evas/engines/gl_generic/evas_engine.c
index 9d93c43..0153c80 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -2182,6 +2182,18 @@ eng_context_free(void *data, void *context)
    evas_common_draw_context_free(context);
 }
 
+static void *
+eng_context_dup(void *data EINA_UNUSED, void *context)
+{
+   RGBA_Draw_Context *ctx;
+
+   ctx = evas_common_draw_context_dup(context);
+   if (ctx->clip.mask)
+     evas_gl_common_image_ref(ctx->clip.mask);
+
+   return ctx;
+}
+
 static void
 eng_context_3d_use(void *data)
 {
@@ -2565,6 +2577,7 @@ module_open(Evas_Module *em)
    ORD(context_clip_image_set);
    ORD(context_clip_image_unset);
    ORD(context_clip_image_get);
+   ORD(context_dup);
    ORD(context_free);
 
    ORD(rectangle_draw);
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index 3315fef..3291b2a 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -438,6 +438,26 @@ eng_context_new(void *data EINA_UNUSED)
    return evas_common_draw_context_new();
 }
 
+static void *
+eng_context_dup(void *data EINA_UNUSED, void *context)
+{
+   RGBA_Draw_Context *ctx;
+
+   ctx = evas_common_draw_context_dup(context);
+   if (ctx->clip.mask)
+     {
+        Image_Entry *im = ctx->clip.mask;
+#ifdef EVAS_CSERVE2
+        if (evas_cserve2_use_get())
+          evas_cache2_image_ref(im);
+        else
+#endif
+          evas_cache_image_ref(im);
+     }
+
+   return ctx;
+}
+
 static void
 eng_context_clip_set(void *data EINA_UNUSED, void *context, int x, int y, int 
w, int h)
 {
@@ -3787,6 +3807,7 @@ static Evas_Func func =
      eng_output_dump,
      /* draw context virtual methods */
      eng_context_new,
+     eng_context_dup,
      eng_canvas_alpha_get,
      eng_context_free,
      eng_context_clip_set,

-- 


Reply via email to