Merge "Support display resize animation for shell transition" into tm-qpr-dev
This commit is contained in:
@@ -34,7 +34,6 @@ import android.annotation.NonNull;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorSpace;
|
import android.graphics.ColorSpace;
|
||||||
import android.graphics.GraphicBuffer;
|
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.hardware.HardwareBuffer;
|
import android.hardware.HardwareBuffer;
|
||||||
@@ -85,8 +84,6 @@ class ScreenRotationAnimation {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final TransactionPool mTransactionPool;
|
private final TransactionPool mTransactionPool;
|
||||||
private final float[] mTmpFloats = new float[9];
|
private final float[] mTmpFloats = new float[9];
|
||||||
// Complete transformations being applied.
|
|
||||||
private final Matrix mSnapshotInitialMatrix = new Matrix();
|
|
||||||
/** The leash of display. */
|
/** The leash of display. */
|
||||||
private final SurfaceControl mSurfaceControl;
|
private final SurfaceControl mSurfaceControl;
|
||||||
private final Rect mStartBounds = new Rect();
|
private final Rect mStartBounds = new Rect();
|
||||||
@@ -169,16 +166,15 @@ class ScreenRotationAnimation {
|
|||||||
.setName("RotationLayer")
|
.setName("RotationLayer")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
GraphicBuffer buffer = GraphicBuffer.createFromHardwareBuffer(
|
|
||||||
screenshotBuffer.getHardwareBuffer());
|
|
||||||
|
|
||||||
t.setLayer(mAnimLeash, SCREEN_FREEZE_LAYER_BASE);
|
t.setLayer(mAnimLeash, SCREEN_FREEZE_LAYER_BASE);
|
||||||
t.setPosition(mAnimLeash, 0, 0);
|
t.setPosition(mAnimLeash, 0, 0);
|
||||||
t.setAlpha(mAnimLeash, 1);
|
t.setAlpha(mAnimLeash, 1);
|
||||||
t.show(mAnimLeash);
|
t.show(mAnimLeash);
|
||||||
|
|
||||||
t.setBuffer(mScreenshotLayer, buffer);
|
final ColorSpace colorSpace = screenshotBuffer.getColorSpace();
|
||||||
t.setColorSpace(mScreenshotLayer, screenshotBuffer.getColorSpace());
|
final HardwareBuffer hardwareBuffer = screenshotBuffer.getHardwareBuffer();
|
||||||
|
t.setDataSpace(mScreenshotLayer, colorSpace.getDataSpace());
|
||||||
|
t.setBuffer(mScreenshotLayer, hardwareBuffer);
|
||||||
t.show(mScreenshotLayer);
|
t.show(mScreenshotLayer);
|
||||||
|
|
||||||
if (!isCustomRotate()) {
|
if (!isCustomRotate()) {
|
||||||
@@ -189,8 +185,7 @@ class ScreenRotationAnimation {
|
|||||||
.setName("BackColorSurface")
|
.setName("BackColorSurface")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HardwareBuffer hardwareBuffer = screenshotBuffer.getHardwareBuffer();
|
mStartLuma = getMedianBorderLuma(hardwareBuffer, colorSpace);
|
||||||
mStartLuma = getMedianBorderLuma(hardwareBuffer, screenshotBuffer.getColorSpace());
|
|
||||||
|
|
||||||
t.setLayer(mBackColorSurface, -1);
|
t.setLayer(mBackColorSurface, -1);
|
||||||
t.setColor(mBackColorSurface, new float[]{mStartLuma, mStartLuma, mStartLuma});
|
t.setColor(mBackColorSurface, new float[]{mStartLuma, mStartLuma, mStartLuma});
|
||||||
@@ -202,7 +197,7 @@ class ScreenRotationAnimation {
|
|||||||
Slog.w(TAG, "Unable to allocate freeze surface", e);
|
Slog.w(TAG, "Unable to allocate freeze surface", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRotation(t);
|
setScreenshotTransform(t);
|
||||||
t.apply();
|
t.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,19 +205,36 @@ class ScreenRotationAnimation {
|
|||||||
return mAnimHint == ROTATION_ANIMATION_CROSSFADE || mAnimHint == ROTATION_ANIMATION_JUMPCUT;
|
return mAnimHint == ROTATION_ANIMATION_CROSSFADE || mAnimHint == ROTATION_ANIMATION_JUMPCUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRotation(SurfaceControl.Transaction t) {
|
private void setScreenshotTransform(SurfaceControl.Transaction t) {
|
||||||
// Compute the transformation matrix that must be applied
|
|
||||||
// to the snapshot to make it stay in the same original position
|
|
||||||
// with the current screen rotation.
|
|
||||||
int delta = deltaRotation(mEndRotation, mStartRotation);
|
|
||||||
createRotationMatrix(delta, mStartWidth, mStartHeight, mSnapshotInitialMatrix);
|
|
||||||
setRotationTransform(t, mSnapshotInitialMatrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRotationTransform(SurfaceControl.Transaction t, Matrix matrix) {
|
|
||||||
if (mScreenshotLayer == null) {
|
if (mScreenshotLayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final Matrix matrix = new Matrix();
|
||||||
|
final int delta = deltaRotation(mEndRotation, mStartRotation);
|
||||||
|
if (delta != 0) {
|
||||||
|
// Compute the transformation matrix that must be applied to the snapshot to make it
|
||||||
|
// stay in the same original position with the current screen rotation.
|
||||||
|
switch (delta) {
|
||||||
|
case Surface.ROTATION_90:
|
||||||
|
matrix.setRotate(90, 0, 0);
|
||||||
|
matrix.postTranslate(mStartHeight, 0);
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_180:
|
||||||
|
matrix.setRotate(180, 0, 0);
|
||||||
|
matrix.postTranslate(mStartWidth, mStartHeight);
|
||||||
|
break;
|
||||||
|
case Surface.ROTATION_270:
|
||||||
|
matrix.setRotate(270, 0, 0);
|
||||||
|
matrix.postTranslate(0, mStartWidth);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if ((mEndWidth > mStartWidth) == (mEndHeight > mStartHeight)
|
||||||
|
&& (mEndWidth != mStartWidth || mEndHeight != mStartHeight)) {
|
||||||
|
// Display resizes without rotation change.
|
||||||
|
final float scale = Math.max((float) mEndWidth / mStartHeight,
|
||||||
|
(float) mEndHeight / mStartHeight);
|
||||||
|
matrix.setScale(scale, scale);
|
||||||
|
}
|
||||||
matrix.getValues(mTmpFloats);
|
matrix.getValues(mTmpFloats);
|
||||||
float x = mTmpFloats[Matrix.MTRANS_X];
|
float x = mTmpFloats[Matrix.MTRANS_X];
|
||||||
float y = mTmpFloats[Matrix.MTRANS_Y];
|
float y = mTmpFloats[Matrix.MTRANS_Y];
|
||||||
@@ -230,9 +242,7 @@ class ScreenRotationAnimation {
|
|||||||
t.setMatrix(mScreenshotLayer,
|
t.setMatrix(mScreenshotLayer,
|
||||||
mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
|
mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
|
||||||
mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
|
mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
|
||||||
|
|
||||||
t.setAlpha(mScreenshotLayer, (float) 1.0);
|
t.setAlpha(mScreenshotLayer, (float) 1.0);
|
||||||
t.show(mScreenshotLayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -486,27 +496,6 @@ class ScreenRotationAnimation {
|
|||||||
return getMedianBorderLuma(buffer.getHardwareBuffer(), buffer.getColorSpace());
|
return getMedianBorderLuma(buffer.getHardwareBuffer(), buffer.getColorSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createRotationMatrix(int rotation, int width, int height,
|
|
||||||
Matrix outMatrix) {
|
|
||||||
switch (rotation) {
|
|
||||||
case Surface.ROTATION_0:
|
|
||||||
outMatrix.reset();
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_90:
|
|
||||||
outMatrix.setRotate(90, 0, 0);
|
|
||||||
outMatrix.postTranslate(height, 0);
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_180:
|
|
||||||
outMatrix.setRotate(180, 0, 0);
|
|
||||||
outMatrix.postTranslate(width, height);
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_270:
|
|
||||||
outMatrix.setRotate(270, 0, 0);
|
|
||||||
outMatrix.postTranslate(0, width);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void applyColor(int startColor, int endColor, float[] rgbFloat,
|
private static void applyColor(int startColor, int endColor, float[] rgbFloat,
|
||||||
float fraction, SurfaceControl surface, SurfaceControl.Transaction t) {
|
float fraction, SurfaceControl surface, SurfaceControl.Transaction t) {
|
||||||
final int color = (Integer) ArgbEvaluator.getInstance().evaluate(fraction, startColor,
|
final int color = (Integer) ArgbEvaluator.getInstance().evaluate(fraction, startColor,
|
||||||
|
|||||||
@@ -212,10 +212,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
// Map from the PID to the top most app which has a focused window of the process.
|
// Map from the PID to the top most app which has a focused window of the process.
|
||||||
final ArrayMap<Integer, ActivityRecord> mTopFocusedAppByProcess = new ArrayMap<>();
|
final ArrayMap<Integer, ActivityRecord> mTopFocusedAppByProcess = new ArrayMap<>();
|
||||||
|
|
||||||
// Only a separate transaction until we separate the apply surface changes
|
|
||||||
// transaction from the global transaction.
|
|
||||||
private final SurfaceControl.Transaction mDisplayTransaction;
|
|
||||||
|
|
||||||
// The tag for the token to put root tasks on the displays to sleep.
|
// The tag for the token to put root tasks on the displays to sleep.
|
||||||
private static final String DISPLAY_OFF_SLEEP_TOKEN_TAG = "Display-off";
|
private static final String DISPLAY_OFF_SLEEP_TOKEN_TAG = "Display-off";
|
||||||
|
|
||||||
@@ -460,7 +456,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
|
|
||||||
RootWindowContainer(WindowManagerService service) {
|
RootWindowContainer(WindowManagerService service) {
|
||||||
super(service);
|
super(service);
|
||||||
mDisplayTransaction = service.mTransactionFactory.get();
|
|
||||||
mHandler = new MyHandler(service.mH.getLooper());
|
mHandler = new MyHandler(service.mH.getLooper());
|
||||||
mService = service.mAtmService;
|
mService = service.mAtmService;
|
||||||
mTaskSupervisor = mService.mTaskSupervisor;
|
mTaskSupervisor = mService.mTaskSupervisor;
|
||||||
@@ -1005,19 +1000,20 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
mObscuringWindow = null;
|
mObscuringWindow = null;
|
||||||
|
|
||||||
// TODO(multi-display): Support these features on secondary screens.
|
// TODO(multi-display): Support these features on secondary screens.
|
||||||
final DisplayContent defaultDc = mWmService.getDefaultDisplayContentLocked();
|
final DisplayContent defaultDc = mDefaultDisplay;
|
||||||
final DisplayInfo defaultInfo = defaultDc.getDisplayInfo();
|
final DisplayInfo defaultInfo = defaultDc.getDisplayInfo();
|
||||||
final int defaultDw = defaultInfo.logicalWidth;
|
final int defaultDw = defaultInfo.logicalWidth;
|
||||||
final int defaultDh = defaultInfo.logicalHeight;
|
final int defaultDh = defaultInfo.logicalHeight;
|
||||||
|
final SurfaceControl.Transaction t = defaultDc.getSyncTransaction();
|
||||||
if (mWmService.mWatermark != null) {
|
if (mWmService.mWatermark != null) {
|
||||||
mWmService.mWatermark.positionSurface(defaultDw, defaultDh, mDisplayTransaction);
|
mWmService.mWatermark.positionSurface(defaultDw, defaultDh, t);
|
||||||
}
|
}
|
||||||
if (mWmService.mStrictModeFlash != null) {
|
if (mWmService.mStrictModeFlash != null) {
|
||||||
mWmService.mStrictModeFlash.positionSurface(defaultDw, defaultDh, mDisplayTransaction);
|
mWmService.mStrictModeFlash.positionSurface(defaultDw, defaultDh, t);
|
||||||
}
|
}
|
||||||
if (mWmService.mEmulatorDisplayOverlay != null) {
|
if (mWmService.mEmulatorDisplayOverlay != null) {
|
||||||
mWmService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
|
mWmService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
|
||||||
mWmService.getDefaultDisplayRotation(), mDisplayTransaction);
|
defaultDc.getRotation(), t);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int count = mChildren.size();
|
final int count = mChildren.size();
|
||||||
@@ -1028,8 +1024,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
|
|
||||||
// Give the display manager a chance to adjust properties like display rotation if it needs
|
// Give the display manager a chance to adjust properties like display rotation if it needs
|
||||||
// to.
|
// to.
|
||||||
mWmService.mDisplayManagerInternal.performTraversal(mDisplayTransaction);
|
mWmService.mDisplayManagerInternal.performTraversal(t);
|
||||||
SurfaceControl.mergeToGlobalTransaction(mDisplayTransaction);
|
if (t != defaultDc.mSyncTransaction) {
|
||||||
|
SurfaceControl.mergeToGlobalTransaction(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user