summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-05-15 14:47:03 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2012-05-15 14:55:49 -0700
commit15cc68ced062a0dbd174718abfb1c783ac1aa433 (patch)
tree99929c4d4d804bad9bd44acb34f82c781cda10d0 /core
parent776627b8b0f20e88d31ab83e510de1344043b919 (diff)
downloadframeworks_base-15cc68ced062a0dbd174718abfb1c783ac1aa433.zip
frameworks_base-15cc68ced062a0dbd174718abfb1c783ac1aa433.tar.gz
frameworks_base-15cc68ced062a0dbd174718abfb1c783ac1aa433.tar.bz2
Fix bug #6495019 Character gets garbled when locale is changed
- add missing cached data clearing. The Shaper was caching the HB_Face so clear them too - do minor code refactoring Change-Id: Ifa86cc63815bdb4b51ce688cf16e986415b1e8c1
Diffstat (limited to 'core')
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp38
-rw-r--r--core/jni/android/graphics/TextLayoutCache.h5
2 files changed, 33 insertions, 10 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 673c38d..c85b09c 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -332,15 +332,7 @@ uint32_t TextLayoutValue::getElapsedTime() {
}
TextLayoutShaper::TextLayoutShaper() : mShaperItemGlyphArraySize(0) {
- mDefaultTypeface = SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, SkTypeface::kNormal);
- mArabicTypeface = NULL;
- mHebrewRegularTypeface = NULL;
- mHebrewBoldTypeface = NULL;
- mBengaliTypeface = NULL;
- mThaiTypeface = NULL;
- mDevanagariRegularTypeface = NULL;
- mTamilRegularTypeface = NULL;
- mTamilBoldTypeface = NULL;
+ init();
mFontRec.klass = &harfbuzzSkiaClass;
mFontRec.userData = 0;
@@ -359,7 +351,19 @@ TextLayoutShaper::TextLayoutShaper() : mShaperItemGlyphArraySize(0) {
mShaperItem.font->userData = &mShapingPaint;
}
-TextLayoutShaper::~TextLayoutShaper() {
+void TextLayoutShaper::init() {
+ mDefaultTypeface = SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, SkTypeface::kNormal);
+ mArabicTypeface = NULL;
+ mHebrewRegularTypeface = NULL;
+ mHebrewBoldTypeface = NULL;
+ mBengaliTypeface = NULL;
+ mThaiTypeface = NULL;
+ mDevanagariRegularTypeface = NULL;
+ mTamilRegularTypeface = NULL;
+ mTamilBoldTypeface = NULL;
+}
+
+void TextLayoutShaper::unrefTypefaces() {
SkSafeUnref(mDefaultTypeface);
SkSafeUnref(mArabicTypeface);
SkSafeUnref(mHebrewRegularTypeface);
@@ -369,6 +373,10 @@ TextLayoutShaper::~TextLayoutShaper() {
SkSafeUnref(mDevanagariRegularTypeface);
SkSafeUnref(mTamilRegularTypeface);
SkSafeUnref(mTamilBoldTypeface);
+}
+
+TextLayoutShaper::~TextLayoutShaper() {
+ unrefTypefaces();
deleteShaperItemGlyphArrays();
}
@@ -983,6 +991,12 @@ HB_Face TextLayoutShaper::getCachedHBFace(SkTypeface* typeface) {
return face;
}
+void TextLayoutShaper::purgeCaches() {
+ mCachedHBFaces.clear();
+ unrefTypefaces();
+ init();
+}
+
TextLayoutEngine::TextLayoutEngine() {
mShaper = new TextLayoutShaper();
#if USE_TEXT_LAYOUT_CACHE
@@ -1018,6 +1032,10 @@ sp<TextLayoutValue> TextLayoutEngine::getValue(const SkPaint* paint, const jchar
void TextLayoutEngine::purgeCaches() {
#if USE_TEXT_LAYOUT_CACHE
mTextLayoutCache->clear();
+ mShaper->purgeCaches();
+#if DEBUG_GLYPHS
+ ALOGD("Purged TextLayoutEngine caches");
+#endif
#endif
}
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 027e888..cb15a2a 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -169,6 +169,8 @@ public:
void computeValues(TextLayoutValue* value, const SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, int dirFlags);
+ void purgeCaches();
+
private:
/**
* Harfbuzz shaper item
@@ -218,6 +220,9 @@ private:
*/
UnicodeString mBuffer;
+ void init();
+ void unrefTypefaces();
+
SkTypeface* typefaceForUnichar(const SkPaint* paint, SkTypeface* typeface,
SkUnichar unichar, HB_Script script);