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
This commit is contained in:
Chet Haase
2012-07-03 14:17:57 -07:00
parent c03f0a1557
commit 0f8e402e95
2 changed files with 17 additions and 13 deletions

View File

@ -4100,21 +4100,23 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
final int left = mLeft;
final int top = mTop;
if ((mGroupFlags & FLAG_CLIP_CHILDREN) != FLAG_CLIP_CHILDREN ||
dirty.intersect(0, 0, mRight - left, mBottom - top) ||
(mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION) {
mPrivateFlags &= ~DRAWING_CACHE_VALID;
location[CHILD_LEFT_INDEX] = left;
location[CHILD_TOP_INDEX] = top;
if (mLayerType != LAYER_TYPE_NONE) {
mPrivateFlags |= INVALIDATED;
mLocalDirtyRect.union(dirty);
if ((mGroupFlags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN) {
if (!dirty.intersect(0, 0, mRight - left, mBottom - top)) {
dirty.setEmpty();
}
return mParent;
}
mPrivateFlags &= ~DRAWING_CACHE_VALID;
location[CHILD_LEFT_INDEX] = left;
location[CHILD_TOP_INDEX] = top;
if (mLayerType != LAYER_TYPE_NONE) {
mPrivateFlags |= INVALIDATED;
mLocalDirtyRect.union(dirty);
}
return mParent;
} else {
mPrivateFlags &= ~DRAWN & ~DRAWING_CACHE_VALID;

View File

@ -870,6 +870,8 @@ public final class ViewRootImpl implements ViewParent,
if (dirty == null) {
invalidate();
return null;
} else if (dirty.isEmpty()) {
return null;
}
if (mCurScrollY != 0 || mTranslator != null) {