From 2d41cb9433ef3845560a252a5cf8226e1d78209a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 21 Jan 2010 16:04:56 -0800 Subject: fix [2324665] texture leak in surfaceflinger when using camera --- libs/surfaceflinger/LayerBuffer.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libs/surfaceflinger') diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index b9727ab..ac9b6b0 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()); -- cgit v1.1