Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c863f74 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

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
parent e921572b
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -767,20 +767,17 @@ public:

        sp<TextLayoutCacheValue> value;
#if USE_TEXT_LAYOUT_CACHE
        value = TextLayoutCache::getInstance().getValue(paint, textArray, contextCount, flags);
        value = TextLayoutCache::getInstance().getValue(paint, textArray, start, count,
                contextCount, flags);
        if (value == NULL) {
            LOGE("Cannot get TextLayoutCache value");
            return ;
        }
#else
        value = new TextLayoutCacheValue();
        value->computeValues(paint, textArray, contextCount, flags);
        value->computeValues(paint, textArray, start, count, contextCount, flags);
#endif
        size_t startIndex = 0;
        size_t glyphsCount = 0;
        value->getGlyphsIndexAndCount(start, count, &startIndex, &glyphsCount);
        const jchar* glyphs = value->getGlyphs(startIndex, glyphsCount);
        doDrawGlyphs(canvas, glyphs, 0, glyphsCount, x, y, flags, paint);
        doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(), x, y, flags, paint);
    }

    static void doDrawGlyphs(SkCanvas* canvas, const jchar* glyphArray, int index, int count,
+7 −10
Original line number Diff line number Diff line
@@ -483,18 +483,15 @@ public:
        }

        jchar* glyphsArray = env->GetCharArrayElements(glyphs, NULL);
        HB_ShaperItem shaperItem;
        HB_FontRec font;
        FontData fontData;
        TextLayoutCacheValue::shapeWithHarfbuzz(&shaperItem, &font, &fontData, paint, text,
                start, count, contextCount, flags);

        int glyphCount = shaperItem.num_glyphs;
        for (int i = 0; i < glyphCount; i++) {
            glyphsArray[i] = (jchar) shaperItem.glyphs[i];
        }
        TextLayoutCacheValue value;
        value.computeValues(paint, text, start, count, contextCount, flags);
        const jchar* shapedGlyphs = value.getGlyphs();
        size_t glyphsCount = value.getGlyphsCount();
        memcpy(glyphsArray, shapedGlyphs, sizeof(jchar) * glyphsCount);

        env->ReleaseCharArrayElements(glyphs, glyphsArray, JNI_ABORT);
        return glyphCount;
        return glyphsCount;
    }

    static int getTextGlyphs__StringIIIII_C(JNIEnv* env, jobject clazz, SkPaint* paint,
+6 −5
Original line number Diff line number Diff line
@@ -257,17 +257,18 @@ void TextLayout::getTextRunAdvances(SkPaint* paint, const jchar* chars, jint sta
    sp<TextLayoutCacheValue> value;
#if USE_TEXT_LAYOUT_CACHE
    // Return advances from the cache. Compute them if needed
    value = TextLayoutCache::getInstance().getValue(paint, chars, contextCount, dirFlags);
    value = TextLayoutCache::getInstance().getValue(paint, chars, start, count,
            contextCount, dirFlags);
#else
    value = new TextLayoutCacheValue();
    value->computeValues(paint, chars, contextCount, dirFlags);
    value->computeValues(paint, chars, start, count, contextCount, dirFlags);
#endif
    if (value != NULL) {
        if (resultAdvances != NULL) {
            value->getAdvances(start, count, resultAdvances);
        if (resultAdvances) {
            memcpy(resultAdvances, value->getAdvances(), value->getAdvancesCount() * sizeof(jfloat));
        }
        if (resultTotalAdvance) {
            *resultTotalAdvance = value->getTotalAdvance(start, count);
            *resultTotalAdvance = value->getTotalAdvance();
        }
    }
}
+129 −180

File changed.

Preview size limit exceeded, changes collapsed.

+33 −33

File changed.

Preview size limit exceeded, changes collapsed.

Loading