This is a proposed extension to let EGL clients specify the format
of the pixmap that is used as a source for an EGLImage.  This is
necessary when later using the EGLImage as a texture source, for example.

Signed-off-by: Kristian Høgsberg <k...@bitplanet.net>
---
 include/EGL/eglext.h            |    8 ++++++++
 src/egl/drivers/dri2/egl_dri2.c |   12 +++++++++++-
 src/egl/main/eglimage.c         |   10 ++++++++++
 src/egl/main/eglimage.h         |    1 +
 4 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index a9e598d..c59fe7f 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -219,6 +219,14 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) 
(EGLDisplay dpy, EGLCont
 /* Interfaces defined by EGL_KHR_image above */
 #endif
 
+#ifndef EGL_KHR_image_pixmap_format
+#define EGL_KHR_image_pixmap_format 1
+/* Interfaces defined by EGL_KHR_image above */
+#define EGL_NATIVE_PIXMAP_FORMAT_KHR           0x30D3  /* eglCreateImageKHR 
attribute */
+#define EGL_NATIVE_PIXMAP_RGB_KHR              0x30D4  /* eglCreateImageKHR 
value */
+#define EGL_NATIVE_PIXMAP_RGBA_KHR             0x30D5  /* eglCreateImageKHR 
value */
+#endif
+
 #ifndef EGL_IMG_context_priority
 #define EGL_IMG_context_priority 1
 #define EGL_CONTEXT_PRIORITY_LEVEL_IMG         0x3100
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1590190..a199531 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1116,6 +1116,7 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
    xcb_dri2_get_buffers_cookie_t cookie;
    xcb_dri2_dri2_buffer_t *buffers;
    xcb_dri2_get_buffers_reply_t *reply;
+   int format;
 
    dri2_img = malloc(sizeof *dri2_img);
    if (!dri2_img) {
@@ -1154,11 +1155,20 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay 
*disp,
       return EGL_NO_IMAGE_KHR;
    }
 
+   switch (dri2_img->base.NativePixmapFormat) {
+   case EGL_NATIVE_PIXMAP_RGB_KHR:
+      format = GL_RGB;
+      break;
+   case EGL_NATIVE_PIXMAP_RGBA_KHR:
+      format = GL_RGBA;
+      break;
+   }
+
    dri2_img->dri_image =
       dri2_dpy->image->createImageFromName(dri2_ctx->dri_context,
                                           dri2_img->width,
                                           dri2_img->height,
-                                          GL_RGBA,
+                                          format,
                                           dri2_img->name,
                                           dri2_img->pitch,
                                           dri2_img);
diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
index 5732ef3..013057d 100644
--- a/src/egl/main/eglimage.c
+++ b/src/egl/main/eglimage.c
@@ -34,6 +34,15 @@ _eglParseImageAttribList(_EGLImage *img, const EGLint 
*attrib_list)
       case EGL_GL_TEXTURE_ZOFFSET_KHR:
          img->GLTextureZOffset = val;
          break;
+      case EGL_NATIVE_PIXMAP_FORMAT_KHR:
+        if (val == EGL_NATIVE_PIXMAP_RGB_KHR ||
+            val == EGL_NATIVE_PIXMAP_RGBA_KHR) {
+           img->NativePixmapFormat = val;
+        } else {
+            err = EGL_BAD_ATTRIBUTE;
+            break;
+        }
+         break;
       default:
          /* unknown attrs are ignored */
          break;
@@ -60,6 +69,7 @@ _eglInitImage(_EGLImage *img, _EGLDisplay *dpy, const EGLint 
*attrib_list)
    img->Preserved = EGL_FALSE;
    img->GLTextureLevel = 0;
    img->GLTextureZOffset = 0;
+   img->NativePixmapFormat = EGL_NATIVE_PIXMAP_RGB_KHR;
 
    err = _eglParseImageAttribList(img, attrib_list);
    if (err != EGL_SUCCESS)
diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h
index 2c0fb16..fa0a1f6 100644
--- a/src/egl/main/eglimage.h
+++ b/src/egl/main/eglimage.h
@@ -17,6 +17,7 @@ struct _egl_image
    EGLBoolean Preserved;
    EGLint GLTextureLevel;
    EGLint GLTextureZOffset;
+   EGLint NativePixmapFormat;
 };
 
 
-- 
1.6.5.rc2


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to