Skip to content

Commit 0f8e402

Browse files
committed
Force invalidates on non-visible views. DO NOT MERGE
An optimization prunes invalidates on views which are not inside their parent's bounds. This works in most cases, but it is possible to run a situation where a view has been invalidated (and is thus waiting to be redrawn), but the pruning logic ensures that that draw call will not happen. Further, when/if the view comes into the bounds of its parent again, it may still not be redrawn, because now future invalidates on the view are noop'd because it is already in an invalidated state (and thus will not propagate invalidates up the hierarchy). The fix is to remove the optitmization. This will cause some overhead sending the invalidation request up to the view root, but this overhead is minimal (and only extra for cases of out-of-bounds views), and the more expensive part of rendering these views will still not be done since the view root will avoid re-drawing the hierarchy when the dirty rectangle is empty. Issue #6813661 offscreen views don't get invalidated properly (may remain invisible when returning onscreen) Change-Id: Ic4b439540084a7163be9afc585bea6560d073280
1 parent c03f0a1 commit 0f8e402

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

core/java/android/view/ViewGroup.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,21 +4100,23 @@ public ViewParent invalidateChildInParent(final int[] location, final Rect dirty
41004100
final int left = mLeft;
41014101
final int top = mTop;
41024102

4103-
if ((mGroupFlags & FLAG_CLIP_CHILDREN) != FLAG_CLIP_CHILDREN ||
4104-
dirty.intersect(0, 0, mRight - left, mBottom - top) ||
4105-
(mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION) {
4106-
mPrivateFlags &= ~DRAWING_CACHE_VALID;
4107-
4108-
location[CHILD_LEFT_INDEX] = left;
4109-
location[CHILD_TOP_INDEX] = top;
4110-
4111-
if (mLayerType != LAYER_TYPE_NONE) {
4112-
mPrivateFlags |= INVALIDATED;
4113-
mLocalDirtyRect.union(dirty);
4103+
if ((mGroupFlags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN) {
4104+
if (!dirty.intersect(0, 0, mRight - left, mBottom - top)) {
4105+
dirty.setEmpty();
41144106
}
4107+
}
4108+
mPrivateFlags &= ~DRAWING_CACHE_VALID;
4109+
4110+
location[CHILD_LEFT_INDEX] = left;
4111+
location[CHILD_TOP_INDEX] = top;
41154112

4116-
return mParent;
4113+
if (mLayerType != LAYER_TYPE_NONE) {
4114+
mPrivateFlags |= INVALIDATED;
4115+
mLocalDirtyRect.union(dirty);
41174116
}
4117+
4118+
return mParent;
4119+
41184120
} else {
41194121
mPrivateFlags &= ~DRAWN & ~DRAWING_CACHE_VALID;
41204122

core/java/android/view/ViewRootImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,8 @@ public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
870870
if (dirty == null) {
871871
invalidate();
872872
return null;
873+
} else if (dirty.isEmpty()) {
874+
return null;
873875
}
874876

875877
if (mCurScrollY != 0 || mTranslator != null) {

0 commit comments

Comments
 (0)