diff --git a/src/Makefile_Efl_Mono.am b/src/Makefile_Efl_Mono.am index 1028edd0fa..54f950d253 100644 --- a/src/Makefile_Efl_Mono.am +++ b/src/Makefile_Efl_Mono.am @@ -177,7 +177,7 @@ lib/elementary/elm_genlist_eo.cs \ lib/elementary/elm_view_list.eo.cs \ lib/elementary/elm_genlist_item_eo.cs \ lib/elementary/elm_gengrid_eo.cs \ -lib/elementary/elm_glview.eo.cs +lib/elementary/elm_glview_eo.cs efl_mono_blacklisted_files = \ $(evas_eolian_blacklisted_files) \ diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 19180e0292..68eabc094b 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -187,7 +187,6 @@ elm_private_eolian_files = \ elm_legacy_eolian_files = \ lib/elementary/efl_ui_clock_legacy.eo \ lib/elementary/elm_interface_fileselector.eo \ - lib/elementary/elm_glview.eo \ lib/elementary/elm_hover.eo \ lib/elementary/elm_index.eo \ lib/elementary/elm_label.eo \ @@ -354,6 +353,8 @@ lib/elementary/elm_genlist_item_eo.c \ lib/elementary/elm_genlist_pan_eo.c \ lib/elementary/elm_gesture_layer_eo.legacy.c \ lib/elementary/elm_gesture_layer_eo.c \ +lib/elementary/elm_glview_eo.legacy.c \ +lib/elementary/elm_glview_eo.c \ lib/elementary/elm_hoversel_eo.c \ lib/elementary/elm_hoversel_item_eo.c \ lib/elementary/elm_hoversel_item_eo.legacy.c @@ -465,6 +466,8 @@ lib/elementary/elm_genlist_pan_eo.h \ lib/elementary/elm_genlist_pan_eo.legacy.h \ lib/elementary/elm_gesture_layer_eo.h \ lib/elementary/elm_gesture_layer_eo.legacy.h \ +lib/elementary/elm_glview_eo.h \ +lib/elementary/elm_glview_eo.legacy.h \ lib/elementary/elm_hoversel_eo.h \ lib/elementary/elm_hoversel_eo.legacy.h \ lib/elementary/elm_hoversel_item_eo.h \ diff --git a/src/bindings/mono/meson.build b/src/bindings/mono/meson.build index 60401dc899..4f04a01278 100644 --- a/src/bindings/mono/meson.build +++ b/src/bindings/mono/meson.build @@ -85,7 +85,7 @@ blacklisted_files = [ 'elm_view_list.eo', 'elm_genlist_item.eo', 'elm_gengrid.eo', - 'elm_glview.eo.cs' + 'elm_glview_eo.cs' ] efl_mono_lib = library('eflcustomexportsmono', diff --git a/src/lib/elementary/elm_glview.c b/src/lib/elementary/elm_glview.c index 82308479af..1210416253 100644 --- a/src/lib/elementary/elm_glview.c +++ b/src/lib/elementary/elm_glview.c @@ -627,4 +627,4 @@ elm_glview_render_func_set(Elm_Glview *obj, Elm_GLView_Func_Cb func) #define ELM_GLVIEW_EXTRA_OPS \ EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_glview) -#include "elm_glview.eo.c" +#include "elm_glview_eo.c" diff --git a/src/lib/elementary/elm_glview.eo b/src/lib/elementary/elm_glview.eo deleted file mode 100644 index 73b8bf83c2..0000000000 --- a/src/lib/elementary/elm_glview.eo +++ /dev/null @@ -1,234 +0,0 @@ -type Evas_GL: __undefined_type; [[Evas GL type]] -type Evas_GL_API: __undefined_type; [[Evas GL API type]] -type Evas_GL_Context_Version: __undefined_type; [[Evas GL context version type]] - -enum Elm.GLView.Mode -{ - [[ - Selects the target surface properties - - An OR combination of Elm_GLView_Mode values should be passed to - elm_glview_mode_set when setting up a GL widget. These flags will - specify the properties of the rendering target surface; in particular, - the mode can request the surface to support alpha, depth and stencil buffers. - - ELM_GLVIEW_CLIENT_SIDE_ROTATION is a special value that indicates - to EFL that the application will handle the view rotation when the - device is rotated. This is needed only when the application requests - direct rendering. Please refer to Evas_GL - for more information about direct rendering. - - See @Elm.Glview.mode.set - See elm_opengl_page - ]] - legacy: elm_glview; - none = 0, [[Default mode]] - // 0x1 is reserved for future use - alpha = (1<<1), [[Alpha channel enabled rendering mode]] - depth = (1<<2), [[Depth buffer enabled rendering mode (24 bits by default)]] - stencil = (1<<3), [[Stencil buffer enabled rendering mode (8 bits by default)]] - direct = (1<<4), [[Request direct rendering, unless there must be a fallback]] - client_side_rotation = (1<<5), [[Client will handle GL view rotation if direct rendering is enabled]] - // Depth buffer sizes (3 bits) - depth_8 = Elm.GLView.Mode.depth | (1 << 6), [[Request min. 8 bits for the depth buffer]] - depth_16 = Elm.GLView.Mode.depth | (2 << 6), [[Request min. 16 bits for the depth buffer]] - depth_24 = Elm.GLView.Mode.depth | (3 << 6), [[Request min. 24 bits for the depth buffer (default)]] - depth_32 = Elm.GLView.Mode.depth | (4 << 6), [[Request min. 32 bits for the depth buffer]] - // Stencil buffer sizes (3 bits) - stencil_1 = Elm.GLView.Mode.stencil | (1 << 9), [[Request min. 1 bits for the stencil buffer]] - stencil_2 = Elm.GLView.Mode.stencil | (2 << 9), [[Request min. 2 bits for the stencil buffer]] - stencil_4 = Elm.GLView.Mode.stencil | (3 << 9), [[Request min. 4 bits for the stencil buffer]] - stencil_8 = Elm.GLView.Mode.stencil | (4 << 9), [[Request min. 8 bits for the stencil buffer (default)]] - stencil_16 = Elm.GLView.Mode.stencil | (5 << 9), [[Request min. 16 bits for the stencil buffer]] - // MSAA params (2 bits) - multisample_low = (1 << 12), [[MSAA with minimum number of samples]] - multisample_med = (2 << 12), [[MSAA with half the number of maximum samples]] - multisample_high = (3 << 12) [[MSAA with maximum number of samples]] - -} - -enum Elm.GLView.Resize.Policy -{ - [[ - Defines a policy for the glview resizing. - - The resizing policy tells glview what to do with the underlying - surface when resize happens. ELM_GLVIEW_RESIZE_POLICY_RECREATE - will destroy the current surface and recreate the surface to the - new size. ELM_GLVIEW_RESIZE_POLICY_SCALE will instead keep the - current surface but only display the result at the desired size scaled. - - Default is @Elm.GLView.Resize.Policy.recreate - ]] - recreate = 1, [[Resize the internal surface along with the image]] - scale = 2 [[Only resize the internal image and not the surface]] -} - -enum Elm.GLView.Render.Policy -{ - [[ - Defines a policy for gl rendering. - - The rendering policy tells glview where to run the gl rendering code. - ELM_GLVIEW_RENDER_POLICY_ON_DEMAND tells glview to call the rendering - calls on demand, which means that the rendering code gets called - only when it is visible. - - Default is @Elm.GLView.Render.Policy.on_demand - ]] - on_demand = 1, [[Render only when there is a need for redrawing]] - always = 2 [[Render always even when it is not visible]] -} - -class Elm.Glview extends Efl.Ui.Widget implements Efl.Gfx.View, Efl.Ui.Legacy -{ - [[Elementary GL view class]] - legacy_prefix: elm_glview; - eo_prefix: elm_obj_glview; - event_prefix: elm_glview; - methods { - version_constructor { - [[Constructor with context version number.]] - legacy: null; - params { - @in version: Evas_GL_Context_Version; [[GL context version]] - } - } - @property resize_policy { - set { - [[Set the resize policy for the glview object. - - By default, the resize policy is set to - #ELM_GLVIEW_RESIZE_POLICY_RECREATE. When resize is called - it destroys the previous surface and recreates the newly - specified size. If the policy is set to - #ELM_GLVIEW_RESIZE_POLICY_SCALE, however, glview only - scales the image object and not the underlying GL Surface. - ]] - return: bool; [[$true on success, $false otherwise]] - } - values { - policy: Elm.GLView.Resize.Policy; [[The scaling policy.]] - } - } - @property render_policy { - set { - [[Set the render policy for the glview object. - - By default, the render policy is set to - #ELM_GLVIEW_RENDER_POLICY_ON_DEMAND. This policy is set - such that during the render loop, glview is only redrawn - if it needs to be redrawn. (i.e. when it is visible) If the - policy is set to #ELM_GLVIEWW_RENDER_POLICY_ALWAYS, it - redraws regardless of whether it is visible or needs - redrawing. - ]] - return: bool; [[$true on success, $false otherwise]] - } - values { - policy: Elm.GLView.Render.Policy; [[The render policy.]] - } - } - @property mode { - set { - [[Set the mode of the GLView. Supports alpha, depth, stencil. - - Direct is a hint for the elm_glview to render directly to - the window given that the right conditions are met. Otherwise - it falls back to rendering to an offscreen buffer before it - gets composited to the window. - ]] - return: bool; [[$true on success, $false otherwise]] - } - values { - mode: Elm.GLView.Mode; [[The mode Options OR'ed enabling Alpha, Depth, Stencil, Direct.]] - } - } - @property gl_api { - get { - [[Get the gl api struct for gl rendering.]] - return: ptr(Evas_GL_API); [[GL API]] - } - } - @property evas_gl { - get { - [[Get the internal Evas GL attached to this view. - - Note: The returned Evas_GL must not be destroyed as it is - still owned by the view. But this pointer can be used then - to call all the evas_gl_ functions. - - @since 1.12 - ]] - return: ptr(Evas_GL); [[Evas GL]] - } - } - @property rotation { - get { - [[Get the current GL view's rotation when using direct rendering - - Note: This rotation can be different from the device - orientation. This rotation value must be used in case of - direct rendering and should be taken into account by the - application when setting the internal rotation matrix for - the view. - - @since 1.12 - ]] - return: int; [[A window rotation in degrees (0, 90, 180 or 270).]] - } - } - draw_request { - [[Notifies that there has been changes in the GLView. - - @since 1.18 - ]] - legacy: null; - } - } - implements { - class.constructor; - Efl.Object.constructor; - Efl.Object.finalize; - Efl.Gfx.Entity.size { set; } - Efl.Ui.Focus.Object.on_focus_update; - Efl.Gfx.View.view_size { get; set; } - } - events { - created: void; - [[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: void; - [[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: void; - [[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: void; - [[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 @optional; - } -} diff --git a/src/lib/elementary/elm_glview_eo.c b/src/lib/elementary/elm_glview_eo.c new file mode 100644 index 0000000000..2a6f9a3379 --- /dev/null +++ b/src/lib/elementary/elm_glview_eo.c @@ -0,0 +1,105 @@ +EWAPI const Efl_Event_Description _ELM_GLVIEW_EVENT_CREATED = + EFL_EVENT_DESCRIPTION("created"); +EWAPI const Efl_Event_Description _ELM_GLVIEW_EVENT_DESTROYED = + EFL_EVENT_DESCRIPTION("destroyed"); +EWAPI const Efl_Event_Description _ELM_GLVIEW_EVENT_RESIZED = + EFL_EVENT_DESCRIPTION("resized"); +EWAPI const Efl_Event_Description _ELM_GLVIEW_EVENT_RENDER = + EFL_EVENT_DESCRIPTION("render"); + +void _elm_glview_version_constructor(Eo *obj, Elm_Glview_Data *pd, Evas_GL_Context_Version version); + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_glview_version_constructor, EFL_FUNC_CALL(version), Evas_GL_Context_Version version); + +Eina_Bool _elm_glview_resize_policy_set(Eo *obj, Elm_Glview_Data *pd, Elm_GLView_Resize_Policy policy); + +EOAPI EFL_FUNC_BODYV(elm_obj_glview_resize_policy_set, Eina_Bool, 0, EFL_FUNC_CALL(policy), Elm_GLView_Resize_Policy policy); + +Eina_Bool _elm_glview_render_policy_set(Eo *obj, Elm_Glview_Data *pd, Elm_GLView_Render_Policy policy); + +EOAPI EFL_FUNC_BODYV(elm_obj_glview_render_policy_set, Eina_Bool, 0, EFL_FUNC_CALL(policy), Elm_GLView_Render_Policy policy); + +Eina_Bool _elm_glview_mode_set(Eo *obj, Elm_Glview_Data *pd, Elm_GLView_Mode mode); + +EOAPI EFL_FUNC_BODYV(elm_obj_glview_mode_set, Eina_Bool, 0, EFL_FUNC_CALL(mode), Elm_GLView_Mode mode); + +Evas_GL_API *_elm_glview_gl_api_get(const Eo *obj, Elm_Glview_Data *pd); + +EOAPI EFL_FUNC_BODY_CONST(elm_obj_glview_gl_api_get, Evas_GL_API *, NULL); + +Evas_GL *_elm_glview_evas_gl_get(const Eo *obj, Elm_Glview_Data *pd); + +EOAPI EFL_FUNC_BODY_CONST(elm_obj_glview_evas_gl_get, Evas_GL *, NULL); + +int _elm_glview_rotation_get(const Eo *obj, Elm_Glview_Data *pd); + +EOAPI EFL_FUNC_BODY_CONST(elm_obj_glview_rotation_get, int, 0); + +void _elm_glview_draw_request(Eo *obj, Elm_Glview_Data *pd); + +EOAPI EFL_VOID_FUNC_BODY(elm_obj_glview_draw_request); + +Efl_Object *_elm_glview_efl_object_constructor(Eo *obj, Elm_Glview_Data *pd); + + +Efl_Object *_elm_glview_efl_object_finalize(Eo *obj, Elm_Glview_Data *pd); + + +void _elm_glview_efl_gfx_entity_size_set(Eo *obj, Elm_Glview_Data *pd, Eina_Size2D size); + + +Eina_Bool _elm_glview_efl_ui_focus_object_on_focus_update(Eo *obj, Elm_Glview_Data *pd); + + +void _elm_glview_efl_gfx_view_view_size_set(Eo *obj, Elm_Glview_Data *pd, Eina_Size2D size); + + +Eina_Size2D _elm_glview_efl_gfx_view_view_size_get(const Eo *obj, Elm_Glview_Data *pd); + + +static Eina_Bool +_elm_glview_class_initializer(Efl_Class *klass) +{ + const Efl_Object_Ops *opsp = NULL; + + const Efl_Object_Property_Reflection_Ops *ropsp = NULL; + +#ifndef ELM_GLVIEW_EXTRA_OPS +#define ELM_GLVIEW_EXTRA_OPS +#endif + + EFL_OPS_DEFINE(ops, + EFL_OBJECT_OP_FUNC(elm_obj_glview_version_constructor, _elm_glview_version_constructor), + EFL_OBJECT_OP_FUNC(elm_obj_glview_resize_policy_set, _elm_glview_resize_policy_set), + EFL_OBJECT_OP_FUNC(elm_obj_glview_render_policy_set, _elm_glview_render_policy_set), + EFL_OBJECT_OP_FUNC(elm_obj_glview_mode_set, _elm_glview_mode_set), + EFL_OBJECT_OP_FUNC(elm_obj_glview_gl_api_get, _elm_glview_gl_api_get), + EFL_OBJECT_OP_FUNC(elm_obj_glview_evas_gl_get, _elm_glview_evas_gl_get), + EFL_OBJECT_OP_FUNC(elm_obj_glview_rotation_get, _elm_glview_rotation_get), + EFL_OBJECT_OP_FUNC(elm_obj_glview_draw_request, _elm_glview_draw_request), + EFL_OBJECT_OP_FUNC(efl_constructor, _elm_glview_efl_object_constructor), + EFL_OBJECT_OP_FUNC(efl_finalize, _elm_glview_efl_object_finalize), + EFL_OBJECT_OP_FUNC(efl_gfx_entity_size_set, _elm_glview_efl_gfx_entity_size_set), + EFL_OBJECT_OP_FUNC(efl_ui_focus_object_on_focus_update, _elm_glview_efl_ui_focus_object_on_focus_update), + EFL_OBJECT_OP_FUNC(efl_gfx_view_size_set, _elm_glview_efl_gfx_view_view_size_set), + EFL_OBJECT_OP_FUNC(efl_gfx_view_size_get, _elm_glview_efl_gfx_view_view_size_get), + ELM_GLVIEW_EXTRA_OPS + ); + opsp = &ops; + + return efl_class_functions_set(klass, opsp, ropsp); +} + +static const Efl_Class_Description _elm_glview_class_desc = { + EO_VERSION, + "Elm.Glview", + EFL_CLASS_TYPE_REGULAR, + sizeof(Elm_Glview_Data), + _elm_glview_class_initializer, + _elm_glview_class_constructor, + NULL +}; + +EFL_DEFINE_CLASS(elm_glview_class_get, &_elm_glview_class_desc, EFL_UI_WIDGET_CLASS, EFL_GFX_VIEW_INTERFACE, EFL_UI_LEGACY_INTERFACE, NULL); + +#include "elm_glview_eo.legacy.c" diff --git a/src/lib/elementary/elm_glview_eo.h b/src/lib/elementary/elm_glview_eo.h new file mode 100644 index 0000000000..9e8879b805 --- /dev/null +++ b/src/lib/elementary/elm_glview_eo.h @@ -0,0 +1,294 @@ +#ifndef _ELM_GLVIEW_EO_H_ +#define _ELM_GLVIEW_EO_H_ + +#ifndef _ELM_GLVIEW_EO_CLASS_TYPE +#define _ELM_GLVIEW_EO_CLASS_TYPE + +typedef Eo Elm_Glview; + +#endif + +#ifndef _ELM_GLVIEW_EO_TYPES +#define _ELM_GLVIEW_EO_TYPES + +/** + * @brief Selects the target surface properties + * + * An OR combination of Elm_GLView_Mode values should be passed to + * elm_glview_mode_set when setting up a GL widget. These flags will specify + * the properties of the rendering target surface; in particular, the mode can + * request the surface to support alpha, depth and stencil buffers. + * + * ELM_GLVIEW_CLIENT_SIDE_ROTATION is a special value that indicates to EFL + * that the application will handle the view rotation when the device is + * rotated. This is needed only when the application requests direct rendering. + * Please refer to Evas_GL for more information about direct rendering. + * + * See @ref elm_obj_glview_mode_set See elm_opengl_page + * + * @ingroup Elm_GLView + */ +typedef enum +{ + ELM_GLVIEW_NONE = 0, /**< Default mode */ + ELM_GLVIEW_ALPHA = 2 /* 1 >> 1 */, /**< Alpha channel enabled rendering mode + */ + ELM_GLVIEW_DEPTH = 4 /* 1 >> 2 */, /**< Depth buffer enabled rendering mode + * (24 bits by default) */ + ELM_GLVIEW_STENCIL = 8 /* 1 >> 3 */, /**< Stencil buffer enabled rendering + * mode (8 bits by default) */ + ELM_GLVIEW_DIRECT = 16 /* 1 >> 4 */, /**< Request direct rendering, unless + * there must be a fallback */ + ELM_GLVIEW_CLIENT_SIDE_ROTATION = 32 /* 1 >> 5 */, /**< Client will handle GL + * view rotation if direct + * rendering is enabled */ + ELM_GLVIEW_DEPTH_8 = 68 /* Elm.GLView.Mode.depth ^ (1 >> 6) */, /**< Request min. 8 bits for the depth + * buffer */ + ELM_GLVIEW_DEPTH_16 = 132 /* Elm.GLView.Mode.depth ^ (2 >> 6) */, /**< Request min. 16 bits for the depth + * buffer */ + ELM_GLVIEW_DEPTH_24 = 196 /* Elm.GLView.Mode.depth ^ (3 >> 6) */, /**< Request min. 24 bits for the depth + * buffer (default) */ + ELM_GLVIEW_DEPTH_32 = 260 /* Elm.GLView.Mode.depth ^ (4 >> 6) */, /**< Request min. 32 bits for the depth + * buffer */ + ELM_GLVIEW_STENCIL_1 = 520 /* Elm.GLView.Mode.stencil ^ (1 >> 9) */, /**< Request min. 1 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_2 = 1032 /* Elm.GLView.Mode.stencil ^ (2 >> 9) */, /**< Request min. 2 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_4 = 1544 /* Elm.GLView.Mode.stencil ^ (3 >> 9) */, /**< Request min. 4 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_8 = 2056 /* Elm.GLView.Mode.stencil ^ (4 >> 9) */, /**< Request min. 8 bits for the stencil + * buffer (default) */ + ELM_GLVIEW_STENCIL_16 = 2568 /* Elm.GLView.Mode.stencil ^ (5 >> 9) */, /**< Request min. 16 bits for the + * stencil buffer */ + ELM_GLVIEW_MULTISAMPLE_LOW = 4096 /* 1 >> 12 */, /**< MSAA with minimum number + * of samples */ + ELM_GLVIEW_MULTISAMPLE_MED = 8192 /* 2 >> 12 */, /**< MSAA with half the + * number of maximum samples + */ + ELM_GLVIEW_MULTISAMPLE_HIGH = 12288 /* 3 >> 12 */ /**< MSAA with maximum + * number of samples */ +} Elm_GLView_Mode; + +/** + * @brief Defines a policy for the glview resizing. + * + * The resizing policy tells glview what to do with the underlying surface when + * resize happens. ELM_GLVIEW_RESIZE_POLICY_RECREATE will destroy the current + * surface and recreate the surface to the new size. + * ELM_GLVIEW_RESIZE_POLICY_SCALE will instead keep the current surface but + * only display the result at the desired size scaled. + * + * Default is @ref ELM_GLVIEW_RESIZE_POLICY_RECREATE + * + * @ingroup Elm_GLView_Resize + */ +typedef enum +{ + ELM_GLVIEW_RESIZE_POLICY_RECREATE = 1, /**< Resize the internal surface along + * with the image */ + ELM_GLVIEW_RESIZE_POLICY_SCALE = 2 /**< Only resize the internal image and not + * the surface */ +} Elm_GLView_Resize_Policy; + +/** + * @brief Defines a policy for gl rendering. + * + * The rendering policy tells glview where to run the gl rendering code. + * ELM_GLVIEW_RENDER_POLICY_ON_DEMAND tells glview to call the rendering calls + * on demand, which means that the rendering code gets called only when it is + * visible. + * + * Default is @ref ELM_GLVIEW_RENDER_POLICY_ON_DEMAND + * + * @ingroup Elm_GLView_Render + */ +typedef enum +{ + ELM_GLVIEW_RENDER_POLICY_ON_DEMAND = 1, /**< Render only when there is a need + * for redrawing */ + ELM_GLVIEW_RENDER_POLICY_ALWAYS = 2 /**< Render always even when it is not + * visible */ +} Elm_GLView_Render_Policy; + + +#endif +/** Elementary GL view class + * + * @ingroup Elm_Glview + */ +#define ELM_GLVIEW_CLASS elm_glview_class_get() + +EWAPI const Efl_Class *elm_glview_class_get(void); + +/** + * @brief Constructor with context version number. + * + * @param[in] obj The object. + * @param[in] version GL context version + * + * @ingroup Elm_Glview + */ +EOAPI void elm_obj_glview_version_constructor(Eo *obj, Evas_GL_Context_Version version); + +/** + * @brief Set the resize policy for the glview object. + * + * By default, the resize policy is set to #ELM_GLVIEW_RESIZE_POLICY_RECREATE. + * When resize is called it destroys the previous surface and recreates the + * newly specified size. If the policy is set to + * #ELM_GLVIEW_RESIZE_POLICY_SCALE, however, glview only scales the image + * object and not the underlying GL Surface. + * + * @param[in] obj The object. + * @param[in] policy The scaling policy. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview + */ +EOAPI Eina_Bool elm_obj_glview_resize_policy_set(Eo *obj, Elm_GLView_Resize_Policy policy); + +/** + * @brief Set the render policy for the glview object. + * + * By default, the render policy is set to #ELM_GLVIEW_RENDER_POLICY_ON_DEMAND. + * This policy is set such that during the render loop, glview is only redrawn + * if it needs to be redrawn. (i.e. when it is visible) If the policy is set to + * #ELM_GLVIEWW_RENDER_POLICY_ALWAYS, it redraws regardless of whether it is + * visible or needs redrawing. + * + * @param[in] obj The object. + * @param[in] policy The render policy. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview + */ +EOAPI Eina_Bool elm_obj_glview_render_policy_set(Eo *obj, Elm_GLView_Render_Policy policy); + +/** + * @brief Set the mode of the GLView. Supports alpha, depth, stencil. + * + * Direct is a hint for the elm_glview to render directly to the window given + * that the right conditions are met. Otherwise it falls back to rendering to + * an offscreen buffer before it gets composited to the window. + * + * @param[in] obj The object. + * @param[in] mode The mode Options OR'ed enabling Alpha, Depth, Stencil, + * Direct. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview + */ +EOAPI Eina_Bool elm_obj_glview_mode_set(Eo *obj, Elm_GLView_Mode mode); + +/** + * @brief Get the gl api struct for gl rendering. + * + * @param[in] obj The object. + * + * @return GL API + * + * @ingroup Elm_Glview + */ +EOAPI Evas_GL_API *elm_obj_glview_gl_api_get(const Eo *obj); + +/** + * @brief Get the internal Evas GL attached to this view. + * + * @note The returned Evas_GL must not be destroyed as it is still owned by the + * view. But this pointer can be used then to call all the evas_gl_ functions. + * + * @param[in] obj The object. + * + * @return Evas GL + * + * @since 1.12 + * + * @ingroup Elm_Glview + */ +EOAPI Evas_GL *elm_obj_glview_evas_gl_get(const Eo *obj); + +/** + * @brief Get the current GL view's rotation when using direct rendering + * + * @note This rotation can be different from the device orientation. This + * rotation value must be used in case of direct rendering and should be taken + * into account by the application when setting the internal rotation matrix + * for the view. + * + * @param[in] obj The object. + * + * @return A window rotation in degrees (0, 90, 180 or 270). + * + * @since 1.12 + * + * @ingroup Elm_Glview + */ +EOAPI int elm_obj_glview_rotation_get(const Eo *obj); + +/** Notifies that there has been changes in the GLView. + * + * @since 1.18 + * + * @ingroup Elm_Glview + */ +EOAPI void elm_obj_glview_draw_request(Eo *obj); + +EWAPI extern const Efl_Event_Description _ELM_GLVIEW_EVENT_CREATED; + +/** + * @brief 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. + * + * @ingroup Elm_Glview + */ +#define ELM_GLVIEW_EVENT_CREATED (&(_ELM_GLVIEW_EVENT_CREATED)) + +EWAPI extern const Efl_Event_Description _ELM_GLVIEW_EVENT_DESTROYED; + +/** + * @brief 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. + * + * @ingroup Elm_Glview + */ +#define ELM_GLVIEW_EVENT_DESTROYED (&(_ELM_GLVIEW_EVENT_DESTROYED)) + +EWAPI extern const Efl_Event_Description _ELM_GLVIEW_EVENT_RESIZED; + +/** + * @brief 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. + * + * @ingroup Elm_Glview + */ +#define ELM_GLVIEW_EVENT_RESIZED (&(_ELM_GLVIEW_EVENT_RESIZED)) + +EWAPI extern const Efl_Event_Description _ELM_GLVIEW_EVENT_RENDER; + +/** + * @brief 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 @ref elm_obj_glview_draw_request + * gets called. + * + * @ingroup Elm_Glview + */ +#define ELM_GLVIEW_EVENT_RENDER (&(_ELM_GLVIEW_EVENT_RENDER)) + +#endif diff --git a/src/lib/elementary/elm_glview_eo.legacy.c b/src/lib/elementary/elm_glview_eo.legacy.c new file mode 100644 index 0000000000..5275f6d19e --- /dev/null +++ b/src/lib/elementary/elm_glview_eo.legacy.c @@ -0,0 +1,36 @@ + +EAPI Eina_Bool +elm_glview_resize_policy_set(Elm_Glview *obj, Elm_GLView_Resize_Policy policy) +{ + return elm_obj_glview_resize_policy_set(obj, policy); +} + +EAPI Eina_Bool +elm_glview_render_policy_set(Elm_Glview *obj, Elm_GLView_Render_Policy policy) +{ + return elm_obj_glview_render_policy_set(obj, policy); +} + +EAPI Eina_Bool +elm_glview_mode_set(Elm_Glview *obj, Elm_GLView_Mode mode) +{ + return elm_obj_glview_mode_set(obj, mode); +} + +EAPI Evas_GL_API * +elm_glview_gl_api_get(const Elm_Glview *obj) +{ + return elm_obj_glview_gl_api_get(obj); +} + +EAPI Evas_GL * +elm_glview_evas_gl_get(const Elm_Glview *obj) +{ + return elm_obj_glview_evas_gl_get(obj); +} + +EAPI int +elm_glview_rotation_get(const Elm_Glview *obj) +{ + return elm_obj_glview_rotation_get(obj); +} diff --git a/src/lib/elementary/elm_glview_eo.legacy.h b/src/lib/elementary/elm_glview_eo.legacy.h new file mode 100644 index 0000000000..562b31207d --- /dev/null +++ b/src/lib/elementary/elm_glview_eo.legacy.h @@ -0,0 +1,216 @@ +#ifndef _ELM_GLVIEW_EO_LEGACY_H_ +#define _ELM_GLVIEW_EO_LEGACY_H_ + +#ifndef _ELM_GLVIEW_EO_CLASS_TYPE +#define _ELM_GLVIEW_EO_CLASS_TYPE + +typedef Eo Elm_Glview; + +#endif + +#ifndef _ELM_GLVIEW_EO_TYPES +#define _ELM_GLVIEW_EO_TYPES + +/** + * @brief Selects the target surface properties + * + * An OR combination of Elm_GLView_Mode values should be passed to + * elm_glview_mode_set when setting up a GL widget. These flags will specify + * the properties of the rendering target surface; in particular, the mode can + * request the surface to support alpha, depth and stencil buffers. + * + * ELM_GLVIEW_CLIENT_SIDE_ROTATION is a special value that indicates to EFL + * that the application will handle the view rotation when the device is + * rotated. This is needed only when the application requests direct rendering. + * Please refer to Evas_GL for more information about direct rendering. + * + * See @ref elm_glview_mode_set See elm_opengl_page + * + * @ingroup Elm_GLView + */ +typedef enum +{ + ELM_GLVIEW_NONE = 0, /**< Default mode */ + ELM_GLVIEW_ALPHA = 2 /* 1 >> 1 */, /**< Alpha channel enabled rendering mode + */ + ELM_GLVIEW_DEPTH = 4 /* 1 >> 2 */, /**< Depth buffer enabled rendering mode + * (24 bits by default) */ + ELM_GLVIEW_STENCIL = 8 /* 1 >> 3 */, /**< Stencil buffer enabled rendering + * mode (8 bits by default) */ + ELM_GLVIEW_DIRECT = 16 /* 1 >> 4 */, /**< Request direct rendering, unless + * there must be a fallback */ + ELM_GLVIEW_CLIENT_SIDE_ROTATION = 32 /* 1 >> 5 */, /**< Client will handle GL + * view rotation if direct + * rendering is enabled */ + ELM_GLVIEW_DEPTH_8 = 68 /* Elm.GLView.Mode.depth ^ (1 >> 6) */, /**< Request min. 8 bits for the depth + * buffer */ + ELM_GLVIEW_DEPTH_16 = 132 /* Elm.GLView.Mode.depth ^ (2 >> 6) */, /**< Request min. 16 bits for the depth + * buffer */ + ELM_GLVIEW_DEPTH_24 = 196 /* Elm.GLView.Mode.depth ^ (3 >> 6) */, /**< Request min. 24 bits for the depth + * buffer (default) */ + ELM_GLVIEW_DEPTH_32 = 260 /* Elm.GLView.Mode.depth ^ (4 >> 6) */, /**< Request min. 32 bits for the depth + * buffer */ + ELM_GLVIEW_STENCIL_1 = 520 /* Elm.GLView.Mode.stencil ^ (1 >> 9) */, /**< Request min. 1 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_2 = 1032 /* Elm.GLView.Mode.stencil ^ (2 >> 9) */, /**< Request min. 2 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_4 = 1544 /* Elm.GLView.Mode.stencil ^ (3 >> 9) */, /**< Request min. 4 bits for the stencil + * buffer */ + ELM_GLVIEW_STENCIL_8 = 2056 /* Elm.GLView.Mode.stencil ^ (4 >> 9) */, /**< Request min. 8 bits for the stencil + * buffer (default) */ + ELM_GLVIEW_STENCIL_16 = 2568 /* Elm.GLView.Mode.stencil ^ (5 >> 9) */, /**< Request min. 16 bits for the + * stencil buffer */ + ELM_GLVIEW_MULTISAMPLE_LOW = 4096 /* 1 >> 12 */, /**< MSAA with minimum number + * of samples */ + ELM_GLVIEW_MULTISAMPLE_MED = 8192 /* 2 >> 12 */, /**< MSAA with half the + * number of maximum samples + */ + ELM_GLVIEW_MULTISAMPLE_HIGH = 12288 /* 3 >> 12 */ /**< MSAA with maximum + * number of samples */ +} Elm_GLView_Mode; + +/** + * @brief Defines a policy for the glview resizing. + * + * The resizing policy tells glview what to do with the underlying surface when + * resize happens. ELM_GLVIEW_RESIZE_POLICY_RECREATE will destroy the current + * surface and recreate the surface to the new size. + * ELM_GLVIEW_RESIZE_POLICY_SCALE will instead keep the current surface but + * only display the result at the desired size scaled. + * + * Default is @ref ELM_GLVIEW_RESIZE_POLICY_RECREATE + * + * @ingroup Elm_GLView_Resize + */ +typedef enum +{ + ELM_GLVIEW_RESIZE_POLICY_RECREATE = 1, /**< Resize the internal surface along + * with the image */ + ELM_GLVIEW_RESIZE_POLICY_SCALE = 2 /**< Only resize the internal image and not + * the surface */ +} Elm_GLView_Resize_Policy; + +/** + * @brief Defines a policy for gl rendering. + * + * The rendering policy tells glview where to run the gl rendering code. + * ELM_GLVIEW_RENDER_POLICY_ON_DEMAND tells glview to call the rendering calls + * on demand, which means that the rendering code gets called only when it is + * visible. + * + * Default is @ref ELM_GLVIEW_RENDER_POLICY_ON_DEMAND + * + * @ingroup Elm_GLView_Render + */ +typedef enum +{ + ELM_GLVIEW_RENDER_POLICY_ON_DEMAND = 1, /**< Render only when there is a need + * for redrawing */ + ELM_GLVIEW_RENDER_POLICY_ALWAYS = 2 /**< Render always even when it is not + * visible */ +} Elm_GLView_Render_Policy; + + +#endif + + +/** + * @brief Set the resize policy for the glview object. + * + * By default, the resize policy is set to #ELM_GLVIEW_RESIZE_POLICY_RECREATE. + * When resize is called it destroys the previous surface and recreates the + * newly specified size. If the policy is set to + * #ELM_GLVIEW_RESIZE_POLICY_SCALE, however, glview only scales the image + * object and not the underlying GL Surface. + * + * @param[in] obj The object. + * @param[in] policy The scaling policy. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview_Group + */ +EAPI Eina_Bool elm_glview_resize_policy_set(Elm_Glview *obj, Elm_GLView_Resize_Policy policy); + +/** + * @brief Set the render policy for the glview object. + * + * By default, the render policy is set to #ELM_GLVIEW_RENDER_POLICY_ON_DEMAND. + * This policy is set such that during the render loop, glview is only redrawn + * if it needs to be redrawn. (i.e. when it is visible) If the policy is set to + * #ELM_GLVIEWW_RENDER_POLICY_ALWAYS, it redraws regardless of whether it is + * visible or needs redrawing. + * + * @param[in] obj The object. + * @param[in] policy The render policy. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview_Group + */ +EAPI Eina_Bool elm_glview_render_policy_set(Elm_Glview *obj, Elm_GLView_Render_Policy policy); + +/** + * @brief Set the mode of the GLView. Supports alpha, depth, stencil. + * + * Direct is a hint for the elm_glview to render directly to the window given + * that the right conditions are met. Otherwise it falls back to rendering to + * an offscreen buffer before it gets composited to the window. + * + * @param[in] obj The object. + * @param[in] mode The mode Options OR'ed enabling Alpha, Depth, Stencil, + * Direct. + * + * @return @c true on success, @c false otherwise + * + * @ingroup Elm_Glview_Group + */ +EAPI Eina_Bool elm_glview_mode_set(Elm_Glview *obj, Elm_GLView_Mode mode); + +/** + * @brief Get the gl api struct for gl rendering. + * + * @param[in] obj The object. + * + * @return GL API + * + * @ingroup Elm_Glview_Group + */ +EAPI Evas_GL_API *elm_glview_gl_api_get(const Elm_Glview *obj); + +/** + * @brief Get the internal Evas GL attached to this view. + * + * @note The returned Evas_GL must not be destroyed as it is still owned by the + * view. But this pointer can be used then to call all the evas_gl_ functions. + * + * @param[in] obj The object. + * + * @return Evas GL + * + * @since 1.12 + * + * @ingroup Elm_Glview_Group + */ +EAPI Evas_GL *elm_glview_evas_gl_get(const Elm_Glview *obj); + +/** + * @brief Get the current GL view's rotation when using direct rendering + * + * @note This rotation can be different from the device orientation. This + * rotation value must be used in case of direct rendering and should be taken + * into account by the application when setting the internal rotation matrix + * for the view. + * + * @param[in] obj The object. + * + * @return A window rotation in degrees (0, 90, 180 or 270). + * + * @since 1.12 + * + * @ingroup Elm_Glview_Group + */ +EAPI int elm_glview_rotation_get(const Elm_Glview *obj); + + +#endif diff --git a/src/lib/elementary/elm_glview_legacy.h b/src/lib/elementary/elm_glview_legacy.h index 1f0bea4b7e..84e148c511 100644 --- a/src/lib/elementary/elm_glview_legacy.h +++ b/src/lib/elementary/elm_glview_legacy.h @@ -89,4 +89,4 @@ EAPI void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func); * @ingroup Elm_GLView */ EAPI void elm_glview_render_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func); -#include "elm_glview.eo.legacy.h" +#include "elm_glview_eo.legacy.h" diff --git a/src/lib/elementary/elm_widget_glview.h b/src/lib/elementary/elm_widget_glview.h index d561c0985e..2ce9144ed0 100644 --- a/src/lib/elementary/elm_widget_glview.h +++ b/src/lib/elementary/elm_widget_glview.h @@ -2,7 +2,7 @@ #define ELM_WIDGET_GLVIEW_H #include "Elementary.h" -#include "elm_glview.eo.h" +#include "elm_glview_eo.h" /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build index c7e5ba4225..9691f549b8 100644 --- a/src/lib/elementary/meson.build +++ b/src/lib/elementary/meson.build @@ -1,7 +1,6 @@ pub_legacy_eo_files = [ 'efl_ui_clock_legacy.eo', 'elm_interface_fileselector.eo', - 'elm_glview.eo', 'elm_hover.eo', 'elm_index.eo', 'elm_label.eo', @@ -753,6 +752,8 @@ elementary_pub_headers = [ 'elm_genlist_pan_eo.legacy.h', 'elm_gesture_layer_eo.h', 'elm_gesture_layer_eo.legacy.h', + 'elm_glview_eo.h', + 'elm_glview_eo.legacy.h', 'elm_hoversel_eo.h', 'elm_hoversel_eo.legacy.h', 'elm_hoversel_item_eo.h',