summaryrefslogtreecommitdiff
path: root/opengl/libagl/egl.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2010-02-04 17:04:53 -0800
committer Mathias Agopian <mathias@google.com> 2010-02-04 17:04:53 -0800
commit8dccb26901973722164f2a11551fd6d5c52081bf (patch)
tree085878f347b99a4b5141e5e68b7b63939f8848a6 /opengl/libagl/egl.cpp
parent6b578cba3971f0e4f2489c4cd40785872ab48463 (diff)
Proper EGLImageKHR error handling
Validate EGLImageKHR format and return an error for unsupported ones. Also make sure to return an error when binding EGL_NO_IMAGE_KHR to a texture
Diffstat (limited to 'opengl/libagl/egl.cpp')
-rw-r--r--opengl/libagl/egl.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 81864bd791..b6e0aae74e 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -2092,7 +2092,20 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
if (native_buffer->common.version != sizeof(android_native_buffer_t))
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
-
+
+ switch (native_buffer->format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGB_888:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ break;
+ default:
+ return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+ }
+
native_buffer->common.incRef(&native_buffer->common);
return (EGLImageKHR)native_buffer;
}