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
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user