Merge "Reduce flicker for split resizing" into tm-qpr-dev
This commit is contained in:
@@ -48,6 +48,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.android.launcher3.icons.IconProvider;
|
import com.android.launcher3.icons.IconProvider;
|
||||||
import com.android.wm.shell.R;
|
import com.android.wm.shell.R;
|
||||||
|
import com.android.wm.shell.common.ScreenshotUtils;
|
||||||
import com.android.wm.shell.common.SurfaceUtils;
|
import com.android.wm.shell.common.SurfaceUtils;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -74,10 +75,14 @@ public class SplitDecorManager extends WindowlessWindowManager {
|
|||||||
|
|
||||||
private boolean mShown;
|
private boolean mShown;
|
||||||
private boolean mIsResizing;
|
private boolean mIsResizing;
|
||||||
private Rect mBounds = new Rect();
|
private final Rect mBounds = new Rect();
|
||||||
|
private final Rect mResizingBounds = new Rect();
|
||||||
|
private final Rect mTempRect = new Rect();
|
||||||
private ValueAnimator mFadeAnimator;
|
private ValueAnimator mFadeAnimator;
|
||||||
|
|
||||||
private int mIconSize;
|
private int mIconSize;
|
||||||
|
private int mOffsetX;
|
||||||
|
private int mOffsetY;
|
||||||
|
|
||||||
public SplitDecorManager(Configuration configuration, IconProvider iconProvider,
|
public SplitDecorManager(Configuration configuration, IconProvider iconProvider,
|
||||||
SurfaceSession surfaceSession) {
|
SurfaceSession surfaceSession) {
|
||||||
@@ -158,7 +163,7 @@ public class SplitDecorManager extends WindowlessWindowManager {
|
|||||||
|
|
||||||
/** Showing resizing hint. */
|
/** Showing resizing hint. */
|
||||||
public void onResizing(ActivityManager.RunningTaskInfo resizingTask, Rect newBounds,
|
public void onResizing(ActivityManager.RunningTaskInfo resizingTask, Rect newBounds,
|
||||||
Rect sideBounds, SurfaceControl.Transaction t) {
|
Rect sideBounds, SurfaceControl.Transaction t, int offsetX, int offsetY) {
|
||||||
if (mResizingIconView == null) {
|
if (mResizingIconView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,6 +172,9 @@ public class SplitDecorManager extends WindowlessWindowManager {
|
|||||||
mIsResizing = true;
|
mIsResizing = true;
|
||||||
mBounds.set(newBounds);
|
mBounds.set(newBounds);
|
||||||
}
|
}
|
||||||
|
mResizingBounds.set(newBounds);
|
||||||
|
mOffsetX = offsetX;
|
||||||
|
mOffsetY = offsetY;
|
||||||
|
|
||||||
final boolean show =
|
final boolean show =
|
||||||
newBounds.width() > mBounds.width() || newBounds.height() > mBounds.height();
|
newBounds.width() > mBounds.width() || newBounds.height() > mBounds.height();
|
||||||
@@ -221,11 +229,37 @@ public class SplitDecorManager extends WindowlessWindowManager {
|
|||||||
|
|
||||||
/** Stops showing resizing hint. */
|
/** Stops showing resizing hint. */
|
||||||
public void onResized(SurfaceControl.Transaction t) {
|
public void onResized(SurfaceControl.Transaction t) {
|
||||||
|
if (!mShown && mIsResizing) {
|
||||||
|
mTempRect.set(mResizingBounds);
|
||||||
|
mTempRect.offsetTo(-mOffsetX, -mOffsetY);
|
||||||
|
final SurfaceControl screenshot = ScreenshotUtils.takeScreenshot(t,
|
||||||
|
mHostLeash, mTempRect, Integer.MAX_VALUE - 1);
|
||||||
|
|
||||||
|
final SurfaceControl.Transaction animT = new SurfaceControl.Transaction();
|
||||||
|
final ValueAnimator va = ValueAnimator.ofFloat(1, 0);
|
||||||
|
va.addUpdateListener(valueAnimator -> {
|
||||||
|
final float progress = (float) valueAnimator.getAnimatedValue();
|
||||||
|
animT.setAlpha(screenshot, progress);
|
||||||
|
animT.apply();
|
||||||
|
});
|
||||||
|
va.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(@androidx.annotation.NonNull Animator animation) {
|
||||||
|
animT.remove(screenshot);
|
||||||
|
animT.apply();
|
||||||
|
animT.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
va.start();
|
||||||
|
}
|
||||||
|
|
||||||
if (mResizingIconView == null) {
|
if (mResizingIconView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsResizing = false;
|
mIsResizing = false;
|
||||||
|
mOffsetX = 0;
|
||||||
|
mOffsetY = 0;
|
||||||
if (mFadeAnimator != null && mFadeAnimator.isRunning()) {
|
if (mFadeAnimator != null && mFadeAnimator.isRunning()) {
|
||||||
if (!mShown) {
|
if (!mShown) {
|
||||||
// If fade-out animation is running, just add release callback to it.
|
// If fade-out animation is running, just add release callback to it.
|
||||||
|
|||||||
@@ -448,7 +448,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
*/
|
*/
|
||||||
void updateDivideBounds(int position) {
|
void updateDivideBounds(int position) {
|
||||||
updateBounds(position);
|
updateBounds(position);
|
||||||
mSplitLayoutHandler.onLayoutSizeChanging(this);
|
mSplitLayoutHandler.onLayoutSizeChanging(this, mSurfaceEffectPolicy.mParallaxOffset.x,
|
||||||
|
mSurfaceEffectPolicy.mParallaxOffset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDividePosition(int position, boolean applyLayoutChange) {
|
void setDividePosition(int position, boolean applyLayoutChange) {
|
||||||
@@ -811,7 +812,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||||
* SurfaceControl, SurfaceControl, boolean)
|
* SurfaceControl, SurfaceControl, boolean)
|
||||||
*/
|
*/
|
||||||
void onLayoutSizeChanging(SplitLayout layout);
|
void onLayoutSizeChanging(SplitLayout layout, int offsetX, int offsetY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls when finish resizing the split bounds.
|
* Calls when finish resizing the split bounds.
|
||||||
|
|||||||
@@ -1633,14 +1633,14 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
public void onLayoutSizeChanging(SplitLayout layout, int offsetX, int offsetY) {
|
||||||
final SurfaceControl.Transaction t = mTransactionPool.acquire();
|
final SurfaceControl.Transaction t = mTransactionPool.acquire();
|
||||||
t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
|
t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
|
||||||
updateSurfaceBounds(layout, t, true /* applyResizingOffset */);
|
updateSurfaceBounds(layout, t, true /* applyResizingOffset */);
|
||||||
getMainStageBounds(mTempRect1);
|
getMainStageBounds(mTempRect1);
|
||||||
getSideStageBounds(mTempRect2);
|
getSideStageBounds(mTempRect2);
|
||||||
mMainStage.onResizing(mTempRect1, mTempRect2, t);
|
mMainStage.onResizing(mTempRect1, mTempRect2, t, offsetX, offsetY);
|
||||||
mSideStage.onResizing(mTempRect2, mTempRect1, t);
|
mSideStage.onResizing(mTempRect2, mTempRect1, t, offsetX, offsetY);
|
||||||
t.apply();
|
t.apply();
|
||||||
mTransactionPool.release(t);
|
mTransactionPool.release(t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,9 +288,11 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResizing(Rect newBounds, Rect sideBounds, SurfaceControl.Transaction t) {
|
void onResizing(Rect newBounds, Rect sideBounds, SurfaceControl.Transaction t, int offsetX,
|
||||||
|
int offsetY) {
|
||||||
if (mSplitDecorManager != null && mRootTaskInfo != null) {
|
if (mSplitDecorManager != null && mRootTaskInfo != null) {
|
||||||
mSplitDecorManager.onResizing(mRootTaskInfo, newBounds, sideBounds, t);
|
mSplitDecorManager.onResizing(mRootTaskInfo, newBounds, sideBounds, t, offsetX,
|
||||||
|
offsetY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ public class SplitLayoutTests extends ShellTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testUpdateDivideBounds() {
|
public void testUpdateDivideBounds() {
|
||||||
mSplitLayout.updateDivideBounds(anyInt());
|
mSplitLayout.updateDivideBounds(anyInt());
|
||||||
verify(mSplitLayoutHandler).onLayoutSizeChanging(any(SplitLayout.class));
|
verify(mSplitLayoutHandler).onLayoutSizeChanging(any(SplitLayout.class), anyInt(),
|
||||||
|
anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user