/** * Invalidate the whole view. If the view is visible, * {@link #onDraw(android.graphics.Canvas)} will be called at some point in * the future. * <p> * This must be called from a UI thread. To call from a non-UI thread, call * {@link #postInvalidate()}. */ // android.view.View#invalidate() publicvoidinvalidate() { invalidate(true); }
/** * This is where the invalidate() work actually happens. A full invalidate() * causes the drawing cache to be invalidated, but this function can be * called with invalidateCache set to false to skip that invalidation step * for cases that do not need it (for example, a component that remains at * the same dimensions with the same content). * * @param invalidateCache Whether the drawing cache for this view should be * invalidated as well. This is usually true for a full * invalidate, but may be set to false if the View's contents or * dimensions have not changed. * @hide */ // android.view.View#invalidate(boolean) publicvoidinvalidate(boolean invalidateCache) { invalidateInternal(0, 0, mRight - mLeft, mBottom - mTop, invalidateCache, true); }
// Propagate the damage rectangle to the parent view. finalAttachInfoai= mAttachInfo; finalViewParentp= mParent; if (p != null && ai != null && l < r && t < b) { finalRectdamage= ai.mTmpInvalRect; damage.set(l, t, r, b); p.invalidateChild(this, damage); // 向父View报告脏区位置 }
/** * All or part of a child is dirty and needs to be redrawn. * * @param child The child which is dirty * @param r The area within the child that is invalid * * @deprecated Use {@link #onDescendantInvalidated(View, View)} instead. */ // android.view.ViewParent#invalidateChild @Deprecated publicvoidinvalidateChild(View child, Rect r);
/** * Don't call or override this method. It is used for the implementation of * the view hierarchy. * * @deprecated Use {@link #onDescendantInvalidated(View, View)} instead to observe updates to * draw state in descendants. */ // android.view.ViewGroup#invalidateChild @Deprecated @Override publicfinalvoidinvalidateChild(View child, final Rect dirty) { ......
ViewParentparent=this; if (attachInfo != null) { ......
do { Viewview=null; if (parent instanceof View) { view = (View) parent; }
/** * Don't call or override this method. It is used for the implementation of * the view hierarchy. * * This implementation returns null if this ViewGroup does not have a parent, * if this ViewGroup is already fully invalidated or if the dirty rectangle * does not intersect with this ViewGroup's bounds. * * @deprecated Use {@link #onDescendantInvalidated(View, View)} instead to observe updates to * draw state in descendants. */ // android.view.ViewGroup#invalidateChildInParent @Deprecated @Override public ViewParent invalidateChildInParent(finalint[] location, final Rect dirty) { if ((mPrivateFlags & (PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID)) != 0) { ......
return mParent; }
returnnull; }
// android.view.ViewRootImpl#invalidateChildInParent @Override public ViewParent invalidateChildInParent(int[] location, Rect dirty) { .....