jpeg pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=b73da54bc261283e7ae80c55de43ca4f536a7f1a
commit b73da54bc261283e7ae80c55de43ca4f536a7f1a Author: Jean-Philippe Andre <[email protected]> Date: Tue Sep 23 14:04:32 2014 +0900 GLView: Add constructor for GLES 1.1 context glview This also adds the legacy bindings @feature --- src/lib/elm_glview.c | 47 +++++++++++++++++++++++++++++++++++++-------- src/lib/elm_glview.eo | 13 ++++++++++++- src/lib/elm_glview_legacy.h | 13 ++++++++++++- src/lib/elm_widget_glview.h | 1 + 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/lib/elm_glview.c b/src/lib/elm_glview.c index d12012d..ffb2c8c 100644 --- a/src/lib/elm_glview.c +++ b/src/lib/elm_glview.c @@ -173,7 +173,7 @@ _set_render_policy_callback(Evas_Object *obj) } EOLIAN static void -_elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv) +_elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv EINA_UNUSED) { Evas_Object *img; @@ -185,7 +185,11 @@ _elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv) evas_object_image_size_set(img, 1, 1); eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); +} +static void +_elm_glview_constructor(Eo *obj, Elm_Glview_Data *priv) +{ // Evas_GL priv->evasgl = evas_gl_new(evas_object_evas_get(obj)); if (!priv->evasgl) @@ -215,15 +219,22 @@ _elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv) priv->w = 64; priv->h = 64; + // Set context version + if (!priv->gles_version) + priv->gles_version = EVAS_GL_GLES_2_X; + priv->config->gles_version = priv->gles_version; + // Create Context - priv->context = evas_gl_context_create(priv->evasgl, NULL); + 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); if (!priv->context) { ERR("Error Creating an Evas_GL Context.\n"); - evas_gl_config_free(priv->config); - evas_gl_free(priv->evasgl); - priv->evasgl = NULL; + ELM_SAFE_FREE(priv->config, evas_gl_config_free); + ELM_SAFE_FREE(priv->evasgl, evas_gl_free); return; } } @@ -258,14 +269,34 @@ EAPI Evas_Object * elm_glview_add(Evas_Object *parent) { EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - Evas_Object *obj = eo_add(MY_CLASS, parent); + Evas_Object *obj = eo_add(MY_CLASS, parent, + elm_obj_glview_version_constructor(EVAS_GL_GLES_2_X)); + return obj; +} + +EAPI Evas_Object * +elm_glview_version_add(Evas_Object *parent, Evas_GL_Context_Version version) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + Evas_Object *obj = eo_add(MY_CLASS, parent, + elm_obj_glview_version_constructor(version)); return obj; } EOLIAN static void -_elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd) +_elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); +} + +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); + eo_do(obj, evas_obj_type_set(MY_CLASS_NAME_LEGACY), evas_obj_smart_callbacks_descriptions_set(_smart_callbacks), @@ -281,7 +312,7 @@ _elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd) EOLIAN static Evas_GL_API* _elm_glview_gl_api_get(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd) { - return evas_gl_api_get(sd->evasgl); + return evas_gl_context_api_get(sd->evasgl, sd->context); } EOLIAN static Eina_Bool diff --git a/src/lib/elm_glview.eo b/src/lib/elm_glview.eo index 839cb66..cee3277 100644 --- a/src/lib/elm_glview.eo +++ b/src/lib/elm_glview.eo @@ -1,6 +1,15 @@ class Elm_Glview (Elm_Widget) { eo_prefix: elm_obj_glview; + methods { + version_constructor { + /*@ Constructor with context version number. */ + legacy: null; + params { + @in Evas_GL_Context_Version version; + } + } + } properties { size { set { @@ -216,5 +225,7 @@ class Elm_Glview (Elm_Widget) language,changed; access,changed; } - + constructors { + .version_constructor; + } } diff --git a/src/lib/elm_glview_legacy.h b/src/lib/elm_glview_legacy.h index b5c545e..fdfbb6a 100644 --- a/src/lib/elm_glview_legacy.h +++ b/src/lib/elm_glview_legacy.h @@ -8,4 +8,15 @@ */ EAPI Evas_Object *elm_glview_add(Evas_Object *parent); -#include "elm_glview.eo.legacy.h" \ No newline at end of file +/** + * Adds a new GLView to the parent, given an OpenGL-ES context version number. + * + * @param[in] parent The parent object + * @param[in] version Requested GL ES version number (default is 2.x, 1.x may also be supported) + * @return The new object or @c NULL if it cannot be created + * + * @since 1.12 + */ +EAPI Evas_Object *elm_glview_version_add(Evas_Object *parent, Evas_GL_Context_Version version); + +#include "elm_glview.eo.legacy.h" diff --git a/src/lib/elm_widget_glview.h b/src/lib/elm_widget_glview.h index 175bdf1..93ce2f8 100644 --- a/src/lib/elm_widget_glview.h +++ b/src/lib/elm_widget_glview.h @@ -29,6 +29,7 @@ struct _Elm_Glview_Data Elm_GLView_Mode mode; Elm_GLView_Resize_Policy scale_policy; Elm_GLView_Render_Policy render_policy; + Evas_GL_Context_Version gles_version; Evas_GL *evasgl; Evas_GL_Config *config; --
