Fix EGLImage memory leak
am: f8b0360298
Change-Id: Ibf8adad1b0fc66fe9de2bbd86d14b67ffe73efd0
This commit is contained in:
@@ -136,7 +136,7 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
|
|||||||
EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attrs);
|
EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attrs);
|
||||||
|
|
||||||
if (sourceImage == EGL_NO_IMAGE_KHR) {
|
if (sourceImage == EGL_NO_IMAGE_KHR) {
|
||||||
ALOGW("Error creating image (%#x)", eglGetError());
|
ALOGW("eglCreateImageKHR failed (%#x)", eglGetError());
|
||||||
return CopyResult::UnknownError;
|
return CopyResult::UnknownError;
|
||||||
}
|
}
|
||||||
GLuint sourceTexId;
|
GLuint sourceTexId;
|
||||||
@@ -147,7 +147,8 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
|
|||||||
|
|
||||||
GLenum status = GL_NO_ERROR;
|
GLenum status = GL_NO_ERROR;
|
||||||
while ((status = glGetError()) != 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;
|
return CopyResult::UnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +184,13 @@ CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
|
|||||||
caches.textureState().deleteTexture(texture);
|
caches.textureState().deleteTexture(texture);
|
||||||
renderState.deleteFramebuffer(fbo);
|
renderState.deleteFramebuffer(fbo);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
GL_CHECKPOINT(MODERATE);
|
GL_CHECKPOINT(MODERATE);
|
||||||
|
|
||||||
return CopyResult::Success;
|
return CopyResult::Success;
|
||||||
|
|||||||
Reference in New Issue
Block a user