diff options
author | Eric Engestrom <[email protected]> | 2016-10-01 00:23:26 +0100 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2016-11-16 08:02:16 +0200 |
commit | 25c60fa6a2d9861655271b5236c27aa72e48edbf (patch) | |
tree | 366935bbd2d2ad36c83ed8822ceb1c71b8252b4d /src | |
parent | 19a01f8139f74d98548c87a0fd3cc2ff9c60b46b (diff) |
egl: add missing error-checking to eglReleaseTexImage()
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/main/eglsurface.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 8e56919a429..04f42caf79e 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -525,14 +525,51 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, } EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, +_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer) { - /* TODO: do basic error checking and return success/fail. + /* Just do basic error checking and return success/fail. * Drivers must implement the real stuff. */ - return EGL_TRUE; + EGLint texture_type = EGL_PBUFFER_BIT; + + if (surf == EGL_NO_SURFACE) + { + _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + return EGL_FALSE; + } + + if (!surf->BoundToTexture) + { + /* Not an error, simply nothing to do */ + return EGL_TRUE; + } + + if (surf->TextureFormat == EGL_NO_TEXTURE) + { + _eglError(EGL_BAD_MATCH, "eglReleaseTexImage"); + return EGL_FALSE; + } + + if (buffer != EGL_BACK_BUFFER) + { + _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + return EGL_FALSE; + } + + if (dpy->Extensions.NOK_texture_from_pixmap) + texture_type |= EGL_PIXMAP_BIT; + + if (!(surf->Type & texture_type)) + { + _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + return EGL_FALSE; + } + + surf->BoundToTexture = EGL_FALSE; + + return EGL_TRUE; } |