From 8e0fedbdb183bd9022f64232bb2515517c88e240 Mon Sep 17 00:00:00 2001 From: Arthur Hung Date: Thu, 10 Jun 2021 22:57:18 +0800 Subject: Update transform hint from relayout window (1/2) The transform hint is used to prevent allocating a buffer of a different size when a window is rotated. We return the fixed rotation transform and pass it to BLASTBufferQueue so the producer can choose to consume the hint and allocate the buffer with the same size. Bug: 188893403 Bug: 177029197 Test: atest WmTests Test: gfxbenchmark Test: atest libsurfaceflinger_unittest SurfaceFlinger_test Change-Id: If631984cf6b4b74ccdf19547fd6a63e759ed5732 --- core/java/android/view/SurfaceControl.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 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 f34cd8f9de50..4e66ceb76a60 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -233,6 +233,7 @@ public final class SurfaceControl implements Parcelable { private static native void nativeRemoveJankDataListener(long nativeListener); private static native long nativeCreateJankDataListenerWrapper(OnJankDataListener listener); private static native int nativeGetGPUContextPriority(); + private static native void nativeSetTransformHint(long nativeObject, int transformHint); @Nullable @GuardedBy("mLock") @@ -348,6 +349,8 @@ public final class SurfaceControl implements Parcelable { @GuardedBy("mLock") private int mHeight; + private int mTransformHint; + private WeakReference mLocalOwnerView; static GlobalTransactionWrapper sGlobalTransaction; @@ -605,6 +608,7 @@ public final class SurfaceControl implements Parcelable { mName = other.mName; mWidth = other.mWidth; mHeight = other.mHeight; + mTransformHint = other.mTransformHint; mLocalOwnerView = other.mLocalOwnerView; assignNativeObject(nativeCopyFromSurfaceControl(other.mNativeObject), callsite); } @@ -1467,6 +1471,7 @@ public final class SurfaceControl implements Parcelable { mName = in.readString8(); mWidth = in.readInt(); mHeight = in.readInt(); + mTransformHint = in.readInt(); long object = 0; if (in.readInt() != 0) { @@ -1485,6 +1490,7 @@ public final class SurfaceControl implements Parcelable { dest.writeString8(mName); dest.writeInt(mWidth); dest.writeInt(mHeight); + dest.writeInt(mTransformHint); if (mNativeObject == 0) { dest.writeInt(0); } else { @@ -3602,4 +3608,27 @@ public final class SurfaceControl implements Parcelable { mHeight = h; nativeUpdateDefaultBufferSize(mNativeObject, w, h); } + + /** + * @hide + */ + public int getTransformHint() { + return mTransformHint; + } + + /** + * Update the transform hint of current SurfaceControl. Only affect if type is + * {@link #FX_SURFACE_BLAST} + * + * The transform hint is used to prevent allocating a buffer of different size when a + * layer is rotated. The producer can choose to consume the hint and allocate the buffer + * with the same size. + * @hide + */ + public void setTransformHint(@Surface.Rotation int transformHint) { + if (mTransformHint != transformHint) { + mTransformHint = transformHint; + nativeSetTransformHint(mNativeObject, transformHint); + } + } } -- cgit v1.2.3