Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +27 −33 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ import android.os.RemoteException; import android.util.Size; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; import android.view.WindowManagerGlobal; import com.android.internal.protolog.common.ProtoLog; Loading @@ -42,6 +40,7 @@ import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController.ActionListener; import com.android.wm.shell.pip.PipMenuController; import com.android.wm.shell.pip.PipSurfaceTransactionHelper; import com.android.wm.shell.pip.PipUiEventLogger; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.SplitScreenController; Loading Loading @@ -115,6 +114,10 @@ public class PhonePipMenuController implements PipMenuController { private final ShellExecutor mMainExecutor; private final Handler mMainHandler; private final PipSurfaceTransactionHelper.SurfaceControlTransactionFactory mSurfaceControlTransactionFactory; private final float[] mTmpTransform = new float[9]; private final ArrayList<Listener> mListeners = new ArrayList<>(); private final SystemWindows mSystemWindows; private final Optional<SplitScreenController> mSplitScreenController; Loading @@ -124,7 +127,6 @@ public class PhonePipMenuController implements PipMenuController { private RemoteAction mCloseAction; private List<RemoteAction> mMediaActions; private SyncRtSurfaceTransactionApplier mApplier; private int mMenuState; private PipMenuView mPipMenuView; Loading @@ -150,6 +152,9 @@ public class PhonePipMenuController implements PipMenuController { mMainHandler = mainHandler; mSplitScreenController = splitScreenOptional; mPipUiEventLogger = pipUiEventLogger; mSurfaceControlTransactionFactory = new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory(); } public boolean isMenuVisible() { Loading Loading @@ -194,7 +199,6 @@ public class PhonePipMenuController implements PipMenuController { return; } mApplier = null; mSystemWindows.removeView(mPipMenuView); mPipMenuView = null; } Loading Loading @@ -289,7 +293,7 @@ public class PhonePipMenuController implements PipMenuController { willResizeMenu, withDelay, showResizeHandle, Debug.getCallers(5, " ")); } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } Loading @@ -312,7 +316,7 @@ public class PhonePipMenuController implements PipMenuController { return; } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } Loading @@ -328,18 +332,15 @@ public class PhonePipMenuController implements PipMenuController { mTmpSourceRectF.set(mTmpSourceBounds); mTmpDestinationRectF.set(destinationBounds); mMoveTransform.setRectToRect(mTmpSourceRectF, mTmpDestinationRectF, Matrix.ScaleToFit.FILL); SurfaceControl surfaceControl = getSurfaceControl(); SurfaceParams params = new SurfaceParams.Builder(surfaceControl) .withMatrix(mMoveTransform) .build(); final SurfaceControl surfaceControl = getSurfaceControl(); final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setMatrix(surfaceControl, mMoveTransform, mTmpTransform); if (pipLeash != null && t != null) { SurfaceParams pipParams = new SurfaceParams.Builder(pipLeash) .withMergeTransaction(t) .build(); mApplier.scheduleApply(params, pipParams); } else { mApplier.scheduleApply(params); // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); } menuTx.apply(); } /** Loading @@ -353,36 +354,29 @@ public class PhonePipMenuController implements PipMenuController { return; } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } SurfaceControl surfaceControl = getSurfaceControl(); SurfaceParams params = new SurfaceParams.Builder(surfaceControl) .withWindowCrop(destinationBounds) .build(); final SurfaceControl surfaceControl = getSurfaceControl(); final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setCrop(surfaceControl, destinationBounds); if (pipLeash != null && t != null) { SurfaceParams pipParams = new SurfaceParams.Builder(pipLeash) .withMergeTransaction(t) .build(); mApplier.scheduleApply(params, pipParams); } else { mApplier.scheduleApply(params); // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); } menuTx.apply(); } private boolean maybeCreateSyncApplier() { private boolean checkPipMenuState() { if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: Not going to move PiP, either menu or its parent is not created.", TAG); return false; } if (mApplier == null) { mApplier = new SyncRtSurfaceTransactionApplier(mPipMenuView); } return mApplier != null; return true; } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipInputConsumer.java +1 −4 Original line number Diff line number Diff line Loading @@ -146,11 +146,8 @@ public class PipInputConsumer { "%s: Failed to create input consumer, %s", TAG, e); } mMainExecutor.execute(() -> { // Choreographer.getSfInstance() must be called on the thread that the input event // receiver should be receiving events // TODO(b/222697646): remove getSfInstance usage and use vsyncId for transactions mInputEventReceiver = new InputEventReceiver(inputChannel, Looper.myLooper(), Choreographer.getSfInstance()); Looper.myLooper(), Choreographer.getInstance()); if (mRegistrationListener != null) { mRegistrationListener.onRegistrationChanged(true /* isRegistered */); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +1 −2 Original line number Diff line number Diff line Loading @@ -625,8 +625,7 @@ public class PipResizeGestureHandler { class PipResizeInputEventReceiver extends BatchedInputEventReceiver { PipResizeInputEventReceiver(InputChannel channel, Looper looper) { // TODO(b/222697646): remove getSfInstance usage and use vsyncId for transactions super(channel, looper, Choreographer.getSfInstance()); super(channel, looper, Choreographer.getInstance()); } public void onInputEvent(InputEvent event) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +27 −33 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ import android.os.RemoteException; import android.util.Size; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; import android.view.WindowManagerGlobal; import com.android.internal.protolog.common.ProtoLog; Loading @@ -42,6 +40,7 @@ import com.android.wm.shell.pip.PipBoundsState; import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController.ActionListener; import com.android.wm.shell.pip.PipMenuController; import com.android.wm.shell.pip.PipSurfaceTransactionHelper; import com.android.wm.shell.pip.PipUiEventLogger; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.SplitScreenController; Loading Loading @@ -115,6 +114,10 @@ public class PhonePipMenuController implements PipMenuController { private final ShellExecutor mMainExecutor; private final Handler mMainHandler; private final PipSurfaceTransactionHelper.SurfaceControlTransactionFactory mSurfaceControlTransactionFactory; private final float[] mTmpTransform = new float[9]; private final ArrayList<Listener> mListeners = new ArrayList<>(); private final SystemWindows mSystemWindows; private final Optional<SplitScreenController> mSplitScreenController; Loading @@ -124,7 +127,6 @@ public class PhonePipMenuController implements PipMenuController { private RemoteAction mCloseAction; private List<RemoteAction> mMediaActions; private SyncRtSurfaceTransactionApplier mApplier; private int mMenuState; private PipMenuView mPipMenuView; Loading @@ -150,6 +152,9 @@ public class PhonePipMenuController implements PipMenuController { mMainHandler = mainHandler; mSplitScreenController = splitScreenOptional; mPipUiEventLogger = pipUiEventLogger; mSurfaceControlTransactionFactory = new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory(); } public boolean isMenuVisible() { Loading Loading @@ -194,7 +199,6 @@ public class PhonePipMenuController implements PipMenuController { return; } mApplier = null; mSystemWindows.removeView(mPipMenuView); mPipMenuView = null; } Loading Loading @@ -289,7 +293,7 @@ public class PhonePipMenuController implements PipMenuController { willResizeMenu, withDelay, showResizeHandle, Debug.getCallers(5, " ")); } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } Loading @@ -312,7 +316,7 @@ public class PhonePipMenuController implements PipMenuController { return; } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } Loading @@ -328,18 +332,15 @@ public class PhonePipMenuController implements PipMenuController { mTmpSourceRectF.set(mTmpSourceBounds); mTmpDestinationRectF.set(destinationBounds); mMoveTransform.setRectToRect(mTmpSourceRectF, mTmpDestinationRectF, Matrix.ScaleToFit.FILL); SurfaceControl surfaceControl = getSurfaceControl(); SurfaceParams params = new SurfaceParams.Builder(surfaceControl) .withMatrix(mMoveTransform) .build(); final SurfaceControl surfaceControl = getSurfaceControl(); final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setMatrix(surfaceControl, mMoveTransform, mTmpTransform); if (pipLeash != null && t != null) { SurfaceParams pipParams = new SurfaceParams.Builder(pipLeash) .withMergeTransaction(t) .build(); mApplier.scheduleApply(params, pipParams); } else { mApplier.scheduleApply(params); // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); } menuTx.apply(); } /** Loading @@ -353,36 +354,29 @@ public class PhonePipMenuController implements PipMenuController { return; } if (!maybeCreateSyncApplier()) { if (!checkPipMenuState()) { return; } SurfaceControl surfaceControl = getSurfaceControl(); SurfaceParams params = new SurfaceParams.Builder(surfaceControl) .withWindowCrop(destinationBounds) .build(); final SurfaceControl surfaceControl = getSurfaceControl(); final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setCrop(surfaceControl, destinationBounds); if (pipLeash != null && t != null) { SurfaceParams pipParams = new SurfaceParams.Builder(pipLeash) .withMergeTransaction(t) .build(); mApplier.scheduleApply(params, pipParams); } else { mApplier.scheduleApply(params); // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); } menuTx.apply(); } private boolean maybeCreateSyncApplier() { private boolean checkPipMenuState() { if (mPipMenuView == null || mPipMenuView.getViewRootImpl() == null) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: Not going to move PiP, either menu or its parent is not created.", TAG); return false; } if (mApplier == null) { mApplier = new SyncRtSurfaceTransactionApplier(mPipMenuView); } return mApplier != null; return true; } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipInputConsumer.java +1 −4 Original line number Diff line number Diff line Loading @@ -146,11 +146,8 @@ public class PipInputConsumer { "%s: Failed to create input consumer, %s", TAG, e); } mMainExecutor.execute(() -> { // Choreographer.getSfInstance() must be called on the thread that the input event // receiver should be receiving events // TODO(b/222697646): remove getSfInstance usage and use vsyncId for transactions mInputEventReceiver = new InputEventReceiver(inputChannel, Looper.myLooper(), Choreographer.getSfInstance()); Looper.myLooper(), Choreographer.getInstance()); if (mRegistrationListener != null) { mRegistrationListener.onRegistrationChanged(true /* isRegistered */); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +1 −2 Original line number Diff line number Diff line Loading @@ -625,8 +625,7 @@ public class PipResizeGestureHandler { class PipResizeInputEventReceiver extends BatchedInputEventReceiver { PipResizeInputEventReceiver(InputChannel channel, Looper looper) { // TODO(b/222697646): remove getSfInstance usage and use vsyncId for transactions super(channel, looper, Choreographer.getSfInstance()); super(channel, looper, Choreographer.getInstance()); } public void onInputEvent(InputEvent event) { Loading