summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/Makefile_Edje.am2
-rw-r--r--src/lib/ecore/ecore_main.c2
-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
7 files changed, 52 insertions, 30 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index cf7d9f2655..e1a1973430 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -5,7 +5,6 @@ edje_eolian_files = \
lib/edje/efl_canvas_layout_calc.eo \
lib/edje/efl_canvas_layout_signal.eo \
lib/edje/efl_canvas_layout_group.eo \
- lib/edje/edje_global.eo \
lib/edje/edje_object.eo \
lib/edje/efl_canvas_layout_part.eo \
lib/edje/efl_canvas_layout_part_box.eo \
@@ -19,6 +18,7 @@ edje_eolian_type_files = \
lib/edje/edje_types.eot
edje_eolian_priv_files = \
+ lib/edje/edje_global.eo \
$(NULL)
edje_eolian_c = $(edje_eolian_files:%.eo=%.eo.c)
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 4b7c93d79c..f85d2cdc0d 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -3056,7 +3056,7 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
efl_event_callback_array_add(obj, event_catcher_watch(), pd);
- pd->providers = eina_hash_pointer_new((void*) efl_unref);
+ pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
return obj;
}
diff --git a/src/lib/edje/edje_global.eo b/src/lib/edje/edje_global.eo
index 07ebba5130..f5001f2e73 100644
--- a/src/lib/edje/edje_global.eo
+++ b/src/lib/edje/edje_global.eo
@@ -1,5 +1,9 @@
class Edje.Global (Efl.Object, Efl.Gfx.Color_Class, Efl.Gfx.Text_Class, Efl.Gfx.Size_Class)
{
+ [[An internal object that manages global color, text and size classes for
+ the whole application. Individual edje objects also support the same
+ features.
+ ]]
data: null;
implements {
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 f5980cc67e..bd96acca4b 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;
Eina_Cow *_edje_calc_params_map_cow = NULL;
Eina_Cow *_edje_calc_params_physics_cow = NULL;
+Edje_Global *_edje_global_obj = NULL;
+
static const Edje_Calc_Params_Map default_calc_map = {
{ 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
};
@@ -82,6 +84,11 @@ edje_init(void)
_edje_scale = FROM_DOUBLE(1.0);
_edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, NULL);
+ if (!_edje_global_obj ||
+ !efl_loop_register(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj) ||
+ !efl_loop_register(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj) ||
+ !efl_loop_register(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj))
+ goto shutdown_efreet;
_edje_edd_init();
_edje_text_init();
@@ -141,8 +148,15 @@ shutdown_all:
_edje_text_class_hash_free();
_edje_size_class_hash_free();
_edje_edd_shutdown();
- efl_del(_edje_global_obj);
- _edje_global_obj = NULL;
+ if (_edje_global_obj)
+ {
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
+ efl_del(_edje_global_obj);
+ _edje_global_obj = NULL;
+ }
+shutdown_efreet:
efreet_shutdown();
shutdown_evas:
evas_shutdown();
@@ -195,6 +209,9 @@ _edje_shutdown_core(void)
_edje_text_class_hash_free();
_edje_size_class_hash_free();
_edje_edd_shutdown();
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
+ efl_loop_unregister(ecore_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
efl_del(_edje_global_obj);
_edje_global_obj = NULL;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 369dddc55a..5c6b7a629d 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -98,6 +98,9 @@
# endif
#endif
+// This object is internal, only the interface needs to be exposed.
+#include "edje_global.eo.h"
+
EAPI extern int _edje_default_log_dom ;
#ifdef EDJE_DEFAULT_LOG_COLOR
@@ -2348,8 +2351,6 @@ const Eina_Inarray *edje_match_signal_source_hash_get(const char *signal,
void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data);
void _edje_signal_callback_matches_unref(Edje_Signal_Callback_Matches *m);
-extern Edje_Global *_edje_global_obj;
-
// FIXME remove below 3 eapi decls when edje_convert goes
EAPI void _edje_edd_init(void);
EAPI 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;
EAPI extern Eina_Mempool *_emp_part;
EAPI extern Eina_Mempool *_emp_VECTOR;
+static inline Edje_Global *
+_edje_global(void)
+{
+#ifndef NDEBUG
+ return efl_provider_find(ecore_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE);
+#else
+ extern Edje_Global *_edje_global_obj;
+ return _edje_global_obj;
+#endif
+}
+
static inline void
_edje_calc_params_need_type_common(Edje_Calc_Params *p)
{
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index fd1e2470b2..733879c36a 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)
return 1.0/pd->duration_scale;
}
-EOLIAN static Efl_Object *
-_edje_object_efl_object_provider_find(Eo *obj, Edje *ed EINA_UNUSED, const Efl_Class *klass)
-{
- if (klass == EDJE_GLOBAL_CLASS)
- return _edje_global_obj;
-
- return efl_provider_find(efl_super(obj, EDJE_OBJECT_CLASS), klass);
-}
-
/* Internal EO APIs and hidden overrides */
#define EDJE_OBJECT_EXTRA_OPS \
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index da6d413411..da5c3cb069 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -16,8 +16,6 @@ struct _Edje_Box_Layout
char name[];
};
-Edje_Global *_edje_global_obj = NULL;
-
static Eina_Hash *_edje_color_class_hash = NULL;
static Eina_Hash *_edje_text_class_hash = NULL;
static 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
{
Eina_Bool int_ret = EINA_TRUE;
- int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
- int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
- int_ret &= efl_gfx_color_class_set(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
+ int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
+ int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
+ int_ret &= efl_gfx_color_class_set(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
return int_ret;
}
@@ -678,9 +676,9 @@ edje_color_class_get(const char *color_class, int *r, int *g, int *b, int *a, in
{
Eina_Bool int_ret = EINA_TRUE;
- int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
- int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
- int_ret &= efl_gfx_color_class_get(_edje_global_obj, color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
+ int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_NORMAL, r, g, b, a);
+ int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_OUTLINE, r2, g2, b2, a2);
+ int_ret &= efl_gfx_color_class_get(_edje_global(), color_class, EFL_GFX_COLOR_CLASS_LAYER_SHADOW, r3, g3, b3, a3);
return int_ret;
}
@@ -702,7 +700,7 @@ _edje_global_efl_gfx_color_class_color_class_get(Eo *obj EINA_UNUSED, void *pd E
EAPI void
edje_color_class_del(const char *color_class)
{
- efl_gfx_color_class_del(_edje_global_obj, color_class);
+ efl_gfx_color_class_del(_edje_global(), color_class);
}
EOLIAN void
@@ -1080,7 +1078,7 @@ on_error:
EAPI Eina_Bool
edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size)
{
- return efl_gfx_text_class_set(_edje_global_obj, text_class, font, (Efl_Font_Size)size);
+ return efl_gfx_text_class_set(_edje_global(), text_class, font, (Efl_Font_Size)size);
}
EOLIAN Eina_Bool
@@ -1131,7 +1129,7 @@ _edje_global_efl_gfx_text_class_text_class_set(Eo *obj EINA_UNUSED, void *pd EIN
EAPI Eina_Bool
edje_text_class_get(const char *text_class, const char **font, Evas_Font_Size *size)
{
- return efl_gfx_text_class_get(_edje_global_obj, text_class, font, (Efl_Font_Size *)size);
+ return efl_gfx_text_class_get(_edje_global(), text_class, font, (Efl_Font_Size *)size);
}
EOLIAN Eina_Bool
@@ -1162,7 +1160,7 @@ _edje_global_efl_gfx_text_class_text_class_get(Eo *obj EINA_UNUSED, void *pd EIN
EAPI void
edje_text_class_del(const char *text_class)
{
- efl_gfx_text_class_del(_edje_global_obj, text_class);
+ efl_gfx_text_class_del(_edje_global(), text_class);
}
EOLIAN void
@@ -1484,7 +1482,7 @@ on_error:
EAPI Eina_Bool
edje_size_class_set(const char *size_class, Evas_Coord minw, Evas_Coord minh, Evas_Coord maxw, Evas_Coord maxh)
{
- return efl_gfx_size_class_set(_edje_global_obj, size_class, minw, minh, maxw, maxh);
+ return efl_gfx_size_class_set(_edje_global(), size_class, minw, minh, maxw, maxh);
}
EOLIAN Eina_Bool
@@ -1538,7 +1536,7 @@ _edje_global_efl_gfx_size_class_size_class_set(Eo *obj EINA_UNUSED, void *pd EIN
EAPI Eina_Bool
edje_size_class_get(const char *size_class, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord *maxw, Evas_Coord *maxh)
{
- return efl_gfx_size_class_get(_edje_global_obj, size_class, minw, minh, maxw, maxh);
+ return efl_gfx_size_class_get(_edje_global(), size_class, minw, minh, maxw, maxh);
}
EOLIAN Eina_Bool
@@ -1573,7 +1571,7 @@ _edje_global_efl_gfx_size_class_size_class_get(Eo *obj EINA_UNUSED, void *pd EIN
EAPI void
edje_size_class_del(const char *size_class)
{
- efl_gfx_size_class_del(_edje_global_obj, size_class);
+ efl_gfx_size_class_del(_edje_global(), size_class);
}
EOLIAN void