summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-09-23 14:04:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-10-20 12:16:43 +0900
commitb73da54bc261283e7ae80c55de43ca4f536a7f1a (patch)
tree08354cbca38ba00f3bc5cbf89b7a9ceff4e29638
parent899f28a4abf11858ccb701b00895a235bbfe70fc (diff)
GLView: Add constructor for GLES 1.1 context glview
This also adds the legacy bindings @feature
-rw-r--r--src/lib/elm_glview.c47
-rw-r--r--src/lib/elm_glview.eo13
-rw-r--r--src/lib/elm_glview_legacy.h13
-rw-r--r--src/lib/elm_widget_glview.h1
4 files changed, 64 insertions, 10 deletions
diff --git a/src/lib/elm_glview.c b/src/lib/elm_glview.c
index d12012d53..ffb2c8ca3 100644
--- a/src/lib/elm_glview.c
+++ b/src/lib/elm_glview.c
@@ -173,7 +173,7 @@ _set_render_policy_callback(Evas_Object *obj)
173} 173}
174 174
175EOLIAN static void 175EOLIAN static void
176_elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv) 176_elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv EINA_UNUSED)
177{ 177{
178 Evas_Object *img; 178 Evas_Object *img;
179 179
@@ -185,7 +185,11 @@ _elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv)
185 evas_object_image_size_set(img, 1, 1); 185 evas_object_image_size_set(img, 1, 1);
186 186
187 eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); 187 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
188}
188 189
190static void
191_elm_glview_constructor(Eo *obj, Elm_Glview_Data *priv)
192{
189 // Evas_GL 193 // Evas_GL
190 priv->evasgl = evas_gl_new(evas_object_evas_get(obj)); 194 priv->evasgl = evas_gl_new(evas_object_evas_get(obj));
191 if (!priv->evasgl) 195 if (!priv->evasgl)
@@ -215,15 +219,22 @@ _elm_glview_evas_object_smart_add(Eo *obj, Elm_Glview_Data *priv)
215 priv->w = 64; 219 priv->w = 64;
216 priv->h = 64; 220 priv->h = 64;
217 221
222 // Set context version
223 if (!priv->gles_version)
224 priv->gles_version = EVAS_GL_GLES_2_X;
225 priv->config->gles_version = priv->gles_version;
226
218 // Create Context 227 // Create Context
219 priv->context = evas_gl_context_create(priv->evasgl, NULL); 228 if (priv->gles_version == EVAS_GL_GLES_2_X)
229 priv->context = evas_gl_context_create(priv->evasgl, NULL);
230 else
231 priv->context = evas_gl_context_version_create(priv->evasgl, NULL, priv->gles_version);
220 if (!priv->context) 232 if (!priv->context)
221 { 233 {
222 ERR("Error Creating an Evas_GL Context.\n"); 234 ERR("Error Creating an Evas_GL Context.\n");
223 235
224 evas_gl_config_free(priv->config); 236 ELM_SAFE_FREE(priv->config, evas_gl_config_free);
225 evas_gl_free(priv->evasgl); 237 ELM_SAFE_FREE(priv->evasgl, evas_gl_free);
226 priv->evasgl = NULL;
227 return; 238 return;
228 } 239 }
229} 240}
@@ -258,14 +269,34 @@ EAPI Evas_Object *
258elm_glview_add(Evas_Object *parent) 269elm_glview_add(Evas_Object *parent)
259{ 270{
260 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); 271 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
261 Evas_Object *obj = eo_add(MY_CLASS, parent); 272 Evas_Object *obj = eo_add(MY_CLASS, parent,
273 elm_obj_glview_version_constructor(EVAS_GL_GLES_2_X));
274 return obj;
275}
276
277EAPI Evas_Object *
278elm_glview_version_add(Evas_Object *parent, Evas_GL_Context_Version version)
279{
280 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
281 Evas_Object *obj = eo_add(MY_CLASS, parent,
282 elm_obj_glview_version_constructor(version));
262 return obj; 283 return obj;
263} 284}
264 285
265EOLIAN static void 286EOLIAN static void
266_elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd) 287_elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd EINA_UNUSED)
267{ 288{
268 eo_do_super(obj, MY_CLASS, eo_constructor()); 289 eo_do_super(obj, MY_CLASS, eo_constructor());
290}
291
292EOLIAN static void
293_elm_glview_version_constructor(Eo *obj, Elm_Glview_Data *sd,
294 Evas_GL_Context_Version version)
295{
296 sd->gles_version =
297 ((version > 0) && (version <= 3)) ? version : EVAS_GL_GLES_2_X;
298 _elm_glview_constructor(obj, sd);
299
269 eo_do(obj, 300 eo_do(obj,
270 evas_obj_type_set(MY_CLASS_NAME_LEGACY), 301 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
271 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks), 302 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
@@ -281,7 +312,7 @@ _elm_glview_eo_base_constructor(Eo *obj, Elm_Glview_Data *sd)
281EOLIAN static Evas_GL_API* 312EOLIAN static Evas_GL_API*
282_elm_glview_gl_api_get(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd) 313_elm_glview_gl_api_get(Eo *obj EINA_UNUSED, Elm_Glview_Data *sd)
283{ 314{
284 return evas_gl_api_get(sd->evasgl); 315 return evas_gl_context_api_get(sd->evasgl, sd->context);
285} 316}
286 317
287EOLIAN static Eina_Bool 318EOLIAN static Eina_Bool
diff --git a/src/lib/elm_glview.eo b/src/lib/elm_glview.eo
index 839cb669a..cee3277ba 100644
--- a/src/lib/elm_glview.eo
+++ b/src/lib/elm_glview.eo
@@ -1,6 +1,15 @@
1class Elm_Glview (Elm_Widget) 1class Elm_Glview (Elm_Widget)
2{ 2{
3 eo_prefix: elm_obj_glview; 3 eo_prefix: elm_obj_glview;
4 methods {
5 version_constructor {
6 /*@ Constructor with context version number. */
7 legacy: null;
8 params {
9 @in Evas_GL_Context_Version version;
10 }
11 }
12 }
4 properties { 13 properties {
5 size { 14 size {
6 set { 15 set {
@@ -216,5 +225,7 @@ class Elm_Glview (Elm_Widget)
216 language,changed; 225 language,changed;
217 access,changed; 226 access,changed;
218 } 227 }
219 228 constructors {
229 .version_constructor;
230 }
220} 231}
diff --git a/src/lib/elm_glview_legacy.h b/src/lib/elm_glview_legacy.h
index b5c545e42..fdfbb6a81 100644
--- a/src/lib/elm_glview_legacy.h
+++ b/src/lib/elm_glview_legacy.h
@@ -8,4 +8,15 @@
8 */ 8 */
9EAPI Evas_Object *elm_glview_add(Evas_Object *parent); 9EAPI Evas_Object *elm_glview_add(Evas_Object *parent);
10 10
11#include "elm_glview.eo.legacy.h" \ No newline at end of file 11/**
12 * Adds a new GLView to the parent, given an OpenGL-ES context version number.
13 *
14 * @param[in] parent The parent object
15 * @param[in] version Requested GL ES version number (default is 2.x, 1.x may also be supported)
16 * @return The new object or @c NULL if it cannot be created
17 *
18 * @since 1.12
19 */
20EAPI Evas_Object *elm_glview_version_add(Evas_Object *parent, Evas_GL_Context_Version version);
21
22#include "elm_glview.eo.legacy.h"
diff --git a/src/lib/elm_widget_glview.h b/src/lib/elm_widget_glview.h
index 175bdf1c9..93ce2f815 100644
--- a/src/lib/elm_widget_glview.h
+++ b/src/lib/elm_widget_glview.h
@@ -29,6 +29,7 @@ struct _Elm_Glview_Data
29 Elm_GLView_Mode mode; 29 Elm_GLView_Mode mode;
30 Elm_GLView_Resize_Policy scale_policy; 30 Elm_GLView_Resize_Policy scale_policy;
31 Elm_GLView_Render_Policy render_policy; 31 Elm_GLView_Render_Policy render_policy;
32 Evas_GL_Context_Version gles_version;
32 33
33 Evas_GL *evasgl; 34 Evas_GL *evasgl;
34 Evas_GL_Config *config; 35 Evas_GL_Config *config;