2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
#define EFL_ACCESS_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
#include "elm_priv.h"
|
2012-07-31 15:04:54 -07:00
|
|
|
#include "elm_widget_glview.h"
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_GLVIEW_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Glview"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_glview"
|
2011-06-03 00:09:25 -07:00
|
|
|
|
|
|
|
static const char SIG_FOCUSED[] = "focused";
|
|
|
|
static const char SIG_UNFOCUSED[] = "unfocused";
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
/* smart callbacks coming from elm glview objects: */
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_FOCUSED, ""},
|
|
|
|
{SIG_UNFOCUSED, ""},
|
2014-01-23 02:30:34 -08:00
|
|
|
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-07 21:05:06 -08:00
|
|
|
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
|
2012-05-03 15:43:42 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-01-19 00:25:47 -08:00
|
|
|
_elm_glview_efl_ui_focus_object_on_focus_update(Eo *obj, Elm_Glview_Data *_pd EINA_UNUSED)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2014-03-23 02:39:00 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
2013-06-06 09:13:37 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
2018-01-19 00:25:47 -08:00
|
|
|
int_ret = efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS));
|
2014-03-23 02:39:00 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2017-11-29 00:39:42 -08:00
|
|
|
if (efl_ui_focus_object_focus_get(obj))
|
2013-06-06 09:13:37 -07:00
|
|
|
evas_object_focus_set(wd->resize_obj, EINA_TRUE);
|
2011-06-03 00:09:25 -07:00
|
|
|
else
|
2013-06-06 09:13:37 -07:00
|
|
|
evas_object_focus_set(wd->resize_obj, EINA_FALSE);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_TRUE;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_glview_update_surface(Evas_Object *obj)
|
|
|
|
{
|
2016-04-06 00:34:53 -07:00
|
|
|
Evas_Native_Surface ns = {};
|
2015-04-06 01:26:31 -07:00
|
|
|
Evas_GL_Options_Bits opt;
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
ELM_GLVIEW_DATA_GET(obj, sd);
|
2013-10-05 01:14:28 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:43:42 -07:00
|
|
|
if (!sd) return;
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2015-04-14 04:52:38 -07:00
|
|
|
evas_gl_make_current(sd->evasgl, NULL, NULL);
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->surface)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2014-09-22 19:19:18 -07:00
|
|
|
evas_object_image_native_surface_set(wd->resize_obj, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
evas_gl_surface_destroy(sd->evasgl, sd->surface);
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
2011-06-03 10:44:24 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
evas_object_image_size_set(wd->resize_obj, sd->w, sd->h);
|
2011-06-03 10:44:24 -07:00
|
|
|
|
2015-04-06 01:26:31 -07:00
|
|
|
opt = sd->config->options_bits;
|
|
|
|
if ((opt & EVAS_GL_OPTIONS_DIRECT) &&
|
|
|
|
(sd->render_policy != ELM_GLVIEW_RENDER_POLICY_ON_DEMAND))
|
|
|
|
{
|
|
|
|
if (!sd->warned_about_dr)
|
|
|
|
{
|
|
|
|
WRN("App requested direct rendering but render policy is not ON_DEMAND. "
|
|
|
|
"Disabling direct rendering...");
|
|
|
|
sd->warned_about_dr = EINA_TRUE;
|
|
|
|
}
|
|
|
|
sd->config->options_bits &= ~(EVAS_GL_OPTIONS_DIRECT);
|
|
|
|
}
|
2014-09-22 19:19:18 -07:00
|
|
|
sd->surface = evas_gl_surface_create(sd->evasgl, sd->config, sd->w, sd->h);
|
2015-04-06 01:26:31 -07:00
|
|
|
sd->config->options_bits = opt;
|
2014-09-22 19:19:18 -07:00
|
|
|
evas_gl_native_surface_get(sd->evasgl, sd->surface, &ns);
|
|
|
|
evas_object_image_native_surface_set(wd->resize_obj, &ns);
|
2016-08-16 01:06:19 -07:00
|
|
|
elm_obj_glview_draw_request(obj);
|
2015-04-06 06:44:30 -07:00
|
|
|
|
|
|
|
// fake a resize event so that clients can reconfigure their viewport
|
|
|
|
sd->resized = EINA_TRUE;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static void
|
2017-09-15 02:37:25 -07:00
|
|
|
_elm_glview_efl_gfx_size_set(Eo *obj, Elm_Glview_Data *sd, Eina_Size2D sz)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
|
evas/elm: Remove function group_resize
This is an override of efl_gfx_size_set. Same as before, the
order of operations matter so it is possible that a corner
case will break. In particular, legacy code was:
- intercept
- smart resize (do stuff), super, super, super
- evas object resize
The new code is more like:
- intercept
- super, super, super, evas object resize
- do stuff
But unfortunately this broke elm_widget (read: all widgets) as
the internal resize was done before the object resize. So,
inside the resize event cb, the resize_obj size would not match
the smart object size. >_<
2016-10-11 00:54:31 -07:00
|
|
|
return;
|
|
|
|
|
2017-09-15 02:37:25 -07:00
|
|
|
efl_gfx_size_set(efl_super(obj, MY_CLASS), sz);
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
sd->resized = EINA_TRUE;
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->scale_policy == ELM_GLVIEW_RESIZE_POLICY_RECREATE)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
if ((sz.w == 0) || (sz.h == 0))
|
|
|
|
sz = EINA_SIZE2D(64, 64);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2017-09-15 02:37:25 -07:00
|
|
|
sd->w = sz.w;
|
|
|
|
sd->h = sz.h;
|
2012-05-03 15:43:42 -07:00
|
|
|
|
|
|
|
_glview_update_surface(obj);
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_render_cb(void *obj, const Efl_Event *event EINA_UNUSED)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2012-05-03 15:43:42 -07:00
|
|
|
ELM_GLVIEW_DATA_GET(obj, sd);
|
2016-06-20 07:31:31 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, );
|
2015-07-13 01:02:32 -07:00
|
|
|
|
|
|
|
evas_object_render_op_set(wd->resize_obj, evas_object_render_op_get(obj));
|
2011-06-03 00:09:25 -07:00
|
|
|
|
|
|
|
// Do a make current
|
2012-05-03 15:43:42 -07:00
|
|
|
if (!evas_gl_make_current(sd->evasgl, sd->surface, sd->context))
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Failed doing make current.");
|
2016-04-21 16:26:25 -07:00
|
|
|
goto on_error;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
// Call the init function if it hasn't been called already
|
2012-05-03 15:43:42 -07:00
|
|
|
if (!sd->initialized)
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
{
|
2016-03-15 23:58:35 -07:00
|
|
|
//TODO:will be optimized
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, ELM_GLVIEW_EVENT_CREATED, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->init_func) sd->init_func(obj);
|
|
|
|
sd->initialized = EINA_TRUE;
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->resized)
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
{
|
2016-03-15 23:58:35 -07:00
|
|
|
//TODO:will be optimized
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, ELM_GLVIEW_EVENT_RESIZED, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->resize_func) sd->resize_func(obj);
|
|
|
|
sd->resized = EINA_FALSE;
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
}
|
|
|
|
|
2014-01-10 07:40:01 -08:00
|
|
|
if (sd->render_policy == ELM_GLVIEW_RENDER_POLICY_ALWAYS)
|
|
|
|
evas_sync(evas_object_evas_get(obj));
|
2011-06-03 00:09:25 -07:00
|
|
|
// Call the render function
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->render_func) sd->render_func(obj);
|
2016-03-15 23:58:35 -07:00
|
|
|
//TODO:will be optimized
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, ELM_GLVIEW_EVENT_RENDER, NULL);
|
2011-06-03 00:09:25 -07:00
|
|
|
|
|
|
|
// Depending on the policy return true or false
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->render_policy == ELM_GLVIEW_RENDER_POLICY_ON_DEMAND)
|
2016-04-21 16:26:25 -07:00
|
|
|
{
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2016-04-21 16:26:25 -07:00
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
else if (sd->render_policy == ELM_GLVIEW_RENDER_POLICY_ALWAYS)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
|
|
|
// Return false so it only runs once
|
2016-04-21 16:26:25 -07:00
|
|
|
goto on_error;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Invalid Render Policy.");
|
2016-04-21 16:26:25 -07:00
|
|
|
goto on_error;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2016-04-21 16:26:25 -07:00
|
|
|
|
|
|
|
on_error:
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_event_callback_del(efl_main_loop_get(),
|
2016-04-21 16:26:25 -07:00
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
|
|
|
_render_cb,
|
|
|
|
obj);
|
|
|
|
sd->render_idle_enterer = 0;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_set_render_policy_callback(Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:43:42 -07:00
|
|
|
ELM_GLVIEW_DATA_GET(obj, sd);
|
2013-10-05 01:14:28 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
switch (sd->render_policy)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
|
|
|
case ELM_GLVIEW_RENDER_POLICY_ON_DEMAND:
|
2015-05-28 12:35:35 -07:00
|
|
|
if (sd->render_idle_enterer)
|
2016-11-21 00:31:48 -08:00
|
|
|
{
|
|
|
|
evas_object_image_pixels_dirty_set(wd->resize_obj, EINA_TRUE);
|
|
|
|
evas_object_image_data_update_add(wd->resize_obj, 0, 0, sd->w, sd->h);
|
|
|
|
}
|
2014-01-21 16:55:58 -08:00
|
|
|
// Delete idle_enterer if it for some reason is around
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_event_callback_del(efl_main_loop_get(),
|
2016-04-21 16:26:25 -07:00
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
|
|
|
_render_cb,
|
|
|
|
obj);
|
|
|
|
sd->render_idle_enterer = 0;
|
2012-05-03 15:43:42 -07:00
|
|
|
|
|
|
|
// Set pixel getter callback
|
|
|
|
evas_object_image_pixels_get_callback_set
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj,
|
2012-05-03 15:43:42 -07:00
|
|
|
(Evas_Object_Image_Pixels_Get_Cb)_render_cb,
|
|
|
|
obj);
|
|
|
|
break;
|
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
case ELM_GLVIEW_RENDER_POLICY_ALWAYS:
|
2017-08-20 19:34:48 -07:00
|
|
|
if (evas_object_image_pixels_dirty_get(wd->resize_obj) && !sd->render_idle_enterer)
|
2018-02-26 21:10:12 -08:00
|
|
|
sd->render_idle_enterer = efl_event_callback_priority_add(efl_main_loop_get(),
|
2016-04-21 16:26:25 -07:00
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
2016-08-15 06:44:41 -07:00
|
|
|
EFL_CALLBACK_PRIORITY_BEFORE,
|
2016-04-21 16:26:25 -07:00
|
|
|
_render_cb,
|
|
|
|
obj);
|
2012-05-03 15:43:42 -07:00
|
|
|
// Unset the pixel getter callback if set already
|
|
|
|
evas_object_image_pixels_get_callback_set
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, NULL, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
|
|
|
break;
|
Upon reviewing the elm_glview, I've realized a few issues and mistakes that i've
made originally so I've made some changes/ updates to elm_glview
1.) GL Resource Deletion in ELM_GLView
In order to delete GL resources, the current approach simply registered a
delete callback to the GLView object and handled resource deletion there.
Unfortunately, using the delete callback did not guarantee the glview context to be
current. In order to guarantee that the current context was the glview context,
the make_current call needs to be called explicitly. Since we were hiding all the
make current details in elm_glview, i've decided to add an API that registers a
delete callback function. I know that this may seem redundant since there is already
a delete callback that you can register with glview objects. Unfortunately, this is the
only option that we have apart from exposing make_current, which is something that
went again what we are trying to do with elm_glview.
Since adding delete callback alone seemed a little out of place, i've taken the liberty
to add other callback functions to make it seem consistent.
void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func func);
void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func func);
resize callback can be controversial as well but I want to argue that adding this callback
makes the render function a lot cleaner. To handle resize differently, the user in
render function needs to manually compare and see if the size has changed, and
then handle the cases. Doing all of this internally once makes the developers life
a lot easier in my opinion.
these callback functions do make the render function a lot cleaner. You can check
out the updated test_glview.c or newly added test_glview_simple.
2.) Minor bug fixes/changes
elm_glview_scale_policy_set() was supposed to be elm_glview_resize_policy_set()
but it somehow evaded our reviews. That has been fixed.
Also, in _glview_resize, after updating the surface, it was explicitly calling the
render function. It is actually unnecessary here and calling it here will cause
problems if resize gets called before everything else is setup properly. So that has
been commented out.
3.) test_glview & test_glview_simple
elementary_test case for glview has been updated to reflect the api changes.
when you run the elmentary_test, you need to make sure that you set
ELM_ENGINE=gl as glview currently only runs on gl backend.
test_glview runs the gears example. For testing purposes I've included a simple
glview test case that renders a triangle and changing background color.
SVN revision: 60517
2011-06-20 03:55:02 -07:00
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
default:
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Invalid Render Policy.");
|
2012-05-03 15:43:42 -07:00
|
|
|
return;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_glview_efl_canvas_group_group_add(Eo *obj, Elm_Glview_Data *priv EINA_UNUSED)
|
2012-05-03 15:43:42 -07:00
|
|
|
{
|
2013-09-24 21:33:39 -07:00
|
|
|
Evas_Object *img;
|
|
|
|
|
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2013-08-26 22:19:19 -07:00
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
// Create image to render Evas_GL Surface
|
2013-09-24 21:33:39 -07:00
|
|
|
img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
2017-08-08 05:06:43 -07:00
|
|
|
elm_widget_resize_object_set(obj, img);
|
2013-02-16 05:39:59 -08:00
|
|
|
evas_object_image_size_set(img, 1, 1);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2014-09-22 22:04:32 -07:00
|
|
|
}
|
2012-07-17 11:44:43 -07:00
|
|
|
|
2014-09-22 22:04:32 -07:00
|
|
|
static void
|
|
|
|
_elm_glview_constructor(Eo *obj, Elm_Glview_Data *priv)
|
|
|
|
{
|
2012-07-17 11:44:43 -07:00
|
|
|
// Evas_GL
|
|
|
|
priv->evasgl = evas_gl_new(evas_object_evas_get(obj));
|
|
|
|
if (!priv->evasgl)
|
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Failed Creating an Evas GL Object.");
|
2012-07-17 11:44:43 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a default config
|
|
|
|
priv->config = evas_gl_config_new();
|
|
|
|
if (!priv->config)
|
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Failed Creating a Config Object.");
|
2012-07-17 11:44:43 -07:00
|
|
|
evas_gl_free(priv->evasgl);
|
|
|
|
priv->evasgl = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
priv->config->color_format = EVAS_GL_RGB_888;
|
|
|
|
|
|
|
|
// Initialize variables
|
|
|
|
priv->scale_policy = ELM_GLVIEW_RESIZE_POLICY_RECREATE;
|
|
|
|
priv->render_policy = ELM_GLVIEW_RENDER_POLICY_ON_DEMAND;
|
|
|
|
|
|
|
|
// Initialize it to (64,64) (It's an arbitrary value)
|
|
|
|
priv->w = 64;
|
|
|
|
priv->h = 64;
|
|
|
|
|
2014-09-22 22:04:32 -07:00
|
|
|
// Set context version
|
|
|
|
if (!priv->gles_version)
|
|
|
|
priv->gles_version = EVAS_GL_GLES_2_X;
|
|
|
|
priv->config->gles_version = priv->gles_version;
|
|
|
|
|
2012-07-17 11:44:43 -07:00
|
|
|
// Create Context
|
2014-09-22 22:04:32 -07:00
|
|
|
if (priv->gles_version == EVAS_GL_GLES_2_X)
|
|
|
|
priv->context = evas_gl_context_create(priv->evasgl, NULL);
|
|
|
|
else
|
|
|
|
priv->context = evas_gl_context_version_create(priv->evasgl, NULL, priv->gles_version);
|
2012-07-17 11:44:43 -07:00
|
|
|
if (!priv->context)
|
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Error Creating an Evas_GL Context.");
|
2014-09-22 22:04:32 -07:00
|
|
|
ELM_SAFE_FREE(priv->config, evas_gl_config_free);
|
|
|
|
ELM_SAFE_FREE(priv->evasgl, evas_gl_free);
|
2012-07-17 11:44:43 -07:00
|
|
|
return;
|
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_glview_efl_canvas_group_group_del(Eo *obj, Elm_Glview_Data *sd)
|
2012-05-03 15:43:42 -07:00
|
|
|
{
|
2014-09-01 00:36:36 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
// Call delete func if it's registered
|
|
|
|
if (sd->del_func)
|
|
|
|
{
|
|
|
|
evas_gl_make_current(sd->evasgl, sd->surface, sd->context);
|
|
|
|
sd->del_func(obj);
|
|
|
|
}
|
2016-03-15 23:58:35 -07:00
|
|
|
//TODO:will be optimised
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, ELM_GLVIEW_EVENT_DESTROYED, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2018-02-26 21:10:12 -08:00
|
|
|
efl_event_callback_del(efl_main_loop_get(),
|
2016-04-21 16:26:25 -07:00
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
|
|
|
_render_cb,
|
|
|
|
obj);
|
2015-04-14 04:52:38 -07:00
|
|
|
evas_gl_make_current(sd->evasgl, NULL, NULL);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2014-09-01 00:36:36 -07:00
|
|
|
if (sd->surface)
|
|
|
|
{
|
|
|
|
evas_object_image_native_surface_set(wd->resize_obj, NULL);
|
|
|
|
evas_gl_surface_destroy(sd->evasgl, sd->surface);
|
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->context) evas_gl_context_destroy(sd->evasgl, sd->context);
|
|
|
|
if (sd->config) evas_gl_config_free(sd->config);
|
|
|
|
if (sd->evasgl) evas_gl_free(sd->evasgl);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
2012-05-03 15:43:42 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_cb_added(void *data EINA_UNUSED, const Efl_Event *ev)
|
2016-03-15 23:58:35 -07:00
|
|
|
{
|
2016-08-10 07:23:04 -07:00
|
|
|
const Efl_Callback_Array_Item *event = ev->info;
|
2016-03-15 23:58:35 -07:00
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
ELM_GLVIEW_DATA_GET(ev->object, sd);
|
2016-03-15 23:58:35 -07:00
|
|
|
|
|
|
|
if (event->desc == ELM_GLVIEW_EVENT_CREATED)
|
|
|
|
{
|
|
|
|
sd->initialized = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else if (event->desc == ELM_GLVIEW_EVENT_RENDER)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
_set_render_policy_callback(ev->object);
|
2016-03-15 23:58:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_glview_add(Evas_Object *parent)
|
|
|
|
{
|
2012-05-03 15:43:42 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2017-11-06 21:00:43 -08:00
|
|
|
return elm_legacy_add(MY_CLASS, parent,
|
|
|
|
elm_obj_glview_version_constructor(efl_added, EVAS_GL_GLES_2_X));
|
2014-09-22 22:04:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_glview_version_add(Evas_Object *parent, Evas_GL_Context_Version version)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2017-11-06 21:00:43 -08:00
|
|
|
return elm_legacy_add(MY_CLASS, parent,
|
|
|
|
elm_obj_glview_version_constructor(efl_added, version));
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2014-09-22 22:04:32 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_glview_version_constructor(Eo *obj, Elm_Glview_Data *sd,
|
|
|
|
Evas_GL_Context_Version version)
|
|
|
|
{
|
|
|
|
sd->gles_version =
|
|
|
|
((version > 0) && (version <= 3)) ? version : EVAS_GL_GLES_2_X;
|
|
|
|
_elm_glview_constructor(obj, sd);
|
|
|
|
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_role_set(obj, EFL_ACCESS_ROLE_ANIMATION);
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL);
|
2015-05-20 08:31:04 -07:00
|
|
|
}
|
2012-07-18 14:03:39 -07:00
|
|
|
|
2015-05-20 08:31:04 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_glview_efl_object_finalize(Eo *obj, Elm_Glview_Data *sd)
|
2015-05-20 08:31:04 -07:00
|
|
|
{
|
2012-05-03 15:43:42 -07:00
|
|
|
if (!sd->evasgl)
|
2012-10-31 04:41:01 -07:00
|
|
|
{
|
2015-05-20 08:31:04 -07:00
|
|
|
ERR("Failed");
|
|
|
|
return NULL;
|
2012-10-31 04:41:01 -07:00
|
|
|
}
|
2015-05-20 08:31:04 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
return efl_finalize(efl_super(obj, MY_CLASS));
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static Evas_GL_API*
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_glview_gl_api_get(const Eo *obj EINA_UNUSED, Elm_Glview_Data *sd)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2014-09-22 22:04:32 -07:00
|
|
|
return evas_gl_context_api_get(sd->evasgl, sd->context);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_glview_mode_set(Eo *obj, Elm_Glview_Data *sd, Elm_GLView_Mode mode)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-23 02:39:00 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
2011-06-03 00:09:25 -07:00
|
|
|
|
|
|
|
// Set the configs
|
2012-05-03 15:43:42 -07:00
|
|
|
if (mode & ELM_GLVIEW_ALPHA) sd->config->color_format = EVAS_GL_RGBA_8888;
|
|
|
|
else sd->config->color_format = EVAS_GL_RGB_888;
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2014-09-04 01:44:21 -07:00
|
|
|
if (mode & ELM_GLVIEW_DEPTH)
|
|
|
|
{
|
|
|
|
const int mask = 7 << 6;
|
|
|
|
if ((mode & mask) == (ELM_GLVIEW_DEPTH_8 & mask))
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_BIT_8;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_DEPTH_16 & mask))
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_BIT_16;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_DEPTH_24 & mask))
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_BIT_24;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_DEPTH_32 & mask))
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_BIT_32;
|
|
|
|
else
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_BIT_24;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sd->config->depth_bits = EVAS_GL_DEPTH_NONE;
|
2011-06-03 00:09:25 -07:00
|
|
|
|
|
|
|
if (mode & ELM_GLVIEW_STENCIL)
|
2014-09-04 01:44:21 -07:00
|
|
|
{
|
|
|
|
const int mask = 7 << 9;
|
|
|
|
if ((mode & mask) == (ELM_GLVIEW_STENCIL_1 & mask))
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_1;
|
2017-05-16 22:32:08 -07:00
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_STENCIL_2 & mask))
|
2014-09-04 01:44:21 -07:00
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_2;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_STENCIL_4 & mask))
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_4;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_STENCIL_8 & mask))
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
|
|
|
|
else if ((mode & mask) == (ELM_GLVIEW_STENCIL_16 & mask))
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_16;
|
|
|
|
else
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sd->config->stencil_bits = EVAS_GL_STENCIL_NONE;
|
2012-01-12 06:35:43 -08:00
|
|
|
|
2014-09-04 01:44:21 -07:00
|
|
|
if (mode & ELM_GLVIEW_MULTISAMPLE_HIGH)
|
|
|
|
{
|
|
|
|
if ((mode & ELM_GLVIEW_MULTISAMPLE_HIGH) == ELM_GLVIEW_MULTISAMPLE_LOW)
|
|
|
|
sd->config->multisample_bits = EVAS_GL_MULTISAMPLE_LOW;
|
|
|
|
else if ((mode & ELM_GLVIEW_MULTISAMPLE_HIGH) == ELM_GLVIEW_MULTISAMPLE_MED)
|
|
|
|
sd->config->multisample_bits = EVAS_GL_MULTISAMPLE_MED;
|
|
|
|
else
|
|
|
|
sd->config->multisample_bits = EVAS_GL_MULTISAMPLE_HIGH;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sd->config->multisample_bits = EVAS_GL_MULTISAMPLE_NONE;
|
|
|
|
|
|
|
|
sd->config->options_bits = EVAS_GL_OPTIONS_NONE;
|
2012-01-12 06:35:43 -08:00
|
|
|
if (mode & ELM_GLVIEW_DIRECT)
|
2012-05-03 15:43:42 -07:00
|
|
|
sd->config->options_bits = EVAS_GL_OPTIONS_DIRECT;
|
2014-09-04 01:44:21 -07:00
|
|
|
if (mode & ELM_GLVIEW_CLIENT_SIDE_ROTATION)
|
|
|
|
sd->config->options_bits |= EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION;
|
2011-06-03 10:44:24 -07:00
|
|
|
|
2014-09-18 21:10:02 -07:00
|
|
|
// Check for Alpha Channel and enable it
|
|
|
|
if (mode & ELM_GLVIEW_ALPHA)
|
|
|
|
evas_object_image_alpha_set(wd->resize_obj, EINA_TRUE);
|
|
|
|
else
|
|
|
|
evas_object_image_alpha_set(wd->resize_obj, EINA_FALSE);
|
|
|
|
|
2012-05-03 15:43:42 -07:00
|
|
|
sd->mode = mode;
|
2015-04-06 01:26:31 -07:00
|
|
|
sd->warned_about_dr = EINA_FALSE;
|
2011-06-03 10:44:24 -07:00
|
|
|
|
2013-03-07 02:20:40 -08:00
|
|
|
_glview_update_surface(obj);
|
2015-03-16 00:38:20 -07:00
|
|
|
if (!sd->surface)
|
|
|
|
{
|
|
|
|
ERR("Failed to create a surface with the requested configuration.");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2011-06-03 00:09:25 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_glview_resize_policy_set(Eo *obj, Elm_Glview_Data *sd, Elm_GLView_Resize_Policy policy)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-23 02:39:00 -07:00
|
|
|
if (policy == sd->scale_policy) return EINA_TRUE;
|
2011-06-03 00:09:25 -07:00
|
|
|
switch (policy)
|
|
|
|
{
|
|
|
|
case ELM_GLVIEW_RESIZE_POLICY_RECREATE:
|
|
|
|
case ELM_GLVIEW_RESIZE_POLICY_SCALE:
|
2012-05-03 15:43:42 -07:00
|
|
|
sd->scale_policy = policy;
|
|
|
|
_glview_update_surface(obj);
|
2016-08-16 01:06:19 -07:00
|
|
|
elm_obj_glview_draw_request(obj);
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2011-06-03 00:09:25 -07:00
|
|
|
default:
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Invalid Scale Policy.");
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_FALSE;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_glview_render_policy_set(Eo *obj, Elm_Glview_Data *sd, Elm_GLView_Render_Policy policy)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2011-06-03 10:44:24 -07:00
|
|
|
if ((policy != ELM_GLVIEW_RENDER_POLICY_ON_DEMAND) &&
|
2011-06-03 00:09:25 -07:00
|
|
|
(policy != ELM_GLVIEW_RENDER_POLICY_ALWAYS))
|
|
|
|
{
|
2018-01-16 22:23:52 -08:00
|
|
|
ERR("Invalid Render Policy.");
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_FALSE;
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
if (sd->render_policy == policy) return EINA_TRUE;
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2015-04-06 01:26:31 -07:00
|
|
|
sd->warned_about_dr = EINA_FALSE;
|
2012-05-03 15:43:42 -07:00
|
|
|
sd->render_policy = policy;
|
2011-06-03 00:09:25 -07:00
|
|
|
_set_render_policy_callback(obj);
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static void
|
2017-09-18 04:16:33 -07:00
|
|
|
_elm_glview_efl_gfx_view_view_size_set(Eo *obj, Elm_Glview_Data *sd, Eina_Size2D sz)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
if ((sz.w == sd->w) && (sz.h == sd->h)) return;
|
2011-06-03 10:44:24 -07:00
|
|
|
|
2017-09-18 04:16:33 -07:00
|
|
|
sd->w = sz.w;
|
|
|
|
sd->h = sz.h;
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2013-03-07 02:20:40 -08:00
|
|
|
_glview_update_surface(obj);
|
2016-08-16 01:06:19 -07:00
|
|
|
elm_obj_glview_draw_request(obj);
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
2017-09-18 04:16:33 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_glview_efl_gfx_view_view_size_get(const Eo *obj EINA_UNUSED, Elm_Glview_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
return EINA_SIZE2D(sd->w, sd->h);
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
EOLIAN static void
|
2016-03-10 23:41:00 -08:00
|
|
|
_elm_glview_draw_request(Eo *obj, Elm_Glview_Data *sd)
|
2011-06-03 00:09:25 -07:00
|
|
|
{
|
2013-10-05 01:14:28 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:43:42 -07:00
|
|
|
|
2016-11-21 00:31:48 -08:00
|
|
|
evas_object_image_pixels_dirty_set(wd->resize_obj, EINA_TRUE);
|
|
|
|
evas_object_image_data_update_add(wd->resize_obj, 0, 0, sd->w, sd->h);
|
2012-05-03 15:43:42 -07:00
|
|
|
if (sd->render_policy == ELM_GLVIEW_RENDER_POLICY_ALWAYS &&
|
|
|
|
!sd->render_idle_enterer)
|
2018-02-26 21:10:12 -08:00
|
|
|
sd->render_idle_enterer = efl_event_callback_priority_add(efl_main_loop_get(),
|
2016-04-21 16:26:25 -07:00
|
|
|
EFL_LOOP_EVENT_IDLE_ENTER,
|
2016-08-15 06:44:41 -07:00
|
|
|
EFL_CALLBACK_PRIORITY_BEFORE,
|
2016-04-21 16:26:25 -07:00
|
|
|
_render_cb, obj);
|
2011-06-03 00:09:25 -07:00
|
|
|
}
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2014-08-31 23:49:10 -07:00
|
|
|
EOLIAN static Evas_GL *
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_glview_evas_gl_get(const Eo *obj EINA_UNUSED, Elm_Glview_Data *sd)
|
2014-08-31 23:49:10 -07:00
|
|
|
{
|
|
|
|
return sd->evasgl;
|
|
|
|
}
|
|
|
|
|
2014-09-18 21:10:02 -07:00
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_elm_glview_rotation_get(const Eo *obj EINA_UNUSED, Elm_Glview_Data *sd)
|
2014-09-18 21:10:02 -07:00
|
|
|
{
|
|
|
|
return evas_gl_rotation_get(sd->evasgl);
|
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_glview_class_constructor(Efl_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2016-03-15 23:58:35 -07:00
|
|
|
/* Legacy deprecated functions */
|
2016-03-11 06:22:23 -08:00
|
|
|
EAPI void
|
|
|
|
elm_glview_changed_set(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_GLVIEW_CHECK(obj);
|
|
|
|
|
2016-08-16 01:06:19 -07:00
|
|
|
elm_obj_glview_draw_request(obj);
|
2016-03-11 06:22:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_glview_size_get(const Elm_Glview *obj, int *w, int *h)
|
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
Eina_Size2D sz;
|
|
|
|
sz = efl_gfx_view_size_get(obj);
|
|
|
|
if (w) *w = sz.w;
|
|
|
|
if (h) *h = sz.h;
|
2016-03-11 06:22:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_glview_size_set(Elm_Glview *obj, int w, int h)
|
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
efl_gfx_view_size_set(obj, EINA_SIZE2D(w, h));
|
2016-03-11 06:22:23 -08:00
|
|
|
}
|
2016-03-15 23:58:35 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2017-05-18 01:52:17 -07:00
|
|
|
|
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define ELM_GLVIEW_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_glview)
|
|
|
|
|
2014-03-23 02:39:00 -07:00
|
|
|
#include "elm_glview.eo.c"
|