summaryrefslogtreecommitdiff
path: root/libs/hwui/TextDropShadowCache.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-12-10 12:33:05 -0800
committerRomain Guy <romainguy@google.com>2010-12-10 12:33:05 -0800
commit25dc3a7dbac2f90f5144035e9c8ed99c09cc3132 (patch)
tree437bc11671362d200c011b63abb767e603867da8 /libs/hwui/TextDropShadowCache.cpp
parentaf636ebf5feb2837683fbfe965040cb706b32ec1 (diff)
Correctly compare strings in UTF-8 instead of UTF-16
Bug #3272858 Change-Id: Idacd5d7c2c052b4834a8ddb5906ab32b3f548f73
Diffstat (limited to 'libs/hwui/TextDropShadowCache.cpp')
-rw-r--r--libs/hwui/TextDropShadowCache.cpp21
1 files changed, 17 insertions, 4 deletions
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<ShadowText, ShadowTexture*>::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 {