From 44f1f73079b7d5d5348104edb921f0585cff196e Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 6 Jul 2023 13:46:22 +0000 Subject: [PATCH] Sync transform of mirrored surface with the source If the transform of the recording Window container and the mirror surface are applied separately, the mirror surface may show inconsistent content, such as the mirror surface has updated to landscape but the source window is still in portrait. Bug: 290194103 Test: Start a screen record from QuickSetting. Rotate screen between portrait and landscape. Stop recording and check the video won't show half black at the beginning of rotation animation. Change-Id: Id50d598c5ca3b90b712c51935dc1f7440e4824d6 --- .../core/java/com/android/server/wm/ContentRecorder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java index 6a7e76411fee4..2ecbf8a25ed94 100644 --- a/services/core/java/com/android/server/wm/ContentRecorder.java +++ b/services/core/java/com/android/server/wm/ContentRecorder.java @@ -166,7 +166,7 @@ final class ContentRecorder implements WindowContainerListener { + "%d to new bounds %s and/or orientation %d.", mDisplayContent.getDisplayId(), recordedContentBounds, recordedContentOrientation); - updateMirroredSurface(mDisplayContent.mWmService.mTransactionFactory.get(), + updateMirroredSurface(mRecordedWindowContainer.getSyncTransaction(), recordedContentBounds, surfaceSize); } else { // If the surface removed, do nothing. We will handle this via onDisplayChanged @@ -325,6 +325,7 @@ final class ContentRecorder implements WindowContainerListener { .reparent(mDisplayContent.getOverlayLayer(), null); // Retrieve the size of the DisplayArea to mirror. updateMirroredSurface(transaction, mRecordedWindowContainer.getBounds(), surfaceSize); + transaction.apply(); // Notify the client about the visibility of the mirrored region, now that we have begun // capture. @@ -481,8 +482,7 @@ final class ContentRecorder implements WindowContainerListener { .setMatrix(mRecordedSurface, scale, 0 /* dtdx */, 0 /* dtdy */, scale) // Position needs to be updated when the mirrored DisplayArea has changed, since // the content will no longer be centered in the output surface. - .setPosition(mRecordedSurface, shiftedX /* x */, shiftedY /* y */) - .apply(); + .setPosition(mRecordedSurface, shiftedX /* x */, shiftedY /* y */); mLastRecordedBounds = new Rect(recordedContentBounds); // Request to notify the client about the resize. mMediaProjectionManager.notifyActiveProjectionCapturedContentResized(