From 9883831b761c9a7e4681a259487fbfd07d1a0d9f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 13 Apr 2017 15:25:29 -0700 Subject: [PATCH] evas: move Efl_Canvas_Output to be an internal only API. --- src/Makefile_Evas.am | 2 +- src/lib/evas/Evas_Common.h | 4 - src/lib/evas/Evas_Internal.h | 56 +++++++ src/lib/evas/canvas/efl_canvas_output.eo | 55 ------- src/lib/evas/canvas/evas_main.c | 4 +- src/lib/evas/canvas/evas_out.c | 178 ++++++++++----------- src/lib/evas/include/evas_common_private.h | 2 + 7 files changed, 147 insertions(+), 154 deletions(-) create mode 100644 src/lib/evas/Evas_Internal.h delete mode 100644 src/lib/evas/canvas/efl_canvas_output.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index b2f4885fce..a1f37892be 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -50,7 +50,6 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_input_hold.eo \ lib/evas/canvas/efl_input_focus.eo \ lib/evas/canvas/efl_gfx_map.eo \ - lib/evas/canvas/efl_canvas_output.eo \ $(NULL) evas_eolian_legacy_files = \ @@ -114,6 +113,7 @@ dist_installed_evascanvasheaders_DATA = lib/evas/canvas/evas_textblock_legacy.h noinst_DATA += $(evas_eolian_priv_h) noinst_HEADERS += \ +lib/evas/Evas_Internal.h \ lib/evas/include/evas_inline.x \ lib/evas/include/evas_private.h \ lib/evas/include/evas_options.h \ diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 59f11a09c5..0844260971 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3569,10 +3569,6 @@ EAPI Eina_Bool evas_seat_key_lock_is_set(const Evas_Lock *l, const ch * @ingroup Evas_Canvas */ -typedef Eo Evas_Out; - -#define _EVAS_OUT_EO_CLASS_TYPE - /** * @ingroup Evas_Font_Group * diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h new file mode 100644 index 0000000000..79a1806ee6 --- /dev/null +++ b/src/lib/evas/Evas_Internal.h @@ -0,0 +1,56 @@ +/* This header is not to be installed and should only be used by EFL internals */ +#ifndef _EVAS_INTERNAL_H +#define _EVAS_INTERNAL_H + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_EVAS_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EVAS_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif /* ! _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _Efl_Canvas_Output Efl_Canvas_Output; + +EAPI Efl_Canvas_Output *efl_canvas_output_add(Evas *canvas); +EAPI void efl_canvas_output_del(Efl_Canvas_Output *output); +EAPI void efl_canvas_output_view_set(Efl_Canvas_Output *output, + Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); +EAPI void efl_canvas_output_view_get(Efl_Canvas_Output *output, + Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); +EAPI Eina_Bool efl_canvas_output_engine_info_set(Efl_Canvas_Output *output, + Evas_Engine_Info *info); +EAPI Evas_Engine_Info *efl_canvas_output_engine_info_get(Efl_Canvas_Output *output); +EAPI Eina_Bool efl_canvas_output_lock(Efl_Canvas_Output *output); +EAPI Eina_Bool efl_canvas_output_unlock(Efl_Canvas_Output *output); + +#ifdef __cplusplus +} +#endif + +#undef EAPI +#define EAPI + +#endif diff --git a/src/lib/evas/canvas/efl_canvas_output.eo b/src/lib/evas/canvas/efl_canvas_output.eo deleted file mode 100644 index 3e1441f053..0000000000 --- a/src/lib/evas/canvas/efl_canvas_output.eo +++ /dev/null @@ -1,55 +0,0 @@ -import evas_types; - -class Efl.Canvas.Output (Efl.Object, Efl.Gfx.Buffer) -{ - [[Efl canvas output class]] - methods { - @property view { - set { - [[Sets the viewport region of the canvas that the output displays. - - This sets both the viewport region in the canvas that displays - on the given output, but also the viewport size will match the - output resolution 1:1.]] - } - get { - [[Gets the viewport region of the canvas that the output displays.]] - } - values { - x: Evas.Coord; [[X coordinate viewport]] - y: Evas.Coord; [[Y coordinate viewport]] - w: Evas.Coord; [[Viewport width]] - h: Evas.Coord; [[Viewport height]] - } - } - lock { - [[Lock this output and prevent rendering any buffer associated to it.]] - return: bool; [[$true on success, $false otherwise]] - } - unlock { - [[Unlock this output and will rendering of this buffer during next call to evas_render.]] - return: bool; [[$true on success, $false otherwise]] - } - @property engine_info { - set { - [[Sets the engine specific output parameters for a given output.]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Gets the engine specific output parameters for a given output.]] - } - values { - info: ptr(Evas.Engine_Info); [[The engine parameters.]] - } - } - } - implements { - Efl.Object.constructor; - Efl.Object.destructor; - Efl.Object.parent { set; } - Efl.Object.finalize; - } - events { - pixels,ready; [[Called when pixels in output are ready to be used]] - } -} diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c index e66393bfc8..1dac92127e 100644 --- a/src/lib/evas/canvas/evas_main.c +++ b/src/lib/evas/canvas/evas_main.c @@ -274,7 +274,7 @@ _evas_canvas_efl_object_destructor(Eo *eo_e, Evas_Public_Data *e) Evas_Coord_Touch_Point *touch_point; Evas_Post_Render_Job *job; Evas_Layer *lay; - Evas_Out *evo; + Efl_Canvas_Output *evo; int i; Eina_Bool del; Evas_Pointer_Data *pdata; @@ -350,7 +350,7 @@ _evas_canvas_efl_object_destructor(Eo *eo_e, Evas_Public_Data *e) evas_event_callback_all_del(eo_e); evas_event_callback_cleanup(eo_e); - EINA_LIST_FREE(e->outputs, evo) efl_del(evo); + EINA_LIST_FREE(e->outputs, evo) efl_canvas_output_del(evo); if (e->engine.func) { diff --git a/src/lib/evas/canvas/evas_out.c b/src/lib/evas/canvas/evas_out.c index 12f0ea275a..429f7a8675 100644 --- a/src/lib/evas/canvas/evas_out.c +++ b/src/lib/evas/canvas/evas_out.c @@ -5,134 +5,128 @@ #include "evas_cs2_private.h" #endif -#include "efl_canvas_output.eo.h" - -#define MY_CLASS EFL_CANVAS_OUTPUT_CLASS -typedef struct _Efl_Canvas_Output_Data Efl_Canvas_Output_Data; -struct _Efl_Canvas_Output_Data +typedef struct _Efl_Canvas_Output Efl_Canvas_Output; +struct _Efl_Canvas_Output { + Eo *canvas; + void *info;/*, *context, *output;*/ Evas_Coord x, y, w, h; - - Eina_Bool finalized : 1; }; -EOLIAN static Eo * -_efl_canvas_output_efl_object_constructor(Eo *eo_obj, Efl_Canvas_Output_Data *data EINA_UNUSED) +static Evas_Public_Data * +_efl_canvas_output_async_block(Efl_Canvas_Output *output) { - eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); - - return eo_obj; -} - -EOLIAN static void -_efl_canvas_output_efl_object_destructor(Eo *eo_obj, Efl_Canvas_Output_Data *eo_dat) -{ - Eo *eo_parent = NULL; Evas_Public_Data *e; - eo_parent = efl_parent_get(eo_obj); - e = efl_data_scope_get(eo_parent, EVAS_CANVAS_CLASS); + if (!output->canvas) return NULL; + e = efl_data_scope_get(output->canvas, EVAS_CANVAS_CLASS); + if (!e) return NULL; + evas_canvas_async_block(e); - if (!e) return; - // XXX: need to free output and context one they get allocated one day - // e->engine.func->context_free(eo_dat->output, eo_dat->context); - // e->engine.func->output_free(eo_dat->output); - e->engine.func->info_free(eo_parent, eo_dat->info); - e->outputs = eina_list_remove(e->outputs, eo_obj); - efl_destructor(efl_super(eo_obj, MY_CLASS)); + return e; } -EOLIAN static void -_efl_canvas_output_view_set(Eo *eo_e, Efl_Canvas_Output_Data *eo_dat, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +EAPI Efl_Canvas_Output * +efl_canvas_output_add(Evas *canvas) { - Eo *eo_parent = NULL; + Efl_Canvas_Output *r; Evas_Public_Data *e; - eo_parent = efl_parent_get(eo_e); - e = efl_data_scope_get(eo_parent, EVAS_CANVAS_CLASS); - evas_canvas_async_block(e); - eo_dat->x = x; - eo_dat->y = y; - eo_dat->w = w; - eo_dat->h = h; + + if (!efl_isa(canvas, EVAS_CANVAS_CLASS)) return NULL; + + r = calloc(1, sizeof (Efl_Canvas_Output)); + if (!r) return NULL; + + efl_wref_add(canvas, &r->canvas); + + e = _efl_canvas_output_async_block(r); + // Track this output in Evas + e->outputs = eina_list_append(e->outputs, r); + + return r; +} + +EAPI void +efl_canvas_output_del(Efl_Canvas_Output *output) +{ + if (output->canvas) + { + Evas_Public_Data *e; + + e = _efl_canvas_output_async_block(output); + if (!e) goto on_error; + + // XXX: need to free output and context one they get allocated one day + // e->engine.func->context_free(eo_dat->output, eo_dat->context); + // e->engine.func->output_free(eo_dat->output); + e->engine.func->info_free(output->canvas, output->info); + e->outputs = eina_list_remove(e->outputs, output); + + efl_wref_del(output->canvas, &output->canvas); + } + + on_error: + free(output); +} + +EAPI void +efl_canvas_output_view_set(Efl_Canvas_Output *output, + Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + Evas_Public_Data *e; + + e = _efl_canvas_output_async_block(output); + if (!e) return ; + + output->x = x; + output->y = y; + output->w = w; + output->h = h; // XXX: tell engine about any output size etc. changes // XXX: tell evas to add damage if viewport loc/size changed } -EOLIAN static void -_efl_canvas_output_view_get(Eo *eo_e EINA_UNUSED, Efl_Canvas_Output_Data *eo_dat, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +EAPI void +efl_canvas_output_view_get(Efl_Canvas_Output *output, + Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { - if (x) *x = eo_dat->x; - if (y) *y = eo_dat->y; - if (w) *w = eo_dat->w; - if (h) *h = eo_dat->h; + if (x) *x = output->x; + if (y) *y = output->y; + if (w) *w = output->w; + if (h) *h = output->h; } -EOLIAN static Eina_Bool -_efl_canvas_output_engine_info_set(Eo *eo_e, Efl_Canvas_Output_Data *eo_dat, Evas_Engine_Info *info) +EAPI Eina_Bool +efl_canvas_output_engine_info_set(Efl_Canvas_Output *output, + Evas_Engine_Info *info) { - Eo *eo_parent = NULL; Evas_Public_Data *e; - eo_parent = efl_parent_get(eo_e); - e = efl_data_scope_get(eo_parent, EVAS_CANVAS_CLASS); - evas_canvas_async_block(e); - if (eo_dat->info != info) return EINA_FALSE; + + e = _efl_canvas_output_async_block(output); + if (!e) return EINA_FALSE; + if (output->info != info) return EINA_FALSE; // XXX: handle setting of engine info here return EINA_TRUE; } -EOLIAN static Evas_Engine_Info* -_efl_canvas_output_engine_info_get(Eo *eo_e EINA_UNUSED, Efl_Canvas_Output_Data *eo_dat) +EAPI Evas_Engine_Info* +efl_canvas_output_engine_info_get(Efl_Canvas_Output *output) { - return eo_dat->info; + return output->info; } -static Eina_Bool -_efl_canvas_output_lock(Eo *obj EINA_UNUSED, Efl_Canvas_Output_Data *pd EINA_UNUSED) +EAPI Eina_Bool +efl_canvas_output_lock(Efl_Canvas_Output *output EINA_UNUSED) { return EINA_FALSE; } -static Eina_Bool -_efl_canvas_output_unlock(Eo *obj EINA_UNUSED, Efl_Canvas_Output_Data *pd EINA_UNUSED) +EAPI Eina_Bool +efl_canvas_output_unlock(Efl_Canvas_Output *output EINA_UNUSED) { return EINA_FALSE; } - -static void -_efl_canvas_output_efl_object_parent_set(Eo *obj, Efl_Canvas_Output_Data *pd, Efl_Object *parent) -{ - if (parent != NULL && pd->finalized) return ; - - efl_parent_set(efl_super(obj, EFL_CANVAS_OUTPUT_CLASS), parent); -} - -static Efl_Object * -_efl_canvas_output_efl_object_finalize(Eo *obj, Efl_Canvas_Output_Data *pd) -{ - Eo *eo_parent = NULL; - Evas_Public_Data *e; - - eo_parent = efl_parent_get(obj); - - if (!eo_parent || !efl_isa(eo_parent, EVAS_CANVAS_CLASS)) return NULL; - e = efl_data_scope_get(eo_parent, EVAS_CANVAS_CLASS); - evas_canvas_async_block(e); - - if (!e) return NULL; - - e->outputs = eina_list_append(e->outputs, obj); - if (e->engine.func->info) pd->info = e->engine.func->info(eo_parent); - // XXX: context and output are currently held in the core engine and are - // allocated by engine specific internal code. this all needs a new engine - // api to make it work - - pd->finalized = EINA_TRUE; - - return obj; -} - -#include "canvas/efl_canvas_output.eo.c" diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h index 0da1e3200c..a3558f6e55 100644 --- a/src/lib/evas/include/evas_common_private.h +++ b/src/lib/evas/include/evas_common_private.h @@ -61,6 +61,8 @@ #include "Evas.h" +#include "Evas_Internal.h" + #ifdef EAPI # undef EAPI #endif