From 3cd5a117083e6a53b9946e8c316377658ab79b3d Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 26 Apr 2011 14:57:40 -0700 Subject: [PATCH] Report errors when eglCreateImageKHR fails Change-Id: Ica39b72ac2505675e619ef4994bd67b98bf6e7da --- libs/gui/SurfaceTexture.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 39418f03a..15a176e9d 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -274,10 +274,14 @@ status_t SurfaceTexture::updateTexImage() { EGLImageKHR image = mSlots[mLastQueued].mEglImage; if (image == EGL_NO_IMAGE_KHR) { EGLDisplay dpy = eglGetCurrentDisplay(); - sp graphicBuffer = mSlots[mLastQueued].mGraphicBuffer; - image = createImage(dpy, graphicBuffer); + image = createImage(dpy, mSlots[mLastQueued].mGraphicBuffer); mSlots[mLastQueued].mEglImage = image; mSlots[mLastQueued].mEglDisplay = dpy; + if (image == EGL_NO_IMAGE_KHR) { + // NOTE: if dpy was invalid, createImage() is guaranteed to + // fail. so we'd end up here. + return -EINVAL; + } } GLint error; @@ -483,12 +487,9 @@ EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy, }; EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs); - EGLint error = eglGetError(); - if (error != EGL_SUCCESS) { + if (image == EGL_NO_IMAGE_KHR) { + EGLint error = eglGetError(); LOGE("error creating EGLImage: %#x", error); - } else if (image == EGL_NO_IMAGE_KHR) { - LOGE("no error reported, but no image was returned by " - "eglCreateImageKHR"); } return image; }