Merge "Take snapshot directly during change transition" into qt-dev
am: ed057ab244
Change-Id: I3f127cf09d2ac6340095121a36795a59e1d5a94a
This commit is contained in:
@@ -1733,17 +1733,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
|
||||
return;
|
||||
}
|
||||
|
||||
if (mThumbnail == null && getTask() != null) {
|
||||
final TaskSnapshotController snapshotCtrl = mWmService.mTaskSnapshotController;
|
||||
final ArraySet<Task> tasks = new ArraySet<>();
|
||||
tasks.add(getTask());
|
||||
snapshotCtrl.snapshotTasks(tasks);
|
||||
snapshotCtrl.addSkipClosingAppSnapshotTasks(tasks);
|
||||
final ActivityManager.TaskSnapshot snapshot = snapshotCtrl.getSnapshot(
|
||||
getTask().mTaskId, getTask().mUserId, false /* restoreFromDisk */,
|
||||
false /* reducedResolution */);
|
||||
Task task = getTask();
|
||||
if (mThumbnail == null && task != null && !hasCommittedReparentToAnimationLeash()) {
|
||||
SurfaceControl.ScreenshotGraphicBuffer snapshot =
|
||||
mWmService.mTaskSnapshotController.createTaskSnapshot(
|
||||
task, 1 /* scaleFraction */);
|
||||
if (snapshot != null) {
|
||||
mThumbnail = new AppWindowThumbnail(t, this, snapshot.getSnapshot(),
|
||||
mThumbnail = new AppWindowThumbnail(t, this, snapshot.getGraphicBuffer(),
|
||||
true /* relative */);
|
||||
}
|
||||
}
|
||||
@@ -2858,7 +2854,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
|
||||
}
|
||||
}
|
||||
t.hide(mTransitChangeLeash);
|
||||
t.reparent(mTransitChangeLeash, null);
|
||||
t.remove(mTransitChangeLeash);
|
||||
mTransitChangeLeash = null;
|
||||
if (cancel) {
|
||||
onAnimationLeashLost(t);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT;
|
||||
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
|
||||
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.TaskSnapshot;
|
||||
@@ -241,6 +242,28 @@ class TaskSnapshotController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
SurfaceControl.ScreenshotGraphicBuffer createTaskSnapshot(@NonNull Task task,
|
||||
float scaleFraction) {
|
||||
if (task.getSurfaceControl() == null) {
|
||||
if (DEBUG_SCREENSHOT) {
|
||||
Slog.w(TAG_WM, "Failed to take screenshot. No surface control for " + task);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
task.getBounds(mTmpRect);
|
||||
mTmpRect.offsetTo(0, 0);
|
||||
final SurfaceControl.ScreenshotGraphicBuffer screenshotBuffer =
|
||||
SurfaceControl.captureLayers(
|
||||
task.getSurfaceControl().getHandle(), mTmpRect, scaleFraction);
|
||||
final GraphicBuffer buffer = screenshotBuffer != null ? screenshotBuffer.getGraphicBuffer()
|
||||
: null;
|
||||
if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
|
||||
return null;
|
||||
}
|
||||
return screenshotBuffer;
|
||||
}
|
||||
|
||||
@Nullable private TaskSnapshot snapshotTask(Task task) {
|
||||
if (!mService.mPolicy.isScreenOn()) {
|
||||
if (DEBUG_SCREENSHOT) {
|
||||
@@ -248,12 +271,6 @@ class TaskSnapshotController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (task.getSurfaceControl() == null) {
|
||||
if (DEBUG_SCREENSHOT) {
|
||||
Slog.w(TAG_WM, "Failed to take screenshot. No surface control for " + task);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppWindowToken appWindowToken = findAppTokenForSnapshot(task);
|
||||
if (appWindowToken == null) {
|
||||
@@ -271,8 +288,6 @@ class TaskSnapshotController {
|
||||
|
||||
final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic();
|
||||
final float scaleFraction = isLowRamDevice ? mPersister.getReducedScale() : 1f;
|
||||
task.getBounds(mTmpRect);
|
||||
mTmpRect.offsetTo(0, 0);
|
||||
|
||||
final WindowState mainWindow = appWindowToken.findMainWindow();
|
||||
if (mainWindow == null) {
|
||||
@@ -280,18 +295,17 @@ class TaskSnapshotController {
|
||||
return null;
|
||||
}
|
||||
final SurfaceControl.ScreenshotGraphicBuffer screenshotBuffer =
|
||||
SurfaceControl.captureLayers(
|
||||
task.getSurfaceControl().getHandle(), mTmpRect, scaleFraction);
|
||||
final GraphicBuffer buffer = screenshotBuffer != null ? screenshotBuffer.getGraphicBuffer()
|
||||
: null;
|
||||
if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
|
||||
createTaskSnapshot(task, scaleFraction);
|
||||
|
||||
if (screenshotBuffer == null) {
|
||||
if (DEBUG_SCREENSHOT) {
|
||||
Slog.w(TAG_WM, "Failed to take screenshot for " + task);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE;
|
||||
return new TaskSnapshot(appWindowToken.mActivityComponent, buffer,
|
||||
return new TaskSnapshot(
|
||||
appWindowToken.mActivityComponent, screenshotBuffer.getGraphicBuffer(),
|
||||
screenshotBuffer.getColorSpace(), appWindowToken.getConfiguration().orientation,
|
||||
getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */,
|
||||
true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
|
||||
|
||||
Reference in New Issue
Block a user