summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-08 19:29:13 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-08 20:02:31 +0900
commitcc1ed7183c9ccab57ffd010338e781744fa424ad (patch)
tree4c6210bf10cb45e012fa5cfe0fd1c1c6480db5a6 /src/lib/edje
parent2f838acd4ef0f3f914bb5d03081aef2fd1f412b5 (diff)
edje: Hide edje_global from the rest of the world
Call provider_find on the loop (or basically any object) with the color/text/size class interface instead, to find it. The main loop is the main holder of those objects. Note: This makes use of provider_find instead of direct access to the variable, in order to self-test the code. In theory release builds will not do this and user directly the variable.
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_global.eo4
-rw-r--r--src/lib/edje/edje_main.c21
-rw-r--r--src/lib/edje/edje_private.h16
-rw-r--r--src/lib/edje/edje_smart.c9
-rw-r--r--src/lib/edje/edje_util.c28
5 files changed, 50 insertions, 28 deletions
diff --git a/src/lib/edje/edje_global.eo b/src/lib/edje/edje_global.eo
index 07ebba5..f5001f2 100644
--- a/src/lib/edje/edje_global.eo
+++ b/src/lib/edje/edje_global.eo
@@ -1,5 +1,9 @@
1class Edje.Global (Efl.Object, Efl.Gfx.Color_Class, Efl.Gfx.Text_Class, Efl.Gfx.Size_Class) 1class Edje.Global (Efl.Object, Efl.Gfx.Color_Class, Efl.Gfx.Text_Class, Efl.Gfx.Size_Class)
2{ 2{
3 [[An internal object that manages global color, text and size classes for
4 the whole application. Individual edje objects also support the same
5 features.
6 ]]
3 data: null; 7 data: null;
4 implements { 8 implements {
5 Efl.Gfx.Color_Class.color_class { get; set; } 9 Efl.Gfx.Color_Class.color_class { get; set; }
diff --git a/src/lib/edje/edje_main.c b/src/lib/edje/edje_main.c
index f5980cc..bd96acc 100644
--- a/src/lib/edje/edje_main.c
+++ b/src/lib/edje/edje_main.c
@@ -13,6 +13,8 @@ Eina_Mempool *_edje_real_part_state_mp = NULL;
13Eina_Cow *_edje_calc_params_map_cow = NULL; 13Eina_Cow *_edje_calc_params_map_cow = NULL;
14Eina_Cow *_edje_calc_params_physics_cow = NULL; 14Eina_Cow *_edje_calc_params_physics_cow = NULL;
15 15
16Edje_Global *_edje_global_obj = NULL;
17
16static const Edje_Calc_Params_Map default_calc_map = { 18static const Edje_Calc_Params_Map default_calc_map = {
17 { 0, 0, 0 }, { 0.0, 0.0, 0.0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0.0, 0.0 }, NULL, 0 19 { 0, 0, 0 }, { 0.0, 0.0, 0.0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0.0, 0.0 }, NULL, 0
18}; 20};
@@ -82,6 +84,11 @@ edje_init(void)
82 84
83 _edje_scale = FROM_DOUBLE(1.0); 85 _edje_scale = FROM_DOUBLE(1.0);
84 _edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, NULL); 86 _edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, NULL);
87 if (!_edje_global_obj ||
88 !efl_loop_register(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj) ||
89 !efl_loop_register(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj) ||
90 !efl_loop_register(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj))
91 goto shutdown_efreet;
85 92
86 _edje_edd_init(); 93 _edje_edd_init();
87 _edje_text_init(); 94 _edje_text_init();
@@ -141,8 +148,15 @@ shutdown_all:
141 _edje_text_class_hash_free(); 148 _edje_text_class_hash_free();
142 _edje_size_class_hash_free(); 149 _edje_size_class_hash_free();
143 _edje_edd_shutdown(); 150 _edje_edd_shutdown();
144 efl_del(_edje_global_obj); 151 if (_edje_global_obj)
145 _edje_global_obj = NULL; 152 {
153 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
154 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
155 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
156 efl_del(_edje_global_obj);
157 _edje_global_obj = NULL;
158 }
159shutdown_efreet:
146 efreet_shutdown(); 160 efreet_shutdown();
147shutdown_evas: 161shutdown_evas:
148 evas_shutdown(); 162 evas_shutdown();
@@ -195,6 +209,9 @@ _edje_shutdown_core(void)
195 _edje_text_class_hash_free(); 209 _edje_text_class_hash_free();
196 _edje_size_class_hash_free(); 210 _edje_size_class_hash_free();
197 _edje_edd_shutdown(); 211 _edje_edd_shutdown();
212 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
213 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
214 efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
198 efl_del(_edje_global_obj); 215 efl_del(_edje_global_obj);
199 _edje_global_obj = NULL; 216 _edje_global_obj = NULL;
200 217
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 369dddc..5c6b7a6 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -98,6 +98,9 @@
98# endif 98# endif
99#endif 99#endif
100 100
101// This object is internal, only the interface needs to be exposed.
102#include "edje_global.eo.h"
103
101EAPI extern int _edje_default_log_dom ; 104EAPI extern int _edje_default_log_dom ;
102 105
103#ifdef EDJE_DEFAULT_LOG_COLOR 106#ifdef EDJE_DEFAULT_LOG_COLOR
@@ -2348,8 +2351,6 @@ const Eina_Inarray *edje_match_signal_source_hash_get(const char *signal,
2348void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data); 2351void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data);
2349void _edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m); 2352void _edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m);
2350 2353
2351extern Edje_Global *_edje_global_obj;
2352
2353// FIXME remove below 3 eapi decls when edje_convert goes 2354// FIXME remove below 3 eapi decls when edje_convert goes
2354EAPI void _edje_edd_init(void); 2355EAPI void _edje_edd_init(void);
2355EAPI void _edje_data_font_list_desc_make(Eet_Data_Descriptor **_font_list_edd, Eet_Data_Descriptor **_font_edd); 2356EAPI void _edje_data_font_list_desc_make(Eet_Data_Descriptor **_font_list_edd, Eet_Data_Descriptor **_font_edd);
@@ -2399,6 +2400,17 @@ EAPI extern Eina_Mempool *_emp_SNAPSHOT;
2399EAPI extern Eina_Mempool *_emp_part; 2400EAPI extern Eina_Mempool *_emp_part;
2400EAPI extern Eina_Mempool *_emp_VECTOR; 2401EAPI extern Eina_Mempool *_emp_VECTOR;
2401 2402
2403static inline Edje_Global *
2404_edje_global(void)
2405{
2406#ifndef NDEBUG
2407 return efl_provider_find(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE);
2408#else
2409 extern Edje_Global *_edje_global_obj;
2410 return _edje_global_obj;
2411#endif
2412}
2413
2402static inline void 2414static inline void
2403_edje_calc_params_need_type_common(Edje_Calc_Params *p) 2415_edje_calc_params_need_type_common(Edje_Calc_Params *p)
2404{ 2416{
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index fd1e247..733879c 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -536,15 +536,6 @@ _edje_object_efl_player_play_speed_get(Eo *obj EINA_UNUSED, Edje *pd)
536 return 1.0/pd->duration_scale; 536 return 1.0/pd->duration_scale;
537} 537}
538 538
539EOLIAN static Efl_Object *
540_edje_object_efl_object_provider_find(Eo *obj, Edje *ed EINA_UNUSED, const Efl_Class *klass)
541{
542 if (klass == EDJE_GLOBAL_CLASS)
543 return _edje_global_obj;
544
545 return efl_provider_find(efl_super(obj, EDJE_OBJECT_CLASS), klass);
546}
547
548/* Internal EO APIs and hidden overrides */ 539/* Internal EO APIs and hidden overrides */
549 540
550#define EDJE_OBJECT_EXTRA_OPS \ 541#define EDJE_OBJECT_EXTRA_OPS \
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index da6d413..da5c3cb 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -16,8 +16,6 @@ struct _Edje_Box_Layout
16 char name[]; 16 char name[];
17}; 17};
18 18
19Edje_Global *_edje_global_obj = NULL;
20
21static Eina_Hash *_edje_color_class_hash = NULL; 19static Eina_Hash *_edje_color_class_hash = NULL;
22static Eina_Hash *_edje_text_class_hash = NULL; 20static Eina_Hash *_edje_text_class_hash = NULL;
23static Eina_Hash *_edje_size_class_hash = NULL; 21static Eina_Hash *_edje_size_class_hash = NULL;
@@ -648,9 +646,9 @@ edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2
648{ 646{
649 Eina_Bool int_ret = EINA_TRUE; 647 Eina_Bool int_ret = EINA_TRUE;
650 648
651 int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a); 649 int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
652 int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2); 650 int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
653 int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3); 651 int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
654 652
655 return int_ret; 653 return int_ret;
656} 654}
@@ -678,9 +676,9 @@ edje_color_class_get(const char *color_class, int *r, int *g, int *b, int *a, in
678{ 676{
679 Eina_Bool int_ret = EINA_TRUE; 677 Eina_Bool int_ret = EINA_TRUE;
680 678
681 int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a); 679 int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
682 int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2); 680 int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
683 int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3); 681 int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
684 682
685 return int_ret; 683 return int_ret;
686} 684}
@@ -702,7 +700,7 @@ _edje_global_efl_gfx_color_class_color_class_get(Eo *obj EINA_UNUSED, void *pd E
702EAPI void 700EAPI void
703edje_color_class_del(const char *color_class) 701edje_color_class_del(const char *color_class)
704{ 702{
705 efl_gfx_color_class_del(_edje_global_obj, color_class); 703 efl_gfx_color_class_del(_edje_global(), color_class);
706} 704}
707 705
708EOLIAN void 706EOLIAN void
@@ -1080,7 +1078,7 @@ on_error:
1080EAPI Eina_Bool 1078EAPI Eina_Bool
1081edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size) 1079edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size)
1082{ 1080{
1083 return efl_gfx_text_class_set(_edje_global_obj, text_class, font, (Efl_Font_Size)size); 1081 return efl_gfx_text_class_set(_edje_global(), text_class, font, (Efl_Font_Size)size);
1084} 1082}
1085 1083
1086EOLIAN Eina_Bool 1084EOLIAN Eina_Bool
@@ -1131,7 +1129,7 @@ _edje_global_efl_gfx_text_class_text_class_set(Eo *obj EINA_UNUSED, void *pd EIN
1131EAPI Eina_Bool 1129EAPI Eina_Bool
1132edje_text_class_get(const char *text_class, const char **font, Evas_Font_Size *size) 1130edje_text_class_get(const char *text_class, const char **font, Evas_Font_Size *size)
1133{ 1131{
1134 return efl_gfx_text_class_get(_edje_global_obj, text_class, font, (Efl_Font_Size *)size); 1132 return efl_gfx_text_class_get(_edje_global(), text_class, font, (Efl_Font_Size *)size);
1135} 1133}
1136 1134
1137EOLIAN Eina_Bool 1135EOLIAN Eina_Bool
@@ -1162,7 +1160,7 @@ _edje_global_efl_gfx_text_class_text_class_get(Eo *obj EINA_UNUSED, void *pd EIN
1162EAPI void 1160EAPI void
1163edje_text_class_del(const char *text_class) 1161edje_text_class_del(const char *text_class)
1164{ 1162{
1165 efl_gfx_text_class_del(_edje_global_obj, text_class); 1163 efl_gfx_text_class_del(_edje_global(), text_class);
1166} 1164}
1167 1165
1168EOLIAN void 1166EOLIAN void
@@ -1484,7 +1482,7 @@ on_error:
1484EAPI Eina_Bool 1482EAPI Eina_Bool
1485edje_size_class_set(const char *size_class, Evas_Coord minw, Evas_Coord minh, Evas_Coord maxw, Evas_Coord maxh) 1483edje_size_class_set(const char *size_class, Evas_Coord minw, Evas_Coord minh, Evas_Coord maxw, Evas_Coord maxh)
1486{ 1484{
1487 return efl_gfx_size_class_set(_edje_global_obj, size_class, minw, minh, maxw, maxh); 1485 return efl_gfx_size_class_set(_edje_global(), size_class, minw, minh, maxw, maxh);
1488} 1486}
1489 1487
1490EOLIAN Eina_Bool 1488EOLIAN Eina_Bool
@@ -1538,7 +1536,7 @@ _edje_global_efl_gfx_size_class_size_class_set(Eo *obj EINA_UNUSED, void *pd EIN
1538EAPI Eina_Bool 1536EAPI Eina_Bool
1539edje_size_class_get(const char *size_class, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord *maxw, Evas_Coord *maxh) 1537edje_size_class_get(const char *size_class, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord *maxw, Evas_Coord *maxh)
1540{ 1538{
1541 return efl_gfx_size_class_get(_edje_global_obj, size_class, minw, minh, maxw, maxh); 1539 return efl_gfx_size_class_get(_edje_global(), size_class, minw, minh, maxw, maxh);
1542} 1540}
1543 1541
1544EOLIAN Eina_Bool 1542EOLIAN Eina_Bool
@@ -1573,7 +1571,7 @@ _edje_global_efl_gfx_size_class_size_class_get(Eo *obj EINA_UNUSED, void *pd EIN
1573EAPI void 1571EAPI void
1574edje_size_class_del(const char *size_class) 1572edje_size_class_del(const char *size_class)
1575{ 1573{
1576 efl_gfx_size_class_del(_edje_global_obj, size_class); 1574 efl_gfx_size_class_del(_edje_global(), size_class);
1577} 1575}
1578 1576
1579EOLIAN void 1577EOLIAN void