summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2019-06-23 13:35:41 -0700
committer Winson Chung <winsonc@google.com> 2019-06-24 16:03:13 -0700
commit357deda0ef48f54411a7d47f20deb8b677a6d22c (patch)
treecfaa2eabcc9b9c53f0ffa8940628a88f306146ee
parent18fff17455fd88fba239d0fa8b9bac7c2959633d (diff)
Skip redrawing the bars if the surface aspect ratio matches
- In this case, just scale the child window up to match the frame Bug: 135755182 Test: atest TaskSnapshotSurfaceTest Change-Id: I0d34d2f82aaf65459c60748b735cd01847ade411
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotSurface.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index a7760a865b20..c3762d6352b8 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -317,6 +317,11 @@ class TaskSnapshotSurface implements StartingSurface {
throw new IllegalStateException("mSurface does not hold a valid surface.");
}
final SurfaceSession session = new SurfaceSession();
+ // We consider nearly matched dimensions as there can be rounding errors and the user won't
+ // notice very minute differences from scaling one dimension more than the other
+ final boolean aspectRatioMismatch = Math.abs(
+ ((float) buffer.getWidth() / buffer.getHeight())
+ - ((float) mFrame.width() / mFrame.height())) > 0.01f;
// Keep a reference to it such that it doesn't get destroyed when finalized.
mChildSurfaceControl = new SurfaceControl.Builder(session)
@@ -328,16 +333,21 @@ class TaskSnapshotSurface implements StartingSurface {
Surface surface = new Surface();
surface.copyFrom(mChildSurfaceControl);
- // Clip off ugly navigation bar.
- final Rect crop = calculateSnapshotCrop();
- final Rect frame = calculateSnapshotFrame(crop);
+ final Rect frame;
SurfaceControl.openTransaction();
try {
// We can just show the surface here as it will still be hidden as the parent is
// still hidden.
mChildSurfaceControl.show();
- mChildSurfaceControl.setWindowCrop(crop);
- mChildSurfaceControl.setPosition(frame.left, frame.top);
+ if (aspectRatioMismatch) {
+ // Clip off ugly navigation bar.
+ final Rect crop = calculateSnapshotCrop();
+ frame = calculateSnapshotFrame(crop);
+ mChildSurfaceControl.setWindowCrop(crop);
+ mChildSurfaceControl.setPosition(frame.left, frame.top);
+ } else {
+ frame = null;
+ }
// Scale the mismatch dimensions to fill the task bounds
final float scale = 1 / mSnapshot.getScale();
@@ -348,10 +358,12 @@ class TaskSnapshotSurface implements StartingSurface {
surface.attachAndQueueBuffer(buffer);
surface.release();
- final Canvas c = mSurface.lockCanvas(null);
- drawBackgroundAndBars(c, frame);
- mSurface.unlockCanvasAndPost(c);
- mSurface.release();
+ if (aspectRatioMismatch) {
+ final Canvas c = mSurface.lockCanvas(null);
+ drawBackgroundAndBars(c, frame);
+ mSurface.unlockCanvasAndPost(c);
+ mSurface.release();
+ }
}
/**