Account for early display rotation for gestures with shell transitions

- Ensure the events are in a consistent coordinate frame from the start
  of the gesture
- Now that the display rotation happens at the start of the gesture, we
  need to use the rotation at the start of the gesture in some cases
- Use the pre-rotation screenspace bounds when calculating the thumbnail
  matrix

Bug: 197687032
Test: Enable shell transitions and swipe up from a landscape app into
      force-portrait Launcher

Change-Id: I61ebe9947a55937c59a47336aa92561e7e3e8b66
This commit is contained in:
Winson Chung
2021-12-03 05:20:24 +00:00
parent eef3ed6628
commit f12e7dbab3
5 changed files with 43 additions and 7 deletions
@@ -66,7 +66,7 @@ public class OrientationRectF extends RectF {
return applyTransform(event, deltaRotation(mRotation, currentRotation), forceTransform);
}
private boolean applyTransform(MotionEvent event, int deltaRotation, boolean forceTransform) {
public boolean applyTransform(MotionEvent event, int deltaRotation, boolean forceTransform) {
mTmpMatrix.reset();
postDisplayRotation(deltaRotation, mHeight, mWidth, mTmpMatrix);
if (forceTransform) {
@@ -22,6 +22,7 @@ import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.states.RotationHelper.deltaRotation;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.RectF;
@@ -358,7 +359,18 @@ class OrientationTouchTransformer {
if (mLastRectTouched == null) {
return;
}
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, true);
if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
if (event.getSurfaceRotation() != mActiveTouchRotation) {
// With Shell transitions, we should rotated to the orientation at the start
// of the gesture not the current display rotation which will happen early
mLastRectTouched.applyTransform(event,
deltaRotation(event.getSurfaceRotation(), mActiveTouchRotation),
true);
}
} else {
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation,
true);
}
break;
}
case ACTION_CANCEL:
@@ -366,7 +378,18 @@ class OrientationTouchTransformer {
if (mLastRectTouched == null) {
return;
}
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, true);
if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
if (event.getSurfaceRotation() != mActiveTouchRotation) {
// With Shell transitions, we should rotated to the orientation at the start
// of the gesture not the current display rotation which will happen early
mLastRectTouched.applyTransform(event,
deltaRotation(event.getSurfaceRotation(), mActiveTouchRotation),
true);
}
} else {
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation,
true);
}
mLastRectTouched = null;
break;
}
@@ -117,8 +117,8 @@ public class RemoteTargetGluer {
secondaryTaskTarget = targets.findTask(splitIds[1]);
mStagedSplitBounds = new StagedSplitBounds(
primaryTaskTarget.screenSpaceBounds,
secondaryTaskTarget.screenSpaceBounds, splitIds[0], splitIds[1]);
primaryTaskTarget.startScreenSpaceBounds,
secondaryTaskTarget.startScreenSpaceBounds, splitIds[0], splitIds[1]);
mRemoteTargetHandles[0].mTransformParams.setTargetSet(
createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets));
mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget,
@@ -52,6 +52,7 @@ import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.SettingsCache;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.views.TaskView;
import java.lang.annotation.Retention;
@@ -340,6 +341,11 @@ public class RecentsOrientedState implements
@SurfaceRotation
public int getDisplayRotation() {
if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
// When shell transitions are enabled, both the display and activity rotations should
// be the same once the gesture starts
return mRecentsActivityRotation;
}
return mDisplayRotation;
}
@@ -44,6 +44,7 @@ import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitBounds;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.views.TaskThumbnailView.PreviewPositionHelper;
import com.android.quickstep.views.TaskView.FullscreenDrawParams;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -170,7 +171,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
* Sets the targets which the simulator will control
*/
public void setPreview(RemoteAnimationTargetCompat runningTarget) {
setPreviewBounds(runningTarget.screenSpaceBounds, runningTarget.contentInsets);
setPreviewBounds(runningTarget.startScreenSpaceBounds, runningTarget.contentInsets);
}
/**
@@ -304,7 +305,13 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
mOrientationStateId = mOrientationState.getStateId();
getFullScreenScale();
mThumbnailData.rotation = mOrientationState.getDisplayRotation();
if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
// With shell transitions, the display is rotated early so we need to actually use
// the rotation when the gesture starts
mThumbnailData.rotation = mOrientationState.getTouchRotation();
} else {
mThumbnailData.rotation = mOrientationState.getDisplayRotation();
}
// mIsRecentsRtl is the inverse of TaskView RTL.
boolean isRtlEnabled = !mIsRecentsRtl;