Loading libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java +24 −24 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.wm.shell.activityembedding; import static android.graphics.Matrix.MTRANS_X; import static android.graphics.Matrix.MTRANS_Y; import static com.android.wm.shell.activityembedding.ActivityEmbeddingAnimationRunner.shouldUseSnapshotAnimationForClosingChange; import android.annotation.CallSuper; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -62,7 +60,7 @@ class ActivityEmbeddingAnimationAdapter { private final Rect mContentBounds = new Rect(); /** Offset relative to the window parent surface for {@link #mContentBounds}. */ @NonNull private final Point mContentRelOffset = new Point(); final Point mContentRelOffset = new Point(); @NonNull final Transformation mTransformation = new Transformation(); Loading @@ -75,8 +73,8 @@ class ActivityEmbeddingAnimationAdapter { private int mOverrideLayer = LAYER_NO_OVERRIDE; ActivityEmbeddingAnimationAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change) { this(animation, change, change.getLeash(), change.getEndAbsBounds()); @NonNull TransitionInfo.Change change, @NonNull TransitionInfo.Root root) { this(animation, change, change.getLeash(), change.getEndAbsBounds(), root); } /** Loading @@ -87,32 +85,34 @@ class ActivityEmbeddingAnimationAdapter { */ ActivityEmbeddingAnimationAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull SurfaceControl leash, @NonNull Rect wholeAnimationBounds) { @NonNull Rect wholeAnimationBounds, @NonNull TransitionInfo.Root root) { mAnimation = animation; mChange = change; mLeash = leash; mWholeAnimationBounds.set(wholeAnimationBounds); final Rect startBounds = change.getStartAbsBounds(); final Rect endBounds = change.getEndAbsBounds(); if (change.getParent() != null) { mContentRelOffset.set(change.getEndRelOffset()); } else { // Change leash has been reparented to the root if its parent is not in the transition. // Because it is reparented to the root, the actual offset should be its relative // position to the root instead. See Transitions#setupAnimHierarchy. final Point rootOffset = root.getOffset(); mContentRelOffset.set(endBounds.left - rootOffset.x, endBounds.top - rootOffset.y); } if (TransitionUtil.isClosingType(change.getMode())) { // When it is closing, we want to show the content at the start position in case the // window is resizing as well. For example, when the activities is changing from split // to stack, the bottom TaskFragment will be resized to fullscreen when hiding. final Rect startBounds = change.getStartAbsBounds(); final Rect endBounds = change.getEndAbsBounds(); mContentBounds.set(startBounds); // Put the transition to the top left for snapshot animation. if (shouldUseSnapshotAnimationForClosingChange(mChange)) { // TODO(b/275034335): Fix an issue that black hole when closing the right container // in bounds change transition. mContentRelOffset.set(0, 0); } else { mContentRelOffset.set(change.getEndRelOffset()); mContentRelOffset.offset( startBounds.left - endBounds.left, startBounds.top - endBounds.top); } } else { mContentBounds.set(change.getEndAbsBounds()); mContentRelOffset.set(change.getEndRelOffset()); } } Loading Loading @@ -192,8 +192,8 @@ class ActivityEmbeddingAnimationAdapter { static class SnapshotAdapter extends ActivityEmbeddingAnimationAdapter { SnapshotAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull SurfaceControl snapshotLeash) { super(animation, change, snapshotLeash, change.getEndAbsBounds()); @NonNull SurfaceControl snapshotLeash, @NonNull TransitionInfo.Root root) { super(animation, change, snapshotLeash, change.getEndAbsBounds(), root); } @Override Loading @@ -219,14 +219,14 @@ class ActivityEmbeddingAnimationAdapter { */ static class BoundsChangeAdapter extends ActivityEmbeddingAnimationAdapter { BoundsChangeAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change) { super(animation, change); BoundsChangeAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull TransitionInfo.Root root) { super(animation, change, root); } @Override void onAnimationUpdateInner(@NonNull SurfaceControl.Transaction t) { final Point offset = mChange.getEndRelOffset(); mTransformation.getMatrix().postTranslate(offset.x, offset.y); mTransformation.getMatrix().postTranslate(mContentRelOffset.x, mContentRelOffset.y); t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix); t.setAlpha(mLeash, mTransformation.getAlpha()); Loading libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java +27 −7 Original line number Diff line number Diff line Loading @@ -250,7 +250,8 @@ class ActivityEmbeddingAnimationRunner { SurfaceControl screenshot = getOrCreateScreenshot(change, change, startTransaction); if (screenshot != null) { final SnapshotAdapter snapshotAdapter = new SnapshotAdapter( createShowSnapshotForClosingAnimation(), change, screenshot); createShowSnapshotForClosingAnimation(), change, screenshot, TransitionUtil.getRootFor(change, info)); if (!isOpening) { snapshotAdapter.overrideLayer(offsetLayer++); } Loading Loading @@ -338,7 +339,7 @@ class ActivityEmbeddingAnimationRunner { @NonNull AnimationProvider animationProvider, @NonNull Rect wholeAnimationBounds) { final Animation animation = animationProvider.get(info, change, wholeAnimationBounds); return new ActivityEmbeddingAnimationAdapter(animation, change, change.getLeash(), wholeAnimationBounds); wholeAnimationBounds, TransitionUtil.getRootFor(change, info)); } @NonNull Loading Loading @@ -387,6 +388,12 @@ class ActivityEmbeddingAnimationRunner { // size. parentBounds.union(boundsAnimationChange.getStartAbsBounds()); parentBounds.union(boundsAnimationChange.getEndAbsBounds()); if (boundsAnimationChange != change) { // Union the change starting bounds in case the activity is resized and reparented // to a TaskFragment. In that case, the TaskFragment may not cover the activity's // starting bounds. parentBounds.union(change.getStartAbsBounds()); } // There are two animations in the array. The first one is for the start leash // (snapshot), and the second one is for the end leash (TaskFragment). Loading @@ -401,17 +408,18 @@ class ActivityEmbeddingAnimationRunner { // boundsAnimationChange. final SurfaceControl screenshotLeash = getOrCreateScreenshot(change, boundsAnimationChange, startTransaction); final TransitionInfo.Root root = TransitionUtil.getRootFor(change, info); if (screenshotLeash != null) { // Adapter for the starting screenshot leash. // The screenshot leash will be removed in SnapshotAdapter#onAnimationEnd adapters.add(new ActivityEmbeddingAnimationAdapter.SnapshotAdapter( animations[0], change, screenshotLeash)); animations[0], change, screenshotLeash, root)); } else { Log.e(TAG, "Failed to take screenshot for change=" + change); } // Adapter for the ending bounds changed leash. adapters.add(new ActivityEmbeddingAnimationAdapter.BoundsChangeAdapter( animations[1], boundsAnimationChange)); animations[1], boundsAnimationChange, root)); } if (parentBounds.isEmpty()) { Loading Loading @@ -443,7 +451,8 @@ class ActivityEmbeddingAnimationRunner { animation = mAnimationSpec.createChangeBoundsOpenAnimation(change, parentBounds); shouldShouldBackgroundColor = false; } adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change)); adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change, TransitionUtil.getRootFor(change, info))); } if (shouldShouldBackgroundColor && changeAnimation != null) { Loading Loading @@ -534,8 +543,19 @@ class ActivityEmbeddingAnimationRunner { @NonNull SurfaceControl.Transaction startTransaction) { for (TransitionInfo.Change change : info.getChanges()) { final SurfaceControl leash = change.getLeash(); if (change.getParent() != null) { startTransaction.setPosition(leash, change.getEndRelOffset().x, change.getEndRelOffset().y); } else { // Change leash has been reparented to the root if its parent is not in the // transition. // Because it is reparented to the root, the actual offset should be its relative // position to the root instead. See Transitions#setupAnimHierarchy. final TransitionInfo.Root root = TransitionUtil.getRootFor(change, info); startTransaction.setPosition(leash, change.getEndAbsBounds().left - root.getOffset().x, change.getEndAbsBounds().top - root.getOffset().y); } startTransaction.setWindowCrop(leash, change.getEndAbsBounds().width(), change.getEndAbsBounds().height()); if (change.getMode() == TRANSIT_CLOSE) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java +10 −0 Original line number Diff line number Diff line Loading @@ -306,4 +306,14 @@ public class TransitionUtil { if (rootIdx >= 0) return rootIdx; return 0; } /** * Gets the {@link TransitionInfo.Root} for the given {@link TransitionInfo.Change}. * @see #rootIndexFor(TransitionInfo.Change, TransitionInfo) */ @NonNull public static TransitionInfo.Root getRootFor(@NonNull TransitionInfo.Change change, @NonNull TransitionInfo info) { return info.getRoot(rootIndexFor(change, info)); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java +24 −24 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ package com.android.wm.shell.activityembedding; import static android.graphics.Matrix.MTRANS_X; import static android.graphics.Matrix.MTRANS_Y; import static com.android.wm.shell.activityembedding.ActivityEmbeddingAnimationRunner.shouldUseSnapshotAnimationForClosingChange; import android.annotation.CallSuper; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -62,7 +60,7 @@ class ActivityEmbeddingAnimationAdapter { private final Rect mContentBounds = new Rect(); /** Offset relative to the window parent surface for {@link #mContentBounds}. */ @NonNull private final Point mContentRelOffset = new Point(); final Point mContentRelOffset = new Point(); @NonNull final Transformation mTransformation = new Transformation(); Loading @@ -75,8 +73,8 @@ class ActivityEmbeddingAnimationAdapter { private int mOverrideLayer = LAYER_NO_OVERRIDE; ActivityEmbeddingAnimationAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change) { this(animation, change, change.getLeash(), change.getEndAbsBounds()); @NonNull TransitionInfo.Change change, @NonNull TransitionInfo.Root root) { this(animation, change, change.getLeash(), change.getEndAbsBounds(), root); } /** Loading @@ -87,32 +85,34 @@ class ActivityEmbeddingAnimationAdapter { */ ActivityEmbeddingAnimationAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull SurfaceControl leash, @NonNull Rect wholeAnimationBounds) { @NonNull Rect wholeAnimationBounds, @NonNull TransitionInfo.Root root) { mAnimation = animation; mChange = change; mLeash = leash; mWholeAnimationBounds.set(wholeAnimationBounds); final Rect startBounds = change.getStartAbsBounds(); final Rect endBounds = change.getEndAbsBounds(); if (change.getParent() != null) { mContentRelOffset.set(change.getEndRelOffset()); } else { // Change leash has been reparented to the root if its parent is not in the transition. // Because it is reparented to the root, the actual offset should be its relative // position to the root instead. See Transitions#setupAnimHierarchy. final Point rootOffset = root.getOffset(); mContentRelOffset.set(endBounds.left - rootOffset.x, endBounds.top - rootOffset.y); } if (TransitionUtil.isClosingType(change.getMode())) { // When it is closing, we want to show the content at the start position in case the // window is resizing as well. For example, when the activities is changing from split // to stack, the bottom TaskFragment will be resized to fullscreen when hiding. final Rect startBounds = change.getStartAbsBounds(); final Rect endBounds = change.getEndAbsBounds(); mContentBounds.set(startBounds); // Put the transition to the top left for snapshot animation. if (shouldUseSnapshotAnimationForClosingChange(mChange)) { // TODO(b/275034335): Fix an issue that black hole when closing the right container // in bounds change transition. mContentRelOffset.set(0, 0); } else { mContentRelOffset.set(change.getEndRelOffset()); mContentRelOffset.offset( startBounds.left - endBounds.left, startBounds.top - endBounds.top); } } else { mContentBounds.set(change.getEndAbsBounds()); mContentRelOffset.set(change.getEndRelOffset()); } } Loading Loading @@ -192,8 +192,8 @@ class ActivityEmbeddingAnimationAdapter { static class SnapshotAdapter extends ActivityEmbeddingAnimationAdapter { SnapshotAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull SurfaceControl snapshotLeash) { super(animation, change, snapshotLeash, change.getEndAbsBounds()); @NonNull SurfaceControl snapshotLeash, @NonNull TransitionInfo.Root root) { super(animation, change, snapshotLeash, change.getEndAbsBounds(), root); } @Override Loading @@ -219,14 +219,14 @@ class ActivityEmbeddingAnimationAdapter { */ static class BoundsChangeAdapter extends ActivityEmbeddingAnimationAdapter { BoundsChangeAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change) { super(animation, change); BoundsChangeAdapter(@NonNull Animation animation, @NonNull TransitionInfo.Change change, @NonNull TransitionInfo.Root root) { super(animation, change, root); } @Override void onAnimationUpdateInner(@NonNull SurfaceControl.Transaction t) { final Point offset = mChange.getEndRelOffset(); mTransformation.getMatrix().postTranslate(offset.x, offset.y); mTransformation.getMatrix().postTranslate(mContentRelOffset.x, mContentRelOffset.y); t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix); t.setAlpha(mLeash, mTransformation.getAlpha()); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java +27 −7 Original line number Diff line number Diff line Loading @@ -250,7 +250,8 @@ class ActivityEmbeddingAnimationRunner { SurfaceControl screenshot = getOrCreateScreenshot(change, change, startTransaction); if (screenshot != null) { final SnapshotAdapter snapshotAdapter = new SnapshotAdapter( createShowSnapshotForClosingAnimation(), change, screenshot); createShowSnapshotForClosingAnimation(), change, screenshot, TransitionUtil.getRootFor(change, info)); if (!isOpening) { snapshotAdapter.overrideLayer(offsetLayer++); } Loading Loading @@ -338,7 +339,7 @@ class ActivityEmbeddingAnimationRunner { @NonNull AnimationProvider animationProvider, @NonNull Rect wholeAnimationBounds) { final Animation animation = animationProvider.get(info, change, wholeAnimationBounds); return new ActivityEmbeddingAnimationAdapter(animation, change, change.getLeash(), wholeAnimationBounds); wholeAnimationBounds, TransitionUtil.getRootFor(change, info)); } @NonNull Loading Loading @@ -387,6 +388,12 @@ class ActivityEmbeddingAnimationRunner { // size. parentBounds.union(boundsAnimationChange.getStartAbsBounds()); parentBounds.union(boundsAnimationChange.getEndAbsBounds()); if (boundsAnimationChange != change) { // Union the change starting bounds in case the activity is resized and reparented // to a TaskFragment. In that case, the TaskFragment may not cover the activity's // starting bounds. parentBounds.union(change.getStartAbsBounds()); } // There are two animations in the array. The first one is for the start leash // (snapshot), and the second one is for the end leash (TaskFragment). Loading @@ -401,17 +408,18 @@ class ActivityEmbeddingAnimationRunner { // boundsAnimationChange. final SurfaceControl screenshotLeash = getOrCreateScreenshot(change, boundsAnimationChange, startTransaction); final TransitionInfo.Root root = TransitionUtil.getRootFor(change, info); if (screenshotLeash != null) { // Adapter for the starting screenshot leash. // The screenshot leash will be removed in SnapshotAdapter#onAnimationEnd adapters.add(new ActivityEmbeddingAnimationAdapter.SnapshotAdapter( animations[0], change, screenshotLeash)); animations[0], change, screenshotLeash, root)); } else { Log.e(TAG, "Failed to take screenshot for change=" + change); } // Adapter for the ending bounds changed leash. adapters.add(new ActivityEmbeddingAnimationAdapter.BoundsChangeAdapter( animations[1], boundsAnimationChange)); animations[1], boundsAnimationChange, root)); } if (parentBounds.isEmpty()) { Loading Loading @@ -443,7 +451,8 @@ class ActivityEmbeddingAnimationRunner { animation = mAnimationSpec.createChangeBoundsOpenAnimation(change, parentBounds); shouldShouldBackgroundColor = false; } adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change)); adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change, TransitionUtil.getRootFor(change, info))); } if (shouldShouldBackgroundColor && changeAnimation != null) { Loading Loading @@ -534,8 +543,19 @@ class ActivityEmbeddingAnimationRunner { @NonNull SurfaceControl.Transaction startTransaction) { for (TransitionInfo.Change change : info.getChanges()) { final SurfaceControl leash = change.getLeash(); if (change.getParent() != null) { startTransaction.setPosition(leash, change.getEndRelOffset().x, change.getEndRelOffset().y); } else { // Change leash has been reparented to the root if its parent is not in the // transition. // Because it is reparented to the root, the actual offset should be its relative // position to the root instead. See Transitions#setupAnimHierarchy. final TransitionInfo.Root root = TransitionUtil.getRootFor(change, info); startTransaction.setPosition(leash, change.getEndAbsBounds().left - root.getOffset().x, change.getEndAbsBounds().top - root.getOffset().y); } startTransaction.setWindowCrop(leash, change.getEndAbsBounds().width(), change.getEndAbsBounds().height()); if (change.getMode() == TRANSIT_CLOSE) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java +10 −0 Original line number Diff line number Diff line Loading @@ -306,4 +306,14 @@ public class TransitionUtil { if (rootIdx >= 0) return rootIdx; return 0; } /** * Gets the {@link TransitionInfo.Root} for the given {@link TransitionInfo.Change}. * @see #rootIndexFor(TransitionInfo.Change, TransitionInfo) */ @NonNull public static TransitionInfo.Root getRootFor(@NonNull TransitionInfo.Change change, @NonNull TransitionInfo info) { return info.getRoot(rootIndexFor(change, info)); } }