Skip to content

Commit b78ee0e

Browse files
committed
Skip drawing offscreen objects
Previous logic in ViewRoot would schedule and perform a draw when it was requested by offscreen objects. The problem was that the logic checking for an interesection between the offscreen invalidation rectangle and the onscreen display rectangle was flawed. The fix was to use the return value from Rect.intersect() to do the right thing and skip drawing. Issue #7366568 Offscreen invalidates can cause useless work for framework Change-Id: Ie4e277c695dacee39848a8a223f0c4ee34d9bb4d
1 parent be29d82 commit b78ee0e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,12 @@ public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
887887
// Intersect with the bounds of the window to skip
888888
// updates that lie outside of the visible region
889889
final float appScale = mAttachInfo.mApplicationScale;
890-
localDirty.intersect(0, 0,
891-
(int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f));
892-
893-
if (!mWillDrawSoon) {
890+
if (localDirty.intersect(0, 0,
891+
(int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)) &&
892+
!mWillDrawSoon) {
894893
scheduleTraversals();
894+
} else {
895+
localDirty.setEmpty();
895896
}
896897

897898
return null;

0 commit comments

Comments
 (0)