diff options
| author | 2011-11-18 14:50:39 -0800 | |
|---|---|---|
| committer | 2011-11-18 15:23:53 -0800 | |
| commit | a4f5aa87c73de7a2581dc4dd72e0f90ccea79a18 (patch) | |
| tree | 3d0005f7aec69b09ccee61c7b18dacbe7754a751 | |
| parent | 78137d77991f129b349b258474ef8b5133b300d9 (diff) | |
Fix TextLayoutCache Skia Typeface caching
- fix reference passing for globals
Change-Id: I806dd4406d455b98c6be733847419b06b6774ccc
| -rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 19 | ||||
| -rw-r--r-- | core/jni/android/graphics/TextLayoutCache.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index e993e2aa195e..5fed2f349f2e 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -416,7 +416,7 @@ unsigned TextLayoutCacheValue::shapeFontRun(HB_ShaperItem& shaperItem, SkPaint* FontData* data = reinterpret_cast<FontData*>(shaperItem.font->userData); switch(shaperItem.item.script) { case HB_Script_Arabic: - data->typeFace = getCachedTypeface(gArabicTypeface, TYPEFACE_ARABIC); + data->typeFace = getCachedTypeface(&gArabicTypeface, TYPEFACE_ARABIC); #if DEBUG_GLYPHS LOGD("Using Arabic Typeface"); #endif @@ -428,21 +428,21 @@ unsigned TextLayoutCacheValue::shapeFontRun(HB_ShaperItem& shaperItem, SkPaint* case SkTypeface::kNormal: case SkTypeface::kItalic: default: - data->typeFace = getCachedTypeface(gHebrewRegularTypeface, TYPE_FACE_HEBREW_REGULAR); + data->typeFace = getCachedTypeface(&gHebrewRegularTypeface, TYPE_FACE_HEBREW_REGULAR); #if DEBUG_GLYPHS LOGD("Using Hebrew Regular/Italic Typeface"); #endif break; case SkTypeface::kBold: case SkTypeface::kBoldItalic: - data->typeFace = getCachedTypeface(gHebrewBoldTypeface, TYPE_FACE_HEBREW_BOLD); + data->typeFace = getCachedTypeface(&gHebrewBoldTypeface, TYPE_FACE_HEBREW_BOLD); #if DEBUG_GLYPHS LOGD("Using Hebrew Bold/BoldItalic Typeface"); #endif break; } } else { - data->typeFace = getCachedTypeface(gHebrewRegularTypeface, TYPE_FACE_HEBREW_REGULAR); + data->typeFace = getCachedTypeface(&gHebrewRegularTypeface, TYPE_FACE_HEBREW_REGULAR); #if DEBUG_GLYPHS LOGD("Using Hebrew Regular Typeface"); #endif @@ -482,11 +482,14 @@ unsigned TextLayoutCacheValue::shapeFontRun(HB_ShaperItem& shaperItem, SkPaint* return result; } -SkTypeface* TextLayoutCacheValue::getCachedTypeface(SkTypeface* typeface, const char path[]) { - if (!typeface) { - typeface = SkTypeface::CreateFromFile(path); +SkTypeface* TextLayoutCacheValue::getCachedTypeface(SkTypeface** typeface, const char path[]) { + if (!*typeface) { + *typeface = SkTypeface::CreateFromFile(path); +#if DEBUG_GLYPHS + LOGD("Created SkTypeface from file: %s", path); +#endif } - return typeface; + return *typeface; } void TextLayoutCacheValue::computeValuesWithHarfbuzz(SkPaint* paint, const UChar* chars, diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h index 06c74fcecefd..5c938f7582a8 100644 --- a/core/jni/android/graphics/TextLayoutCache.h +++ b/core/jni/android/graphics/TextLayoutCache.h @@ -174,7 +174,7 @@ private: static unsigned shapeFontRun(HB_ShaperItem& shaperItem, SkPaint* paint, size_t count, bool isRTL); - static SkTypeface* getCachedTypeface(SkTypeface* typeface, const char path[]); + static SkTypeface* getCachedTypeface(SkTypeface** typeface, const char path[]); static void deleteGlyphArrays(HB_ShaperItem& shaperItem); |