@@ -2128,6 +2128,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
21282128 */
21292129 static final int ACCESSIBILITY_STATE_CHANGED = 0x00000080 << IMPORTANT_FOR_ACCESSIBILITY_SHIFT;
21302130
2131+ /**
2132+ * Flag indicating that view has an animation set on it. This is used to track whether an
2133+ * animation is cleared between successive frames, in order to tell the associated
2134+ * DisplayList to clear its animation matrix.
2135+ */
2136+ static final int VIEW_IS_ANIMATING_TRANSFORM = 0x10000000;
2137+
21312138 /* End of masks for mPrivateFlags2 */
21322139
21332140 static final int DRAG_MASK = DRAG_CAN_ACCEPT | DRAG_HOVERED;
@@ -12777,16 +12784,27 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1277712784 if (a != null) {
1277812785 more = drawAnimation(parent, drawingTime, a, scalingRequired);
1277912786 concatMatrix = a.willChangeTransformationMatrix();
12787+ if (concatMatrix) {
12788+ mPrivateFlags2 |= VIEW_IS_ANIMATING_TRANSFORM;
12789+ }
1278012790 transformToApply = parent.mChildTransformation;
12781- } else if (!useDisplayListProperties &&
12782- (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
12783- final boolean hasTransform =
12784- parent.getChildStaticTransformation(this, parent.mChildTransformation);
12785- if (hasTransform) {
12786- final int transformType = parent.mChildTransformation.getTransformationType();
12787- transformToApply = transformType != Transformation.TYPE_IDENTITY ?
12788- parent.mChildTransformation : null;
12789- concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
12791+ } else {
12792+ if ((mPrivateFlags2 & VIEW_IS_ANIMATING_TRANSFORM) == VIEW_IS_ANIMATING_TRANSFORM &&
12793+ mDisplayList != null) {
12794+ // No longer animating: clear out old animation matrix
12795+ mDisplayList.setAnimationMatrix(null);
12796+ mPrivateFlags2 &= ~VIEW_IS_ANIMATING_TRANSFORM;
12797+ }
12798+ if (!useDisplayListProperties &&
12799+ (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
12800+ final boolean hasTransform =
12801+ parent.getChildStaticTransformation(this, parent.mChildTransformation);
12802+ if (hasTransform) {
12803+ final int transformType = parent.mChildTransformation.getTransformationType();
12804+ transformToApply = transformType != Transformation.TYPE_IDENTITY ?
12805+ parent.mChildTransformation : null;
12806+ concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
12807+ }
1279012808 }
1279112809 }
1279212810
0 commit comments