@@ -3604,130 +3604,135 @@ public final void invalidateChild(View child, final Rect dirty) {
36043604 // through
36053605 final boolean drawAnimation = (child .mPrivateFlags & DRAW_ANIMATION ) == DRAW_ANIMATION ;
36063606
3607- if (dirty == null ) {
3608- if (child .mLayerType != LAYER_TYPE_NONE ) {
3609- mPrivateFlags |= INVALIDATED ;
3610- mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3611- child .mLocalDirtyRect .setEmpty ();
3612- }
3613- do {
3614- View view = null ;
3615- if (parent instanceof View ) {
3616- view = (View ) parent ;
3617- if (view .mLayerType != LAYER_TYPE_NONE ) {
3618- view .mLocalDirtyRect .setEmpty ();
3619- if (view .getParent () instanceof View ) {
3620- final View grandParent = (View ) view .getParent ();
3621- grandParent .mPrivateFlags |= INVALIDATED ;
3622- grandParent .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3607+ //noinspection PointlessBooleanExpression
3608+ if (!HardwareRenderer .RENDER_DIRTY_REGIONS ) {
3609+ if (dirty == null ) {
3610+ if (child .mLayerType != LAYER_TYPE_NONE ) {
3611+ mPrivateFlags |= INVALIDATED ;
3612+ mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3613+ child .mLocalDirtyRect .setEmpty ();
3614+ }
3615+ do {
3616+ View view = null ;
3617+ if (parent instanceof View ) {
3618+ view = (View ) parent ;
3619+ if (view .mLayerType != LAYER_TYPE_NONE ) {
3620+ view .mLocalDirtyRect .setEmpty ();
3621+ if (view .getParent () instanceof View ) {
3622+ final View grandParent = (View ) view .getParent ();
3623+ grandParent .mPrivateFlags |= INVALIDATED ;
3624+ grandParent .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3625+ }
3626+ }
3627+ if ((view .mPrivateFlags & DIRTY_MASK ) != 0 ) {
3628+ // already marked dirty - we're done
3629+ break ;
36233630 }
36243631 }
3625- if ((view .mPrivateFlags & DIRTY_MASK ) != 0 ) {
3626- // already marked dirty - we're done
3627- break ;
3628- }
3629- }
3630-
3631- if (drawAnimation ) {
3632- if (view != null ) {
3633- view .mPrivateFlags |= DRAW_ANIMATION ;
3634- } else if (parent instanceof ViewRootImpl ) {
3635- ((ViewRootImpl ) parent ).mIsAnimating = true ;
3632+
3633+ if (drawAnimation ) {
3634+ if (view != null ) {
3635+ view .mPrivateFlags |= DRAW_ANIMATION ;
3636+ } else if (parent instanceof ViewRootImpl ) {
3637+ ((ViewRootImpl ) parent ).mIsAnimating = true ;
3638+ }
36363639 }
3637- }
3638-
3639- if (parent instanceof ViewRootImpl ) {
3640- ((ViewRootImpl ) parent ).invalidate ();
3641- parent = null ;
3642- } else if (view != null ) {
3643- if ((view .mPrivateFlags & DRAWN ) == DRAWN ||
3644- (view .mPrivateFlags & DRAWING_CACHE_VALID ) == DRAWING_CACHE_VALID ) {
3645- view .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3646- view .mPrivateFlags |= DIRTY ;
3647- parent = view .mParent ;
3648- } else {
3640+
3641+ if (parent instanceof ViewRootImpl ) {
3642+ ((ViewRootImpl ) parent ).invalidate ();
36493643 parent = null ;
3644+ } else if (view != null ) {
3645+ if ((view .mPrivateFlags & DRAWN ) == DRAWN ||
3646+ (view .mPrivateFlags & DRAWING_CACHE_VALID ) == DRAWING_CACHE_VALID ) {
3647+ view .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3648+ view .mPrivateFlags |= DIRTY ;
3649+ parent = view .mParent ;
3650+ } else {
3651+ parent = null ;
3652+ }
36503653 }
3651- }
3652- } while (parent != null );
3653- } else {
3654- // Check whether the child that requests the invalidate is fully opaque
3655- // Views being animated or transformed are not considered opaque because we may
3656- // be invalidating their old position and need the parent to paint behind them.
3657- Matrix childMatrix = child .getMatrix ();
3658- final boolean isOpaque = child .isOpaque () && !drawAnimation &&
3659- child .getAnimation () == null && childMatrix .isIdentity ();
3660- // Mark the child as dirty, using the appropriate flag
3661- // Make sure we do not set both flags at the same time
3662- int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY ;
3663-
3664- if (child .mLayerType != LAYER_TYPE_NONE ) {
3665- mPrivateFlags |= INVALIDATED ;
3666- mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3667- child .mLocalDirtyRect .union (dirty );
3654+ } while (parent != null );
36683655 }
36693656
3670- final int [] location = attachInfo .mInvalidateChildLocation ;
3671- location [CHILD_LEFT_INDEX ] = child .mLeft ;
3672- location [CHILD_TOP_INDEX ] = child .mTop ;
3673- if (!childMatrix .isIdentity ()) {
3674- RectF boundingRect = attachInfo .mTmpTransformRect ;
3675- boundingRect .set (dirty );
3676- //boundingRect.inset(-0.5f, -0.5f);
3677- childMatrix .mapRect (boundingRect );
3678- dirty .set ((int ) (boundingRect .left - 0.5f ),
3679- (int ) (boundingRect .top - 0.5f ),
3680- (int ) (boundingRect .right + 0.5f ),
3681- (int ) (boundingRect .bottom + 0.5f ));
3682- }
3657+ return ;
3658+ }
36833659
3684- do {
3685- View view = null ;
3686- if (parent instanceof View ) {
3687- view = (View ) parent ;
3688- if (view .mLayerType != LAYER_TYPE_NONE &&
3689- view .getParent () instanceof View ) {
3690- final View grandParent = (View ) view .getParent ();
3691- grandParent .mPrivateFlags |= INVALIDATED ;
3692- grandParent .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3693- }
3694- }
3660+ // Check whether the child that requests the invalidate is fully opaque
3661+ // Views being animated or transformed are not considered opaque because we may
3662+ // be invalidating their old position and need the parent to paint behind them.
3663+ Matrix childMatrix = child .getMatrix ();
3664+ final boolean isOpaque = child .isOpaque () && !drawAnimation &&
3665+ child .getAnimation () == null && childMatrix .isIdentity ();
3666+ // Mark the child as dirty, using the appropriate flag
3667+ // Make sure we do not set both flags at the same time
3668+ int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY ;
3669+
3670+ if (child .mLayerType != LAYER_TYPE_NONE ) {
3671+ mPrivateFlags |= INVALIDATED ;
3672+ mPrivateFlags &= ~DRAWING_CACHE_VALID ;
3673+ child .mLocalDirtyRect .union (dirty );
3674+ }
36953675
3696- if (drawAnimation ) {
3697- if (view != null ) {
3698- view .mPrivateFlags |= DRAW_ANIMATION ;
3699- } else if (parent instanceof ViewRootImpl ) {
3700- ((ViewRootImpl ) parent ).mIsAnimating = true ;
3701- }
3676+ final int [] location = attachInfo .mInvalidateChildLocation ;
3677+ location [CHILD_LEFT_INDEX ] = child .mLeft ;
3678+ location [CHILD_TOP_INDEX ] = child .mTop ;
3679+ if (!childMatrix .isIdentity ()) {
3680+ RectF boundingRect = attachInfo .mTmpTransformRect ;
3681+ boundingRect .set (dirty );
3682+ //boundingRect.inset(-0.5f, -0.5f);
3683+ childMatrix .mapRect (boundingRect );
3684+ dirty .set ((int ) (boundingRect .left - 0.5f ),
3685+ (int ) (boundingRect .top - 0.5f ),
3686+ (int ) (boundingRect .right + 0.5f ),
3687+ (int ) (boundingRect .bottom + 0.5f ));
3688+ }
3689+
3690+ do {
3691+ View view = null ;
3692+ if (parent instanceof View ) {
3693+ view = (View ) parent ;
3694+ if (view .mLayerType != LAYER_TYPE_NONE &&
3695+ view .getParent () instanceof View ) {
3696+ final View grandParent = (View ) view .getParent ();
3697+ grandParent .mPrivateFlags |= INVALIDATED ;
3698+ grandParent .mPrivateFlags &= ~DRAWING_CACHE_VALID ;
37023699 }
3700+ }
37033701
3704- // If the parent is dirty opaque or not dirty, mark it dirty with the opaque
3705- // flag coming from the child that initiated the invalidate
3702+ if (drawAnimation ) {
37063703 if (view != null ) {
3707- if ((view .mViewFlags & FADING_EDGE_MASK ) != 0 &&
3708- view .getSolidColor () == 0 ) {
3709- opaqueFlag = DIRTY ;
3710- }
3711- if ((view .mPrivateFlags & DIRTY_MASK ) != DIRTY ) {
3712- view .mPrivateFlags = (view .mPrivateFlags & ~DIRTY_MASK ) | opaqueFlag ;
3713- }
3704+ view .mPrivateFlags |= DRAW_ANIMATION ;
3705+ } else if (parent instanceof ViewRootImpl ) {
3706+ ((ViewRootImpl ) parent ).mIsAnimating = true ;
37143707 }
3708+ }
37153709
3716- parent = parent .invalidateChildInParent (location , dirty );
3717- if (view != null ) {
3718- // Account for transform on current parent
3719- Matrix m = view .getMatrix ();
3720- if (!m .isIdentity ()) {
3721- RectF boundingRect = attachInfo .mTmpTransformRect ;
3722- boundingRect .set (dirty );
3723- m .mapRect (boundingRect );
3724- dirty .set ((int ) boundingRect .left , (int ) boundingRect .top ,
3725- (int ) (boundingRect .right + 0.5f ),
3726- (int ) (boundingRect .bottom + 0.5f ));
3727- }
3710+ // If the parent is dirty opaque or not dirty, mark it dirty with the opaque
3711+ // flag coming from the child that initiated the invalidate
3712+ if (view != null ) {
3713+ if ((view .mViewFlags & FADING_EDGE_MASK ) != 0 &&
3714+ view .getSolidColor () == 0 ) {
3715+ opaqueFlag = DIRTY ;
37283716 }
3729- } while (parent != null );
3730- }
3717+ if ((view .mPrivateFlags & DIRTY_MASK ) != DIRTY ) {
3718+ view .mPrivateFlags = (view .mPrivateFlags & ~DIRTY_MASK ) | opaqueFlag ;
3719+ }
3720+ }
3721+
3722+ parent = parent .invalidateChildInParent (location , dirty );
3723+ if (view != null ) {
3724+ // Account for transform on current parent
3725+ Matrix m = view .getMatrix ();
3726+ if (!m .isIdentity ()) {
3727+ RectF boundingRect = attachInfo .mTmpTransformRect ;
3728+ boundingRect .set (dirty );
3729+ m .mapRect (boundingRect );
3730+ dirty .set ((int ) boundingRect .left , (int ) boundingRect .top ,
3731+ (int ) (boundingRect .right + 0.5f ),
3732+ (int ) (boundingRect .bottom + 0.5f ));
3733+ }
3734+ }
3735+ } while (parent != null );
37313736 }
37323737 }
37333738
0 commit comments