From 22158e139a3d6c6a9787ca0de224e9368f643284 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 6 Aug 2010 11:18:34 -0700 Subject: Automatically cleanup textures that don't fit in the cache. Change-Id: I4f29ed96ea11118b391fb957e1e4d1b8fcef1537 --- libs/hwui/OpenGLRenderer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libs/hwui/OpenGLRenderer.cpp') diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index a72045b44b2f..db8c8637aa67 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -436,6 +436,8 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, const S } const Texture* texture = mTextureCache.get(bitmap); + const AutoTexture autoCleanup(texture); + drawTextureRect(left, top, right, bottom, texture, paint); } @@ -449,6 +451,8 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, const SkMatrix* matrix, const } const Texture* texture = mTextureCache.get(bitmap); + const AutoTexture autoCleanup(texture); + drawTextureRect(r.left, r.top, r.right, r.bottom, texture, paint); } @@ -461,6 +465,7 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, } const Texture* texture = mTextureCache.get(bitmap); + const AutoTexture autoCleanup(texture); const float width = texture->width; const float height = texture->height; @@ -484,6 +489,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, } const Texture* texture = mTextureCache.get(bitmap); + const AutoTexture autoCleanup(texture); int alpha; SkXfermode::Mode mode; @@ -610,7 +616,8 @@ void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) { GLuint textureUnit = 0; glActiveTexture(gTextureUnits[textureUnit]); - PathTexture* texture = mPathCache.get(path, paint); + const PathTexture* texture = mPathCache.get(path, paint); + const AutoTexture autoCleanup(texture); int alpha; SkXfermode::Mode mode; -- cgit v1.2.3-59-g8ed1b