@@ -52,13 +52,7 @@ void TextLayoutCache::init() {
5252 mCacheStartTime = systemTime (SYSTEM_TIME_MONOTONIC);
5353
5454 if (mDebugEnabled ) {
55- LOGD (" Start time: %lld" , mCacheStartTime );
56- #if RTL_USE_HARFBUZZ
57- LOGD (" Using HARFBUZZ" );
58- #else
59- LOGD (" Using ICU" );
60- #endif
61- LOGD (" Initialization is done" );
55+ LOGD (" Initialization is done - Start time: %lld" , mCacheStartTime );
6256 }
6357
6458 mInitialized = true ;
@@ -302,13 +296,8 @@ void TextLayoutCacheValue::computeValues(SkPaint* paint, const UChar* chars, siz
302296 mAdvancesCount = count;
303297 mAdvances = new float [count];
304298
305- #if RTL_USE_HARFBUZZ
306299 computeValuesWithHarfbuzz (paint, chars, start, count, contextCount, dirFlags,
307300 mAdvances , &mTotalAdvance , &mGlyphs , &mGlyphsCount );
308- #else
309- computeAdvancesWithICU (paint, chars, start, count, contextCount, dirFlags,
310- mAdvances , &mTotalAdvance );
311- #endif
312301#if DEBUG_ADVANCES
313302 LOGD (" Advances - count=%d - countextCount=%d - totalAdvance=%f - "
314303 " adv[0]=%f adv[1]=%f adv[2]=%f adv[3]=%f" , count, contextCount, mTotalAdvance ,
@@ -632,75 +621,6 @@ void TextLayoutCacheValue::computeRunValuesWithHarfbuzz(SkPaint* paint, const UC
632621 HB_FreeFace (shaperItem.face );
633622}
634623
635- void TextLayoutCacheValue::computeAdvancesWithICU (SkPaint* paint, const UChar* chars,
636- size_t start, size_t count, size_t contextCount, int dirFlags,
637- jfloat* outAdvances, jfloat* outTotalAdvance) {
638- SkAutoSTMalloc<CHAR_BUFFER_SIZE, jchar> tempBuffer (contextCount);
639- jchar* buffer = tempBuffer.get ();
640- SkScalar* scalarArray = (SkScalar*)outAdvances;
641-
642- // this is where we'd call harfbuzz
643- // for now we just use ushape.c
644- size_t widths;
645- const jchar* text;
646- if (dirFlags & 0x1 ) { // rtl, call arabic shaping in case
647- UErrorCode status = U_ZERO_ERROR;
648- // Use fixed length since we need to keep start and count valid
649- u_shapeArabic (chars, contextCount, buffer, contextCount,
650- U_SHAPE_LENGTH_FIXED_SPACES_NEAR |
651- U_SHAPE_TEXT_DIRECTION_LOGICAL | U_SHAPE_LETTERS_SHAPE |
652- U_SHAPE_X_LAMALEF_SUB_ALTERNATE, &status);
653- // we shouldn't fail unless there's an out of memory condition,
654- // in which case we're hosed anyway
655- for (int i = start, e = i + count; i < e; ++i) {
656- if (buffer[i] == UNICODE_NOT_A_CHAR) {
657- buffer[i] = UNICODE_ZWSP; // zero-width-space for skia
658- }
659- }
660- text = buffer + start;
661- widths = paint->getTextWidths (text, count << 1 , scalarArray);
662- } else {
663- text = chars + start;
664- widths = paint->getTextWidths (text, count << 1 , scalarArray);
665- }
666-
667- jfloat totalAdvance = 0 ;
668- if (widths < count) {
669- #if DEBUG_ADVANCES
670- LOGD (" ICU -- count=%d" , widths);
671- #endif
672- // Skia operates on code points, not code units, so surrogate pairs return only
673- // one value. Expand the result so we have one value per UTF-16 code unit.
674-
675- // Note, skia's getTextWidth gets confused if it encounters a surrogate pair,
676- // leaving the remaining widths zero. Not nice.
677- for (size_t i = 0 , p = 0 ; i < widths; ++i) {
678- totalAdvance += outAdvances[p++] = SkScalarToFloat (scalarArray[i]);
679- if (p < count &&
680- text[p] >= UNICODE_FIRST_LOW_SURROGATE &&
681- text[p] < UNICODE_FIRST_PRIVATE_USE &&
682- text[p-1 ] >= UNICODE_FIRST_HIGH_SURROGATE &&
683- text[p-1 ] < UNICODE_FIRST_LOW_SURROGATE) {
684- outAdvances[p++] = 0 ;
685- }
686- #if DEBUG_ADVANCES
687- LOGD (" icu-adv = %f - total = %f" , outAdvances[i], totalAdvance);
688- #endif
689- }
690- } else {
691- #if DEBUG_ADVANCES
692- LOGD (" ICU -- count=%d" , count);
693- #endif
694- for (size_t i = 0 ; i < count; i++) {
695- totalAdvance += outAdvances[i] = SkScalarToFloat (scalarArray[i]);
696- #if DEBUG_ADVANCES
697- LOGD (" icu-adv = %f - total = %f" , outAdvances[i], totalAdvance);
698- #endif
699- }
700- }
701- *outTotalAdvance = totalAdvance;
702- }
703-
704624void TextLayoutCacheValue::deleteGlyphArrays (HB_ShaperItem* shaperItem) {
705625 delete[] shaperItem->glyphs ;
706626 delete[] shaperItem->attributes ;
0 commit comments