summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 16:43:15 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 18:50:58 +0900
commitba43e12722bcdaef38ceb82fcd7eada7802ff11d (patch)
tree6934321b7ea20bab734a5c0849651a31872835b0
parentdf375ca395c669192c4a8ee7b88e3fbdb93f7901 (diff)
Edje: cache proxy objects (1 slot only)
Also, fix calls to a proxy obj from a proxy function.
-rw-r--r--src/lib/edje/edje_containers.c148
-rw-r--r--src/lib/edje/edje_main.c1
-rw-r--r--src/lib/edje/edje_private.h2
3 files changed, 132 insertions, 19 deletions
diff --git a/src/lib/edje/edje_containers.c b/src/lib/edje/edje_containers.c
index b4a134c1c4..037af612b2 100644
--- a/src/lib/edje/edje_containers.c
+++ b/src/lib/edje/edje_containers.c
@@ -21,7 +21,7 @@ struct _Edje_Part_Data
21 Edje *ed; 21 Edje *ed;
22 Edje_Real_Part *rp; 22 Edje_Real_Part *rp;
23 const char *part; 23 const char *part;
24 Eina_Bool temp; 24 unsigned char temp;
25}; 25};
26 26
27struct _Part_Item_Iterator 27struct _Part_Item_Iterator
@@ -32,24 +32,90 @@ struct _Part_Item_Iterator
32 Eo *object; 32 Eo *object;
33}; 33};
34 34
35#define RETURN_VAL(a) do { typeof(a) _ret = a; if (pd->temp) { pd->temp = 0; eo_unref(obj); } return _ret; } while(0) 35#define PROXY_REF(obj, pd) do { if (!(pd->temp++)) eo_ref(obj); } while(0)
36#define RETURN_VOID do { if (pd->temp) { pd->temp = 0; eo_unref(obj); } return; } while(0) 36#define PROXY_UNREF(obj, pd) do { if (pd->temp) { if (!(--pd->temp)) eo_unref(obj); } } while(0)
37#define RETURN_VAL(a) do { typeof(a) _ret = a; PROXY_UNREF(obj, pd); return _ret; } while(0)
38#define RETURN_VOID do { PROXY_UNREF(obj, pd); return; } while(0)
39#define PROXY_CALL(a) ({ PROXY_REF(obj, pd); a; })
40
41static Eo *_box_proxy = NULL;
42static Eo *_table_proxy = NULL;
43
44void
45_edje_internal_proxy_shutdown(void)
46{
47 if (_box_proxy)
48 {
49 eo_del_intercept_set(_box_proxy, NULL);
50 eo_unref(_box_proxy);
51 _box_proxy = NULL;
52 }
53 if (_table_proxy)
54 {
55 eo_del_intercept_set(_table_proxy, NULL);
56 eo_unref(_table_proxy);
57 _table_proxy = NULL;
58 }
59}
60
61static void
62_box_del_cb(Eo *proxy)
63{
64 if (_box_proxy)
65 {
66 eo_del_intercept_set(proxy, NULL);
67 eo_unref(proxy);
68 return;
69 }
70 if (eo_parent_get(proxy))
71 {
72 eo_ref(proxy);
73 eo_parent_set(proxy, NULL);
74 }
75 _box_proxy = proxy;
76}
37 77
38Eo * 78Eo *
39_edje_box_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp) 79_edje_box_internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Edje_Real_Part *rp)
40{ 80{
41 // TODO: optimize (cache) 81 Edje_Box_Data *pd;
42 return eo_add(BOX_CLASS, obj, 82 Eo *proxy;
43 efl_canvas_layout_internal_box_real_part_set(eo_self, ed, rp, rp->part->name)); 83
84 pd = eo_data_scope_get(_box_proxy, BOX_CLASS);
85 if (!pd)
86 {
87 if (_box_proxy)
88 {
89 ERR("Found invalid handle for efl_part. Reset.");
90 _box_proxy = NULL;
91 }
92 return eo_add
93 (BOX_CLASS, ed->obj,
94 efl_canvas_layout_internal_box_real_part_set(eo_self, ed, rp, rp->part->name));
95 }
96 if (EINA_UNLIKELY(pd->temp))
97 {
98 /* warn about misuse, since non-implemented functions may trigger this
99 * misuse by accident. */
100 ERR("Misuse of efl_part detected. Handles returned by efl_part() are "
101 "valid for a single function call! Did you call a non implemented "
102 "function?");
103 }
104 proxy = _box_proxy;
105 _box_proxy = NULL;
106 efl_canvas_layout_internal_box_real_part_set(proxy, ed, rp, rp->part->name);
107 return proxy;
44} 108}
45 109
46EOLIAN static void 110EOLIAN static void
47_efl_canvas_layout_internal_box_real_part_set(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, void *ed, void *rp, const char *part) 111_efl_canvas_layout_internal_box_real_part_set(Eo *obj, Edje_Box_Data *pd, void *ed, void *rp, const char *part)
48{ 112{
49 pd->ed = ed; 113 pd->ed = ed;
50 pd->rp = rp; 114 pd->rp = rp;
51 pd->part = part; 115 pd->part = part;
52 pd->temp = EINA_TRUE; 116 pd->temp = 1;
117 eo_del_intercept_set(obj, _box_del_cb);
118 eo_parent_set(obj, pd->ed->obj);
53} 119}
54 120
55EOLIAN static Eo_Base * 121EOLIAN static Eo_Base *
@@ -114,7 +180,7 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_after(Eo *obj, Edje_Box_Dat
114EOLIAN static Eina_Bool 180EOLIAN static Eina_Bool
115_efl_canvas_layout_internal_box_efl_pack_linear_pack_at(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj, int index) 181_efl_canvas_layout_internal_box_efl_pack_linear_pack_at(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj, int index)
116{ 182{
117 int cnt = efl_content_count(obj); 183 int cnt = PROXY_CALL(efl_content_count(obj));
118 if ((index < 0) && ((-index) <= (cnt + 1))) 184 if ((index < 0) && ((-index) <= (cnt + 1)))
119 index = cnt + index + 1; 185 index = cnt + index + 1;
120 if ((index >= 0) && (index < cnt)) 186 if ((index >= 0) && (index < cnt))
@@ -126,7 +192,7 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_at(Eo *obj, Edje_Box_Data *
126EOLIAN static Efl_Gfx * 192EOLIAN static Efl_Gfx *
127_efl_canvas_layout_internal_box_efl_pack_linear_pack_unpack_at(Eo *obj, Edje_Box_Data *pd, int index) 193_efl_canvas_layout_internal_box_efl_pack_linear_pack_unpack_at(Eo *obj, Edje_Box_Data *pd, int index)
128{ 194{
129 if (index < 0) index += efl_content_count(obj); 195 if (index < 0) index += PROXY_CALL(efl_content_count(obj));
130 RETURN_VAL(_edje_part_box_remove_at(pd->ed, pd->part, index)); 196 RETURN_VAL(_edje_part_box_remove_at(pd->ed, pd->part, index));
131} 197}
132 198
@@ -135,14 +201,14 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_unpack_at(Eo *obj, Edje_Box
135EOLIAN static Efl_Gfx * 201EOLIAN static Efl_Gfx *
136_efl_canvas_layout_internal_box_efl_pack_linear_pack_content_get(Eo *obj, Edje_Box_Data *pd, int index) 202_efl_canvas_layout_internal_box_efl_pack_linear_pack_content_get(Eo *obj, Edje_Box_Data *pd, int index)
137{ 203{
138 if (index < 0) index += efl_content_count(obj); 204 if (index < 0) index += PROXY_CALL(efl_content_count(obj));
139 RETURN_VAL(_edje_part_box_content_at(pd->ed, pd->part, index)); 205 RETURN_VAL(_edje_part_box_content_at(pd->ed, pd->part, index));
140} 206}
141 207
142EOLIAN static Eina_Bool 208EOLIAN static Eina_Bool
143_efl_canvas_layout_internal_box_efl_container_content_remove(Eo *obj, Edje_Box_Data *pd EINA_UNUSED, Efl_Gfx *subobj) 209_efl_canvas_layout_internal_box_efl_container_content_remove(Eo *obj, Edje_Box_Data *pd EINA_UNUSED, Efl_Gfx *subobj)
144{ 210{
145 RETURN_VAL(efl_pack_unpack(obj, subobj)); 211 RETURN_VAL(PROXY_CALL(efl_pack_unpack(obj, subobj)));
146} 212}
147 213
148EOLIAN static int 214EOLIAN static int
@@ -249,12 +315,54 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_direction_get(Eo *obj, Edje
249 315
250/* Table */ 316/* Table */
251 317
318static void
319_table_del_cb(Eo *proxy)
320{
321 if (_table_proxy)
322 {
323 eo_del_intercept_set(proxy, NULL);
324 eo_unref(proxy);
325 return;
326 }
327 if (eo_parent_get(proxy))
328 {
329 eo_ref(proxy);
330 eo_parent_set(proxy, NULL);
331 }
332 _table_proxy = proxy;
333}
334
252Eo * 335Eo *
253_edje_table_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp) 336_edje_table_internal_proxy_get(Edje_Object *obj EINA_UNUSED, Edje *ed, Edje_Real_Part *rp)
254{ 337{
255 // TODO: optimize (cache) 338 Edje_Box_Data *pd;
256 return eo_add(TABLE_CLASS, obj, 339 Eo *proxy;
257 efl_canvas_layout_internal_table_real_part_set(eo_self, ed, rp, rp->part->name)); 340
341 pd = eo_data_scope_get(_table_proxy, TABLE_CLASS);
342 if (!pd)
343 {
344 if (_table_proxy)
345 {
346 ERR("Found invalid handle for efl_part. Reset.");
347 _table_proxy = NULL;
348 }
349 return eo_add
350 (TABLE_CLASS, ed->obj,
351 efl_canvas_layout_internal_table_real_part_set(eo_self, ed, rp, rp->part->name));
352 }
353
354 if (EINA_UNLIKELY(pd->temp))
355 {
356 /* warn about misuse, since non-implemented functions may trigger this
357 * misuse by accident. */
358 ERR("Misuse of efl_part detected. Handles returned by efl_part() are "
359 "valid for a single function call! Did you call a non implemented "
360 "function?");
361 }
362 proxy = _table_proxy;
363 _table_proxy = NULL;
364 efl_canvas_layout_internal_table_real_part_set(proxy, ed, rp, rp->part->name);
365 return proxy;
258} 366}
259 367
260EOLIAN static void 368EOLIAN static void
@@ -263,7 +371,9 @@ _efl_canvas_layout_internal_table_real_part_set(Eo *obj EINA_UNUSED, Edje_Table_
263 pd->ed = ed; 371 pd->ed = ed;
264 pd->rp = rp; 372 pd->rp = rp;
265 pd->part = part; 373 pd->part = part;
266 pd->temp = EINA_TRUE; 374 pd->temp = 1;
375 eo_del_intercept_set(obj, _table_del_cb);
376 eo_parent_set(obj, pd->ed->obj);
267} 377}
268 378
269EOLIAN static Eo_Base * 379EOLIAN static Eo_Base *
@@ -293,7 +403,7 @@ _efl_canvas_layout_internal_table_efl_container_content_count(Eo *obj, Edje_Tabl
293EOLIAN static Eina_Bool 403EOLIAN static Eina_Bool
294_efl_canvas_layout_internal_table_efl_container_content_remove(Eo *obj, Edje_Table_Data *pd EINA_UNUSED, Efl_Gfx *content) 404_efl_canvas_layout_internal_table_efl_container_content_remove(Eo *obj, Edje_Table_Data *pd EINA_UNUSED, Efl_Gfx *content)
295{ 405{
296 RETURN_VAL(efl_pack_unpack(obj, content)); 406 RETURN_VAL(PROXY_CALL(efl_pack_unpack(obj, content)));
297} 407}
298 408
299EOLIAN static Eina_Bool 409EOLIAN static Eina_Bool
diff --git a/src/lib/edje/edje_main.c b/src/lib/edje/edje_main.c
index f46be4802d..13809e6a2c 100644
--- a/src/lib/edje/edje_main.c
+++ b/src/lib/edje/edje_main.c
@@ -129,6 +129,7 @@ shutdown_all:
129 _edje_module_shutdown(); 129 _edje_module_shutdown();
130 _edje_external_shutdown(); 130 _edje_external_shutdown();
131 _edje_box_shutdown(); 131 _edje_box_shutdown();
132 _edje_internal_proxy_shutdown();
132 _edje_text_class_members_free(); 133 _edje_text_class_members_free();
133 _edje_text_class_hash_free(); 134 _edje_text_class_hash_free();
134 _edje_size_class_members_free(); 135 _edje_size_class_members_free();
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 604e7a4ca7..d307ea6974 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -2959,6 +2959,8 @@ Eina_Bool _edje_part_table_unpack(Edje *ed, const char *part, Evas_Object *child
2959Eina_Bool _edje_part_table_col_row_size_get(Edje *ed, const char *part, int *cols, int *rows); 2959Eina_Bool _edje_part_table_col_row_size_get(Edje *ed, const char *part, int *cols, int *rows);
2960Eina_Bool _edje_part_table_clear(Edje *ed, const char *part, Eina_Bool clear); 2960Eina_Bool _edje_part_table_clear(Edje *ed, const char *part, Eina_Bool clear);
2961 2961
2962void _edje_internal_proxy_shutdown(void);
2963
2962#ifdef HAVE_LIBREMIX 2964#ifdef HAVE_LIBREMIX
2963#include <remix/remix.h> 2965#include <remix/remix.h>
2964#endif 2966#endif