diff options
author | Marek Olšák <[email protected]> | 2015-05-12 20:42:05 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-06-05 19:44:33 +0200 |
commit | 515f04ed6fe0c914b2cd22c7ea65db6e34c362e3 (patch) | |
tree | 83085ecba1de96411ce5122f99536a0efebfff2e /src/egl/main/eglapi.c | |
parent | 1e79e054e7dff0c45538fff1257e1f81a206d7c9 (diff) |
egl: add eglCreateImage (v2)
v2: - use calloc
- return BAD_ALLOC if calloc fails
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r-- | src/egl/main/eglapi.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 96968694ac5..e4fd44e90c5 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -251,6 +251,31 @@ _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; + + size += 1; /* add space for EGL_NONE */ + + int_attribs = calloc(size, sizeof(int_attribs[0])); + if (!int_attribs) + return NULL; + + 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. @@ -1255,6 +1280,22 @@ 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); + + if (attr_list && !int_attribs) + RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_NO_IMAGE); + + image = eglCreateImageKHR(dpy, ctx, target, buffer, int_attribs); + free(int_attribs); + return image; +} + + EGLBoolean EGLAPIENTRY eglDestroyImage(EGLDisplay dpy, EGLImage image) { @@ -1751,6 +1792,7 @@ eglGetProcAddress(const char *procname) { "eglClientWaitSync", (_EGLProc) eglClientWaitSync }, { "eglGetSyncAttrib", (_EGLProc) eglGetSyncAttrib }, { "eglWaitSync", (_EGLProc) eglWaitSync }, + { "eglCreateImage", (_EGLProc) eglCreateImage }, { "eglDestroyImage", (_EGLProc) eglDestroyImage }, #ifdef EGL_MESA_drm_display { "eglGetDRMDisplayMESA", (_EGLProc) eglGetDRMDisplayMESA }, |