summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-09-03 12:03:23 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-09-04 11:11:39 +0900
commit69cbbc2184050330c4a70b2432001be717e20a4b (patch)
tree251f1cccf923bc26eb4d3889e9bbb8bee342bb85 /src
parentbcbf7d14e66b7438a7756198d2d6a84c9df672b5 (diff)
evas: Add internal context_dup function
This will simplify some code related to clipping and masking.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/common/evas_draw.h1
-rw-r--r--src/lib/evas/common/evas_draw_main.c26
-rw-r--r--src/lib/evas/include/evas_private.h1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c13
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c21
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 10cb26f..0beb84c 100644
--- a/src/lib/evas/common/evas_draw.h
+++ b/src/lib/evas/common/evas_draw.h
@@ -5,6 +5,7 @@
5EAPI void evas_common_draw_init (void); 5EAPI void evas_common_draw_init (void);
6 6
7EAPI RGBA_Draw_Context *evas_common_draw_context_new (void); 7EAPI RGBA_Draw_Context *evas_common_draw_context_new (void);
8EAPI RGBA_Draw_Context *evas_common_draw_context_dup (RGBA_Draw_Context *dc);
8EAPI void evas_common_draw_context_free (RGBA_Draw_Context *dc); 9EAPI void evas_common_draw_context_free (RGBA_Draw_Context *dc);
9EAPI void evas_common_draw_context_font_ext_set (RGBA_Draw_Context *dc, 10EAPI void evas_common_draw_context_font_ext_set (RGBA_Draw_Context *dc,
10 void *data, 11 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)
11 return rects; 11 return rects;
12} 12}
13 13
14static void
15evas_common_draw_context_cutouts_dup(Cutout_Rects *rects2, const Cutout_Rects *rects)
16{
17 if (!rects) return;
18 rects2->active = rects->active;
19 rects2->max = rects->max;
20 if (rects->max > 0)
21 {
22 const size_t sz = sizeof(Cutout_Rect) * rects->max;
23 rects2->rects = malloc(sz);
24 memcpy(rects2->rects, rects->rects, sz);
25 }
26}
27
14EAPI void 28EAPI void
15evas_common_draw_context_cutouts_free(Cutout_Rects* rects) 29evas_common_draw_context_cutouts_free(Cutout_Rects* rects)
16{ 30{
@@ -81,6 +95,18 @@ evas_common_draw_context_new(void)
81 return dc; 95 return dc;
82} 96}
83 97
98EAPI RGBA_Draw_Context *
99evas_common_draw_context_dup(RGBA_Draw_Context *dc)
100{
101 RGBA_Draw_Context *dc2;
102
103 if (!dc) return evas_common_draw_context_new();
104 dc2 = calloc(1, sizeof(RGBA_Draw_Context));
105 memcpy(dc2, dc, sizeof(RGBA_Draw_Context));
106 evas_common_draw_context_cutouts_dup(&dc2->cutout, &dc->cutout);
107 return dc2;
108}
109
84EAPI void 110EAPI void
85evas_common_draw_context_free(RGBA_Draw_Context *dc) 111evas_common_draw_context_free(RGBA_Draw_Context *dc)
86{ 112{
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
1263 void (*output_dump) (void *data); 1263 void (*output_dump) (void *data);
1264 1264
1265 void *(*context_new) (void *data); 1265 void *(*context_new) (void *data);
1266 void *(*context_dup) (void *data, void *context);
1266 Eina_Bool (*canvas_alpha_get) (void *data, void *context); 1267 Eina_Bool (*canvas_alpha_get) (void *data, void *context);
1267 void (*context_free) (void *data, void *context); 1268 void (*context_free) (void *data, void *context);
1268 void (*context_clip_set) (void *data, void *context, int x, int y, int w, int h); 1269 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)
2182 evas_common_draw_context_free(context); 2182 evas_common_draw_context_free(context);
2183} 2183}
2184 2184
2185static void *
2186eng_context_dup(void *data EINA_UNUSED, void *context)
2187{
2188 RGBA_Draw_Context *ctx;
2189
2190 ctx = evas_common_draw_context_dup(context);
2191 if (ctx->clip.mask)
2192 evas_gl_common_image_ref(ctx->clip.mask);
2193
2194 return ctx;
2195}
2196
2185static void 2197static void
2186eng_context_3d_use(void *data) 2198eng_context_3d_use(void *data)
2187{ 2199{
@@ -2565,6 +2577,7 @@ module_open(Evas_Module *em)
2565 ORD(context_clip_image_set); 2577 ORD(context_clip_image_set);
2566 ORD(context_clip_image_unset); 2578 ORD(context_clip_image_unset);
2567 ORD(context_clip_image_get); 2579 ORD(context_clip_image_get);
2580 ORD(context_dup);
2568 ORD(context_free); 2581 ORD(context_free);
2569 2582
2570 ORD(rectangle_draw); 2583 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)
438 return evas_common_draw_context_new(); 438 return evas_common_draw_context_new();
439} 439}
440 440
441static void *
442eng_context_dup(void *data EINA_UNUSED, void *context)
443{
444 RGBA_Draw_Context *ctx;
445
446 ctx = evas_common_draw_context_dup(context);
447 if (ctx->clip.mask)
448 {
449 Image_Entry *im = ctx->clip.mask;
450#ifdef EVAS_CSERVE2
451 if (evas_cserve2_use_get())
452 evas_cache2_image_ref(im);
453 else
454#endif
455 evas_cache_image_ref(im);
456 }
457
458 return ctx;
459}
460
441static void 461static void
442eng_context_clip_set(void *data EINA_UNUSED, void *context, int x, int y, int w, int h) 462eng_context_clip_set(void *data EINA_UNUSED, void *context, int x, int y, int w, int h)
443{ 463{
@@ -3787,6 +3807,7 @@ static Evas_Func func =
3787 eng_output_dump, 3807 eng_output_dump,
3788 /* draw context virtual methods */ 3808 /* draw context virtual methods */
3789 eng_context_new, 3809 eng_context_new,
3810 eng_context_dup,
3790 eng_canvas_alpha_get, 3811 eng_canvas_alpha_get,
3791 eng_context_free, 3812 eng_context_free,
3792 eng_context_clip_set, 3813 eng_context_clip_set,