evas_gl: add missed wrapper functions in GLES 3.0 93/151593/4
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Thu, 21 Sep 2017 07:54:17 +0000 (16:54 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 11 Oct 2017 05:26:12 +0000 (14:26 +0900)
Evas have to wrap below 3 functions.
glFramebufferTestureLayer, glInvalidateFramebuffer,
glInvalidateSubFramebuffer.

Change-Id: I43fccb00e82a276a9c9bc7c87c8d5b99dc7c4d58

src/modules/evas/engines/gl_common/evas_gl_api.c
src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h

index 09b5a55..1ae715d 100644 (file)
@@ -866,6 +866,57 @@ _evgl_glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLi
     _gles3_api.glFramebufferTexture(target, attachment, texture, level);
 }
 
+static void
+_evgl_glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
+{
+    EVGL_Resource *rsc;
+    EVGL_Context *ctx;
+
+    if (!(rsc=_evgl_tls_resource_get()))
+      {
+         ERR("Unable to execute GL command. Error retrieving tls");
+         return;
+      }
+
+    if (!rsc->current_eng)
+      {
+         ERR("Unable to retrive Current Engine");
+         return;
+      }
+
+    ctx = rsc->current_ctx;
+    if (!ctx)
+      {
+         ERR("Unable to retrive Current Context");
+         return;
+      }
+
+    if (!_evgl_direct_enabled())
+      {
+         if (ctx->version == EVAS_GL_GLES_3_X)
+           {
+              if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
+                {
+                   if (ctx->current_draw_fbo == 0)
+                     {
+                        SET_GL_ERROR(GL_INVALID_OPERATION);
+                        return;
+                     }
+                }
+              else if (target == GL_READ_FRAMEBUFFER)
+                {
+                   if (ctx->current_read_fbo == 0)
+                     {
+                        SET_GL_ERROR(GL_INVALID_OPERATION);
+                        return;
+                     }
+                }
+           }
+      }
+
+    _gles3_api.glFramebufferTextureLayer(target, attachment, texture, level, layer);
+}
+
 
 static void
 _evgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
@@ -1511,6 +1562,144 @@ _evgl_glGetStringi(GLenum name, GLuint index)
 }
 
 static void
+_evgl_glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
+{
+   EVGL_Resource *rsc;
+   EVGL_Context *ctx;
+   GLenum *cp_attachments = NULL;
+
+   if (!(rsc=_evgl_tls_resource_get()))
+     {
+        ERR("Unable to execute GL command. Error retrieving tls");
+        return;
+     }
+
+   if (!rsc->current_eng)
+     {
+        ERR("Unable to retrive Current Engine");
+        return;
+     }
+
+   ctx = rsc->current_ctx;
+   if (!ctx)
+     {
+        ERR("Unable to retrive Current Context");
+        return;
+     }
+
+   if (!_evgl_direct_enabled())
+     {
+        if (ctx->current_draw_fbo == 0)
+          {
+             int i;
+             cp_attachments = (GLenum *) malloc(sizeof(GLenum) * numAttachments);
+
+             if (!cp_attachments)
+               {
+                 ERR("malloc failed");
+                 return;
+               }
+
+             for (i = 0; i < numAttachments; i++)
+               {
+                  if (attachments[i] == GL_COLOR)
+                    cp_attachments[i] = GL_COLOR_ATTACHMENT0;
+                  else if (attachments[i] == GL_DEPTH)
+                    cp_attachments[i] = GL_DEPTH_ATTACHMENT;
+                  else if (attachments[i] == GL_STENCIL)
+                    cp_attachments[i] = GL_STENCIL_ATTACHMENT;
+                  else
+                    {
+                       // When default framebuffer is bound, GL_DEPTH_STENCIL generates INVALID_ENUM.
+                       SET_GL_ERROR(GL_INVALID_ENUM);
+                       free(cp_attachments);
+                       return;
+                    }
+               }
+          }
+      }
+
+   if (cp_attachments)
+     {
+        _gles3_api.glInvalidateFramebuffer(target, numAttachments, cp_attachments);
+        free(cp_attachments);
+     }
+   else
+      _gles3_api.glInvalidateFramebuffer(target, numAttachments, attachments);
+
+   return;
+}
+
+static void
+_evgl_glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   EVGL_Resource *rsc;
+   EVGL_Context *ctx;
+   GLenum *cp_attachments = NULL;
+
+   if (!(rsc=_evgl_tls_resource_get()))
+     {
+        ERR("Unable to execute GL command. Error retrieving tls");
+        return;
+     }
+
+   if (!rsc->current_eng)
+     {
+        ERR("Unable to retrive Current Engine");
+        return;
+     }
+
+   ctx = rsc->current_ctx;
+   if (!ctx)
+     {
+        ERR("Unable to retrive Current Context");
+        return;
+     }
+
+   if (!_evgl_direct_enabled())
+     {
+        if (ctx->current_draw_fbo == 0)
+          {
+             int i;
+             cp_attachments = (GLenum *) malloc(sizeof(GLenum) * numAttachments);
+
+             if (!cp_attachments)
+               {
+                 ERR("malloc failed");
+                 return;
+               }
+
+             for (i = 0; i < numAttachments; i++)
+               {
+                  if (attachments[i] == GL_COLOR)
+                    cp_attachments[i] = GL_COLOR_ATTACHMENT0;
+                  else if (attachments[i] == GL_DEPTH)
+                    cp_attachments[i] = GL_DEPTH_ATTACHMENT;
+                  else if (attachments[i] == GL_STENCIL)
+                    cp_attachments[i] = GL_STENCIL_ATTACHMENT;
+                  else
+                    {
+                       // When default framebuffer is bound, GL_DEPTH_STENCIL generates INVALID_ENUM.
+                       SET_GL_ERROR(GL_INVALID_ENUM);
+                       free(cp_attachments);
+                       return;
+                    }
+               }
+          }
+      }
+
+   if (cp_attachments)
+     {
+        _gles3_api.glInvalidateSubFramebuffer(target, numAttachments, cp_attachments, x, y, width, height);
+        free(cp_attachments);
+     }
+   else
+      _gles3_api.glInvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
+
+   return;
+}
+
+static void
 _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
 {
    EVGL_Resource *rsc;
index 075da31..68d825c 100644 (file)
@@ -1,6 +1,10 @@
 _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glDrawBuffers, GLsizei, n, const GLenum *, bufs )
