summaryrefslogtreecommitdiffstats
path: root/core/jni/android/graphics/TextLayoutCache.cpp
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2012-06-25 16:05:57 -0700
committerRaph Levien <raph@google.com>2012-06-26 08:59:17 -0700
commitf62034d89611fbd3e1d41413847241757acd0c10 (patch)
tree731d7a1f4f4de46d6680622bff4dea3be1a66ef0 /core/jni/android/graphics/TextLayoutCache.cpp
parent6212a4f2ed2a5921de08b527cd1b25e1d155e56b (diff)
downloadframeworks_base-f62034d89611fbd3e1d41413847241757acd0c10.zip
frameworks_base-f62034d89611fbd3e1d41413847241757acd0c10.tar.gz
frameworks_base-f62034d89611fbd3e1d41413847241757acd0c10.tar.bz2
Initialize shaper offset array. Needed for bug 5443796.
Harfbuzz apparently requires the offset array to be initialized to zero, otherwise it can report corrupt glyph positions. This change also contains a small amount of refactoring to avoid code duplication. Change-Id: I2553974f40bc8e0549876c7d31243960ca92a8a2
Diffstat (limited to 'core/jni/android/graphics/TextLayoutCache.cpp')
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 6e12b95..5466be4 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -915,22 +915,23 @@ size_t TextLayoutShaper::shapeFontRun(const SkPaint* paint, bool isRTL) {
// Shape
assert(mShaperItem.item.length > 0); // Harfbuzz will overwrite other memory if length is 0.
- ensureShaperItemGlyphArrays(mShaperItem.item.length * 3 / 2);
- mShaperItem.num_glyphs = mShaperItemGlyphArraySize;
- while (!HB_ShapeItem(&mShaperItem)) {
+ size_t size = mShaperItem.item.length * 3 / 2;
+ while (!doShaping(size)) {
// We overflowed our glyph arrays. Resize and retry.
// HB_ShapeItem fills in shaperItem.num_glyphs with the needed size.
- ensureShaperItemGlyphArrays(mShaperItem.num_glyphs * 2);
- mShaperItem.num_glyphs = mShaperItemGlyphArraySize;
+ size = mShaperItem.num_glyphs * 2;
}
return baseGlyphCount;
}
-void TextLayoutShaper::ensureShaperItemGlyphArrays(size_t size) {
+bool TextLayoutShaper::doShaping(size_t size) {
if (size > mShaperItemGlyphArraySize) {
deleteShaperItemGlyphArrays();
createShaperItemGlyphArrays(size);
}
+ mShaperItem.num_glyphs = mShaperItemGlyphArraySize;
+ memset(mShaperItem.offsets, 0, mShaperItem.num_glyphs * sizeof(HB_FixedPoint));
+ return HB_ShapeItem(&mShaperItem);
}
void TextLayoutShaper::createShaperItemGlyphArrays(size_t size) {