Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,8 @@ public class PipTransition extends PipTransitionController { switch (type) { switch (type) { case TRANSIT_EXIT_PIP: case TRANSIT_EXIT_PIP: startExitAnimation(info, startTransaction, finishCallback, exitPipChange); startExitAnimation(info, startTransaction, finishTransaction, finishCallback, exitPipChange); break; break; case TRANSIT_EXIT_PIP_TO_SPLIT: case TRANSIT_EXIT_PIP_TO_SPLIT: startExitToSplitAnimation(info, startTransaction, finishTransaction, startExitToSplitAnimation(info, startTransaction, finishTransaction, Loading Loading @@ -283,6 +284,7 @@ public class PipTransition extends PipTransitionController { private void startExitAnimation(@NonNull TransitionInfo info, private void startExitAnimation(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull TransitionInfo.Change pipChange) { @NonNull TransitionInfo.Change pipChange) { TransitionInfo.Change displayRotationChange = null; TransitionInfo.Change displayRotationChange = null; Loading @@ -298,8 +300,8 @@ public class PipTransition extends PipTransitionController { if (displayRotationChange != null) { if (displayRotationChange != null) { // Exiting PIP to fullscreen with orientation change. // Exiting PIP to fullscreen with orientation change. startExpandAndRotationAnimation(info, startTransaction, finishCallback, startExpandAndRotationAnimation(info, startTransaction, finishTransaction, displayRotationChange, pipChange); finishCallback, displayRotationChange, pipChange); return; return; } } Loading @@ -322,6 +324,7 @@ public class PipTransition extends PipTransitionController { private void startExpandAndRotationAnimation(@NonNull TransitionInfo info, private void startExpandAndRotationAnimation(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull TransitionInfo.Change displayRotationChange, @NonNull TransitionInfo.Change displayRotationChange, @NonNull TransitionInfo.Change pipChange) { @NonNull TransitionInfo.Change pipChange) { Loading @@ -335,7 +338,6 @@ public class PipTransition extends PipTransitionController { rotator.handleClosingChanges(info, startTransaction, rotateDelta, displayW, displayH); rotator.handleClosingChanges(info, startTransaction, rotateDelta, displayW, displayH); mFinishCallback = (wct, wctCB) -> { mFinishCallback = (wct, wctCB) -> { rotator.cleanUp(); mPipOrganizer.onExitPipFinished(pipChange.getTaskInfo()); mPipOrganizer.onExitPipFinished(pipChange.getTaskInfo()); finishCallback.onTransitionFinished(wct, wctCB); finishCallback.onTransitionFinished(wct, wctCB); }; }; Loading Loading @@ -366,6 +368,7 @@ public class PipTransition extends PipTransitionController { endBounds, startBounds, new Rect(), degree, x, y, true /* isExpanding */, endBounds, startBounds, new Rect(), degree, x, y, true /* isExpanding */, pipRotateDelta == ROTATION_270 /* clockwise */); pipRotateDelta == ROTATION_270 /* clockwise */); startTransaction.apply(); startTransaction.apply(); rotator.cleanUp(finishTransaction); // Expand and rotate the pip window to fullscreen. // Expand and rotate the pip window to fullscreen. final PipAnimationController.PipTransitionAnimator animator = final PipAnimationController.PipTransitionAnimator animator = Loading libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -35,13 +35,11 @@ import java.util.List; */ */ public class CounterRotatorHelper { public class CounterRotatorHelper { private final ArrayMap<WindowContainerToken, CounterRotator> mRotatorMap = new ArrayMap<>(); private final ArrayMap<WindowContainerToken, CounterRotator> mRotatorMap = new ArrayMap<>(); private SurfaceControl mRootLeash; /** Puts the surface controls of closing changes to counter-rotated surfaces. */ /** Puts the surface controls of closing changes to counter-rotated surfaces. */ public void handleClosingChanges(@NonNull TransitionInfo info, public void handleClosingChanges(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, int rotateDelta, int displayW, int displayH) { int rotateDelta, int displayW, int displayH) { mRootLeash = info.getRootLeash(); final List<TransitionInfo.Change> changes = info.getChanges(); final List<TransitionInfo.Change> changes = info.getChanges(); final int numChanges = changes.size(); final int numChanges = changes.size(); for (int i = numChanges - 1; i >= 0; --i) { for (int i = numChanges - 1; i >= 0; --i) { Loading Loading @@ -71,10 +69,15 @@ public class CounterRotatorHelper { } } } } /** Restores to the original state, i.e. reparent back to transition root. */ /** public void cleanUp() { * Removes the counter rotation surface in the finish transaction. No need to reparent the * children as the finish transaction should have already taken care of that. * * This can only be called after startTransaction for {@link #handleClosingChanges} is applied. */ public void cleanUp(@NonNull SurfaceControl.Transaction finishTransaction) { for (int i = mRotatorMap.size() - 1; i >= 0; --i) { for (int i = mRotatorMap.size() - 1; i >= 0; --i) { mRotatorMap.valueAt(i).cleanUp(mRootLeash); mRotatorMap.valueAt(i).cleanUp(finishTransaction); } } mRotatorMap.clear(); mRotatorMap.clear(); } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -282,7 +282,6 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { final Runnable onAnimFinish = () -> { final Runnable onAnimFinish = () -> { if (!animations.isEmpty()) return; if (!animations.isEmpty()) return; rotator.cleanUp(); if (mRotationAnimation != null) { if (mRotationAnimation != null) { mRotationAnimation.kill(); mRotationAnimation.kill(); mRotationAnimation = null; mRotationAnimation = null; Loading Loading @@ -382,6 +381,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { } } startTransaction.apply(); startTransaction.apply(); rotator.cleanUp(finishTransaction); TransitionMetrics.getInstance().reportAnimationStart(transition); TransitionMetrics.getInstance().reportAnimationStart(transition); // run finish now in-case there are no animations // run finish now in-case there are no animations onAnimFinish.run(); onAnimFinish.run(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/util/CounterRotator.java +6 −15 Original line number Original line Diff line number Diff line Loading @@ -18,14 +18,11 @@ package com.android.wm.shell.util; import android.view.SurfaceControl; import android.view.SurfaceControl; import java.util.ArrayList; /** /** * Utility class that takes care of counter-rotating surfaces during a transition animation. * Utility class that takes care of counter-rotating surfaces during a transition animation. */ */ public class CounterRotator { public class CounterRotator { SurfaceControl mSurface = null; private SurfaceControl mSurface = null; ArrayList<SurfaceControl> mRotateChildren = null; /** Gets the surface with the counter-rotation. */ /** Gets the surface with the counter-rotation. */ public SurfaceControl getSurface() { public SurfaceControl getSurface() { Loading @@ -41,7 +38,6 @@ public class CounterRotator { public void setup(SurfaceControl.Transaction t, SurfaceControl parent, int rotateDelta, public void setup(SurfaceControl.Transaction t, SurfaceControl parent, int rotateDelta, float displayW, float displayH) { float displayW, float displayH) { if (rotateDelta == 0) return; if (rotateDelta == 0) return; mRotateChildren = new ArrayList<>(); // We want to counter-rotate, so subtract from 4 // We want to counter-rotate, so subtract from 4 rotateDelta = 4 - (rotateDelta + 4) % 4; rotateDelta = 4 - (rotateDelta + 4) % 4; mSurface = new SurfaceControl.Builder() mSurface = new SurfaceControl.Builder() Loading @@ -64,24 +60,19 @@ public class CounterRotator { } } /** /** * Add a surface that needs to be counter-rotate. * Adds a surface that needs to be counter-rotate. */ */ public void addChild(SurfaceControl.Transaction t, SurfaceControl child) { public void addChild(SurfaceControl.Transaction t, SurfaceControl child) { if (mSurface == null) return; if (mSurface == null) return; t.reparent(child, mSurface); t.reparent(child, mSurface); mRotateChildren.add(child); } } /** /** * Clean-up. This undoes any reparenting and effectively stops the counter-rotation. * Clean-up. Since finishTransaction should reset all change leashes, we only need to remove the * counter rotation surface. */ */ public void cleanUp(SurfaceControl rootLeash) { public void cleanUp(SurfaceControl.Transaction finishTransaction) { if (mSurface == null) return; if (mSurface == null) return; SurfaceControl.Transaction t = new SurfaceControl.Transaction(); finishTransaction.remove(mSurface); for (int i = mRotateChildren.size() - 1; i >= 0; --i) { t.reparent(mRotateChildren.get(i), rootLeash); } t.remove(mSurface); t.apply(); } } } } packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -205,8 +205,10 @@ public class RemoteAnimationAdapterCompat { @Override @Override @SuppressLint("NewApi") @SuppressLint("NewApi") public void run() { public void run() { counterLauncher.cleanUp(info.getRootLeash()); final SurfaceControl.Transaction finishTransaction = counterWallpaper.cleanUp(info.getRootLeash()); new SurfaceControl.Transaction(); counterLauncher.cleanUp(finishTransaction); counterWallpaper.cleanUp(finishTransaction); // Release surface references now. This is apparently to free GPU memory // Release surface references now. This is apparently to free GPU memory // while doing quick operations (eg. during CTS). // while doing quick operations (eg. during CTS). for (int i = info.getChanges().size() - 1; i >= 0; --i) { for (int i = info.getChanges().size() - 1; i >= 0; --i) { Loading @@ -216,7 +218,7 @@ public class RemoteAnimationAdapterCompat { leashMap.valueAt(i).release(); leashMap.valueAt(i).release(); } } try { try { finishCallback.onTransitionFinished(null /* wct */, null /* sct */); finishCallback.onTransitionFinished(null /* wct */, finishTransaction); } catch (RemoteException e) { } catch (RemoteException e) { Log.e("ActivityOptionsCompat", "Failed to call app controlled animation" Log.e("ActivityOptionsCompat", "Failed to call app controlled animation" + " finished callback", e); + " finished callback", e); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,8 @@ public class PipTransition extends PipTransitionController { switch (type) { switch (type) { case TRANSIT_EXIT_PIP: case TRANSIT_EXIT_PIP: startExitAnimation(info, startTransaction, finishCallback, exitPipChange); startExitAnimation(info, startTransaction, finishTransaction, finishCallback, exitPipChange); break; break; case TRANSIT_EXIT_PIP_TO_SPLIT: case TRANSIT_EXIT_PIP_TO_SPLIT: startExitToSplitAnimation(info, startTransaction, finishTransaction, startExitToSplitAnimation(info, startTransaction, finishTransaction, Loading Loading @@ -283,6 +284,7 @@ public class PipTransition extends PipTransitionController { private void startExitAnimation(@NonNull TransitionInfo info, private void startExitAnimation(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull TransitionInfo.Change pipChange) { @NonNull TransitionInfo.Change pipChange) { TransitionInfo.Change displayRotationChange = null; TransitionInfo.Change displayRotationChange = null; Loading @@ -298,8 +300,8 @@ public class PipTransition extends PipTransitionController { if (displayRotationChange != null) { if (displayRotationChange != null) { // Exiting PIP to fullscreen with orientation change. // Exiting PIP to fullscreen with orientation change. startExpandAndRotationAnimation(info, startTransaction, finishCallback, startExpandAndRotationAnimation(info, startTransaction, finishTransaction, displayRotationChange, pipChange); finishCallback, displayRotationChange, pipChange); return; return; } } Loading @@ -322,6 +324,7 @@ public class PipTransition extends PipTransitionController { private void startExpandAndRotationAnimation(@NonNull TransitionInfo info, private void startExpandAndRotationAnimation(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull Transitions.TransitionFinishCallback finishCallback, @NonNull TransitionInfo.Change displayRotationChange, @NonNull TransitionInfo.Change displayRotationChange, @NonNull TransitionInfo.Change pipChange) { @NonNull TransitionInfo.Change pipChange) { Loading @@ -335,7 +338,6 @@ public class PipTransition extends PipTransitionController { rotator.handleClosingChanges(info, startTransaction, rotateDelta, displayW, displayH); rotator.handleClosingChanges(info, startTransaction, rotateDelta, displayW, displayH); mFinishCallback = (wct, wctCB) -> { mFinishCallback = (wct, wctCB) -> { rotator.cleanUp(); mPipOrganizer.onExitPipFinished(pipChange.getTaskInfo()); mPipOrganizer.onExitPipFinished(pipChange.getTaskInfo()); finishCallback.onTransitionFinished(wct, wctCB); finishCallback.onTransitionFinished(wct, wctCB); }; }; Loading Loading @@ -366,6 +368,7 @@ public class PipTransition extends PipTransitionController { endBounds, startBounds, new Rect(), degree, x, y, true /* isExpanding */, endBounds, startBounds, new Rect(), degree, x, y, true /* isExpanding */, pipRotateDelta == ROTATION_270 /* clockwise */); pipRotateDelta == ROTATION_270 /* clockwise */); startTransaction.apply(); startTransaction.apply(); rotator.cleanUp(finishTransaction); // Expand and rotate the pip window to fullscreen. // Expand and rotate the pip window to fullscreen. final PipAnimationController.PipTransitionAnimator animator = final PipAnimationController.PipTransitionAnimator animator = Loading
libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -35,13 +35,11 @@ import java.util.List; */ */ public class CounterRotatorHelper { public class CounterRotatorHelper { private final ArrayMap<WindowContainerToken, CounterRotator> mRotatorMap = new ArrayMap<>(); private final ArrayMap<WindowContainerToken, CounterRotator> mRotatorMap = new ArrayMap<>(); private SurfaceControl mRootLeash; /** Puts the surface controls of closing changes to counter-rotated surfaces. */ /** Puts the surface controls of closing changes to counter-rotated surfaces. */ public void handleClosingChanges(@NonNull TransitionInfo info, public void handleClosingChanges(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction startTransaction, int rotateDelta, int displayW, int displayH) { int rotateDelta, int displayW, int displayH) { mRootLeash = info.getRootLeash(); final List<TransitionInfo.Change> changes = info.getChanges(); final List<TransitionInfo.Change> changes = info.getChanges(); final int numChanges = changes.size(); final int numChanges = changes.size(); for (int i = numChanges - 1; i >= 0; --i) { for (int i = numChanges - 1; i >= 0; --i) { Loading Loading @@ -71,10 +69,15 @@ public class CounterRotatorHelper { } } } } /** Restores to the original state, i.e. reparent back to transition root. */ /** public void cleanUp() { * Removes the counter rotation surface in the finish transaction. No need to reparent the * children as the finish transaction should have already taken care of that. * * This can only be called after startTransaction for {@link #handleClosingChanges} is applied. */ public void cleanUp(@NonNull SurfaceControl.Transaction finishTransaction) { for (int i = mRotatorMap.size() - 1; i >= 0; --i) { for (int i = mRotatorMap.size() - 1; i >= 0; --i) { mRotatorMap.valueAt(i).cleanUp(mRootLeash); mRotatorMap.valueAt(i).cleanUp(finishTransaction); } } mRotatorMap.clear(); mRotatorMap.clear(); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -282,7 +282,6 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { final Runnable onAnimFinish = () -> { final Runnable onAnimFinish = () -> { if (!animations.isEmpty()) return; if (!animations.isEmpty()) return; rotator.cleanUp(); if (mRotationAnimation != null) { if (mRotationAnimation != null) { mRotationAnimation.kill(); mRotationAnimation.kill(); mRotationAnimation = null; mRotationAnimation = null; Loading Loading @@ -382,6 +381,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler { } } startTransaction.apply(); startTransaction.apply(); rotator.cleanUp(finishTransaction); TransitionMetrics.getInstance().reportAnimationStart(transition); TransitionMetrics.getInstance().reportAnimationStart(transition); // run finish now in-case there are no animations // run finish now in-case there are no animations onAnimFinish.run(); onAnimFinish.run(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/util/CounterRotator.java +6 −15 Original line number Original line Diff line number Diff line Loading @@ -18,14 +18,11 @@ package com.android.wm.shell.util; import android.view.SurfaceControl; import android.view.SurfaceControl; import java.util.ArrayList; /** /** * Utility class that takes care of counter-rotating surfaces during a transition animation. * Utility class that takes care of counter-rotating surfaces during a transition animation. */ */ public class CounterRotator { public class CounterRotator { SurfaceControl mSurface = null; private SurfaceControl mSurface = null; ArrayList<SurfaceControl> mRotateChildren = null; /** Gets the surface with the counter-rotation. */ /** Gets the surface with the counter-rotation. */ public SurfaceControl getSurface() { public SurfaceControl getSurface() { Loading @@ -41,7 +38,6 @@ public class CounterRotator { public void setup(SurfaceControl.Transaction t, SurfaceControl parent, int rotateDelta, public void setup(SurfaceControl.Transaction t, SurfaceControl parent, int rotateDelta, float displayW, float displayH) { float displayW, float displayH) { if (rotateDelta == 0) return; if (rotateDelta == 0) return; mRotateChildren = new ArrayList<>(); // We want to counter-rotate, so subtract from 4 // We want to counter-rotate, so subtract from 4 rotateDelta = 4 - (rotateDelta + 4) % 4; rotateDelta = 4 - (rotateDelta + 4) % 4; mSurface = new SurfaceControl.Builder() mSurface = new SurfaceControl.Builder() Loading @@ -64,24 +60,19 @@ public class CounterRotator { } } /** /** * Add a surface that needs to be counter-rotate. * Adds a surface that needs to be counter-rotate. */ */ public void addChild(SurfaceControl.Transaction t, SurfaceControl child) { public void addChild(SurfaceControl.Transaction t, SurfaceControl child) { if (mSurface == null) return; if (mSurface == null) return; t.reparent(child, mSurface); t.reparent(child, mSurface); mRotateChildren.add(child); } } /** /** * Clean-up. This undoes any reparenting and effectively stops the counter-rotation. * Clean-up. Since finishTransaction should reset all change leashes, we only need to remove the * counter rotation surface. */ */ public void cleanUp(SurfaceControl rootLeash) { public void cleanUp(SurfaceControl.Transaction finishTransaction) { if (mSurface == null) return; if (mSurface == null) return; SurfaceControl.Transaction t = new SurfaceControl.Transaction(); finishTransaction.remove(mSurface); for (int i = mRotateChildren.size() - 1; i >= 0; --i) { t.reparent(mRotateChildren.get(i), rootLeash); } t.remove(mSurface); t.apply(); } } } }
packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -205,8 +205,10 @@ public class RemoteAnimationAdapterCompat { @Override @Override @SuppressLint("NewApi") @SuppressLint("NewApi") public void run() { public void run() { counterLauncher.cleanUp(info.getRootLeash()); final SurfaceControl.Transaction finishTransaction = counterWallpaper.cleanUp(info.getRootLeash()); new SurfaceControl.Transaction(); counterLauncher.cleanUp(finishTransaction); counterWallpaper.cleanUp(finishTransaction); // Release surface references now. This is apparently to free GPU memory // Release surface references now. This is apparently to free GPU memory // while doing quick operations (eg. during CTS). // while doing quick operations (eg. during CTS). for (int i = info.getChanges().size() - 1; i >= 0; --i) { for (int i = info.getChanges().size() - 1; i >= 0; --i) { Loading @@ -216,7 +218,7 @@ public class RemoteAnimationAdapterCompat { leashMap.valueAt(i).release(); leashMap.valueAt(i).release(); } } try { try { finishCallback.onTransitionFinished(null /* wct */, null /* sct */); finishCallback.onTransitionFinished(null /* wct */, finishTransaction); } catch (RemoteException e) { } catch (RemoteException e) { Log.e("ActivityOptionsCompat", "Failed to call app controlled animation" Log.e("ActivityOptionsCompat", "Failed to call app controlled animation" + " finished callback", e); + " finished callback", e); Loading