summaryrefslogtreecommitdiffstats
path: root/core/jni/android/graphics
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-05-07 17:45:44 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2012-05-07 20:17:38 -0700
commit30ca5cd11a23f06f2f8eeaa587685450826f800f (patch)
tree69cdc7dc7653340c0fb27daccf1f82af7a0e45ed /core/jni/android/graphics
parent476b03b0c0d5cae4d1b114c6f80858d59ba36cad (diff)
downloadframeworks_base-30ca5cd11a23f06f2f8eeaa587685450826f800f.zip
frameworks_base-30ca5cd11a23f06f2f8eeaa587685450826f800f.tar.gz
frameworks_base-30ca5cd11a23f06f2f8eeaa587685450826f800f.tar.bz2
Fix bug #6408393 Character corruption is caused when locale is changed
- free the TextLayoutCache on Locale change - also free TextLayoutCache when memory is low Change-Id: I39a37ac8ec3c292cfb1c0eea4bb41ff71897d089
Diffstat (limited to 'core/jni/android/graphics')
-rw-r--r--core/jni/android/graphics/Canvas.cpp10
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp7
-rw-r--r--core/jni/android/graphics/TextLayoutCache.h3
3 files changed, 18 insertions, 2 deletions
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index ef6af74..6b74705 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -69,7 +69,11 @@ public:
SkImageRef_GlobalPool::SetRAMUsed(0);
SkGraphics::PurgeFontCache();
}
-
+
+ static void freeTextLayoutCaches(JNIEnv* env, jobject) {
+ TextLayoutEngine::getInstance().purgeCaches();
+ }
+
static jboolean isOpaque(JNIEnv* env, jobject jcanvas) {
NPE_CHECK_RETURN_ZERO(env, jcanvas);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
@@ -986,7 +990,9 @@ static JNINativeMethod gCanvasMethods[] = {
(void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint},
{"native_drawPicture", "(II)V", (void*) SkCanvasGlue::drawPicture},
- {"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches}
+ {"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches},
+
+ {"freeTextLayoutCaches", "()V", (void*) SkCanvasGlue::freeTextLayoutCaches}
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 2c38893..71c7ab0 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -991,4 +991,11 @@ sp<TextLayoutValue> TextLayoutEngine::getValue(const SkPaint* paint, const jchar
return value;
}
+void TextLayoutEngine::purgeCaches() {
+#if USE_TEXT_LAYOUT_CACHE
+ mTextLayoutCache->clear();
+#endif
+}
+
+
} // namespace android
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 7d7caac..7308367 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -309,6 +309,9 @@ public:
sp<TextLayoutValue> getValue(const SkPaint* paint, const jchar* text, jint start,
jint count, jint contextCount, jint dirFlags);
+
+ void purgeCaches();
+
private:
TextLayoutCache* mTextLayoutCache;
TextLayoutShaper* mShaper;