Don't recreate the EGL surface if the surface is not ready

Bug #5114545

Change-Id: I95149dc18e0582ca358716a6b0d89a4edc8fca26
This commit is contained in:
Romain Guy
2011-08-03 11:14:38 -07:00
parent 85de77a1c7
commit d3facf341b

View File

@@ -713,17 +713,23 @@ public abstract class HardwareRenderer {
// Cancels any existing buffer to ensure we'll get a buffer
// of the right size before we call eglSwapBuffers
sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
sEgl.eglDestroySurface(sEglDisplay, mEglSurface);
mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null);
if (mEglSurface != null && mEglSurface != EGL_NO_SURFACE) {
sEgl.eglDestroySurface(sEglDisplay, mEglSurface);
}
if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) {
int error = sEgl.eglGetError();
if (error == EGL_BAD_NATIVE_WINDOW) {
Log.e(LOG_TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
return;
if (holder.getSurface().isValid()) {
mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null);
if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) {
int error = sEgl.eglGetError();
if (error == EGL_BAD_NATIVE_WINDOW) {
Log.e(LOG_TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
return;
}
throw new RuntimeException("createWindowSurface failed "
+ getEGLErrorString(error));
}
throw new RuntimeException("createWindowSurface failed "
+ getEGLErrorString(error));
}
}