From 0bfc89b9fedf376fb6a761e984b26d38fc7118ee Mon Sep 17 00:00:00 2001 From: chaviw Date: Tue, 16 Mar 2021 10:11:41 -0500 Subject: Use BLAST layer for screen rotation, surface freezer, and organizer Use a BLAST layer when taking a screenshot and using it for an animation. This is simple enough to do with BLAST instead of a buffer queue since we can just submit a single buffer and it will be presented. Added new methods in SurfaceControl to support sending a buffer and colorSpace. Test: ScreenRotation Test: Freeform animation Bug: 170765639 Change-Id: I72081ab833d76fac40667eed52cf16798112a5b6 --- core/java/android/view/SurfaceControl.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'core/java/android/view/SurfaceControl.java') diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 85a4f2035901..3e94b2881fe7 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -35,6 +35,7 @@ import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; import android.graphics.Bitmap; import android.graphics.ColorSpace; +import android.graphics.GraphicBuffer; import android.graphics.Matrix; import android.graphics.PixelFormat; import android.graphics.Point; @@ -189,6 +190,10 @@ public final class SurfaceControl implements Parcelable { long barrierObject, long frame); private static native void nativeReparent(long transactionObj, long nativeObject, long newParentNativeObject); + private static native void nativeSetBuffer(long transactionObj, long nativeObject, + GraphicBuffer buffer); + private static native void nativeSetColorSpace(long transactionObj, long nativeObject, + int colorSpace); private static native void nativeOverrideHdrTypes(IBinder displayToken, int[] modes); @@ -3365,6 +3370,31 @@ public final class SurfaceControl implements Parcelable { return this; } + /** + * Set a buffer for a SurfaceControl. This can only be used for SurfaceControls that were + * created as type {@link #FX_SURFACE_BLAST} + * + * @hide + */ + public Transaction setBuffer(SurfaceControl sc, GraphicBuffer buffer) { + checkPreconditions(sc); + nativeSetBuffer(mNativeObject, sc.mNativeObject, buffer); + return this; + } + + /** + * Set the color space for the SurfaceControl. The supported color spaces are SRGB + * and Display P3, other color spaces will be treated as SRGB. This can only be used for + * SurfaceControls that were created as type {@link #FX_SURFACE_BLAST} + * + * @hide + */ + public Transaction setColorSpace(SurfaceControl sc, ColorSpace colorSpace) { + checkPreconditions(sc); + nativeSetColorSpace(mNativeObject, sc.mNativeObject, colorSpace.getId()); + return this; + } + /** * Merge the other transaction into this transaction, clearing the * other transaction as if it had been applied. -- cgit v1.2.3