Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90eefa68 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Use non-protected screenshot buffer to calculate animation color" into main

parents 68e865fa cc03f083
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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 =
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ class ScreenRotationAnimation {
                t.show(mScreenshotLayer);
                if (!isCustomRotate()) {
                    mStartLuma = TransitionAnimation.getBorderLuma(hardwareBuffer,
                            screenshotBuffer.getColorSpace());
                            screenshotBuffer.getColorSpace(), mSurfaceControl);
                }
                hardwareBuffer.close();
            }
+1 −1
Original line number Diff line number Diff line
@@ -3787,7 +3787,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);