Loading services/core/java/com/android/server/wm/WindowAnimationSpec.java +15 −4 Original line number Diff line number Diff line Loading @@ -98,14 +98,25 @@ public class WindowAnimationSpec implements AnimationSpec { tmp.transformation.getMatrix().postTranslate(mPosition.x, mPosition.y); t.setMatrix(leash, tmp.transformation.getMatrix(), tmp.floats); t.setAlpha(leash, tmp.transformation.getAlpha()); if (mStackClipMode == STACK_CLIP_NONE || mStackClipMode == STACK_CLIP_AFTER_ANIM) { boolean cropSet = false; if (mStackClipMode == STACK_CLIP_NONE) { if (tmp.transformation.hasClipRect()) { t.setWindowCrop(leash, tmp.transformation.getClipRect()); cropSet = true; } } else { mTmpRect.set(mStackBounds); if (tmp.transformation.hasClipRect()) { mTmpRect.intersect(tmp.transformation.getClipRect()); } t.setWindowCrop(leash, mTmpRect); cropSet = true; } if (mAnimation.hasRoundedCorners() && mWindowCornerRadius > 0) { // We can only apply rounded corner if a crop is set, as otherwise the value is meaningless, // since it doesn't have anything it's relative to. if (cropSet && mAnimation.hasRoundedCorners() && mWindowCornerRadius > 0) { t.setCornerRadius(leash, mWindowCornerRadius); } } Loading services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java +17 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; Loading Loading @@ -70,7 +72,8 @@ public class WindowAnimationSpecTest { mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_AFTER_ANIM, true /* isAppAnimation */, 0 /* windowCornerRadius */); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(Rect::isEmpty)); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(rect -> rect.equals(mStackBounds))); } @Test Loading @@ -80,7 +83,8 @@ public class WindowAnimationSpecTest { new Point(20, 40), mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_AFTER_ANIM, true /* isAppAnimation */, 0 /* windowCornerRadius */); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(Rect::isEmpty)); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(rect -> rect.equals(mStackBounds))); } @Test Loading Loading @@ -120,6 +124,17 @@ public class WindowAnimationSpecTest { verify(mTransaction).setCornerRadius(eq(mSurfaceControl), eq(windowCornerRadius)); } @Test public void testApply_setCornerRadius_noClip() { final float windowCornerRadius = 30f; WindowAnimationSpec windowAnimationSpec = new WindowAnimationSpec(mAnimation, null, mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_NONE, true /* isAppAnimation */, windowCornerRadius); when(mAnimation.hasRoundedCorners()).thenReturn(true); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction, never()).setCornerRadius(any(), anyFloat()); } @Test public void testApply_clipBeforeSmallerAnimationClip() { // Stack bounds is (0, 0, 10, 10) animation clip is (0, 0, 5, 5) Loading Loading
services/core/java/com/android/server/wm/WindowAnimationSpec.java +15 −4 Original line number Diff line number Diff line Loading @@ -98,14 +98,25 @@ public class WindowAnimationSpec implements AnimationSpec { tmp.transformation.getMatrix().postTranslate(mPosition.x, mPosition.y); t.setMatrix(leash, tmp.transformation.getMatrix(), tmp.floats); t.setAlpha(leash, tmp.transformation.getAlpha()); if (mStackClipMode == STACK_CLIP_NONE || mStackClipMode == STACK_CLIP_AFTER_ANIM) { boolean cropSet = false; if (mStackClipMode == STACK_CLIP_NONE) { if (tmp.transformation.hasClipRect()) { t.setWindowCrop(leash, tmp.transformation.getClipRect()); cropSet = true; } } else { mTmpRect.set(mStackBounds); if (tmp.transformation.hasClipRect()) { mTmpRect.intersect(tmp.transformation.getClipRect()); } t.setWindowCrop(leash, mTmpRect); cropSet = true; } if (mAnimation.hasRoundedCorners() && mWindowCornerRadius > 0) { // We can only apply rounded corner if a crop is set, as otherwise the value is meaningless, // since it doesn't have anything it's relative to. if (cropSet && mAnimation.hasRoundedCorners() && mWindowCornerRadius > 0) { t.setCornerRadius(leash, mWindowCornerRadius); } } Loading
services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java +17 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; Loading Loading @@ -70,7 +72,8 @@ public class WindowAnimationSpecTest { mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_AFTER_ANIM, true /* isAppAnimation */, 0 /* windowCornerRadius */); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(Rect::isEmpty)); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(rect -> rect.equals(mStackBounds))); } @Test Loading @@ -80,7 +83,8 @@ public class WindowAnimationSpecTest { new Point(20, 40), mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_AFTER_ANIM, true /* isAppAnimation */, 0 /* windowCornerRadius */); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(Rect::isEmpty)); verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(rect -> rect.equals(mStackBounds))); } @Test Loading Loading @@ -120,6 +124,17 @@ public class WindowAnimationSpecTest { verify(mTransaction).setCornerRadius(eq(mSurfaceControl), eq(windowCornerRadius)); } @Test public void testApply_setCornerRadius_noClip() { final float windowCornerRadius = 30f; WindowAnimationSpec windowAnimationSpec = new WindowAnimationSpec(mAnimation, null, mStackBounds, false /* canSkipFirstFrame */, STACK_CLIP_NONE, true /* isAppAnimation */, windowCornerRadius); when(mAnimation.hasRoundedCorners()).thenReturn(true); windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0); verify(mTransaction, never()).setCornerRadius(any(), anyFloat()); } @Test public void testApply_clipBeforeSmallerAnimationClip() { // Stack bounds is (0, 0, 10, 10) animation clip is (0, 0, 5, 5) Loading