diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2014-11-13 10:40:16 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-01-07 15:06:02 +0900 |
commit | 2a0201d571b0be656855c1d89c453d80bd17e8fe (patch) | |
tree | 7feee8803dfddc09e0425c30940dc6b870ebf157 /src/lib/evas/canvas | |
parent | a9630a77b656ebf7e246296530de70852abf52d5 (diff) |
Evas masking: Allow setting an image object as clipper
The render function is not yet implemented, but this
prepares the infra used to set an object other than
Rectangle as a clipper.
@feature
Diffstat (limited to 'src/lib/evas/canvas')
-rw-r--r-- | src/lib/evas/canvas/evas_clip.c | 49 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_image.c | 2 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_main.c | 25 |
3 files changed, 58 insertions, 18 deletions
diff --git a/src/lib/evas/canvas/evas_clip.c b/src/lib/evas/canvas/evas_clip.c index 1947f0f457..08166644aa 100644 --- a/src/lib/evas/canvas/evas_clip.c +++ b/src/lib/evas/canvas/evas_clip.c | |||
@@ -188,8 +188,33 @@ evas_object_mapped_clip_across_mark(Evas_Object *eo_obj, Evas_Object_Protected_D | |||
188 | #endif | 188 | #endif |
189 | } | 189 | } |
190 | 190 | ||
191 | static void | ||
192 | _evas_object_clip_mask_unset(Evas_Object_Protected_Data *obj) | ||
193 | { | ||
194 | if (!obj || !obj->mask->is_mask) return; | ||
195 | if (obj->clip.clipees) return; | ||
196 | |||
197 | /* this frees the clip surface. is this correct? */ | ||
198 | EINA_COW_WRITE_BEGIN(evas_object_mask_cow, obj->mask, Evas_Object_Mask_Data, mask) | ||
199 | mask->is_mask = EINA_FALSE; | ||
200 | mask->redraw = EINA_FALSE; | ||
201 | mask->is_alpha = EINA_FALSE; | ||
202 | if (mask->surface) | ||
203 | { | ||
204 | obj->layer->evas->engine.func->image_map_surface_free | ||
205 | (obj->layer->evas->engine.data.output, mask->surface); | ||
206 | mask->surface = NULL; | ||
207 | } | ||
208 | mask->x = 0; | ||
209 | mask->y = 0; | ||
210 | mask->w = 0; | ||
211 | mask->h = 0; | ||
212 | EINA_COW_WRITE_END(evas_object_mask_cow, obj->mask, mask); | ||
213 | } | ||
214 | |||
191 | /* public functions */ | 215 | /* public functions */ |
192 | extern const char *o_rect_type; | 216 | extern const char *o_rect_type; |
217 | extern const char *o_image_type; | ||
193 | 218 | ||
194 | EOLIAN void | 219 | EOLIAN void |
195 | _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object *eo_clip) | 220 | _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object *eo_clip) |
@@ -242,10 +267,10 @@ _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object * | |||
242 | } | 267 | } |
243 | 268 | ||
244 | if (evas_object_intercept_call_clip_set(eo_obj, obj, eo_clip)) return; | 269 | if (evas_object_intercept_call_clip_set(eo_obj, obj, eo_clip)) return; |
245 | // illegal to set anything but a rect as a clip | 270 | // illegal to set anything but a rect or an image as a clip |
246 | if (clip->type != o_rect_type) | 271 | if (clip->type != o_rect_type && clip->type != o_image_type) |
247 | { | 272 | { |
248 | ERR("For now a clip on other object than a rectangle is disabled"); | 273 | ERR("For now a clip on other object than a rectangle or an image is disabled"); |
249 | return; | 274 | return; |
250 | } | 275 | } |
251 | if (obj->is_smart) | 276 | if (obj->is_smart) |
@@ -280,6 +305,7 @@ _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object * | |||
280 | } | 305 | } |
281 | } | 306 | } |
282 | */ | 307 | */ |
308 | _evas_object_clip_mask_unset(obj->cur->clipper); | ||
283 | } | 309 | } |
284 | evas_object_change(obj->cur->clipper->object, obj->cur->clipper); | 310 | evas_object_change(obj->cur->clipper->object, obj->cur->clipper); |
285 | evas_object_change(eo_obj, obj); | 311 | evas_object_change(eo_obj, obj); |
@@ -290,6 +316,15 @@ _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object * | |||
290 | } | 316 | } |
291 | EINA_COW_STATE_WRITE_END(obj, state_write, cur); | 317 | EINA_COW_STATE_WRITE_END(obj, state_write, cur); |
292 | } | 318 | } |
319 | |||
320 | /* image object clipper */ | ||
321 | if (clip->type == o_image_type) | ||
322 | { | ||
323 | EINA_COW_WRITE_BEGIN(evas_object_mask_cow, clip->mask, Evas_Object_Mask_Data, mask) | ||
324 | mask->is_mask = EINA_TRUE; | ||
325 | EINA_COW_WRITE_END(evas_object_mask_cow, clip->mask, mask); | ||
326 | } | ||
327 | |||
293 | /* clip me */ | 328 | /* clip me */ |
294 | if ((!clip->clip.clipees) && (clip->cur->visible)) | 329 | if ((!clip->clip.clipees) && (clip->cur->visible)) |
295 | { | 330 | { |
@@ -326,13 +361,6 @@ _evas_object_clip_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object * | |||
326 | evas_object_update_bounding_box(eo_clip, clip); | 361 | evas_object_update_bounding_box(eo_clip, clip); |
327 | } | 362 | } |
328 | 363 | ||
329 | /* If it's NOT a rectangle set the mask bits too */ | ||
330 | /* FIXME: Optmz ths chck */ | ||
331 | if (clip->type != o_rect_type) | ||
332 | { | ||
333 | ERR("Not supported clipping to type '%s', just rectangles.", | ||
334 | clip->type); | ||
335 | } | ||
336 | evas_object_change(eo_clip, clip); | 364 | evas_object_change(eo_clip, clip); |
337 | evas_object_change(eo_obj, obj); | 365 | evas_object_change(eo_obj, obj); |
338 | evas_object_clip_dirty(eo_obj, obj); | 366 | evas_object_clip_dirty(eo_obj, obj); |
@@ -399,6 +427,7 @@ _evas_object_clip_unset(Eo *eo_obj, Evas_Object_Protected_Data *obj) | |||
399 | } | 427 | } |
400 | } | 428 | } |
401 | */ | 429 | */ |
430 | _evas_object_clip_mask_unset(obj->cur->clipper); | ||
402 | } | 431 | } |
403 | evas_object_change(obj->cur->clipper->object, obj->cur->clipper); | 432 | evas_object_change(obj->cur->clipper->object, obj->cur->clipper); |
404 | } | 433 | } |
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index ce03b7158c..26da639922 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c | |||
@@ -29,6 +29,8 @@ | |||
29 | /* private magic number for image objects */ | 29 | /* private magic number for image objects */ |
30 | static const char o_type[] = "image"; | 30 | static const char o_type[] = "image"; |
31 | 31 | ||
32 | const char *o_image_type = o_type; | ||
33 | |||
32 | /* private struct for rectangle object internal data */ | 34 | /* private struct for rectangle object internal data */ |
33 | typedef struct _Evas_Object_Image Evas_Image_Data; | 35 | typedef struct _Evas_Object_Image Evas_Image_Data; |
34 | typedef struct _Evas_Object_Image_Load_Opts Evas_Object_Image_Load_Opts; | 36 | typedef struct _Evas_Object_Image_Load_Opts Evas_Object_Image_Load_Opts; |
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 25f802deb7..208a29eac1 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c | |||
@@ -28,7 +28,7 @@ static const Evas_Object_Map_Data default_map = { | |||
28 | }; | 28 | }; |
29 | static const Evas_Object_Protected_State default_state = { | 29 | static const Evas_Object_Protected_State default_state = { |
30 | NULL, { 0, 0, 0, 0 }, | 30 | NULL, { 0, 0, 0, 0 }, |
31 | { { 0, 0, 0, 0, 0, 0, 0, 0, EINA_FALSE, EINA_FALSE } }, | 31 | { { 0, 0, 0, 0, 0, 0, 0, 0, NULL, EINA_FALSE, EINA_FALSE } }, |
32 | { 255, 255, 255, 255 }, | 32 | { 255, 255, 255, 255 }, |
33 | 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE | 33 | 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE |
34 | }; | 34 | }; |
@@ -36,13 +36,16 @@ static const Evas_Object_Filter_Data default_filter = { | |||
36 | NULL, NULL, NULL, NULL, EINA_FALSE, EINA_FALSE | 36 | NULL, NULL, NULL, NULL, EINA_FALSE, EINA_FALSE |
37 | }; | 37 | }; |
38 | const void * const evas_object_filter_cow_default = &default_filter; | 38 | const void * const evas_object_filter_cow_default = &default_filter; |
39 | static const Evas_Object_Mask_Data default_mask = { | ||
40 | NULL, 0, 0, EINA_FALSE | ||
41 | }; | ||
39 | 42 | ||
40 | Eina_Cow *evas_object_proxy_cow = NULL; | 43 | Eina_Cow *evas_object_proxy_cow = NULL; |
41 | Eina_Cow *evas_object_map_cow = NULL; | 44 | Eina_Cow *evas_object_map_cow = NULL; |
42 | Eina_Cow *evas_object_state_cow = NULL; | 45 | Eina_Cow *evas_object_state_cow = NULL; |
43 | |||
44 | Eina_Cow *evas_object_3d_cow = NULL; | 46 | Eina_Cow *evas_object_3d_cow = NULL; |
45 | Eina_Cow *evas_object_filter_cow = NULL; | 47 | Eina_Cow *evas_object_filter_cow = NULL; |
48 | Eina_Cow *evas_object_mask_cow = NULL; | ||
46 | 49 | ||
47 | static Eina_Bool | 50 | static Eina_Bool |
48 | _init_cow(void) | 51 | _init_cow(void) |
@@ -52,24 +55,26 @@ _init_cow(void) | |||
52 | evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy, EINA_TRUE); | 55 | evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy, EINA_TRUE); |
53 | evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map, EINA_TRUE); | 56 | evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map, EINA_TRUE); |
54 | evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state, EINA_FALSE); | 57 | evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state, EINA_FALSE); |
55 | |||
56 | evas_object_3d_cow = eina_cow_add("Evas Object 3D", sizeof (Evas_Object_3D_Data), 8, &default_proxy, EINA_TRUE); | 58 | evas_object_3d_cow = eina_cow_add("Evas Object 3D", sizeof (Evas_Object_3D_Data), 8, &default_proxy, EINA_TRUE); |
57 | evas_object_filter_cow = eina_cow_add("Evas Filter Data", sizeof (Evas_Object_Filter_Data), 8, &default_filter, EINA_TRUE); | 59 | evas_object_filter_cow = eina_cow_add("Evas Filter Data", sizeof (Evas_Object_Filter_Data), 8, &default_filter, EINA_TRUE); |
60 | evas_object_mask_cow = eina_cow_add("Evas Mask Data", sizeof (Evas_Object_Mask_Data), 8, &default_mask, EINA_TRUE); | ||
58 | 61 | ||
59 | if (!(evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow && evas_object_3d_cow && evas_object_filter_cow)) | 62 | if (!(evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow && |
63 | evas_object_3d_cow && evas_object_filter_cow && evas_object_mask_cow)) | ||
60 | { | 64 | { |
61 | eina_cow_del(evas_object_proxy_cow); | 65 | eina_cow_del(evas_object_proxy_cow); |
62 | eina_cow_del(evas_object_map_cow); | 66 | eina_cow_del(evas_object_map_cow); |
63 | eina_cow_del(evas_object_state_cow); | 67 | eina_cow_del(evas_object_state_cow); |
68 | eina_cow_del(evas_object_3d_cow); | ||
69 | eina_cow_del(evas_object_filter_cow); | ||
70 | eina_cow_del(evas_object_mask_cow); | ||
71 | |||
64 | evas_object_proxy_cow = NULL; | 72 | evas_object_proxy_cow = NULL; |
65 | evas_object_map_cow = NULL; | 73 | evas_object_map_cow = NULL; |
66 | evas_object_state_cow = NULL; | 74 | evas_object_state_cow = NULL; |
67 | |||
68 | eina_cow_del(evas_object_3d_cow); | ||
69 | evas_object_3d_cow = NULL; | 75 | evas_object_3d_cow = NULL; |
70 | |||
71 | eina_cow_del(evas_object_filter_cow); | ||
72 | evas_object_filter_cow = NULL; | 76 | evas_object_filter_cow = NULL; |
77 | evas_object_mask_cow = NULL; | ||
73 | 78 | ||
74 | return EINA_FALSE; | 79 | return EINA_FALSE; |
75 | } | 80 | } |
@@ -97,6 +102,7 @@ _evas_object_eo_base_constructor(Eo *eo_obj, Evas_Object_Protected_Data *obj) | |||
97 | obj->cur = eina_cow_alloc(evas_object_state_cow); | 102 | obj->cur = eina_cow_alloc(evas_object_state_cow); |
98 | obj->prev = eina_cow_alloc(evas_object_state_cow); | 103 | obj->prev = eina_cow_alloc(evas_object_state_cow); |
99 | obj->data_3d = eina_cow_alloc(evas_object_3d_cow); | 104 | obj->data_3d = eina_cow_alloc(evas_object_3d_cow); |
105 | obj->mask = eina_cow_alloc(evas_object_mask_cow); | ||
100 | } | 106 | } |
101 | 107 | ||
102 | void | 108 | void |
@@ -206,6 +212,7 @@ evas_object_free(Evas_Object *eo_obj, int clean_layer) | |||
206 | eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->cur); | 212 | eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->cur); |
207 | eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->prev); | 213 | eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->prev); |
208 | eina_cow_free(evas_object_3d_cow, (const Eina_Cow_Data**) &obj->data_3d); | 214 | eina_cow_free(evas_object_3d_cow, (const Eina_Cow_Data**) &obj->data_3d); |
215 | eina_cow_free(evas_object_mask_cow, (const Eina_Cow_Data**) &obj->mask); | ||
209 | eo_data_unref(eo_obj, obj->private_data); | 216 | eo_data_unref(eo_obj, obj->private_data); |
210 | obj->private_data = NULL; | 217 | obj->private_data = NULL; |
211 | 218 | ||
@@ -509,6 +516,8 @@ evas_object_render_pre_effect_updates(Eina_Array *rects, Evas_Object *eo_obj, in | |||
509 | } | 516 | } |
510 | else | 517 | else |
511 | { | 518 | { |
519 | /* This is a clipper object: add regions that changed here, | ||
520 | * See above: EINA_LIST_FOREACH(clipper->clip.changes) */ | ||
512 | evas_object_clip_changes_clean(eo_obj); | 521 | evas_object_clip_changes_clean(eo_obj); |
513 | EINA_ARRAY_ITER_NEXT(rects, i, r, it) | 522 | EINA_ARRAY_ITER_NEXT(rects, i, r, it) |
514 | obj->clip.changes = eina_list_append(obj->clip.changes, r); | 523 | obj->clip.changes = eina_list_append(obj->clip.changes, r); |