From b78ee0ef60e5323b15b4ffdc97be4d889e272b79 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 17 Oct 2012 11:32:01 -0700 Subject: [PATCH] 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 --- core/java/android/view/ViewRootImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 91df4b56a8ed0..361582c99a84b 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -887,11 +887,12 @@ public final class ViewRootImpl implements ViewParent, // Intersect with the bounds of the window to skip // updates that lie outside of the visible region final float appScale = mAttachInfo.mApplicationScale; - localDirty.intersect(0, 0, - (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); - - if (!mWillDrawSoon) { + if (localDirty.intersect(0, 0, + (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)) && + !mWillDrawSoon) { scheduleTraversals(); + } else { + localDirty.setEmpty(); } return null;