EvasGL: implement evgl_eng_context_create for GLES 3 on wayland_egl 58/52458/2
authorDaeKwang Ryu <dkdk.ryu@samsung.com>
Wed, 28 Oct 2015 05:59:35 +0000 (14:59 +0900)
committerDaeKwang Ryu <dkdk.ryu@samsung.com>
Fri, 4 Dec 2015 06:17:34 +0000 (15:17 +0900)
Change-Id: I450a2dd0ef2c08be4128f9e4685e089967ceba13

src/modules/evas/engines/wayland_egl/evas_engine.c

index 587b998..fbc7c88 100644 (file)
@@ -386,9 +386,50 @@ evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version)
    EGLContext context = EGL_NO_CONTEXT;
    int attrs[3];
 
-   if (!(re = (Render_Engine *)data)) return NULL;
+   if (!(re = (Render_Engine *)data))
+     {
+        ERR("Invalid Render Engine Data!");
+        glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
+        return NULL;
+     }
+
    if (!(ob = eng_get_ob(re))) return NULL;
 
+   if ((version < EVAS_GL_GLES_1_X) || (version > EVAS_GL_GLES_3_X))
+     {
+        ERR("Invalid context version number %d", version);
+        glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_PARAMETER);
+        return NULL;
+     }
+
+   if ((version == EVAS_GL_GLES_3_X) &&
+       ((!ob->gl_context) || (ob->gl_context->gles_version != EVAS_GL_GLES_3_X)))
+     {
+        EGLint num_config=0;
+        EGLint version_config_attrs[3];
+        version_config_attrs[0] = EGL_RENDERABLE_TYPE;
+        version_config_attrs[1] = EGL_OPENGL_ES3_BIT;
+        version_config_attrs[2] = EGL_NONE;
+
+        if ((!eglChooseConfig(ob->egl_disp, version_config_attrs, NULL, 0, &num_config))
+           || (num_config < 1))
+          {
+             ERR("GLES 3 version not supported!");
+             glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_ATTRIBUTE);
+             return NULL;
+          }
+        else if (ob->gl_context)
+          {
+             ob->gl_context->gles_version = EVAS_GL_GLES_3_X;
+          }
+        else
+          {
+             ERR("Evas GL Context not initialised!");
+             glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
+             return NULL;
+          }
+     }
+
    attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
    attrs[1] = version;
    attrs[2] = EGL_NONE;
@@ -415,7 +456,9 @@ evgl_eng_context_create(void *data, void *ctxt, Evas_GL_Context_Version version)
 
    if (!context)
      {
-        ERR("Failed to create egl context: %#x", eglGetError());
+        int err = eglGetError();
+        ERR("Failed to create egl context: %#x", err);
+        glsym_evas_gl_common_error_set(data, err - EGL_SUCCESS);
         return NULL;
      }