[Mesa-dev] [PATCH 2/6] egl: Add EGL_MESA_get_image_attrib
Jakob Bornecrantz
wallbraker at gmail.com
Sat May 29 05:56:30 PDT 2010
---
include/EGL/eglext.h | 8 +++
src/egl/docs/EGL_MESA_get_image_attrib.txt | 84 ++++++++++++++++++++++++++++
src/egl/main/eglapi.c | 27 +++++++++
src/egl/main/eglapi.h | 9 +++
src/egl/main/egldisplay.h | 1 +
src/egl/main/egldriver.c | 4 +
src/egl/main/eglimage.c | 27 +++++++++
src/egl/main/eglimage.h | 4 +
src/egl/main/eglmisc.c | 3 +
9 files changed, 167 insertions(+), 0 deletions(-)
create mode 100644 src/egl/docs/EGL_MESA_get_image_attrib.txt
diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index 317209d..71bdd59 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -251,6 +251,14 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
#define EGL_NEW_IMAGE_MESA 0x3200 /* eglCreateImageKHR target */
#endif
+#ifndef EGL_MESA_get_image_attrib
+#define EGL_MESA_get_image_attrib 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglGetImageAttribMESA(EGLDisplay dpy, EGLImageKHR img, EGLenum attrib, EGLint *out);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETIMAGEATTRIBMESA) (EGLDisplay dpy, EGLImageKHR img, EGLenum attrib, EGLint *out);
+#endif /* EGL_MESA_get_image_attrib */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/egl/docs/EGL_MESA_get_image_attrib.txt b/src/egl/docs/EGL_MESA_get_image_attrib.txt
new file mode 100644
index 0000000..d763b4d
--- /dev/null
+++ b/src/egl/docs/EGL_MESA_get_image_attrib.txt
@@ -0,0 +1,84 @@
+Name
+
+ MESA_get_image_attrib
+
+Name Strings
+
+ EGL_MESA_get_image_attrib
+
+Contributors
+
+ Jakob Bornecrantz
+
+Contacts
+
+ Jakob Bornecrantz, (wallbraker 'at' gmail.com)
+
+Status
+
+ Preliminary - totally subject to change.
+
+Version
+
+ Version 1, February 18, 2010
+
+Number
+
+ EGL Extension #?
+
+Dependencies
+
+ EGL_KHR_base_image is required
+
+Overview
+
+ Allows to query attributes from EGLImages.
+
+New Types
+
+ None
+
+New Procedures and Functions
+
+ EGLBoolean eglGetImageAttribMESA(
+ EGLDisplay dpy,
+ EGLImageKHR img,
+ EGLenum attrib,
+ EGLint *out)
+
+New Tokens
+
+ None
+
+Additions to the EGL Image (EGL_KHR_base_image) Specification:
+
+ Add this somewhere.
+
+ "The Command
+
+ EGLBoolean eglGetImageAttribMESA(
+ EGLDisplay dpy,
+ EGLImageKHR img,
+ EGLenum attrib,
+ EGLint *out)
+
+ Allows to get attributes from a EGLImageKHR. See table below for accepted
+ attributes given to eglGetImageAttribMESA."
+
+ +-------------------------------+---------------------------------------+
+ | | |
+ | Attribute | Description |
+ +-------------------------------+---------------------------------------+
+ | EGL_WIDTH | Image width in pixels. |
+ +-------------------------------+---------------------------------------+
+ | EGL_HEIGHT | Image height in pixels |
+ +-------------------------------+---------------------------------------+
+
+
+
+Issues
+
+ None
+
+Revision History
+
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 1a533e0..8c55fd3 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -841,6 +841,9 @@ eglGetProcAddress(const char *procname)
#ifdef EGL_NOK_swap_region
{ "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK },
#endif
+#ifdef EGL_MESA_get_image_attrib
+ { "eglGetImageAttribMESA", (_EGLProc) eglGetImageAttribMESA },
+#endif /* EGL_MESA_get_image_attrib */
{ NULL, NULL }
};
EGLint i;
@@ -1278,3 +1281,27 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface,
}
#endif /* EGL_NOK_swap_region */
+
+
+#ifdef EGL_MESA_get_image_attrib
+
+
+EGLBoolean
+eglGetImageAttribMESA(EGLDisplay dpy, EGLImageKHR image, EGLenum attrib, EGLint *out)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGLImage *img = _eglLookupImage(image, disp);
+ _EGLDriver *drv;
+ EGLBoolean ret;
+
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+ if (!img)
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+ ret = drv->API.GetImageAttribMESA(drv, disp, img, attrib, out);
+
+ RETURN_EGL_EVAL(disp, ret);
+}
+
+
+#endif /* EGL_MESA_get_image_attrib */
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index d8c8b49..845314d 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -80,6 +80,11 @@ typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLI
typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects);
#endif
+#ifdef EGL_MESA_get_image_attrib
+typedef EGLBoolean (*GetImageAttribMESA_t) (_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image, EGLenum attrib, EGLint *out);
+#endif /* EEGL_MESA_get_image_attrib */
+
+
/**
* The API dispatcher jumps through these functions
*/
@@ -141,6 +146,10 @@ struct _egl_api
#ifdef EGL_NOK_swap_region
SwapBuffersRegionNOK_t SwapBuffersRegionNOK;
#endif
+
+#ifdef EGL_MESA_get_image_attrib
+ GetImageAttribMESA_t GetImageAttribMESA;
+#endif /* EGL_MESA_get_image_attrib */
};
#endif /* EGLAPI_INCLUDED */
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 5b870b6..ea33ac0 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -49,6 +49,7 @@ struct _egl_extensions
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
EGLBoolean MESA_create_image;
+ EGLBoolean MESA_get_image_attrib;
char String[_EGL_MAX_EXTENSIONS_LEN];
};
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 2f42e64..c435c63 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -635,6 +635,10 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
drv->API.CreateImageKHR = _eglCreateImageKHR;
drv->API.DestroyImageKHR = _eglDestroyImageKHR;
#endif /* EGL_KHR_image_base */
+
+#ifdef EGL_MESA_get_image_attrib
+ drv->API.GetImageAttribMESA = _eglGetImageAttribMESA;
+#endif /* EGL_MESA_get_image_attrib */
}
diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
index f92553b..a5e16cd 100644
--- a/src/egl/main/eglimage.c
+++ b/src/egl/main/eglimage.c
@@ -100,3 +100,30 @@ _eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image)
#endif /* EGL_KHR_image_base */
+
+
+#ifdef EGL_MESA_get_image_attrib
+
+
+EGLBoolean
+_eglGetImageAttribMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image, EGLenum attrib, EGLint *out)
+{
+ /* defaults */
+ switch (attrib) {
+#ifdef EGL_MESA_create_image
+ /* XXX check type */
+ case EGL_WIDTH:
+ *out = image->Width;
+ break;
+ case EGL_HEIGHT:
+ *out = image->Height;
+ break;
+#endif
+ default:
+ return EGL_FALSE;
+ }
+ return EGL_TRUE;
+}
+
+
+#endif /* EGL_MESA_get_image_attrib */
diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h
index 3020cda..22f55ab 100644
--- a/src/egl/main/eglimage.h
+++ b/src/egl/main/eglimage.h
@@ -37,6 +37,10 @@ extern EGLBoolean
_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
+PUBLIC EGLBoolean
+_eglGetImageAttribMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image, EGLenum attrib, EGLint *out);
+
+
/**
* Link an image to a display and return the handle of the link.
* The handle can be passed to client directly.
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index 2c344c0..1f9120f 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -98,6 +98,9 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
#ifdef EGL_MESA_create_image
_EGL_CHECK_EXTENSION(MESA_create_image);
#endif
+#ifdef EGL_MESA_get_image_attrib
+ _EGL_CHECK_EXTENSION(MESA_get_image_attrib);
+#endif
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
--
1.7.0.4
More information about the mesa-dev
mailing list