Skip to content

Commit 27ef44c

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Invalidate display lists immediately when views are removed/added quickly" into jb-dev
2 parents 14326fd + 2a0f228 commit 27ef44c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

core/java/android/view/View.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11096,22 +11096,30 @@ protected void onAttachedToWindow() {
1109611096
if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
1109711097
mParent.requestTransparentRegion(this);
1109811098
}
11099+
1109911100
if ((mPrivateFlags & AWAKEN_SCROLL_BARS_ON_ATTACH) != 0) {
1110011101
initialAwakenScrollBars();
1110111102
mPrivateFlags &= ~AWAKEN_SCROLL_BARS_ON_ATTACH;
1110211103
}
11104+
1110311105
jumpDrawablesToCurrentState();
11106+
1110411107
// Order is important here: LayoutDirection MUST be resolved before Padding
1110511108
// and TextDirection
1110611109
resolveLayoutDirection();
1110711110
resolvePadding();
1110811111
resolveTextDirection();
1110911112
resolveTextAlignment();
11113+
1111011114
clearAccessibilityFocus();
1111111115
if (isFocused()) {
1111211116
InputMethodManager imm = InputMethodManager.peekInstance();
1111311117
imm.focusIn(this);
1111411118
}
11119+
11120+
if (mAttachInfo != null && mDisplayList != null) {
11121+
mAttachInfo.mViewRootImpl.dequeueDisplayList(mDisplayList);
11122+
}
1111511123
}
1111611124

1111711125
/**
@@ -11332,7 +11340,7 @@ protected void onDetachedFromWindow() {
1133211340

1133311341
if (mAttachInfo != null) {
1133411342
if (mDisplayList != null) {
11335-
mAttachInfo.mViewRootImpl.invalidateDisplayList(mDisplayList);
11343+
mAttachInfo.mViewRootImpl.enqueueDisplayList(mDisplayList);
1133611344
}
1133711345
mAttachInfo.mViewRootImpl.cancelInvalidate(this);
1133811346
} else {
@@ -12026,7 +12034,6 @@ private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) {
1202612034

1202712035
boolean caching = false;
1202812036
final HardwareCanvas canvas = displayList.start();
12029-
int restoreCount = 0;
1203012037
int width = mRight - mLeft;
1203112038
int height = mBottom - mTop;
1203212039

@@ -12659,10 +12666,6 @@ private boolean drawAnimation(ViewGroup parent, long drawingTime,
1265912666
return more;
1266012667
}
1266112668

12662-
void setDisplayListProperties() {
12663-
setDisplayListProperties(mDisplayList);
12664-
}
12665-
1266612669
/**
1266712670
* This method is called by getDisplayList() when a display list is created or re-rendered.
1266812671
* It sets or resets the current value of all properties on that display list (resetting is

core/java/android/view/ViewRootImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4412,14 +4412,23 @@ public void dispatchInvalidateRectOnAnimation(AttachInfo.InvalidateInfo info) {
44124412
mInvalidateOnAnimationRunnable.addViewRect(info);
44134413
}
44144414

4415-
public void invalidateDisplayList(DisplayList displayList) {
4415+
public void enqueueDisplayList(DisplayList displayList) {
44164416
mDisplayLists.add(displayList);
44174417

44184418
mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST);
44194419
Message msg = mHandler.obtainMessage(MSG_INVALIDATE_DISPLAY_LIST);
44204420
mHandler.sendMessage(msg);
44214421
}
4422-
4422+
4423+
public void dequeueDisplayList(DisplayList displayList) {
4424+
if (mDisplayLists.remove(displayList)) {
4425+
displayList.invalidate();
4426+
if (mDisplayLists.size() == 0) {
4427+
mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST);
4428+
}
4429+
}
4430+
}
4431+
44234432
public void cancelInvalidate(View view) {
44244433
mHandler.removeMessages(MSG_INVALIDATE, view);
44254434
// fixme: might leak the AttachInfo.InvalidateInfo objects instead of returning

0 commit comments

Comments
 (0)