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

Commit dac5f9f3 authored by Romain Guy's avatar Romain Guy
Browse files

Do not draw the fade areas when it's not necessary.

Prior to this change, every singleLine TextView would create, draw
and compose a layer on every draw dispatch. This was unnecessary and
expensive.

Change-Id: Ia4f79d7fc8f485784fe6b795f0f196d38d579838
parent 132f2259
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -6848,16 +6848,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility

        if (verticalEdges) {
            topFadeStrength = Math.max(0.0f, Math.min(1.0f, getTopFadingEdgeStrength()));
            drawTop = topFadeStrength >= 0.0f;
            drawTop = topFadeStrength > 0.0f;
            bottomFadeStrength = Math.max(0.0f, Math.min(1.0f, getBottomFadingEdgeStrength()));
            drawBottom = bottomFadeStrength >= 0.0f;
            drawBottom = bottomFadeStrength > 0.0f;
        }

        if (horizontalEdges) {
            leftFadeStrength = Math.max(0.0f, Math.min(1.0f, getLeftFadingEdgeStrength()));
            drawLeft = leftFadeStrength >= 0.0f;
            drawLeft = leftFadeStrength > 0.0f;
            rightFadeStrength = Math.max(0.0f, Math.min(1.0f, getRightFadingEdgeStrength()));
            drawRight = rightFadeStrength >= 0.0f;
            drawRight = rightFadeStrength > 0.0f;
        }

        saveCount = canvas.getSaveCount();
+4 −2
Original line number Diff line number Diff line
@@ -6790,8 +6790,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    @Override
    protected int computeHorizontalScrollRange() {
        if (mLayout != null)
            return mLayout.getWidth();
        if (mLayout != null) {
            return mSingleLine && (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT ?
                    (int) mLayout.getLineWidth(0) : mLayout.getWidth();
        }

        return super.computeHorizontalScrollRange();
    }