Skip to content

Commit d122d8e

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Re-use the display list valid flag, save a boolean"
2 parents 73ba0df + 28ab0b5 commit d122d8e

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

core/java/android/widget/TextView.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ public void setEnabled(boolean enabled) {
12141214
if (imm != null) imm.restartInput(this);
12151215
}
12161216

1217-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
1217+
if (mEditor != null) getEditor().invalidateTextDisplayList();
12181218
prepareCursorControllers();
12191219

12201220
// start or stop the cursor blinking as appropriate
@@ -2328,7 +2328,7 @@ public final int getCurrentTextColor() {
23282328
public void setHighlightColor(int color) {
23292329
if (mHighlightColor != color) {
23302330
mHighlightColor = color;
2331-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
2331+
if (mEditor != null) getEditor().invalidateTextDisplayList();
23322332
invalidate();
23332333
}
23342334
}
@@ -2349,7 +2349,7 @@ public void setShadowLayer(float radius, float dx, float dy, int color) {
23492349
mShadowDx = dx;
23502350
mShadowDy = dy;
23512351

2352-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
2352+
if (mEditor != null) getEditor().invalidateTextDisplayList();
23532353
invalidate();
23542354
}
23552355

@@ -2841,7 +2841,7 @@ private void updateTextColors() {
28412841
}
28422842
}
28432843
if (inval) {
2844-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
2844+
if (mEditor != null) getEditor().invalidateTextDisplayList();
28452845
invalidate();
28462846
}
28472847
}
@@ -3334,7 +3334,7 @@ public final void setHint(CharSequence hint) {
33343334

33353335
// Invalidate display list if hint will be used
33363336
if (mEditor != null && mText.length() == 0 && mHint != null) {
3337-
getEditor().mTextDisplayListIsValid = false;
3337+
getEditor().invalidateTextDisplayList();
33383338
}
33393339
}
33403340

@@ -4426,13 +4426,13 @@ protected boolean onSetAlpha(int alpha) {
44264426
if (dr.mDrawableStart != null) dr.mDrawableStart.mutate().setAlpha(alpha);
44274427
if (dr.mDrawableEnd != null) dr.mDrawableEnd.mutate().setAlpha(alpha);
44284428
}
4429-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
4429+
if (mEditor != null) getEditor().invalidateTextDisplayList();
44304430
}
44314431
return true;
44324432
}
44334433

44344434
if (mCurrentAlpha != 255) {
4435-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
4435+
if (mEditor != null) getEditor().invalidateTextDisplayList();
44364436
}
44374437
mCurrentAlpha = 255;
44384438
return false;
@@ -6289,7 +6289,7 @@ private void checkForRelayout() {
62896289
@Override
62906290
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
62916291
super.onLayout(changed, left, top, right, bottom);
6292-
if (changed && mEditor != null) getEditor().mTextDisplayListIsValid = false;
6292+
if (changed && mEditor != null) getEditor().invalidateTextDisplayList();
62936293
}
62946294

62956295
private boolean isShowingHint() {
@@ -7127,7 +7127,7 @@ void spanChange(Spanned buf, Object what, int oldStart, int newStart, int oldEnd
71277127
} else {
71287128
ims.mContentChanged = true;
71297129
}
7130-
if (mEditor != null) getEditor().mTextDisplayListIsValid = false;
7130+
if (mEditor != null) getEditor().invalidateTextDisplayList();
71317131
}
71327132

71337133
if (MetaKeyKeyListener.isMetaTracker(buf, what)) {
@@ -8274,7 +8274,7 @@ protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) {
82748274
if (getEditor().mPositionListener != null) {
82758275
getEditor().mPositionListener.onScrollChanged();
82768276
}
8277-
getEditor().mTextDisplayListIsValid = false;
8277+
getEditor().invalidateTextDisplayList();
82788278
}
82798279
}
82808280

@@ -11300,7 +11300,6 @@ private class Editor {
1130011300
InputMethodState mInputMethodState;
1130111301

1130211302
DisplayList mTextDisplayList;
11303-
boolean mTextDisplayListIsValid;
1130411303

1130511304
boolean mFrozenWithFocus;
1130611305
boolean mSelectionMoved;
@@ -11389,9 +11388,7 @@ void onDetachedFromWindow() {
1138911388
removeCallbacks(mShowSuggestionRunnable);
1139011389
}
1139111390

11392-
if (mTextDisplayList != null) {
11393-
mTextDisplayList.invalidate();
11394-
}
11391+
invalidateTextDisplayList();
1139511392

1139611393
if (mSpellChecker != null) {
1139711394
mSpellChecker.closeSession();
@@ -11548,7 +11545,7 @@ void onFocusChanged(boolean focused, int direction) {
1154811545

1154911546
void sendOnTextChanged(int start, int after) {
1155011547
updateSpellCheckSpans(start, start + after, false);
11551-
mTextDisplayListIsValid = false;
11548+
invalidateTextDisplayList();
1155211549

1155311550
// Hide the controllers as soon as text is modified (typing, procedural...)
1155411551
// We do not hide the span controllers, since they can be added when a new text is
@@ -11705,8 +11702,7 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
1170511702
layout.drawBackground(canvas, highlight, mHighlightPaint, cursorOffsetVertical,
1170611703
firstLine, lastLine);
1170711704

11708-
if (mTextDisplayList == null || !mTextDisplayList.isValid() ||
11709-
!mTextDisplayListIsValid) {
11705+
if (mTextDisplayList == null || !mTextDisplayList.isValid()) {
1171011706
if (mTextDisplayList == null) {
1171111707
mTextDisplayList = getHardwareRenderer().createDisplayList("Text");
1171211708
}
@@ -11723,7 +11719,6 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
1172311719
} finally {
1172411720
hardwareCanvas.onPostDraw();
1172511721
mTextDisplayList.end();
11726-
mTextDisplayListIsValid = true;
1172711722
}
1172811723
}
1172911724
canvas.translate(mScrollX, mScrollY);
@@ -11741,6 +11736,10 @@ private void drawCursor(Canvas canvas, int cursorOffsetVertical) {
1174111736
if (translate) canvas.translate(0, -cursorOffsetVertical);
1174211737
}
1174311738

11739+
private void invalidateTextDisplayList() {
11740+
if (mTextDisplayList != null) mTextDisplayList.invalidate();
11741+
}
11742+
1174411743
private void updateCursorsPositions() {
1174511744
if (mCursorDrawableRes == 0) {
1174611745
mCursorCount = 0;

0 commit comments

Comments
 (0)