/frameworks/base/core/java/android/view/View.java
8530
8531 * This is where the invalidate() work actually happens.
@param invalidateCache
8541 void invalidate(boolean invalidateCache) {
8542 if (ViewDebug.TRACE_HIERARCHY) {
8543 ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
8544 }
8545
8546 if (skipInvalidate()) {
8547 return;
8548 }
8549 if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
8550 (invalidateCache && (mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) ||
8551 (mPrivateFlags & INVALIDATED) != INVALIDATED || isOpaque() != mLastIsOpaque) {
8552 mLastIsOpaque = isOpaque();
8553 mPrivateFlags &= ~DRAWN;
8554 mPrivateFlags |= DIRTY;
8555 if (invalidateCache) {
8556 mPrivateFlags |= INVALIDATED;
8557 mPrivateFlags &= ~DRAWING_CACHE_VALID;
8558 }
8559 final AttachInfo ai = mAttachInfo;
8560 final ViewParent p = mParent;
8561
8562 if (!HardwareRenderer.RENDER_DIRTY_REGIONS) {
8563 if (p != null && ai != null && ai.mHardwareAccelerated) {
8564
8565
8566 p.invalidateChild(this, null);
8567 return;
8568 }
8569 }
8570
8571 if (p != null && ai != null) {
8572 final Rect r = ai.mTmpInvalRect;
8573 r.set(0, 0, mRight - mLeft, mBottom - mTop);
8574
8575
8576 p.invalidateChild(this, r);
8577 }
8578 }
8579 }
http:
/frameworks/base/core/java/android/view/ViewGroup.java
3880
3881 * Don't call or override this method.
3884 public final void invalidateChild(View child, final Rect dirty) {
3885 if (ViewDebug.TRACE_HIERARCHY) {
3886 ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE_CHILD);
3887 }
3888
3889 ViewParent parent = this;
3890
3891 final AttachInfo attachInfo = mAttachInfo;
3892 if (attachInfo != null) {
3893
3894
3895
3896 final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
3897
3898 if (dirty == null) {
3899 if (child.mLayerType != LAYER_TYPE_NONE) {
3900 mPrivateFlags |= INVALIDATED;
3901 mPrivateFlags &= ~DRAWING_CACHE_VALID;
3902 child.mLocalDirtyRect.setEmpty();
3903 }
3904 do {
3905 View view = null;
3906 if (parent instanceof View) {
3907 view = (View) parent;
3908 if (view.mLayerType != LAYER_TYPE_NONE) {
3909 view.mLocalDirtyRect.setEmpty();
3910 if (view.getParent() instanceof View) {
3911 final View grandParent = (View) view.getParent();
3912 grandParent.mPrivateFlags |= INVALIDATED;
3913 grandParent.mPrivateFlags &= ~DRAWING_CACHE_VALID;
3914 }
3915 }
3916 if ((view.mPrivateFlags & DIRTY_MASK) != 0) {
3917
3918 break;
3919 }
3920 }
3921
3922 if (drawAnimation) {
3923 if (view != null) {
3924 view.mPrivateFlags |= DRAW_ANIMATION;
3925 } else if (parent instanceof ViewRootImpl) {
3926 ((ViewRootImpl) parent).mIsAnimating = true;
3927 }
3928 }
3929
3930 if (parent instanceof ViewRootImpl) {
3931 ((ViewRootImpl) parent).invalidate();
3932 parent = null;
3933 } else if (view != null) {
3934 if ((view.mPrivateFlags & DRAWN) == DRAWN ||
3935 (view.mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) {
3936 view.mPrivateFlags &= ~DRAWING_CACHE_VALID;
3937 view.mPrivateFlags |= DIRTY;
3938 parent = view.mParent;
3939 } else {
3940 parent = null;
3941 }
3942 }
3943 } while (parent != null);
3944 } else {
3945
3946 final boolean isOpaque = child.isOpaque() && !drawAnimation &&
3947 child.getAnimation() == null;
3948
3949
3950 int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY;
3951
3952 if (child.mLayerType != LAYER_TYPE_NONE) {
3953 mPrivateFlags |= INVALIDATED;
3954 mPrivateFlags &= ~DRAWING_CACHE_VALID;
3955 child.mLocalDirtyRect.union(dirty);
3956 }
3957
3958 final int[] location = attachInfo.mInvalidateChildLocation;
3959 location[CHILD_LEFT_INDEX] = child.mLeft;
3960 location[CHILD_TOP_INDEX] = child.mTop;
3961 Matrix childMatrix = child.getMatrix();
3962 if (!childMatrix.isIdentity()) {
3963 RectF boundingRect = attachInfo.mTmpTransformRect;
3964 boundingRect.set(dirty);
3965
3966 childMatrix.mapRect(boundingRect);
3967 dirty.set((int) (boundingRect.left - 0.5f),
3968 (int) (boundingRect.top - 0.5f),
3969 (int) (boundingRect.right + 0.5f),
3970 (int) (boundingRect.bottom + 0.5f));
3971 }
3972
3973 do {
3974 View view = null;
3975 if (parent instanceof View) {
3976 view = (View) parent;
3977 if (view.mLayerType != LAYER_TYPE_NONE &&
3978 view.getParent() instanceof View) {
3979 final View grandParent = (View) view.getParent();
3980 grandParent.mPrivateFlags |= INVALIDATED;
3981 grandParent.mPrivateFlags &= ~DRAWING_CACHE_VALID;
3982 }
3983 }
3984
3985 if (drawAnimation) {
3986 if (view != null) {
3987 view.mPrivateFlags |= DRAW_ANIMATION;
3988 } else if (parent instanceof ViewRootImpl) {
3989 ((ViewRootImpl) parent).mIsAnimating = true;
3990 }
3991 }
3992
3993
3994
3995 if (view != null) {
3996 if ((view.mViewFlags & FADING_EDGE_MASK) != 0 &&
3997 view.getSolidColor() == 0) {
3998 opaqueFlag = DIRTY;
3999 }
4000 if ((view.mPrivateFlags & DIRTY_MASK) != DIRTY) {
4001 view.mPrivateFlags = (view.mPrivateFlags & ~DIRTY_MASK) | opaqueFlag;
4002 }
4003 }
4004
4005 parent = parent.invalidateChildInParent(location, dirty);
4006 if (view != null) {
4007
4008 Matrix m = view.getMatrix();
4009 if (!m.isIdentity()) {
4010 RectF boundingRect = attachInfo.mTmpTransformRect;
4011 boundingRect.set(dirty);
4012 m.mapRect(boundingRect);
4013 dirty.set((int) boundingRect.left, (int) boundingRect.top,
4014 (int) (boundingRect.right + 0.5f),
4015 (int) (boundingRect.bottom + 0.5f));
4016 }
4017 }
4018 } while (parent != null);
4019 }
4020 }
4021 }
http: