diff options
author | John Reck <jreck@google.com> | 2016-09-01 13:04:00 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2016-09-01 20:58:19 +0000 |
commit | 8a29c0ec86a9411a07bb10018c3da69fffc0fe7d (patch) | |
tree | 23335733af92d22719db428d41e249f87d343519 | |
parent | 994e5909d1a579641efa66c0b04e7af9c67b8fff (diff) |
Fix EGLImage memory leak
bug: 31247709
Change-Id: Ifb3087a6e76d0d1304f55d13e468bafbd78418da
-rw-r--r-- | libs/hwui/Readback.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp index 60eadff66ad1..65a8ebba2ae7 100644 --- a/libs/hwui/Readback.cpp +++ b/libs/hwui/Readback.cpp @@ -169,7 +169,7 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread, EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attrs); if (sourceImage == EGL_NO_IMAGE_KHR) { - ALOGW("Error creating image (%#x)", eglGetError()); + ALOGW("eglCreateImageKHR failed (%#x)", eglGetError()); return CopyResult::UnknownError; } GLuint sourceTexId; @@ -180,7 +180,8 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread, GLenum status = GL_NO_ERROR; while ((status = glGetError()) != GL_NO_ERROR) { - ALOGW("Error creating image (%#x)", status); + ALOGW("glEGLImageTargetTexture2DOES failed (%#x)", status); + eglDestroyImageKHR(display, sourceImage); return CopyResult::UnknownError; } @@ -188,7 +189,15 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread, sourceTexture.wrap(sourceTexId, sourceBuffer->getWidth(), sourceBuffer->getHeight(), 0 /* total lie */); - return copyTextureInto(caches, renderThread.renderState(), sourceTexture, texTransform, bitmap); + CopyResult copyResult = copyTextureInto(caches, renderThread.renderState(), + sourceTexture, texTransform, bitmap); + sourceTexture.deleteTexture(); + // All we're flushing & finishing is the deletion of the texture since + // copyTextureInto already did a major flush & finish as an implicit + // part of glReadPixels, so this shouldn't pose any major stalls. + glFinish(); + eglDestroyImageKHR(display, sourceImage); + return copyResult; } CopyResult Readback::copyTextureLayerInto(renderthread::RenderThread& renderThread, |