summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJi-Youn Park <jy0703.park@samsung.com>2016-03-16 15:28:35 +0830
committerJi-Youn Park <jy0703.park@samsung.com>2016-03-17 16:50:44 +0830
commitd919bf08338e0705c2d7b8b5ea9708408f6e5152 (patch)
treea2bc6efc93357c821209d323e9ed0de214409045
parent1f5331c99e6bf9b9c13666be873f91fc7d3445cc (diff)
downloadelementary-d919bf08338e0705c2d7b8b5ea9708408f6e5152.tar.gz
elm_glview: eo-fication for set function
remove elm_glveiw_XXX_set function and create event render_set-render init_set->created resize_set-> resized del_set -> destroyed
-rw-r--r--src/lib/elm_glview.c95
-rw-r--r--src/lib/elm_glview.eo83
2 files changed, 95 insertions, 83 deletions
diff --git a/src/lib/elm_glview.c b/src/lib/elm_glview.c
index 87571d46e..31d54f29e 100644
--- a/src/lib/elm_glview.c
+++ b/src/lib/elm_glview.c
@@ -128,12 +128,16 @@ _render_cb(void *obj)
// Call the init function if it hasn't been called already
if (!sd->initialized)
{
+ //TODO:will be optimized
+ eo_event_callback_call(obj, ELM_GLVIEW_EVENT_CREATED, NULL);
if (sd->init_func) sd->init_func(obj);
sd->initialized = EINA_TRUE;
}
if (sd->resized)
{
+ //TODO:will be optimized
+ eo_event_callback_call(obj, ELM_GLVIEW_EVENT_RESIZED, NULL);
if (sd->resize_func) sd->resize_func(obj);
sd->resized = EINA_FALSE;
}
@@ -142,6 +146,8 @@ _render_cb(void *obj)
evas_sync(evas_object_evas_get(obj));
// Call the render function
if (sd->render_func) sd->render_func(obj);
+ //TODO:will be optimized
+ eo_event_callback_call(obj, ELM_GLVIEW_EVENT_RENDER, NULL);
// Depending on the policy return true or false
if (sd->render_policy == ELM_GLVIEW_RENDER_POLICY_ON_DEMAND)
@@ -276,6 +282,8 @@ _elm_glview_evas_object_smart_del(Eo *obj, Elm_Glview_Data *sd)
evas_gl_make_current(sd->evasgl, sd->surface, sd->context);
sd->del_func(obj);
}
+ //TODO:will be optimised
+ eo_event_callback_call(obj, ELM_GLVIEW_EVENT_DESTROYED, NULL);
ecore_idle_enterer_del(sd->render_idle_enterer);
evas_gl_make_current(sd->evasgl, NULL, NULL);
@@ -292,6 +300,25 @@ _elm_glview_evas_object_smart_del(Eo *obj, Elm_Glview_Data *sd)
evas_obj_smart_del(eo_super(obj, MY_CLASS));
}
+static Eina_Bool
+_cb_added(void *data EINA_UNUSED, const Eo_Event *ev)
+{
+ const Eo_Callback_Array_Item *event = ev->event_info;
+
+ ELM_GLVIEW_DATA_GET(ev->obj, sd);
+
+ if (event->desc == ELM_GLVIEW_EVENT_CREATED)
+ {
+ sd->initialized = EINA_FALSE;
+ }
+ else if (event->desc == ELM_GLVIEW_EVENT_RENDER)
+ {
+ _set_render_policy_callback(ev->obj);
+ }
+
+ return EO_CALLBACK_CONTINUE;
+}
+
EAPI Evas_Object *
elm_glview_add(Evas_Object *parent)
{
@@ -319,6 +346,7 @@ _elm_glview_version_constructor(Eo *obj, Elm_Glview_Data *sd,
evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_ANIMATION);
+ eo_event_callback_add(obj, EO_BASE_EVENT_CALLBACK_ADD, _cb_added, NULL);
}
EOLIAN static Eo *
@@ -481,32 +509,6 @@ _elm_glview_efl_gfx_view_view_size_get(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd,
}
EOLIAN static void
-_elm_glview_init_func_set(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd, Elm_GLView_Func_Cb func)
-{
- sd->initialized = EINA_FALSE;
- sd->init_func = func;
-}
-
-EOLIAN static void
-_elm_glview_del_func_set(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd, Elm_GLView_Func_Cb func)
-{
- sd->del_func = func;
-}
-
-EOLIAN static void
-_elm_glview_resize_func_set(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd, Elm_GLView_Func_Cb func)
-{
- sd->resize_func = func;
-}
-
-EOLIAN static void
-_elm_glview_render_func_set(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd, Elm_GLView_Func_Cb func)
-{
- sd->render_func = func;
- _set_render_policy_callback(obj);
-}
-
-EOLIAN static void
_elm_glview_draw_request(Eo *obj, Elm_Glview_Data *sd)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
@@ -537,8 +539,7 @@ _elm_glview_class_constructor(Eo_Class *klass)
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}
-/* Legacy wrappers */
-
+/* Legacy deprecated functions */
EAPI void
elm_glview_changed_set(Evas_Object *obj)
{
@@ -558,4 +559,42 @@ elm_glview_size_set(Elm_Glview *obj, int w, int h)
{
efl_gfx_view_size_set(obj, w, h);
}
+
+EAPI void
+elm_glview_init_func_set(Elm_Glview *obj, Elm_GLView_Func_Cb func)
+{
+ ELM_GLVIEW_CHECK(obj);
+ ELM_GLVIEW_DATA_GET(obj, sd);
+
+ sd->initialized = EINA_FALSE;
+ sd->init_func = func;
+}
+
+EAPI void
+elm_glview_del_func_set(Elm_Glview *obj, Elm_GLView_Func_Cb func)
+{
+ ELM_GLVIEW_CHECK(obj);
+ ELM_GLVIEW_DATA_GET(obj, sd);
+
+ sd->del_func = func;
+}
+
+EAPI void
+elm_glview_resize_func_set(Elm_Glview *obj, Elm_GLView_Func_Cb func)
+{
+ ELM_GLVIEW_CHECK(obj);
+ ELM_GLVIEW_DATA_GET(obj, sd);
+
+ sd->resize_func = func;
+}
+
+EAPI void
+elm_glview_render_func_set(Elm_Glview *obj, Elm_GLView_Func_Cb func)
+{
+ ELM_GLVIEW_CHECK(obj);
+ ELM_GLVIEW_DATA_GET(obj, sd);
+
+ sd->render_func = func;
+ _set_render_policy_callback(obj);
+}
#include "elm_glview.eo.c"
diff --git a/src/lib/elm_glview.eo b/src/lib/elm_glview.eo
index 7548a824d..42c4c0164 100644
--- a/src/lib/elm_glview.eo
+++ b/src/lib/elm_glview.eo
@@ -104,48 +104,6 @@ class Elm.Glview (Elm.Widget, Efl.Gfx.View)
policy: Elm.GLView.Resize.Policy; [[The scaling policy.]]
}
}
- @property resize_func {
- set {
- [[Set the resize function that gets called when resize happens.
-
- The resize function gets called during the render loop.
- This function allows glview to hide all the rendering
- context/surface details and have the user just call GL
- alls that they desire when resize happens.
- ]]
- }
- values {
- func: Elm_GLView_Func_Cb; [[The resize function to be registered.]]
- }
- }
- @property del_func {
- set {
- [[Set the render function that runs in the main loop.
-
- The registered del function gets called when GLView object
- is deleted. This function allows glview to hide all the
- rendering context/surface details and have the user just
- call GL calls that they desire when delete happens.
- ]]
- }
- values {
- func: Elm_GLView_Func_Cb @nullable; [[The delete function to be registered.]]
- }
- }
- @property init_func {
- set {
- [[Set the init function that runs once in the main loop.
-
- The registered init function gets called once during the
- render loop. This function allows glview to hide all the
- rendering context/surface details and have the user just
- call GL calls that they desire for initialization GL calls.
- ]]
- }
- values {
- func: Elm_GLView_Func_Cb @nullable; [[The init function to be registered.]]
- }
- }
@property render_policy {
set {
[[Set the render policy for the glview object.
@@ -179,19 +137,6 @@ class Elm.Glview (Elm.Widget, Efl.Gfx.View)
mode: Elm.GLView.Mode; [[The mode Options OR'ed enabling Alpha, Depth, Stencil, Direct.]]
}
}
- @property render_func {
- set {
- [[Set the render function that runs in the main loop.
-
- The render function gets called in the main loop but whether
- it runs depends on the rendering policy and whether
- @.draw_request called.
- ]]
- }
- values {
- func: Elm_GLView_Func_Cb @nullable; [[The render function to be registered.]]
- }
- }
@property gl_api {
get {
[[Get the gl api struct for gl rendering.]]
@@ -241,6 +186,34 @@ class Elm.Glview (Elm.Widget, Efl.Gfx.View)
Efl.Gfx.View.view_size.set;
}
events {
+ created; [[Event dispatched when first render happens.
+
+ The callback function gets called once during the
+ render loop. Callback function allows glview to hide all the
+ rendering context/surface details and have the user just
+ call GL calls that they desire for initialization GL calls.
+ ]]
+ destroyed; [[Event dispatched when GLView object is deleted.
+
+ The registered destroyed function gets called when GLView object
+ is deleted. Callback function allows glview to hide all the
+ rendering context/surface details and have the user just
+ call GL calls that they desire when delete happens.
+ ]]
+ resized; [[Event dispatched when resize happens.
+
+ The resized event callback functions gets called
+ during the render loop. The callback function allows
+ glview to hide all the rendering context/surface
+ details and have the user just call GL alls that
+ they desire when resize happens.
+ ]]
+ render; [[Event dispatched when GLView is rendered.
+
+ The callback function gets called in the main loop but whether
+ it runs depends on the rendering policy and whether
+ @.draw_request gets called.
+ ]]
}
constructors {
.version_constructor;