diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-10-05 18:11:59 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-10-07 11:22:39 -0700 |
commit | 5c863f741e8e484bb39decd516c9fa4c6322e671 (patch) | |
tree | 19b0e47d77e0f286e473118e9c07b9dd31058942 /core/jni/android/graphics/TextLayoutCache.h | |
parent | e921572bda621b75a217bce115c2b605caf9b26a (diff) | |
download | frameworks_base-5c863f741e8e484bb39decd516c9fa4c6322e671.zip frameworks_base-5c863f741e8e484bb39decd516c9fa4c6322e671.tar.gz frameworks_base-5c863f741e8e484bb39decd516c9fa4c6322e671.tar.bz2 |
Fix bug #5371117 Regression : The Hebrew / Arabic text behavior in ICS latest build is wrong
- welcome back start / count
- goodbye log clusters
- clean Paint code
- make private some functions as they should be
- improve memory allocation (create only one Shaper and reuse it for for shaping the runs in
the same input text)
Change-Id: I89a320c7f041319851308c8c9a919fbeafa82cdd
Diffstat (limited to 'core/jni/android/graphics/TextLayoutCache.h')
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h index 6dda1e5..580079d 100644 --- a/core/jni/android/graphics/TextLayoutCache.h +++ b/core/jni/android/graphics/TextLayoutCache.h @@ -68,7 +68,8 @@ class TextLayoutCacheKey { public: TextLayoutCacheKey(); - TextLayoutCacheKey(const SkPaint* paint, const UChar* text, size_t count, int dirFlags); + TextLayoutCacheKey(const SkPaint* paint, const UChar* text, size_t start, size_t count, + size_t contextCount, int dirFlags); TextLayoutCacheKey(const TextLayoutCacheKey& other); @@ -88,7 +89,9 @@ public: private: const UChar* text; // if text is NULL, use textCopy String16 textCopy; + size_t start; size_t count; + size_t contextCount; int dirFlags; SkTypeface* typeface; SkScalar textSize; @@ -119,32 +122,20 @@ public: void setElapsedTime(uint32_t time); uint32_t getElapsedTime(); - void computeValues(SkPaint* paint, const UChar* chars, size_t contextCount, int dirFlags); + void computeValues(SkPaint* paint, const UChar* chars, size_t start, size_t count, + size_t contextCount, int dirFlags); - void getAdvances(size_t start, size_t count, jfloat* outAdvances) const; - jfloat getTotalAdvance(size_t start, size_t count) const; - void getGlyphsIndexAndCount(size_t start, size_t count, size_t* outStartIndex, - size_t* outGlyphsCount) const; - const jchar* getGlyphs(size_t startIndex, size_t count); + inline const jfloat* getAdvances() const { return mAdvances.array(); } + inline size_t getAdvancesCount() const { return mAdvances.size(); } + inline jfloat getTotalAdvance() const { return mTotalAdvance; } + inline const jchar* getGlyphs() const { return mGlyphs.array(); } + inline size_t getGlyphsCount() const { return mGlyphs.size(); } /** * Get the size of the Cache entry */ size_t getSize(); - static void setupShaperItem(HB_ShaperItem* shaperItem, HB_FontRec* font, FontData* fontData, - SkPaint* paint, const UChar* chars, size_t start, size_t count, size_t contextCount, - bool isRTL); - - static void shapeWithHarfbuzz(HB_ShaperItem* shaperItem, HB_FontRec* font, FontData* fontData, - SkPaint* paint, const UChar* chars, size_t start, size_t count, size_t contextCount, - bool isRTL); - - static void computeValuesWithHarfbuzz(SkPaint* paint, const UChar* chars, - size_t contextCount, int dirFlags, - Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance, - Vector<jchar>* const outGlyphs, Vector<unsigned short>* const outLogClusters); - private: /** * Advances vector @@ -162,23 +153,31 @@ private: Vector<jchar> mGlyphs; /** - * Harfbuzz Log Clusters - */ - Vector<unsigned short> mLogClusters; - - /** * Time for computing the values (in milliseconds) */ uint32_t mElapsedTime; - static void deleteGlyphArrays(HB_ShaperItem* shaperItem); - static void createGlyphArrays(HB_ShaperItem* shaperItem, int size); - static void resetGlyphArrays(HB_ShaperItem* shaperItem); + static void computeValuesWithHarfbuzz(SkPaint* paint, const UChar* chars, + size_t start, size_t count, size_t contextCount, int dirFlags, + Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance, + Vector<jchar>* const outGlyphs); - static void computeRunValuesWithHarfbuzz(SkPaint* paint, const UChar* chars, size_t start, - size_t count, size_t contextCount, bool isRTL, + static void computeRunValuesWithHarfbuzz(HB_ShaperItem& shaperItem, SkPaint* paint, + size_t start, size_t count, bool isRTL, Vector<jfloat>* const outAdvances, jfloat* outTotalAdvance, - Vector<jchar>* const outGlyphs, Vector<unsigned short>* const outLogClusters); + Vector<jchar>* const outGlyphs); + + static void initShaperItem(HB_ShaperItem& shaperItem, HB_FontRec* font, FontData* fontData, + SkPaint* paint, const UChar* chars, size_t contextCount); + + static void freeShaperItem(HB_ShaperItem& shaperItem); + + static void shapeRun(HB_ShaperItem& shaperItem, size_t start, size_t count, bool isRTL); + + static void deleteGlyphArrays(HB_ShaperItem& shaperItem); + + static void createGlyphArrays(HB_ShaperItem& shaperItem, int size); + }; // TextLayoutCacheValue /** @@ -202,8 +201,8 @@ public: */ void operator()(TextLayoutCacheKey& text, sp<TextLayoutCacheValue>& desc); - sp<TextLayoutCacheValue> getValue(SkPaint* paint, const jchar* text, jint count, - jint dirFlags); + sp<TextLayoutCacheValue> getValue(SkPaint* paint, const jchar* text, jint start, jint count, + jint contextCount, jint dirFlags); /** * Clear the cache @@ -256,6 +255,7 @@ private: * Dump Cache statistics */ void dumpCacheStats(); + }; // TextLayoutCache } // namespace android |