core: Implement GL_OES_EGL_image entry points
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 11 Feb 2010 22:42:30 +0000 (17:42 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 24 Feb 2010 18:38:56 +0000 (13:38 -0500)
src/mesa/main/dd.h
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/main/mfeatures.h
src/mesa/main/teximage.c
src/mesa/main/teximage.h

index d98a14e09c4ce2fe60722f412e1762c69d819abf..079e44bb955b57dcaf4bf22e73caa076333ddef7 100644 (file)
@@ -1035,6 +1035,17 @@ struct dd_function_table {
                    GLfloat width, GLfloat height);
    /*@}*/
 #endif
+
+#if FEATURE_OES_EGL_image
+   void (*EGLImageTargetTexture2D)(GLcontext *ctx, GLenum target,
+                                  struct gl_texture_object *texObj,
+                                  struct gl_texture_image *texImage,
+                                  GLeglImageOES image_handle);
+   void (*EGLImageTargetRenderbufferStorage)(GLcontext *ctx,
+                                            struct gl_renderbuffer *rb,
+                                            void *image_handle);
+#endif
+
 };
 
 
index 04ea3b4ed7ce0eee770fd3161a7e41db14d66650..8fbe0830c7d74821aa4a48b7575a17ac269dc349 100644 (file)
@@ -1008,6 +1008,30 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
     */
 }
 
+#if FEATURE_OES_EGL_image
+void GLAPIENTRY
+_mesa_EGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+   struct gl_renderbuffer *rb;
+
+   if (target != GL_RENDERBUFFER) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "EGLImageTargetRenderbufferStorageOES");
+      return;
+   }
+
+   rb = ctx->CurrentRenderbuffer;
+   if (!rb) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "EGLImageTargetRenderbufferStorageOES");
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+   ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image);
+}
+#endif
 
 /**
  * Helper function for _mesa_GetRenderbufferParameterivEXT() and
index 54093940733450f3fb4c1c2b88667af575ab7263..28f75dfca795e7a0f2309a4328bce77b4b5cb1cc 100644 (file)
@@ -88,6 +88,9 @@ _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples,
                                      GLenum internalformat,
                                      GLsizei width, GLsizei height);
 
+extern void GLAPIENTRY
+_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
+
 extern void GLAPIENTRY
 _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname,
                                     GLint *params);
index 4e68bc15d8a5b85751d62f183ef7f8edb8fdce34..f0896ee626fa1424c5eeaf61ff7c0fb68025e88c 100644 (file)
 #define FEATURE_NV_fragment_program  _HAVE_FULL_GL
 #define FEATURE_NV_vertex_program  _HAVE_FULL_GL
 
+#define FEATURE_OES_EGL_image _HAVE_FULL_GL
+
 
 #endif /* FEATURES_H */
index 00329c755d5ca7c47c5c72c764c363369d0793e6..40ebff76c6e1d9246330e0948bcf45a57ad3caac 100644 (file)
@@ -2448,6 +2448,47 @@ _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat,
 }
 
 
+#if FEATURE_OES_EGL_image
+void GLAPIENTRY
+_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+   struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
+
+   if (target != GL_TEXTURE_2D) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                 "glEGLImageTargetTexture2D(target=%d)", target);
+      return;
+   }
+
+   if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
+      _mesa_update_state(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   _mesa_lock_texture(ctx, texObj);
+
+   texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
+   if (!texImage) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D");
+   } else {
+      if (texImage->Data)
+        ctx->Driver.FreeTexImageData( ctx, texImage );
+
+      ASSERT(texImage->Data == NULL);
+      ctx->Driver.EGLImageTargetTexture2D(ctx, target,
+                                         texObj, texImage, image);
+
+      /* state update */
+      texObj->_Complete = GL_FALSE;
+      ctx->NewState |= _NEW_TEXTURE;
+   }
+   _mesa_unlock_texture(ctx, texObj);
+
+}
+#endif
+
 
 void GLAPIENTRY
 _mesa_TexSubImage1D( GLenum target, GLint level,
index 97c901831902b421f926b0559af18a1837f07bff..d82cc985211c2d6d34b9cd4d1981916a0c95e696 100644 (file)
@@ -165,6 +165,8 @@ _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
                      GLint border, GLenum format, GLenum type,
                      const GLvoid *pixels );
 
+extern void GLAPIENTRY
+_mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
 
 extern void GLAPIENTRY
 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,