summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/policy/TransitionAnimation.java15
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java2
-rw-r--r--services/core/java/com/android/server/wm/Transition.java2
3 files changed, 17 insertions, 2 deletions
diff --git a/core/java/com/android/internal/policy/TransitionAnimation.java b/core/java/com/android/internal/policy/TransitionAnimation.java
index 2f09a5550fd4..66b2a9c8a424 100644
--- a/core/java/com/android/internal/policy/TransitionAnimation.java
+++ b/core/java/com/android/internal/policy/TransitionAnimation.java
@@ -1299,6 +1299,21 @@ public class TransitionAnimation {
== HardwareBuffer.USAGE_PROTECTED_CONTENT;
}
+ /**
+ * Returns the luminance in 0~1. The surface control is the source of the hardware buffer,
+ * which will be used if the buffer is protected from reading.
+ */
+ public static float getBorderLuma(@NonNull HardwareBuffer hwBuffer,
+ @NonNull ColorSpace colorSpace, @NonNull SurfaceControl sourceSurfaceControl) {
+ if (hasProtectedContent(hwBuffer)) {
+ // The buffer cannot be read. Capture another buffer which excludes protected content
+ // from the source surface.
+ return getBorderLuma(sourceSurfaceControl, hwBuffer.getWidth(), hwBuffer.getHeight());
+ }
+ // Use the existing buffer directly.
+ return getBorderLuma(hwBuffer, colorSpace);
+ }
+
/** Returns the luminance in 0~1. */
public static float getBorderLuma(SurfaceControl surfaceControl, int w, int h) {
final ScreenCapture.ScreenshotHardwareBuffer buffer =
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
index 9ce22094d56b..e196254628d0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
@@ -167,7 +167,7 @@ class ScreenRotationAnimation {
t.show(mScreenshotLayer);
if (!isCustomRotate()) {
mStartLuma = TransitionAnimation.getBorderLuma(hardwareBuffer,
- screenshotBuffer.getColorSpace());
+ screenshotBuffer.getColorSpace(), mSurfaceControl);
}
hardwareBuffer.close();
}
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 7ec31d5a8ecb..29a61e6d0071 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -3757,7 +3757,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
if (changeInfo.mRotation != wc.mDisplayContent.getRotation()) {
// This isn't cheap, so only do it for rotation change.
changeInfo.mSnapshotLuma = TransitionAnimation.getBorderLuma(
- buffer, screenshotBuffer.getColorSpace());
+ buffer, screenshotBuffer.getColorSpace(), wc.mSurfaceControl);
}
SurfaceControl.Transaction t = wc.mWmService.mTransactionFactory.get();
TransitionAnimation.configureScreenshotLayer(t, snapshotSurface, screenshotBuffer);