egl: Add support for more EGLImage extensions to EGL core.
authorChia-I Wu <olvaffe@gmail.com>
Sun, 31 Jan 2010 09:34:02 +0000 (17:34 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Sun, 31 Jan 2010 14:20:42 +0000 (22:20 +0800)
Add support EGL_KHR_vg_parent_image and EGL_KHR_gl_*.  This is as simple
as adding some flags that can be enabled.  Individual drivers need to
implement the extensions before enbaling the flags.

src/egl/main/egldisplay.h
src/egl/main/eglimage.c
src/egl/main/eglimage.h
src/egl/main/eglmisc.c

index b04b094d8472b34a7e2f6686a587d0f55b032b1a..8e3d53864b1ffb186414149bccaac8cfaf7ee360 100644 (file)
@@ -38,6 +38,11 @@ struct _egl_extensions
    EGLBoolean MESA_copy_context;
    EGLBoolean KHR_image_base;
    EGLBoolean KHR_image_pixmap;
+   EGLBoolean KHR_vg_parent_image;
+   EGLBoolean KHR_gl_texture_2D_image;
+   EGLBoolean KHR_gl_texture_cubemap_image;
+   EGLBoolean KHR_gl_texture_3D_image;
+   EGLBoolean KHR_gl_renderbuffer_image;
 
    char String[_EGL_MAX_EXTENSIONS_LEN];
 };
index e7a293b3743a9cd5c1cfe8c4de7e40e267dce526..5732ef35ecdc1aa8d508341e09552a4ead844005 100644 (file)
@@ -28,8 +28,14 @@ _eglParseImageAttribList(_EGLImage *img, const EGLint *attrib_list)
       case EGL_IMAGE_PRESERVED_KHR:
          img->Preserved = val;
          break;
+      case EGL_GL_TEXTURE_LEVEL_KHR:
+         img->GLTextureLevel = val;
+         break;
+      case EGL_GL_TEXTURE_ZOFFSET_KHR:
+         img->GLTextureZOffset = val;
+         break;
       default:
-         err = EGL_BAD_ATTRIBUTE;
+         /* unknown attrs are ignored */
          break;
       }
 
@@ -52,6 +58,8 @@ _eglInitImage(_EGLImage *img, _EGLDisplay *dpy, const EGLint *attrib_list)
    img->Resource.Display = dpy;
 
    img->Preserved = EGL_FALSE;
+   img->GLTextureLevel = 0;
+   img->GLTextureZOffset = 0;
 
    err = _eglParseImageAttribList(img, attrib_list);
    if (err != EGL_SUCCESS)
index 26bf054a07d4fb69668f5e3b8e1e0810b7248a21..2c0fb16d1d332b8dd02291f2c82f8f20eaa46348 100644 (file)
@@ -15,6 +15,8 @@ struct _egl_image
    _EGLResource Resource;
 
    EGLBoolean Preserved;
+   EGLint GLTextureLevel;
+   EGLint GLTextureZOffset;
 };
 
 
index 907a057b4420fdef3bd46d1acdf90f5bec1b096a..984e426686e4119d38a3a75d5050a56b3eb900cd 100644 (file)
 #include "egldisplay.h"
 
 
+/**
+ * Copy the extension into the string and update the string pointer.
+ */
+static EGLint
+_eglAppendExtension(char **str, const char *ext)
+{
+   char *s = *str;
+   EGLint len = strlen(ext);
+
+   if (s) {
+      memcpy(s, ext, len);
+      s[len++] = ' ';
+      s[len] = '\0';
+
+      *str += len;
+   }
+   else {
+      len++;
+   }
+
+   return len;
+}
+
+
 /**
  * Examine the individual extension enable/disable flags and recompute
  * the driver's Extensions string.
 static void
 _eglUpdateExtensionsString(_EGLDisplay *dpy)
 {
+#define _EGL_CHECK_EXTENSION(ext)                                          \
+   do {                                                                    \
+      if (dpy->Extensions.ext) {                                           \
+         _eglAppendExtension(&exts, "EGL_" #ext);                          \
+         assert(exts <= dpy->Extensions.String + _EGL_MAX_EXTENSIONS_LEN); \
+      }                                                                    \
+   } while (0)
+
    char *exts = dpy->Extensions.String;
 
    if (exts[0])
       return;
 
-   if (dpy->Extensions.MESA_screen_surface)
-      strcat(exts, "EGL_MESA_screen_surface ");
-   if (dpy->Extensions.MESA_copy_context)
-      strcat(exts, "EGL_MESA_copy_context ");
+   _EGL_CHECK_EXTENSION(MESA_screen_surface);
+   _EGL_CHECK_EXTENSION(MESA_copy_context);
 
-   if (dpy->Extensions.KHR_image_base)
-      strcat(exts, "EGL_KHR_image_base ");
-   if (dpy->Extensions.KHR_image_pixmap)
-      strcat(exts, "EGL_KHR_image_pixmap ");
+   _EGL_CHECK_EXTENSION(KHR_image_base);
+   _EGL_CHECK_EXTENSION(KHR_image_pixmap);
    if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap)
-      strcat(exts, "EGL_KHR_image ");
+      _eglAppendExtension(&exts, "EGL_KHR_image");
+
+   _EGL_CHECK_EXTENSION(KHR_vg_parent_image);
+   _EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image);
+   _EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image);
+   _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image);
+   _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image);
 
-   assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN);
+#undef _EGL_CHECK_EXTENSION
 }