Skip to content

Commit afd5c3e

Browse files
committed
Clear animations in DisplayLists when done
The matrix calculated by Animations is pushed down to the native DisplayList object, and is then used when the DL is issued to the GL renderer. This works while the animation is running, but the end of animations is not handled correctly. In particular, we never clear the animation, so whatever the last frame of the animation calculated will persist on that DisplayList object until it is recreated. The fix is to note when we used to be animating and are no longer doing so, taking that opportunity to push the cleared state down to the DisplayList. Issue #6448993 action bar -- including settings menu -- disappears on Nakasi Change-Id: I73cdadaef40d87ccbc1beb02599c4d70506ea42b
1 parent 0891a89 commit afd5c3e

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;
@@ -12764,16 +12771,27 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1276412771
if (a != null) {
1276512772
more = drawAnimation(parent, drawingTime, a, scalingRequired);
1276612773
concatMatrix = a.willChangeTransformationMatrix();
12774+
if (concatMatrix) {
12775+
mPrivateFlags2 |= VIEW_IS_ANIMATING_TRANSFORM;
12776+
}
1276712777
transformToApply = parent.mChildTransformation;
12768-
} else if (!useDisplayListProperties &&
12769-
(flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
12770-
final boolean hasTransform =
12771-
parent.getChildStaticTransformation(this, parent.mChildTransformation);
12772-
if (hasTransform) {
12773-
final int transformType = parent.mChildTransformation.getTransformationType();
12774-
transformToApply = transformType != Transformation.TYPE_IDENTITY ?
12775-
parent.mChildTransformation : null;
12776-
concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
12778+
} else {
12779+
if ((mPrivateFlags2 & VIEW_IS_ANIMATING_TRANSFORM) == VIEW_IS_ANIMATING_TRANSFORM &&
12780+
mDisplayList != null) {
12781+
// No longer animating: clear out old animation matrix
12782+
mDisplayList.setAnimationMatrix(null);
12783+
mPrivateFlags2 &= ~VIEW_IS_ANIMATING_TRANSFORM;
12784+
}
12785+
if (!useDisplayListProperties &&
12786+
(flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
12787+
final boolean hasTransform =
12788+
parent.getChildStaticTransformation(this, parent.mChildTransformation);
12789+
if (hasTransform) {
12790+
final int transformType = parent.mChildTransformation.getTransformationType();
12791+
transformToApply = transformType != Transformation.TYPE_IDENTITY ?
12792+
parent.mChildTransformation : null;
12793+
concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
12794+
}
1277712795
}
1277812796
}
1277912797

0 commit comments

Comments
 (0)