diff options
| author | Mathias Agopian <mathias@google.com> | 2010-01-21 16:27:30 -0800 |
|---|---|---|
| committer | Mathias Agopian <mathias@google.com> | 2010-01-21 16:27:30 -0800 |
| commit | a1a1798599361f5f1db8fe612606323c801f4f6c (patch) | |
| tree | 4915d622048e70b4b0093f4b073795793a69dc1c | |
| parent | 04ce08f34e39928a5b8e9ea59134f255c9ff08f6 (diff) | |
| download | frameworks_base-a1a1798599361f5f1db8fe612606323c801f4f6c.zip frameworks_base-a1a1798599361f5f1db8fe612606323c801f4f6c.tar.gz frameworks_base-a1a1798599361f5f1db8fe612606323c801f4f6c.tar.bz2 | |
fix a texture leak introduced recently.
create the texture name once and for all for a given BufferSource
and make sure to recreate it when we're forced to delete the texture.
| -rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 091856f..b9727ab 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -444,6 +444,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 +487,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 +567,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(); } |
