From 25dc3a7dbac2f90f5144035e9c8ed99c09cc3132 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 10 Dec 2010 12:33:05 -0800 Subject: Correctly compare strings in UTF-8 instead of UTF-16 Bug #3272858 Change-Id: Idacd5d7c2c052b4834a8ddb5906ab32b3f548f73 --- libs/hwui/TextDropShadowCache.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'libs/hwui/TextDropShadowCache.cpp') diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp index 2f7c7be782c6..d96a7f516022 100644 --- a/libs/hwui/TextDropShadowCache.cpp +++ b/libs/hwui/TextDropShadowCache.cpp @@ -37,19 +37,24 @@ TextDropShadowCache::TextDropShadowCache(): LOGD(" Using default drop shadow cache size of %.2fMB", DEFAULT_DROP_SHADOW_CACHE_SIZE); } - mCache.setOnEntryRemovedListener(this); + init(); } TextDropShadowCache::TextDropShadowCache(uint32_t maxByteSize): mCache(GenerationCache::kUnlimitedCapacity), mSize(0), mMaxSize(maxByteSize) { - mCache.setOnEntryRemovedListener(this); + init(); } TextDropShadowCache::~TextDropShadowCache() { mCache.clear(); } +void TextDropShadowCache::init() { + mCache.setOnEntryRemovedListener(this); + mDebugEnabled = readDebugLevel() & kDebugMoreCaches; +} + /////////////////////////////////////////////////////////////////////////////// // Size management /////////////////////////////////////////////////////////////////////////////// @@ -75,8 +80,11 @@ void TextDropShadowCache::setMaxSize(uint32_t maxSize) { void TextDropShadowCache::operator()(ShadowText& text, ShadowTexture*& texture) { if (texture) { - const uint32_t size = texture->width * texture->height; - mSize -= size; + mSize -= texture->bitmapSize; + + if (mDebugEnabled) { + LOGD("Shadow texture deleted, size = %d", texture->bitmapSize); + } glDeleteTextures(1, &texture->id); delete texture; @@ -109,6 +117,8 @@ ShadowTexture* TextDropShadowCache::get(SkPaint* paint, const char* text, uint32 texture->blend = true; const uint32_t size = shadow.width * shadow.height; + texture->bitmapSize = size; + // Don't even try to cache a bitmap that's bigger than the cache if (size < mMaxSize) { while (mSize + size > mMaxSize) { @@ -132,6 +142,9 @@ ShadowTexture* TextDropShadowCache::get(SkPaint* paint, const char* text, uint32 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if (size < mMaxSize) { + if (mDebugEnabled) { + LOGD("Shadow texture created, size = %d", texture->bitmapSize); + } mSize += size; mCache.put(entry, texture); } else { -- cgit v1.2.3-59-g8ed1b