diff options
| author | Denis Hsu <denis.hsu@mediatek.com> | 2018-12-06 00:18:00 -0800 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2018-12-06 00:18:00 -0800 |
| commit | 3bfa2ca8ea417007f3f778143df25b366b9ba64f (patch) | |
| tree | e37de9fe92638cffb73b7b20d42bb80946fb0de9 | |
| parent | 05c07b3410d0d277528d711f2807f5a469ab3d6c (diff) | |
| parent | 7604961e1df8dd620d1df53f207e0b666d16415d (diff) | |
Merge "Catch egl errors when drawIntoSurfaces"
am: 7604961e1d
Change-Id: I32e0503ee15061a1f7b35086b2d7bd4bbc52d094
| -rw-r--r-- | core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java index 83a02285e720..1b28d614a7f2 100644 --- a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java +++ b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java @@ -521,9 +521,10 @@ public class SurfaceTextureRenderer { clearState(); } - private void makeCurrent(EGLSurface surface) { + private void makeCurrent(EGLSurface surface) + throws LegacyExceptionUtils.BufferQueueAbandonedException { EGL14.eglMakeCurrent(mEGLDisplay, surface, surface, mEGLContext); - checkEglError("makeCurrent"); + checkEglDrawError("makeCurrent"); } private boolean swapBuffers(EGLSurface surface) @@ -557,6 +558,17 @@ public class SurfaceTextureRenderer { } } + private void checkEglDrawError(String msg) + throws LegacyExceptionUtils.BufferQueueAbandonedException { + int error; + if ((error = EGL14.eglGetError()) == EGL14.EGL_BAD_NATIVE_WINDOW) { + throw new LegacyExceptionUtils.BufferQueueAbandonedException(); + } + if ((error = EGL14.eglGetError()) != EGL14.EGL_SUCCESS) { + throw new IllegalStateException(msg + ": EGL error: 0x" + Integer.toHexString(error)); + } + } + private void checkEglError(String msg) { int error; if ((error = EGL14.eglGetError()) != EGL14.EGL_SUCCESS) { @@ -709,8 +721,14 @@ public class SurfaceTextureRenderer { if (mConversionSurfaces.size() > 0) { configureEGLPbufferSurfaces(mConversionSurfaces); } - makeCurrent((mSurfaces.size() > 0) ? mSurfaces.get(0).eglSurface : + + try { + makeCurrent((mSurfaces.size() > 0) ? mSurfaces.get(0).eglSurface : mConversionSurfaces.get(0).eglSurface); + } catch (LegacyExceptionUtils.BufferQueueAbandonedException e) { + Log.w(TAG, "Surface abandoned, skipping configuration... ", e); + } + initializeGLState(); mSurfaceTexture = new SurfaceTexture(getTextureId()); @@ -798,9 +816,9 @@ public class SurfaceTextureRenderer { } for (EGLSurfaceHolder holder : mConversionSurfaces) { if (LegacyCameraDevice.containsSurfaceId(holder.surface, targetSurfaceIds)) { - makeCurrent(holder.eglSurface); // glReadPixels reads from the bottom of the buffer, so add an extra vertical flip try { + makeCurrent(holder.eglSurface); drawFrame(mSurfaceTexture, holder.width, holder.height, (mFacing == CameraCharacteristics.LENS_FACING_FRONT) ? FLIP_TYPE_BOTH : FLIP_TYPE_VERTICAL); |
