summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglapi.c
diff options
context:
space:
mode:
authorChad Versace <chadversary@chromium.org>2016-09-27 13:27:17 -0700
committerChad Versace <chadversary@chromium.org>2016-10-04 14:11:29 -0700
commit3e0d575a6d727c4334b783c443a5e1980dca43b4 (patch)
treec21dc7f4afcb30b9a2aed7a0efd2cc83ebeee656 /src/egl/main/eglapi.c
parentf2c2f43d4ea2948e8fd9be1ab192664df262c0f4 (diff)
downloadexternal_mesa3d-3e0d575a6d727c4334b783c443a5e1980dca43b4.zip
external_mesa3d-3e0d575a6d727c4334b783c443a5e1980dca43b4.tar.gz
external_mesa3d-3e0d575a6d727c4334b783c443a5e1980dca43b4.tar.bz2
egl: Add _eglConvertIntsToAttribs()
This function converts an attribute list from EGLint[] to EGLAttrib[]. Will be used in following patches to cleanup EGLSync attribute parsing. Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r--src/egl/main/eglapi.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 07f6794..697957e 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -251,6 +251,47 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
}
+/**
+ * Convert an attribute list from EGLint[] to EGLAttrib[].
+ *
+ * Return an EGL error code. The output parameter out_attrib_list is modified
+ * only on success.
+ */
+EGLint
+_eglConvertIntsToAttribs(const EGLint *int_list, EGLAttrib **out_attrib_list)
+{
+ size_t len = 0;
+ EGLAttrib *attrib_list;
+
+ if (int_list) {
+ while (int_list[2*len] != EGL_NONE)
+ ++len;
+ }
+
+ if (len == 0) {
+ *out_attrib_list = NULL;
+ return EGL_SUCCESS;
+ }
+
+ if (2*len + 1 > SIZE_MAX / sizeof(EGLAttrib))
+ return EGL_BAD_ALLOC;
+
+ attrib_list = malloc((2*len + 1) * sizeof(EGLAttrib));
+ if (!attrib_list)
+ return EGL_BAD_ALLOC;
+
+ for (size_t i = 0; i < len; ++i) {
+ attrib_list[2*i + 0] = int_list[2*i + 0];
+ attrib_list[2*i + 1] = int_list[2*i + 1];
+ }
+
+ attrib_list[2*len] = EGL_NONE;
+
+ *out_attrib_list = attrib_list;
+ return EGL_SUCCESS;
+}
+
+
static EGLint *
_eglConvertAttribsToInt(const EGLAttrib *attr_list)
{