diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-12-05 17:19:49 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-12-05 20:24:21 -0800 |
commit | 738ef87eacd3e54132d1bf661dd9329050fddd2f (patch) | |
tree | ca0d8820e0f9780d832a4b1931be19fc7d8972c4 /core/jni/android/graphics/TextLayoutCache.cpp | |
parent | 315e468763c9601e2f06443fda847d2c9eb27a75 (diff) | |
download | frameworks_base-738ef87eacd3e54132d1bf661dd9329050fddd2f.zip frameworks_base-738ef87eacd3e54132d1bf661dd9329050fddd2f.tar.gz frameworks_base-738ef87eacd3e54132d1bf661dd9329050fddd2f.tar.bz2 |
Ensure log_clusters array is big enough.
Bug: 5714171
Change-Id: I886f1af8af177827f052e6406a192f2fad5c2cec
Diffstat (limited to 'core/jni/android/graphics/TextLayoutCache.cpp')
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index d69f2d3..bfd9c7c 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -328,8 +328,7 @@ uint32_t TextLayoutCacheValue::getElapsedTime() { return mElapsedTime; } -TextLayoutEngine::TextLayoutEngine() : mShaperItemGlyphArraySize(0), - mShaperItemLogClustersArraySize(0) { +TextLayoutEngine::TextLayoutEngine() : mShaperItemGlyphArraySize(0) { mDefaultTypeface = SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, SkTypeface::kNormal); mArabicTypeface = NULL; mHebrewRegularTypeface = NULL; @@ -409,7 +408,7 @@ void TextLayoutEngine::computeValues(SkPaint* paint, const UChar* chars, #if DEBUG_GLYPHS LOGD(" -- dirFlags = %d", dirFlags); LOGD(" -- paraDir = %d", paraDir); - LOGD(" -- run-count = %d", rc); + LOGD(" -- run-count = %d", int(rc)); #endif if (U_SUCCESS(status) && rc == 1) { // Normal case: one run, status is ok @@ -418,7 +417,7 @@ void TextLayoutEngine::computeValues(SkPaint* paint, const UChar* chars, } else if (!U_SUCCESS(status) || rc < 1) { LOGW("Need to force to single run -- string = '%s'," " status = %d, rc = %d", - String8(chars + start, count).string(), status, rc); + String8(chars + start, count).string(), status, int(rc)); isRTL = (paraDir == 1); useSingleRun = true; } else { @@ -720,7 +719,6 @@ size_t TextLayoutEngine::shapeFontRun(SkPaint* paint, bool isRTL) { } // Shape - ensureShaperItemLogClustersArray(mShaperItem.item.length); ensureShaperItemGlyphArrays(mShaperItem.item.length * 3 / 2); mShaperItem.num_glyphs = mShaperItemGlyphArraySize; while (!HB_ShapeItem(&mShaperItem)) { @@ -744,10 +742,17 @@ void TextLayoutEngine::createShaperItemGlyphArrays(size_t size) { LOGD("Creating Glyph Arrays with size = %d", size); #endif mShaperItemGlyphArraySize = size; + + // These arrays are all indexed by glyph. mShaperItem.glyphs = new HB_Glyph[size]; mShaperItem.attributes = new HB_GlyphAttributes[size]; mShaperItem.advances = new HB_Fixed[size]; mShaperItem.offsets = new HB_FixedPoint[size]; + + // Although the log_clusters array is indexed by character, Harfbuzz expects that + // it is big enough to hold one element per glyph. So we allocate log_clusters along + // with the other glyph arrays above. + mShaperItem.log_clusters = new unsigned short[size]; } void TextLayoutEngine::deleteShaperItemGlyphArrays() { @@ -755,24 +760,6 @@ void TextLayoutEngine::deleteShaperItemGlyphArrays() { delete[] mShaperItem.attributes; delete[] mShaperItem.advances; delete[] mShaperItem.offsets; -} - -void TextLayoutEngine::ensureShaperItemLogClustersArray(size_t size) { - if (size > mShaperItemLogClustersArraySize) { - deleteShaperItemLogClustersArray(); - createShaperItemLogClustersArray(size); - } -} - -void TextLayoutEngine::createShaperItemLogClustersArray(size_t size) { -#if DEBUG_GLYPHS - LOGD("Creating LogClusters Array with size = %d", size); -#endif - mShaperItemLogClustersArraySize = size; - mShaperItem.log_clusters = new unsigned short[size]; -} - -void TextLayoutEngine::deleteShaperItemLogClustersArray() { delete[] mShaperItem.log_clusters; } |