summaryrefslogtreecommitdiff
path: root/core/java/android/view/SurfaceControl.java
diff options
context:
space:
mode:
authorArthur Hung <arthurhung@google.com>2021-06-10 22:57:18 +0800
committerArthur Hung <arthurhung@google.com>2021-06-17 12:21:45 +0000
commit8e0fedbdb183bd9022f64232bb2515517c88e240 (patch)
tree6e6559dbe4e9d38a9f3885bf3e6af1fba163e044 /core/java/android/view/SurfaceControl.java
parent014c064431a3accda9115c118103b6773d1b65de (diff)
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
Diffstat (limited to 'core/java/android/view/SurfaceControl.java')
-rw-r--r--core/java/android/view/SurfaceControl.java29
1 files changed, 29 insertions, 0 deletions
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<View> 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);
+ }
+ }
}