Merge "Skip redrawing the bars if the surface aspect ratio matches" into qt-dev
This commit is contained in:
@@ -317,6 +317,11 @@ class TaskSnapshotSurface implements StartingSurface {
|
|||||||
throw new IllegalStateException("mSurface does not hold a valid surface.");
|
throw new IllegalStateException("mSurface does not hold a valid surface.");
|
||||||
}
|
}
|
||||||
final SurfaceSession session = new SurfaceSession();
|
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.
|
// Keep a reference to it such that it doesn't get destroyed when finalized.
|
||||||
mChildSurfaceControl = new SurfaceControl.Builder(session)
|
mChildSurfaceControl = new SurfaceControl.Builder(session)
|
||||||
@@ -328,16 +333,21 @@ class TaskSnapshotSurface implements StartingSurface {
|
|||||||
Surface surface = new Surface();
|
Surface surface = new Surface();
|
||||||
surface.copyFrom(mChildSurfaceControl);
|
surface.copyFrom(mChildSurfaceControl);
|
||||||
|
|
||||||
// Clip off ugly navigation bar.
|
final Rect frame;
|
||||||
final Rect crop = calculateSnapshotCrop();
|
|
||||||
final Rect frame = calculateSnapshotFrame(crop);
|
|
||||||
SurfaceControl.openTransaction();
|
SurfaceControl.openTransaction();
|
||||||
try {
|
try {
|
||||||
// We can just show the surface here as it will still be hidden as the parent is
|
// We can just show the surface here as it will still be hidden as the parent is
|
||||||
// still hidden.
|
// still hidden.
|
||||||
mChildSurfaceControl.show();
|
mChildSurfaceControl.show();
|
||||||
|
if (aspectRatioMismatch) {
|
||||||
|
// Clip off ugly navigation bar.
|
||||||
|
final Rect crop = calculateSnapshotCrop();
|
||||||
|
frame = calculateSnapshotFrame(crop);
|
||||||
mChildSurfaceControl.setWindowCrop(crop);
|
mChildSurfaceControl.setWindowCrop(crop);
|
||||||
mChildSurfaceControl.setPosition(frame.left, frame.top);
|
mChildSurfaceControl.setPosition(frame.left, frame.top);
|
||||||
|
} else {
|
||||||
|
frame = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Scale the mismatch dimensions to fill the task bounds
|
// Scale the mismatch dimensions to fill the task bounds
|
||||||
final float scale = 1 / mSnapshot.getScale();
|
final float scale = 1 / mSnapshot.getScale();
|
||||||
@@ -348,11 +358,13 @@ class TaskSnapshotSurface implements StartingSurface {
|
|||||||
surface.attachAndQueueBuffer(buffer);
|
surface.attachAndQueueBuffer(buffer);
|
||||||
surface.release();
|
surface.release();
|
||||||
|
|
||||||
|
if (aspectRatioMismatch) {
|
||||||
final Canvas c = mSurface.lockCanvas(null);
|
final Canvas c = mSurface.lockCanvas(null);
|
||||||
drawBackgroundAndBars(c, frame);
|
drawBackgroundAndBars(c, frame);
|
||||||
mSurface.unlockCanvasAndPost(c);
|
mSurface.unlockCanvasAndPost(c);
|
||||||
mSurface.release();
|
mSurface.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the snapshot crop in snapshot coordinate space.
|
* Calculates the snapshot crop in snapshot coordinate space.
|
||||||
|
|||||||
Reference in New Issue
Block a user