[Mesa-dev] [PATCH 4/4] egl: Unify attrib parsing of eglCreateSync, eglCreateSyncKHR

Chad Versace chad.versace at intel.com
Fri Jul 8 22:44:21 UTC 2016


eglCreateSyncKHR takes an attribute list of type EGLint[]. eglCreateSync
takes one of type EGLAttrib[]. Implement eglCreateSyncKHR's attribute
parsing in terms of eglCreateSync's by converting the EGLint[] into
EGLAttrib[].

This cleanup will simplify the code when later implementing
EGL_ANDROID_native_fence_sync.
---
 src/egl/main/eglsync.c | 47 +++++++++++++++--------------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c
index e90aeb4..eb56655 100644
--- a/src/egl/main/eglsync.c
+++ b/src/egl/main/eglsync.c
@@ -35,38 +35,6 @@
 #include "egllog.h"
 
 
-/**
- * Parse the list of sync attributes and return the proper error code.
- */
-static EGLint
-_eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
-{
-   EGLint i, err = EGL_SUCCESS;
-
-   if (!attrib_list)
-      return EGL_SUCCESS;
-
-   for (i = 0; attrib_list[i] != EGL_NONE; i++) {
-      EGLint attr = attrib_list[i++];
-      EGLint val = attrib_list[i];
-
-      switch (attr) {
-      default:
-         (void) val;
-         err = EGL_BAD_ATTRIBUTE;
-         break;
-      }
-
-      if (err != EGL_SUCCESS) {
-         _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr);
-         break;
-      }
-   }
-
-   return err;
-}
-
-
 static EGLint
 badSyncAttrib(EGLAttrib attr)
 {
@@ -100,6 +68,21 @@ _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib *attrib_list)
    return EGL_SUCCESS;
 }
 
+static EGLint
+_eglParseSyncAttribList(_EGLSync *sync, const EGLint *int_list)
+{
+   EGLAttrib *attrib_list;
+   EGLint err;
+
+   err = _eglConvertIntsToAttribs(int_list, &attrib_list);
+   if (err != EGL_SUCCESS)
+      return err;
+
+   err = _eglParseSyncAttribList64(sync, attrib_list);
+   free(attrib_list);
+   return err;
+}
+
 
 EGLBoolean
 _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
-- 
2.9.0.rc2



More information about the mesa-dev mailing list