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

Commit 08836d4c authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Early exit if there are no spans affecting display

In TextLine#handleRun(), exit early and shape the text as one whole
if there were spans, but none of them were a subclass of
MetricAffectingSpan or CharacterStyle.

Change-Id: I859c896ddb9c4828bfddf200e913e98262da6ea3
Fixes: 30985144
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
parent a3112cee
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -989,7 +989,17 @@ class TextLine {
            return 0f;
        }

        final boolean needsSpanMeasurement;
        if (mSpanned == null) {
            needsSpanMeasurement = false;
        } else {
            mMetricAffectingSpanSpanSet.init(mSpanned, mStart + start, mStart + limit);
            mCharacterStyleSpanSet.init(mSpanned, mStart + start, mStart + limit);
            needsSpanMeasurement = mMetricAffectingSpanSpanSet.numberOfSpans != 0
                    || mCharacterStyleSpanSet.numberOfSpans != 0;
        }

        if (!needsSpanMeasurement) {
            final TextPaint wp = mWorkPaint;
            wp.set(mPaint);
            wp.setHyphenEdit(adjustHyphenEdit(start, limit, wp.getHyphenEdit()));
@@ -997,9 +1007,6 @@ class TextLine {
                    y, bottom, fmi, needWidth, measureLimit, null);
        }

        mMetricAffectingSpanSpanSet.init(mSpanned, mStart + start, mStart + limit);
        mCharacterStyleSpanSet.init(mSpanned, mStart + start, mStart + limit);

        // Shaping needs to take into account context up to metric boundaries,
        // but rendering needs to take into account character style boundaries.
        // So we iterate through metric runs to get metric bounds,