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