+_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glFramebufferTextureLayer, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level, GLint, layer )
 _EVASGL_FUNCTION_PRIVATE_BEGIN(const GLubyte *, glGetStringi, GLenum, name, GLuint, index )
 _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glReadBuffer, GLenum, src )
+_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glInvalidateFramebuffer, GLenum, target, GLsizei, numAttachments, const GLenum *, attachments )
+_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glInvalidateSubFramebuffer, GLenum, target, GLsizei, numAttachments, const GLenum *, attachments, GLint, x, GLint, y, GLsizei, width, GLsizei, height )
+
 //GLES 3.1
 _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glFramebufferParameteri, GLenum, target, GLenum, pname, GLint, param )
 _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glGetFramebufferParameteriv, GLenum, target, GLenum, pname, GLint *, params )
@@ -36,7 +40,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glEndQuery, GLenum, target )
 _EVASGL_FUNCTION_BEGIN_VOID( glEndTransformFeedback )
 _EVASGL_FUNCTION_BEGIN(GLsync, glFenceSync, GLenum, condition, GLbitfield, flags )
 _EVASGL_FUNCTION_BEGIN(GLsync, glFlushMappedBufferRange, GLenum, target, GLintptr, offset, GLsizeiptr, length )
-_EVASGL_FUNCTION_BEGIN_VOID( glFramebufferTextureLayer, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level, GLint, layer )
 _EVASGL_FUNCTION_BEGIN_VOID( glGenQueries, GLsizei, n, GLuint *, ids )
 _EVASGL_FUNCTION_BEGIN_VOID( glGenSamplers, GLsizei, n, GLuint *, samplers )
 _EVASGL_FUNCTION_BEGIN_VOID( glGenTransformFeedbacks, GLsizei, n, GLuint *, ids )
@@ -63,8 +66,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glGetUniformIndices, GLuint, program, GLsizei, unif
 _EVASGL_FUNCTION_BEGIN_VOID( glGetUniformuiv, GLuint, program, GLint, location, GLuint*, params )
 _EVASGL_FUNCTION_BEGIN_VOID( glGetVertexAttribIiv, GLuint, index, GLenum, pname, GLint *, params )
 _EVASGL_FUNCTION_BEGIN_VOID( glGetVertexAttribIuiv, GLuint, index, GLenum, pname, GLuint *, params )
-_EVASGL_FUNCTION_BEGIN_VOID( glInvalidateFramebuffer, GLenum, target, GLsizei, numAttachments, const GLenum *, attachments )
-_EVASGL_FUNCTION_BEGIN_VOID( glInvalidateSubFramebuffer, GLenum, target, GLsizei, numAttachments, const GLenum *, attachments, GLint, x, GLint, y, GLsizei, width, GLsizei, height )
 _EVASGL_FUNCTION_BEGIN(GLboolean, glIsQuery, GLuint, id )
 _EVASGL_FUNCTION_BEGIN(GLboolean, glIsSampler, GLuint, id )
 _EVASGL_FUNCTION_BEGIN(GLboolean, glIsSync, GLsync, sync )