diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-09-03 12:03:23 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-09-04 11:11:39 +0900 |
commit | 69cbbc2184050330c4a70b2432001be717e20a4b (patch) | |
tree | 251f1cccf923bc26eb4d3889e9bbb8bee342bb85 | |
parent | bcbf7d14e66b7438a7756198d2d6a84c9df672b5 (diff) | |
download | efl-69cbbc2184050330c4a70b2432001be717e20a4b.tar.gz |
evas: Add internal context_dup function
This will simplify some code related to clipping and masking.
-rw-r--r-- | src/lib/evas/common/evas_draw.h | 1 | ||||
-rw-r--r-- | src/lib/evas/common/evas_draw_main.c | 26 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 1 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_generic/evas_engine.c | 13 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_engine.c | 21 |
5 files changed, 62 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_draw.h b/src/lib/evas/common/evas_draw.h index 10cb26fe73..0beb84cf79 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 01ba20c679..5830d706f8 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 f513be4c57..80c04a0950 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 9d93c43843..0153c80f82 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 3315fefc4d..3291b2ae98 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, |