summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2010-01-21 16:37:48 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2010-01-21 16:37:48 -0800
commit35e973f696a140e6d7a3af0cec864f5ff5002206 (patch)
tree45a7fb9ad27b7031e2ca5cfd26552aa10e4853a3
parenta2fe2f39d9e5c39b19c32af468827b3c1c5bee7a (diff)
parentedfd97c0f2e679e86699a0f6c4df65ea21ecff15 (diff)
Merge changes I2d41cb94,Ia1a17985
* changes: fix [2324665] texture leak in surfaceflinger when using camera fix a texture leak introduced recently.
-rw-r--r--libs/surfaceflinger/LayerBuffer.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 091856f9dc..ac9b6b05c4 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -370,8 +370,23 @@ LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
LayerBuffer::BufferSource::~BufferSource()
{
+ class MessageDestroyTexture : public MessageBase {
+ SurfaceFlinger* flinger;
+ GLuint name;
+ public:
+ MessageDestroyTexture(
+ SurfaceFlinger* flinger, GLuint name)
+ : flinger(flinger), name(name) { }
+ virtual bool handler() {
+ glDeleteTextures(1, &name);
+ return true;
+ }
+ };
+
if (mTexture.name != -1U) {
- glDeleteTextures(1, &mTexture.name);
+ // GL textures can only be destroyed from the GL thread
+ mLayer.mFlinger->mEventQueue.postMessage(
+ new MessageDestroyTexture(mLayer.mFlinger.get(), mTexture.name) );
}
if (mTexture.image != EGL_NO_IMAGE_KHR) {
EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
@@ -444,6 +459,10 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
NativeBuffer src(ourBuffer->getBuffer());
const Rect transformedBounds(mLayer.getTransformedBounds());
+ if (UNLIKELY(mTexture.name == -1LU)) {
+ mTexture.name = mLayer.createTexture();
+ }
+
#if defined(EGL_ANDROID_image_native_buffer)
if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
copybit_device_t* copybit = mLayer.mBlitEngine;
@@ -483,9 +502,6 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
t.format = src.img.format;
t.data = (GGLubyte*)src.img.base;
const Region dirty(Rect(t.width, t.height));
- if (UNLIKELY(mTexture.name == -1LU)) {
- mTexture.name = mLayer.createTexture();
- }
mLayer.loadTexture(&mTexture, dirty, t);
}
@@ -566,11 +582,17 @@ status_t LayerBuffer::BufferSource::initTempBuffer() const
void LayerBuffer::BufferSource::clearTempBufferImage() const
{
+ // delete the image
EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
- glDeleteTextures(1, &mTexture.name);
eglDestroyImageKHR(dpy, mTexture.image);
+
+ // and the associated texture (recreate a name)
+ glDeleteTextures(1, &mTexture.name);
Texture defaultTexture;
mTexture = defaultTexture;
+ mTexture.name = mLayer.createTexture();
+
+ // and the associated buffer
mTempGraphicBuffer.clear();
}