summaryrefslogtreecommitdiffstats
path: root/opengl
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-02-04 17:04:53 -0800
committerMathias Agopian <mathias@google.com>2010-02-04 17:04:53 -0800
commit42d99d211f547a2b5a4632e62b38ac16a1ad481c (patch)
treee8bef5cdc130f4f0f837f7ecffecf274b7a5e357 /opengl
parent7b4030dbe7c814c78a761d221d18eaaacfe1431e (diff)
downloadframeworks_base-42d99d211f547a2b5a4632e62b38ac16a1ad481c.zip
frameworks_base-42d99d211f547a2b5a4632e62b38ac16a1ad481c.tar.gz
frameworks_base-42d99d211f547a2b5a4632e62b38ac16a1ad481c.tar.bz2
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')
-rw-r--r--opengl/libagl/egl.cpp15
-rw-r--r--opengl/libagl/texture.cpp27
2 files changed, 41 insertions, 1 deletions
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 81864bd..b6e0aae 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;
}
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index a1a776f..fa25fa9 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -1628,6 +1628,11 @@ void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
return;
}
+ if (image == EGL_NO_IMAGE_KHR) {
+ ogles_error(c, GL_INVALID_VALUE);
+ return;
+ }
+
android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
ogles_error(c, GL_INVALID_VALUE);
@@ -1652,4 +1657,26 @@ void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
+ ogles_context_t* c = ogles_context_t::get();
+ if (target != GL_RENDERBUFFER_OES) {
+ ogles_error(c, GL_INVALID_ENUM);
+ return;
+ }
+
+ if (image == EGL_NO_IMAGE_KHR) {
+ ogles_error(c, GL_INVALID_VALUE);
+ return;
+ }
+
+ android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+ if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+ ogles_error(c, GL_INVALID_VALUE);
+ return;
+ }
+ if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+ ogles_error(c, GL_INVALID_VALUE);
+ return;
+ }
+
+ // well, we're not supporting this extension anyways
}