Correctly compare strings in UTF-8 instead of UTF-16
Bug #3272858
Change-Id: Idacd5d7c2c052b4834a8ddb5906ab32b3f548f73
diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp
index 2f7c7be..d96a7f5 100644
--- a/libs/hwui/TextDropShadowCache.cpp
+++ b/libs/hwui/TextDropShadowCache.cpp
@@ -37,19 +37,24 @@
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::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 @@
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 @@
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 {