Skip to content

Commit 2651101

Browse files
chethaaseAndroid (Google) Code Review
authored andcommitted
Merge "Clear animations in DisplayLists when done" into jb-dev
2 parents d303dd3 + afd5c3e commit 2651101

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

core/java/android/view/GLES20DisplayList.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ public void setStaticMatrix(Matrix matrix) {
131131
@Override
132132
public void setAnimationMatrix(Matrix matrix) {
133133
try {
134-
nSetAnimationMatrix(getNativeDisplayList(), matrix.native_instance);
134+
nSetAnimationMatrix(getNativeDisplayList(),
135+
(matrix != null) ? matrix.native_instance : 0);
135136
} catch (IllegalStateException e) {
136137
// invalid DisplayList okay: we'll set current values the next time we render to it
137138
}

core/java/android/view/View.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)