Fix tex and EGLImage leak in ColorBuffer
ColorBuffer wasn't destroying its blit texture and associated
EGLImage, leaking one pair per Android gralloc buffer.
Change-Id: I2fa42d2ecbb654edca7b224bd002d7513a08a633
http://code.google.com/p/android/issues/detail?id=33445
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index 218f32b..681db8b 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -111,7 +111,9 @@
ColorBuffer::ColorBuffer() :
m_tex(0),
+ m_blitTex(0),
m_eglImage(NULL),
+ m_blitEGLImage(NULL),
m_fbo(0),
m_internalFormat(0),
m_warYInvertBug(false)
@@ -134,13 +136,21 @@
{
FrameBuffer *fb = FrameBuffer::getFB();
fb->bind_locked();
- s_gl.glDeleteTextures(1, &m_tex);
+
+ if (m_blitEGLImage) {
+ s_egl.eglDestroyImageKHR(fb->getDisplay(), m_blitEGLImage);
+ }
if (m_eglImage) {
s_egl.eglDestroyImageKHR(fb->getDisplay(), m_eglImage);
}
+
if (m_fbo) {
s_gl.glDeleteFramebuffersOES(1, &m_fbo);
}
+
+ GLuint tex[2] = {m_tex, m_blitTex};
+ s_gl.glDeleteTextures(2, tex);
+
fb->unbind_locked();
}