summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2017-06-28 20:31:18 +0100
committerEmil Velikov <[email protected]>2017-07-12 15:42:51 +0100
commit81e95924ea1411edc5cc82b284e28c56bd236c4a (patch)
tree577a7b39bb3f47f826f70342223589f04d73135f /src/egl
parent9365ff4b885730d76e535edc12445b6f1b72f667 (diff)
egl: call _eglError within _eglParseImageAttribList
As per EGL_KHR_image_base: If an attribute specified in <attrib_list> is not one of the attributes listed in Table bbb, the error EGL_BAD_PARAMETER is generated. We should set the error as opposed to simply log it. Currently we have a partial solution, whereby only some of the callers call _eglError(). Since that has proven to be less robust, simply set the error by the function itself and change the return type to EGLBoolean, updating the callers. So now the code is slightly simpler. Plus the follow-up fixes will be easier to manage. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c25
-rw-r--r--src/egl/main/eglimage.c21
-rw-r--r--src/egl/main/eglimage.h2
3 files changed, 18 insertions, 30 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e55bff6dbbf..c96f0e0d21b 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1719,7 +1719,6 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
const struct wl_drm_components_descriptor *f;
__DRIimage *dri_image;
_EGLImageAttribs attrs;
- EGLint err;
int32_t plane;
buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm,
@@ -1727,13 +1726,10 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
if (!buffer)
return NULL;
- err = _eglParseImageAttribList(&attrs, disp, attr_list);
- plane = attrs.PlaneWL;
- if (err != EGL_SUCCESS) {
- _eglError(EGL_BAD_PARAMETER, "dri2_create_image_wayland_wl_buffer");
+ if (!_eglParseImageAttribList(&attrs, disp, attr_list))
return NULL;
- }
+ plane = attrs.PlaneWL;
f = buffer->driver_format;
if (plane < 0 || plane >= f->nplanes) {
_eglError(EGL_BAD_PARAMETER,
@@ -1819,7 +1815,7 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx,
return EGL_NO_IMAGE_KHR;
}
- if (_eglParseImageAttribList(&attrs, disp, attr_list) != EGL_SUCCESS)
+ if (!_eglParseImageAttribList(&attrs, disp, attr_list))
return EGL_NO_IMAGE_KHR;
switch (target) {
@@ -1906,8 +1902,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
name = (EGLint) (uintptr_t) buffer;
- err = _eglParseImageAttribList(&attrs, disp, attr_list);
- if (err != EGL_SUCCESS)
+ if (!_eglParseImageAttribList(&attrs, disp, attr_list))
return NULL;
if (attrs.Width <= 0 || attrs.Height <= 0 ||
@@ -2199,7 +2194,6 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
_EGLImage *res;
- EGLint err;
_EGLImageAttribs attrs;
__DRIimage *dri_image;
unsigned num_fds;
@@ -2221,11 +2215,8 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
return NULL;
}
- err = _eglParseImageAttribList(&attrs, disp, attr_list);
- if (err != EGL_SUCCESS) {
- _eglError(err, "bad attribute");
+ if (!_eglParseImageAttribList(&attrs, disp, attr_list))
return NULL;
- }
if (!dri2_check_dma_buf_attribs(&attrs))
return NULL;
@@ -2298,7 +2289,6 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp,
_EGLImageAttribs attrs;
unsigned int dri_use, valid_mask;
int format;
- EGLint err = EGL_SUCCESS;
(void) drv;
@@ -2307,11 +2297,8 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp,
return EGL_NO_IMAGE_KHR;
}
- err = _eglParseImageAttribList(&attrs, disp, attr_list);
- if (err != EGL_SUCCESS) {
- _eglError(EGL_BAD_PARAMETER, __func__);
+ if (!_eglParseImageAttribList(&attrs, disp, attr_list))
return EGL_NO_IMAGE_KHR;
- }
if (attrs.Width <= 0 || attrs.Height <= 0) {
_eglError(EGL_BAD_PARAMETER, __func__);
diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
index 7587a4be4a3..619e1a1e5db 100644
--- a/src/egl/main/eglimage.c
+++ b/src/egl/main/eglimage.c
@@ -30,14 +30,18 @@
#include <assert.h>
#include <string.h>
+#include "eglcurrent.h"
#include "eglimage.h"
#include "egllog.h"
/**
- * Parse the list of image attributes and return the proper error code.
+ * Parse the list of image attributes.
+ *
+ * Returns EGL_TRUE on success and EGL_FALSE otherwise.
+ * Function calls _eglError to set the correct error code.
*/
-EGLint
+EGLBoolean
_eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
const EGLint *attrib_list)
{
@@ -48,7 +52,7 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
memset(attrs, 0, sizeof(*attrs));
if (!attrib_list)
- return err;
+ return EGL_TRUE;
for (i = 0; attrib_list[i] != EGL_NONE; i++) {
EGLint attr = attrib_list[i++];
@@ -233,15 +237,12 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
break;
default:
- /* unknown attrs are ignored */
- break;
+ return _eglError(EGL_BAD_ATTRIBUTE, __func__);
}
- if (err != EGL_SUCCESS) {
- _eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr);
- break;
- }
+ if (err != EGL_SUCCESS)
+ return _eglError(err, __func__);
}
- return err;
+ return EGL_TRUE;
}
diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h
index eef98604e7a..87517921320 100644
--- a/src/egl/main/eglimage.h
+++ b/src/egl/main/eglimage.h
@@ -91,7 +91,7 @@ struct _egl_image
};
-extern EGLint
+EGLBoolean
_eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
const EGLint *attrib_list);