summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-13 10:40:16 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-12-22 22:33:10 +0900
commit89ed329352aa0a6752d8d63be39aa1831588cb9e (patch)
treec7f4b61241f67c67529bedb2b87146c045e441c4
parent53402ce54efe3948c557bc74d58a791dd2846b5a (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
-rw-r--r--src/lib/evas/canvas/evas_clip.c49
-rw-r--r--src/lib/evas/canvas/evas_object_image.c2
-rw-r--r--src/lib/evas/canvas/evas_object_main.c25
-rw-r--r--src/lib/evas/include/evas_private.h15
4 files changed, 73 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
191static 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 */
192extern const char *o_rect_type; 216extern const char *o_rect_type;
217extern const char *o_image_type;
193 218
194EOLIAN void 219EOLIAN 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 */
30static const char o_type[] = "image"; 30static const char o_type[] = "image";
31 31
32const char *o_image_type = o_type;
33
32/* private struct for rectangle object internal data */ 34/* private struct for rectangle object internal data */
33typedef struct _Evas_Object_Image Evas_Image_Data; 35typedef struct _Evas_Object_Image Evas_Image_Data;
34typedef struct _Evas_Object_Image_Load_Opts Evas_Object_Image_Load_Opts; 36typedef 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};
29static const Evas_Object_Protected_State default_state = { 29static 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};
38const void * const evas_object_filter_cow_default = &default_filter; 38const void * const evas_object_filter_cow_default = &default_filter;
39static const Evas_Object_Mask_Data default_mask = {
40 NULL, 0, 0, EINA_FALSE
41};
39 42
40Eina_Cow *evas_object_proxy_cow = NULL; 43Eina_Cow *evas_object_proxy_cow = NULL;
41Eina_Cow *evas_object_map_cow = NULL; 44Eina_Cow *evas_object_map_cow = NULL;
42Eina_Cow *evas_object_state_cow = NULL; 45Eina_Cow *evas_object_state_cow = NULL;
43
44Eina_Cow *evas_object_3d_cow = NULL; 46Eina_Cow *evas_object_3d_cow = NULL;
45Eina_Cow *evas_object_filter_cow = NULL; 47Eina_Cow *evas_object_filter_cow = NULL;
48Eina_Cow *evas_object_mask_cow = NULL;
46 49
47static Eina_Bool 50static 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
102void 108void
@@ -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);
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index b07d72b551..2f5afba9e0 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -48,6 +48,7 @@ typedef struct _Evas_Object_Proxy_Data Evas_Object_Proxy_Data;
48typedef struct _Evas_Object_Map_Data Evas_Object_Map_Data; 48typedef struct _Evas_Object_Map_Data Evas_Object_Map_Data;
49typedef struct _Evas_Proxy_Render_Data Evas_Proxy_Render_Data; 49typedef struct _Evas_Proxy_Render_Data Evas_Proxy_Render_Data;
50typedef struct _Evas_Object_3D_Data Evas_Object_3D_Data; 50typedef struct _Evas_Object_3D_Data Evas_Object_3D_Data;
51typedef struct _Evas_Object_Mask_Data Evas_Object_Mask_Data;
51 52
52typedef struct _Evas_Object_Protected_State Evas_Object_Protected_State; 53typedef struct _Evas_Object_Protected_State Evas_Object_Protected_State;
53typedef struct _Evas_Object_Protected_Data Evas_Object_Protected_Data; 54typedef struct _Evas_Object_Protected_Data Evas_Object_Protected_Data;
@@ -890,6 +891,16 @@ struct _Evas_Object_3D_Data
890 int w, h; 891 int w, h;
891}; 892};
892 893
894// Mask clipper information
895struct _Evas_Object_Mask_Data
896{
897 void *surface;
898 int x, y, w, h;
899 Eina_Bool is_mask : 1;
900 Eina_Bool redraw : 1;
901 Eina_Bool is_alpha : 1;
902};
903
893struct _Evas_Object_Protected_State 904struct _Evas_Object_Protected_State
894{ 905{
895 Evas_Object_Protected_Data *clipper; 906 Evas_Object_Protected_Data *clipper;
@@ -899,6 +910,7 @@ struct _Evas_Object_Protected_State
899 struct { 910 struct {
900 Evas_Coord x, y, w, h; 911 Evas_Coord x, y, w, h;
901 unsigned char r, g, b, a; 912 unsigned char r, g, b, a;
913 const Evas_Object_Protected_Data *mask, *prev_mask;
902 Eina_Bool visible : 1; 914 Eina_Bool visible : 1;
903 Eina_Bool dirty : 1; 915 Eina_Bool dirty : 1;
904 } clip; 916 } clip;
@@ -957,6 +969,7 @@ struct _Evas_Object_Protected_Data
957 const Evas_Object_Proxy_Data *proxy; 969 const Evas_Object_Proxy_Data *proxy;
958 const Evas_Object_Map_Data *map; 970 const Evas_Object_Map_Data *map;
959 const Evas_Object_3D_Data *data_3d; 971 const Evas_Object_3D_Data *data_3d;
972 const Evas_Object_Mask_Data *mask;
960 973
961 // Pointer to the Evas_Object itself 974 // Pointer to the Evas_Object itself
962 Evas_Object *object; 975 Evas_Object *object;
@@ -1702,6 +1715,7 @@ void evas_render_invalidate(Evas *e);
1702void evas_render_object_recalc(Evas_Object *obj); 1715void evas_render_object_recalc(Evas_Object *obj);
1703void evas_render_proxy_subrender(Evas *eo_e, Evas_Object *eo_source, Evas_Object *eo_proxy, 1716void evas_render_proxy_subrender(Evas *eo_e, Evas_Object *eo_source, Evas_Object *eo_proxy,
1704 Evas_Object_Protected_Data *proxy_obj, Eina_Bool do_async); 1717 Evas_Object_Protected_Data *proxy_obj, Eina_Bool do_async);
1718void evas_render_mask_subrender(Evas_Public_Data *e, Evas_Object_Protected_Data *mask, Evas_Object_Protected_Data *prev_mask);
1705 1719
1706Eina_Bool evas_map_inside_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y); 1720Eina_Bool evas_map_inside_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y);
1707Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord *mx, Evas_Coord *my, int grab); 1721Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord *mx, Evas_Coord *my, int grab);
@@ -1734,6 +1748,7 @@ extern Eina_Cow *evas_object_image_state_cow;
1734extern Eina_Cow *evas_object_filter_cow; 1748extern Eina_Cow *evas_object_filter_cow;
1735// This should be replaced by something like "eina_cow_default_get()" maybe 1749// This should be replaced by something like "eina_cow_default_get()" maybe
1736extern const void * const evas_object_filter_cow_default; 1750extern const void * const evas_object_filter_cow_default;
1751extern Eina_Cow *evas_object_mask_cow;
1737 1752
1738# define EINA_COW_STATE_WRITE_BEGIN(Obj, Write, State) \ 1753# define EINA_COW_STATE_WRITE_BEGIN(Obj, Write, State) \
1739 EINA_COW_WRITE_BEGIN(evas_object_state_cow, Obj->State, \ 1754 EINA_COW_WRITE_BEGIN(evas_object_state_cow, Obj->State, \