[Mesa-dev] [PATCH 12/15] egl: add eglCreateImage

Marek Olšák maraeo at gmail.com
Tue May 12 15:54:47 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

---
 src/egl/main/eglapi.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 6457798..34a113b 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -251,6 +251,30 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
 }
 
 
+static EGLint *
+_eglConvertAttribsToInt(const EGLAttrib *attr_list)
+{
+   EGLint *int_attribs = NULL;
+
+   /* Convert attributes from EGLAttrib[] to EGLint[] */
+   if (attr_list) {
+      int i, size = 0;
+
+      while (attr_list[size] != EGL_NONE)
+         size += 2;
+
+      if (size) {
+         size += 1; /* add space for EGL_NONE */
+         int_attribs = malloc(size * sizeof(int_attribs[0]));
+
+         for (i = 0; i < size; i++)
+            int_attribs[i] = attr_list[i];
+      }
+   }
+   return int_attribs;
+}
+
+
 /**
  * This is typically the first EGL function that an application calls.
  * It associates a private _EGLDisplay object to the native display.
@@ -1162,6 +1186,7 @@ eglGetProcAddress(const char *procname)
       { "eglDestroySync", (_EGLProc) eglDestroySync },
       { "eglClientWaitSync", (_EGLProc) eglClientWaitSync },
       { "eglGetSyncAttrib", (_EGLProc) eglGetSyncAttrib },
+      { "eglCreateImage", (_EGLProc) eglCreateImage },
       { "eglDestroyImage", (_EGLProc) eglDestroyImage },
       { "eglWaitSync", (_EGLProc) eglWaitSync },
 #endif /* _EGL_GET_CORE_ADDRESSES */
@@ -1370,6 +1395,19 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
 }
 
 
+EGLImage EGLAPIENTRY
+eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target,
+               EGLClientBuffer buffer, const EGLAttrib *attr_list)
+{
+   EGLImage image;
+   EGLint *int_attribs = _eglConvertAttribsToInt(attr_list);
+
+   image = eglCreateImageKHR(dpy, ctx, target, buffer, int_attribs);
+   free(int_attribs);
+   return image;
+}
+
+
 EGLBoolean EGLAPIENTRY
 eglDestroyImage(EGLDisplay dpy, EGLImage image)
 {
-- 
2.1.0



More information about the mesa-dev mailing list