OSDN Git Service

libhwui: fix texture memory leak
authorDohyun Lee <leedhyun11@gmail.com>
Thu, 21 Jan 2016 04:46:21 +0000 (13:46 +0900)
committerDohyun Lee <leedhyun11@gmail.com>
Thu, 21 Jan 2016 04:46:21 +0000 (13:46 +0900)
When there is not enough space and we cannot delete any
Texture in TextureCache to secure space, a new Texture is
created over and over again for the same SkBitmap and
there is the case that it is not deleted.
This patch avoids such cases.

Change-Id: Ic5353995e6d0716c31fe3bb49c60ec1a71574643
Signed-off-by: Dohyun Lee <leedhyun11@gmail.com>
libs/hwui/OpenGLRenderer.cpp
libs/hwui/renderstate/RenderState.cpp

index 9621b54..5233a23 100644 (file)
@@ -1699,6 +1699,7 @@ void OpenGLRenderer::drawPatch(const SkBitmap* bitmap, const Patch* mesh,
 
     Texture* texture = entry ? entry->texture : mCaches.textureCache.get(bitmap);
     if (!texture) return;
+    const AutoTexture autoCleanup(texture);
 
     // 9 patches are built for stretching - always filter
     int textureFillFlags = TextureFillFlags::ForceFilter;
index 1e39bfa..84b6965 100644 (file)
@@ -306,6 +306,10 @@ void RenderState::render(const Glop& glop) {
     // Shader uniforms
     SkiaShader::apply(*mCaches, fill.skiaShaderData);
 
+    Texture* texture = (fill.skiaShaderData.skiaShaderType & kBitmap_SkiaShaderType) ?
+            fill.skiaShaderData.bitmapData.bitmapTexture : nullptr;
+    const AutoTexture autoCleanup(texture);
+
     // ------------------------------------
     // ---------- GL state setup ----------
     // ------------------------------------