Merge "Fix ViewOverlay#onDescendantInvalidated" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-25 23:15:47 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 40 deletions

View File

@@ -5822,34 +5822,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
return null;
}
/**
* Quick invalidation method that simply transforms the dirty rect into the parent's
* coordinate system, pruning the invalidation if the parent has already been invalidated.
*
* @hide
*/
protected ViewParent damageChildInParent(int left, int top, final Rect dirty) {
if ((mPrivateFlags & PFLAG_DRAWN) != 0
|| (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) != 0) {
dirty.offset(left - mScrollX, top - mScrollY);
if ((mGroupFlags & FLAG_CLIP_CHILDREN) == 0) {
dirty.union(0, 0, mRight - mLeft, mBottom - mTop);
}
if ((mGroupFlags & FLAG_CLIP_CHILDREN) == 0 ||
dirty.intersect(0, 0, mRight - mLeft, mBottom - mTop)) {
if (!getMatrix().isIdentity()) {
transformRect(dirty);
}
return mParent;
}
}
return null;
}
/**
* Offset a rectangle that is in a descendant's coordinate
* space into our coordinate space.

View File

@@ -330,20 +330,20 @@ public class ViewOverlay {
@Override
public void onDescendantInvalidated(@NonNull View child, @NonNull View target) {
if (mHostView != null && mHostView.getParent() != null) {
mHostView.getParent().onDescendantInvalidated(mHostView, target);
}
}
if (mHostView != null) {
if (mHostView instanceof ViewGroup) {
// Propagate invalidate through the host...
((ViewGroup) mHostView).onDescendantInvalidated(mHostView, target);
/**
* @hide
*/
@Override
protected ViewParent damageChildInParent(int left, int top, Rect dirty) {
if (mHostView instanceof ViewGroup) {
return ((ViewGroup) mHostView).damageChildInParent(left, top, dirty);
// ...and also this view, since it will hold the descendant, and must later
// propagate the calls to update display lists if dirty
super.onDescendantInvalidated(child, target);
} else {
// Can't use onDescendantInvalidated because host isn't a ViewGroup - fall back
// to invalidating.
invalidate();
}
}
return null;
}
@Override