Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/android/view/SurfaceControl.Transaction#inhconstants) \| [Fields](https://developer.android.com/reference/android/view/SurfaceControl.Transaction#lfields) \| [Ctors](https://developer.android.com/reference/android/view/SurfaceControl.Transaction#pubctors) \| [Methods](https://developer.android.com/reference/android/view/SurfaceControl.Transaction#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/SurfaceControl.Transaction#inhmethods)

# SurfaceControl.Transaction

*** ** * ** ***

` public static class SurfaceControl.Transaction `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/io/Closeable, https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.SurfaceControl.Transaction |

<br />

*** ** * ** ***

An atomic set of changes to a set of SurfaceControl.

## Summary

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/view/SurfaceControl.Transaction>` | `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#CREATOR` <br /> |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#Transaction()() ` Open a new transaction object. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#addTransactionCommittedListener(java.util.concurrent.Executor,%20android.view.SurfaceControl.TransactionCommittedListener)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/view/SurfaceControl.TransactionCommittedListener listener) ` Request to add a `https://developer.android.com/reference/android/view/SurfaceControl.TransactionCommittedListener`. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#addTransactionCompletedListener(java.util.concurrent.Executor,%20java.util.function.Consumer<android.view.SurfaceControl.TransactionStats>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/view/SurfaceControl.TransactionStats> listener) ` Request to add a TransactionCompletedListener. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#apply()() ` Apply the transaction, clearing its state, and making it usable as a new transaction. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#clearFrameRate(android.view.SurfaceControl)(https://developer.android.com/reference/android/view/SurfaceControl sc) ` Clears the frame rate which was set for the surface `https://developer.android.com/reference/android/view/SurfaceControl`. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#clearTrustedPresentationCallback(android.view.SurfaceControl)(https://developer.android.com/reference/android/view/SurfaceControl sc) ` *This method was deprecated in API level 35. Use `https://developer.android.com/reference/android/view/WindowManager#unregisterTrustedPresentationListener(java.util.function.Consumer<java.lang.Boolean>)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#close()() ` Release the native transaction object, without applying it. |
| ` int` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#merge(android.view.SurfaceControl.Transaction)(https://developer.android.com/reference/android/view/SurfaceControl.Transaction other) ` Merge the other transaction into this transaction, clearing the other transaction as if it had been applied. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#reparent(android.view.SurfaceControl,%20android.view.SurfaceControl)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/view/SurfaceControl newParent) ` Re-parents a given layer to a new parent. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setAlpha(android.view.SurfaceControl,%20float)(https://developer.android.com/reference/android/view/SurfaceControl sc, float alpha) ` Set the alpha for a given surface. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer,%20android.hardware.SyncFence)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/hardware/HardwareBuffer buffer, https://developer.android.com/reference/android/hardware/SyncFence fence) ` Updates the HardwareBuffer displayed for the SurfaceControl. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/hardware/HardwareBuffer buffer) ` Updates the HardwareBuffer displayed for the SurfaceControl. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer,%20android.hardware.SyncFence,%20java.util.function.Consumer<android.hardware.SyncFence>)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/hardware/HardwareBuffer buffer, https://developer.android.com/reference/android/hardware/SyncFence fence, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/hardware/SyncFence> releaseCallback) ` Updates the HardwareBuffer displayed for the SurfaceControl. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBufferSize(android.view.SurfaceControl,%20int,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, int w, int h) ` Set the default buffer size for the SurfaceControl, if there is a `https://developer.android.com/reference/android/view/Surface` associated with the control, then this will be the default size for buffers dequeued from it. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBufferTransform(android.view.SurfaceControl,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, int transform) ` Sets the buffer transform that should be applied to the current buffer. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setContentPriority(android.view.SurfaceControl,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, int priority) ` Sets the importance the layer's contents has to the app's user experience. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setCrop(android.view.SurfaceControl,%20android.graphics.Rect)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/graphics/Rect crop) ` Bounds the surface and its children to the bounds specified. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setDamageRegion(android.view.SurfaceControl,%20android.graphics.Region)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/graphics/Region region) ` Updates the region for the content on this surface updated in this transaction. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setDataSpace(android.view.SurfaceControl,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, int dataspace) ` Set the dataspace for the SurfaceControl. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setDesiredHdrHeadroom(android.view.SurfaceControl,%20float)(https://developer.android.com/reference/android/view/SurfaceControl sc, float desiredRatio) ` Sets the desired HDR headroom for the layer. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setDesiredPresentTimeNanos(long)(long desiredPresentTimeNanos) ` Specifies a desiredPresentTimeNanos for the transaction. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)(https://developer.android.com/reference/android/view/SurfaceControl sc, float currentBufferRatio, float desiredRatio) ` Sets the desired extended range brightness for the layer. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameRate(android.view.SurfaceControl,%20float,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, float frameRate, int compatibility) ` Sets the intended frame rate for this surface. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameRate(android.view.SurfaceControl,%20float,%20int,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, float frameRate, int compatibility, int changeFrameRateStrategy) ` Sets the intended frame rate for the surface `https://developer.android.com/reference/android/view/SurfaceControl`. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameTimeline(long)(long vsyncId) ` Sets the frame timeline to use in SurfaceFlinger. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setGeometry(android.view.SurfaceControl,%20android.graphics.Rect,%20android.graphics.Rect,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/graphics/Rect sourceCrop, https://developer.android.com/reference/android/graphics/Rect destFrame, int orientation) ` *This method was deprecated in API level 33. Use `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setCrop(android.view.SurfaceControl,%20android.graphics.Rect)`, `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBufferTransform(android.view.SurfaceControl,%20int)`, `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setPosition(android.view.SurfaceControl,%20float,%20float)` and `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setScale(android.view.SurfaceControl,%20float,%20float)` instead.* |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setLayer(android.view.SurfaceControl,%20int)(https://developer.android.com/reference/android/view/SurfaceControl sc, int z) ` Set the Z-order for a given SurfaceControl, relative to it's siblings. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setLuts(android.view.SurfaceControl,%20android.hardware.DisplayLuts)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/hardware/DisplayLuts displayLuts) ` Sets the Luts for the layer. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setOpaque(android.view.SurfaceControl,%20boolean)(https://developer.android.com/reference/android/view/SurfaceControl sc, boolean isOpaque) ` Indicates whether the surface must be considered opaque, even if its pixel format is set to translucent. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setPosition(android.view.SurfaceControl,%20float,%20float)(https://developer.android.com/reference/android/view/SurfaceControl sc, float x, float y) ` Sets the SurfaceControl to the specified position relative to the parent SurfaceControl |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setScale(android.view.SurfaceControl,%20float,%20float)(https://developer.android.com/reference/android/view/SurfaceControl sc, float scaleX, float scaleY) ` Sets the SurfaceControl to the specified scale with (0, 0) as the center point of the scale. |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setTrustedPresentationCallback(android.view.SurfaceControl,%20android.view.SurfaceControl.TrustedPresentationThresholds,%20java.util.concurrent.Executor,%20java.util.function.Consumer<java.lang.Boolean>)(https://developer.android.com/reference/android/view/SurfaceControl sc, https://developer.android.com/reference/android/view/SurfaceControl.TrustedPresentationThresholds thresholds, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/java/lang/Boolean> listener) ` *This method was deprecated in API level 35. Use `https://developer.android.com/reference/android/view/WindowManager#registerTrustedPresentationListener(android.os.IBinder,%20android.window.TrustedPresentationThresholds,%20java.util.concurrent.Executor,%20java.util.function.Consumer<java.lang.Boolean>)` instead.* |
| ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setVisibility(android.view.SurfaceControl,%20boolean)(https://developer.android.com/reference/android/view/SurfaceControl sc, boolean visible) ` Toggle the visibility of a given Layer and it's sub-tree. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControl.Transaction#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Writes the transaction to parcel, clearing the transaction as if it had been applied so it can be used to store future transactions. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/io/Closeable ` ` abstract void` ` https://developer.android.com/reference/java/io/Closeable#close()() `

Closes this stream and releases any system resources associated with it.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Fields

### CREATOR

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<SurfaceControl.Transaction> CREATOR
```

<br />

<br />

## Public constructors

### Transaction

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Transaction ()
```

Open a new transaction object. The transaction may be filed with commands to manipulate `https://developer.android.com/reference/android/view/SurfaceControl` instances, and then applied atomically with `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#apply()`. Eventually the user should invoke `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#close()`, when the object is no longer required. Note however that re-using a transaction after a call to apply is allowed as a convenience.

<br />

## Public methods

### addTransactionCommittedListener

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction addTransactionCommittedListener (Executor executor, 
                SurfaceControl.TransactionCommittedListener listener)
```

Request to add a `https://developer.android.com/reference/android/view/SurfaceControl.TransactionCommittedListener`. The callback is invoked when transaction is applied and the updates are ready to be presented. This callback does not mean buffers have been released! It simply means that any new transactions applied will not overwrite the transaction for which we are receiving a callback and instead will be included in the next frame. If you are trying to avoid dropping frames (overwriting transactions), and unable to use timestamps (Which provide a more efficient solution), then this method provides a method to pace your transaction application. The listener is invoked once the transaction is applied, and never again. Multiple listeners can be added to the same transaction, however the order the listeners will be called is not guaranteed.

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor that the callback should be invoked on. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `listener` | `SurfaceControl.TransactionCommittedListener`: The callback that will be invoked when the transaction has been committed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

### addTransactionCompletedListener

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction addTransactionCompletedListener (Executor executor, 
                Consumer<SurfaceControl.TransactionStats> listener)
```

Request to add a TransactionCompletedListener. The listener is invoked when transaction is presented, and never again. Multiple listeners can be added to the same transaction, however the order the listeners will be called is not guaranteed.

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor that the callback should be invoked on. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `listener` | `Consumer`: The callback that will be invoked when the transaction has been completed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

### apply

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void apply ()
```

Apply the transaction, clearing its state, and making it usable as a new transaction. This method will also increment the transaction ID for debugging purposes.

<br />

### clearFrameRate

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction clearFrameRate (SurfaceControl sc)
```

Clears the frame rate which was set for the surface `https://developer.android.com/reference/android/view/SurfaceControl`.

This is equivalent to calling `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameRate(android.view.SurfaceControl,%20float,%20int,%20int)` using `0` for `frameRate`.

Note that this only has an effect for surfaces presented on the display. If this surface is consumed by something other than the system compositor, e.g. a media codec, this call has no effect.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to clear the frame rate of. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction object. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameRate(android.view.SurfaceControl,%20float,%20int)`

### clearTrustedPresentationCallback

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction clearTrustedPresentationCallback (SurfaceControl sc)
```

<br />

**This method was deprecated in API level 35.**   

Use `https://developer.android.com/reference/android/view/WindowManager#unregisterTrustedPresentationListener(java.util.function.Consumer<java.lang.Boolean>)` instead.

Clears the callback for a specific `https://developer.android.com/reference/android/view/SurfaceControl`

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl that the callback should be cleared from. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction. This value cannot be `null`. <br /> |

### close

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Release the native transaction object, without applying it.

<br />

### describeContents

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`, the return value of this method must include the `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### merge

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction merge (SurfaceControl.Transaction other)
```

Merge the other transaction into this transaction, clearing the other transaction as if it had been applied.

<br />

| Parameters ||
|---|---|
| `other` | `SurfaceControl.Transaction`: The transaction to merge in to this one. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction. This value cannot be `null`. <br /> |

### reparent

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction reparent (SurfaceControl sc, 
                SurfaceControl newParent)
```

Re-parents a given layer to a new parent. Children inherit transform (position, scaling) crop, visibility, and Z-ordering from their parents, as if the children were pixels within the parent Surface.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to reparent. This value cannot be `null`. <br /> |
| `newParent` | `SurfaceControl`: The new parent for the given control. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This Transaction. This value cannot be `null`. <br /> |

### setAlpha

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setAlpha (SurfaceControl sc, 
                float alpha)
```

Set the alpha for a given surface. If the alpha is non-zero the SurfaceControl will be blended with the Surfaces under it according to the specified ratio.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The given SurfaceControl. This value cannot be `null`. <br /> |
| `alpha` | `float`: The alpha to set. Value is between 0.0f and 1.0f inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

### setBuffer

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setBuffer (SurfaceControl sc, 
                HardwareBuffer buffer, 
                SyncFence fence)
```

Updates the HardwareBuffer displayed for the SurfaceControl. Note that the buffer must be allocated with `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` as well as `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` as the surface control might be composited using either an overlay or using the GPU. A presentation fence may be passed to improve performance by allowing the buffer to complete rendering while it is waiting for the transaction to be applied. For example, if the buffer is being produced by rendering with OpenGL ES then a fence created with `https://developer.android.com/reference/android/opengl/EGLExt#eglDupNativeFenceFDANDROID(android.opengl.EGLDisplay,%20android.opengl.EGLSync)` can be used to allow the GPU rendering to be concurrent with the transaction. The compositor will wait for the fence to be signaled before the buffer is displayed. If multiple buffers are set as part of the same transaction, the presentation fences of all of them must signal before any buffer is displayed. That is, the entire transaction is delayed until all presentation fences have signaled, ensuring the transaction remains consistent.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `buffer` | `HardwareBuffer`: The buffer to be displayed. Pass in a null buffer to release the last displayed buffer. <br /> |
| `fence` | `SyncFence`: The presentation fence. If null or invalid, this is equivalent to `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer)` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setBuffer

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setBuffer (SurfaceControl sc, 
                HardwareBuffer buffer)
```

Updates the HardwareBuffer displayed for the SurfaceControl. Note that the buffer must be allocated with `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` as well as `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` as the surface control might be composited using either an overlay or using the GPU.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `buffer` | `HardwareBuffer`: The buffer to be displayed. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setBuffer

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setBuffer (SurfaceControl sc, 
                HardwareBuffer buffer, 
                SyncFence fence, 
                Consumer<SyncFence> releaseCallback)
```

Updates the HardwareBuffer displayed for the SurfaceControl. Note that the buffer must be allocated with `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` as well as `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` as the surface control might be composited using either an overlay or using the GPU. A presentation fence may be passed to improve performance by allowing the buffer to complete rendering while it is waiting for the transaction to be applied. For example, if the buffer is being produced by rendering with OpenGL ES then a fence created with `https://developer.android.com/reference/android/opengl/EGLExt#eglDupNativeFenceFDANDROID(android.opengl.EGLDisplay,%20android.opengl.EGLSync)` can be used to allow the GPU rendering to be concurrent with the transaction. The compositor will wait for the fence to be signaled before the buffer is displayed. If multiple buffers are set as part of the same transaction, the presentation fences of all of them must signal before any buffer is displayed. That is, the entire transaction is delayed until all presentation fences have signaled, ensuring the transaction remains consistent. A releaseCallback may be passed to know when the buffer is safe to be reused. This is recommended when attempting to render continuously using SurfaceControl transactions instead of through `https://developer.android.com/reference/android/view/Surface`, as it provides a safe \& reliable way to know when a buffer can be re-used. The callback will be invoked with a `https://developer.android.com/reference/android/hardware/SyncFence` which, if `https://developer.android.com/reference/android/hardware/SyncFence#isValid()`, must be waited on prior to using the buffer. This can either be done directly with `https://developer.android.com/reference/android/hardware/SyncFence#awaitForever()` or it may be done indirectly such as passing it as a release fence to `https://developer.android.com/reference/android/media/Image#setFence(android.hardware.SyncFence)` when using `https://developer.android.com/reference/android/media/ImageReader`.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `buffer` | `HardwareBuffer`: The buffer to be displayed. This value may be `null`. <br /> |
| `fence` | `SyncFence`: The presentation fence. If null or invalid, this is equivalent to `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer)` <br /> |
| `releaseCallback` | `Consumer`: The callback to invoke when the buffer being set has been released by a later transaction. That is, the point at which it is safe to re-use the buffer. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setBufferSize

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setBufferSize (SurfaceControl sc, 
                int w, 
                int h)
```

Set the default buffer size for the SurfaceControl, if there is a `https://developer.android.com/reference/android/view/Surface` associated with the control, then this will be the default size for buffers dequeued from it.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The surface to set the buffer size for. This value cannot be `null`. <br /> |
| `w` | `int`: The default width. Value is 0 or greater <br /> |
| `h` | `int`: The default height. Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This Transaction. This value cannot be `null`. <br /> |

### setBufferTransform

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setBufferTransform (SurfaceControl sc, 
                int transform)
```

Sets the buffer transform that should be applied to the current buffer. This can be used in combination with `https://developer.android.com/reference/android/view/AttachedSurfaceControl#addOnBufferTransformHintChangedListener(android.view.AttachedSurfaceControl.OnBufferTransformHintChangedListener)` to pre-rotate the buffer for the current display orientation. This can improve the performance of displaying the associated buffer.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `transform` | `int`: The transform to apply to the buffer. Value is one of the following: - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_IDENTITY` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_MIRROR_HORIZONTAL` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_MIRROR_VERTICAL` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_ROTATE_90` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_ROTATE_180` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_ROTATE_270` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_MIRROR_HORIZONTAL_ROTATE_90` - `https://developer.android.com/reference/android/view/SurfaceControl#BUFFER_TRANSFORM_MIRROR_VERTICAL_ROTATE_90` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setContentPriority

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setContentPriority (SurfaceControl sc, 
                int priority)
```

Sets the importance the layer's contents has to the app's user experience.

When a two layers within the same app are competing for a limited rendering resource, the layer with the highest priority will gets access to the resource.

Resources managed by this priority:

- Picture processing via `https://developer.android.com/`
- Picture processing via `https://developer.android.com/`

<br />

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl of the layer that should be updated. This value cannot be `null`. <br /> |
| `priority` | `int`: The priority this layer should have with respect to other layers in the app. The default priority is zero. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/`
- `https://developer.android.com/`
- `https://developer.android.com/`

### setCrop

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setCrop (SurfaceControl sc, 
                Rect crop)
```

Bounds the surface and its children to the bounds specified. Size of the surface will be ignored and only the crop and buffer size will be used to determine the bounds of the surface. If no crop is specified and the surface has no buffer, the surface bounds is only constrained by the size of its parent bounds. To unset the crop, pass in `null`.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: SurfaceControl to set crop of. This value cannot be `null`. <br /> |
| `crop` | `Rect`: Bounds of the crop to apply. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this This transaction for chaining <br /> |

### setDamageRegion

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setDamageRegion (SurfaceControl sc, 
                Region region)
```

Updates the region for the content on this surface updated in this transaction. The damage region is the area of the buffer that has changed since the previously sent buffer. This can be used to reduce the amount of recomposition that needs to happen when only a small region of the buffer is being updated, such as for a small blinking cursor or a loading indicator.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl on which to set the damage region. This value cannot be `null`. <br /> |
| `region` | `Region`: The region to set. If null, the entire buffer is assumed dirty. This is equivalent to not setting a damage region at all. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

### setDataSpace

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setDataSpace (SurfaceControl sc, 
                int dataspace)
```

Set the dataspace for the SurfaceControl. This will control how the buffer set with `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer)` is displayed.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `dataspace` | `int`: The dataspace to set it to. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_DEPTH` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_DYNAMIC_DEPTH` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_HEIF` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_HEIF_ULTRAHDR` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_JPEG_R` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_UNKNOWN` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_SCRGB_LINEAR` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_SRGB` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_SCRGB` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_DISPLAY_P3` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT2020_HLG` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT2020_PQ` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_ADOBE_RGB` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_JFIF` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT601_625` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT601_525` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT2020` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_BT709` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_DCI_P3` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_SRGB_LINEAR` - `https://developer.android.com/reference/android/hardware/DataSpace#DATASPACE_DISPLAY_BT2020` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setDesiredHdrHeadroom

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setDesiredHdrHeadroom (SurfaceControl sc, 
                float desiredRatio)
```

Sets the desired HDR headroom for the layer.

Prefer using this API over `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)` for formats that . conform to HDR video standards like HLG or HDR10 which do not communicate a HDR/SDR ratio as part of generating the buffer.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The layer whose desired HDR headroom is being specified. This value cannot be `null`. <br /> |
| `desiredRatio` | `float`: The desired HDR/SDR ratio. This can be used to communicate the max desired brightness range. This is similar to the "max luminance" value in other HDR metadata formats, but represented as a ratio of the target SDR whitepoint to the max display brightness. The system may not be able to, or may choose not to, deliver the requested range. Default value is 0.0f and indicates that the system will choose the best headroom for this surface control's content. Typically, this means that HLG/PQ encoded content will be displayed with some HDR headroom greater than 1.0. When called after `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)`, the desiredHeadroom will override the desiredRatio provided by `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)`. Conversely, when called before `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)`, the desiredRatio provided by `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)` will override the desiredHeadroom. Must be finite \&\& \>= 1.0f or 0.0f. Value is 0.0f or greater |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setExtendedRangeBrightness(android.view.SurfaceControl,%20float,%20float)`

### setDesiredPresentTimeNanos

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setDesiredPresentTimeNanos (long desiredPresentTimeNanos)
```

Specifies a desiredPresentTimeNanos for the transaction. The framework will try to present the transaction at or after the time specified. Transactions will not be presented until all of their acquire fences have signaled even if the app requests an earlier present time. If an earlier transaction has a desired present time of x, and a later transaction has a desired present time that is before x, the later transaction will not preempt the earlier transaction.

<br />

| Parameters ||
|---|---|
| `desiredPresentTimeNanos` | `long`: The desired time (in CLOCK_MONOTONIC) for the transaction. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction. This value cannot be `null`. <br /> |

### setExtendedRangeBrightness

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setExtendedRangeBrightness (SurfaceControl sc, 
                float currentBufferRatio, 
                float desiredRatio)
```

Sets the desired extended range brightness for the layer. This only applies for layers whose dataspace has RANGE_EXTENDED.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The layer whose extended range brightness is being specified. This value cannot be `null`. <br /> |
| `currentBufferRatio` | `float`: The current HDR/SDR ratio of the current buffer. For example if the buffer was rendered with a target SDR whitepoint of 100 nits and a max display brightness of 200 nits, this should be set to 2.0f. Default value is 1.0f. Transfer functions that encode their own brightness ranges, such as HLG or PQ, should also set this to 1.0f and instead communicate extended content brightness information via metadata such as CTA861_3 or SMPTE2086. Must be finite \&\& \>= 1.0f |
| `desiredRatio` | `float`: The desired HDR/SDR ratio. This can be used to communicate the max desired brightness range. This is similar to the "max luminance" value in other HDR metadata formats, but represented as a ratio of the target SDR whitepoint to the max display brightness. The system may not be able to, or may choose not to, deliver the requested range. While requesting a large desired ratio will result in the most dynamic range, voluntarily reducing the requested range can help improve battery life as well as can improve quality by ensuring greater bit depth is allocated to the luminance range in use. Default value is 1.0f and indicates that extended range brightness is not being used, so the resulting SDR or HDR behavior will be determined entirely by the dataspace being used (ie, typically SDR however PQ or HLG transfer functions will still result in HDR) Must be finite \&\& \>= 1.0f |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

### setFrameRate

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setFrameRate (SurfaceControl sc, 
                float frameRate, 
                int compatibility)
```

Sets the intended frame rate for this surface. Any switching of refresh rates is most probably going to be seamless.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: This value cannot be `null`. <br /> |
| `frameRate` | `float`: Value is 0.0f or greater <br /> |
| `compatibility` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_DEFAULT` - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_FIXED_SOURCE` - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_AT_LEAST` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setFrameRate(android.view.SurfaceControl,%20float,%20int,%20int)`

### setFrameRate

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setFrameRate (SurfaceControl sc, 
                float frameRate, 
                int compatibility, 
                int changeFrameRateStrategy)
```

Sets the intended frame rate for the surface `https://developer.android.com/reference/android/view/SurfaceControl`.

On devices that are capable of running the display at different refresh rates, the system may choose a display refresh rate to better match this surface's frame rate. Usage of this API won't directly affect the application's frame production pipeline. However, because the system may change the display refresh rate, calls to this function may result in changes to Choreographer callback timings, and changes to the time interval at which the system releases buffers back to the application.

Note that this only has an effect for surfaces presented on the display. If this surface is consumed by something other than the system compositor, e.g. a media codec, this call has no effect.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to specify the frame rate of. This value cannot be `null`. <br /> |
| `frameRate` | `float`: The intended frame rate for this surface, in frames per second. 0 is a special value that indicates the app will accept the system's choice for the display frame rate, which is the default behavior if this function isn't called. The `frameRate` param does *not* need to be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device that can only run the display at 60fps. Value is 0.0f or greater <br /> |
| `compatibility` | `int`: The frame rate compatibility of this surface. The compatibility value may influence the system's choice of display frame rate. This parameter is ignored when `frameRate` is 0. Value is one of the following: - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_DEFAULT` - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_FIXED_SOURCE` - `https://developer.android.com/reference/android/view/Surface#FRAME_RATE_COMPATIBILITY_AT_LEAST` |
| `changeFrameRateStrategy` | `int`: Whether display refresh rate transitions caused by this surface should be seamless. A seamless transition is one that doesn't have any visual interruptions, such as a black screen for a second or two. This parameter is ignored when `frameRate` is 0. Value is one of the following: - `https://developer.android.com/reference/android/view/Surface#CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS` - `https://developer.android.com/reference/android/view/Surface#CHANGE_FRAME_RATE_ALWAYS` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction object. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#clearFrameRate(android.view.SurfaceControl)`

### setFrameTimeline

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setFrameTimeline (long vsyncId)
```

Sets the frame timeline to use in SurfaceFlinger. A frame timeline should be chosen based on the frame deadline the application can meet when rendering the frame and the application's desired presentation time. By setting a frame timeline, SurfaceFlinger tries to present the frame at the corresponding expected presentation time. To receive frame timelines, a callback must be posted to Choreographer using `https://developer.android.com/reference/android/view/Choreographer#postVsyncCallback(android.view.Choreographer.VsyncCallback)` The vsyncId can then be extracted from the `https://developer.android.com/reference/android/view/Choreographer.FrameTimeline#getVsyncId()`.

<br />

| Parameters ||
|---|---|
| `vsyncId` | `long`: The vsync ID received from Choreographer, setting the frame's presentation target to the corresponding expected presentation time and deadline from the frame to be rendered. A stale or invalid value will be ignored. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This value cannot be `null`. <br /> |

### setGeometry

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setGeometry (SurfaceControl sc, 
                Rect sourceCrop, 
                Rect destFrame, 
                int orientation)
```

<br />

**This method was deprecated in API level 33.**   

Use `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setCrop(android.view.SurfaceControl,%20android.graphics.Rect)`, `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBufferTransform(android.view.SurfaceControl,%20int)`, `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setPosition(android.view.SurfaceControl,%20float,%20float)` and `https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setScale(android.view.SurfaceControl,%20float,%20float)` instead.

Specify how the buffer associated with this Surface is mapped in to the parent coordinate space. The source frame will be scaled to fit the destination frame, after being rotated according to the orientation parameter.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to specify the geometry of. This value cannot be `null`. <br /> |
| `sourceCrop` | `Rect`: The source rectangle in buffer space. Or null for the entire buffer. <br /> |
| `destFrame` | `Rect`: The destination rectangle in parent space. Or null for the source frame. <br /> |
| `orientation` | `int`: The buffer rotation. Value is one of the following: - `https://developer.android.com/reference/android/view/Surface#ROTATION_0` - `https://developer.android.com/reference/android/view/Surface#ROTATION_90` - `https://developer.android.com/reference/android/view/Surface#ROTATION_180` - `https://developer.android.com/reference/android/view/Surface#ROTATION_270` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction object. This value cannot be `null`. <br /> |

### setLayer

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setLayer (SurfaceControl sc, 
                int z)
```

Set the Z-order for a given SurfaceControl, relative to it's siblings. If two siblings share the same Z order the ordering is undefined. Surfaces with a negative Z will be placed below the parent surface. Calling setLayer after setRelativeLayer will reset the relative layer in the same transaction.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to set the Z order on. This value cannot be `null`. <br /> |
| `z` | `int`: The Z-order. Value is between `https://developer.android.com/reference/java/lang/Integer#MIN_VALUE` and `https://developer.android.com/reference/java/lang/Integer#MAX_VALUE` inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This Transaction. This value cannot be `null`. <br /> |

### setLuts

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setLuts (SurfaceControl sc, 
                DisplayLuts displayLuts)
```

Sets the Luts for the layer.

The function also allows to clear previously applied lut(s). To do this, set the displayluts to be either `nullptr` or an empty `https://developer.android.com/reference/android/hardware/DisplayLuts` instance.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `displayLuts` | `DisplayLuts`: The selected Lut(s). This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/hardware/DisplayLuts`

### setOpaque

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setOpaque (SurfaceControl sc, 
                boolean isOpaque)
```

Indicates whether the surface must be considered opaque, even if its pixel format is set to translucent. This can be useful if an application needs full RGBA 8888 support for instance but will still draw every pixel opaque.

This flag only determines whether opacity will be sampled from the alpha channel. Plane-alpha from calls to setAlpha() can still result in blended composition regardless of the opaque setting. Combined effects are (assuming a buffer format with an alpha channel):

- OPAQUE + alpha(1.0) == opaque composition
- OPAQUE + alpha(0.x) == blended composition
- OPAQUE + alpha(0.0) == no composition
- !OPAQUE + alpha(1.0) == blended composition
- !OPAQUE + alpha(0.x) == blended composition
- !OPAQUE + alpha(0.0) == no composition

If the underlying buffer lacks an alpha channel, it is as if setOpaque(true) were set automatically.

<br />

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to update. This value cannot be `null`. <br /> |
| `isOpaque` | `boolean`: true if the buffer's alpha should be ignored, false otherwise <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.Builder#setOpaque(boolean)`

### setPosition

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setPosition (SurfaceControl sc, 
                float x, 
                float y)
```

Sets the SurfaceControl to the specified position relative to the parent SurfaceControl

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to change position. This value cannot be `null`. <br /> |
| `x` | `float`: the X position <br /> |
| `y` | `float`: the Y position <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this transaction. This value cannot be `null`. <br /> |

### setScale

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setScale (SurfaceControl sc, 
                float scaleX, 
                float scaleY)
```

Sets the SurfaceControl to the specified scale with (0, 0) as the center point of the scale.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl to change scale. This value cannot be `null`. <br /> |
| `scaleX` | `float`: the X scale <br /> |
| `scaleY` | `float`: the Y scale <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | this transaction. This value cannot be `null`. <br /> |

### setTrustedPresentationCallback

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setTrustedPresentationCallback (SurfaceControl sc, 
                SurfaceControl.TrustedPresentationThresholds thresholds, 
                Executor executor, 
                Consumer<Boolean> listener)
```

<br />

**This method was deprecated in API level 35.**   

Use `https://developer.android.com/reference/android/view/WindowManager#registerTrustedPresentationListener(android.os.IBinder,%20android.window.TrustedPresentationThresholds,%20java.util.concurrent.Executor,%20java.util.function.Consumer<java.lang.Boolean>)` instead.

Sets a callback to receive feedback about the presentation of a `https://developer.android.com/reference/android/view/SurfaceControl`. When the `https://developer.android.com/reference/android/view/SurfaceControl` is presented according to the passed in `https://developer.android.com/reference/android/view/SurfaceControl.TrustedPresentationThresholds`, it is said to "enter the state", and receives the callback with `true`. When the conditions fall out of thresholds, it is then said to leave the state.

There are a few simple thresholds:

- minAlpha: Lower bound on computed alpha
- minFractionRendered: Lower bounds on fraction of pixels that were rendered
- stabilityThresholdMs: A time that alpha and fraction rendered must remain within bounds before we can "enter the state"

The fraction of pixels rendered is a computation based on scale, crop and occlusion. The calculation may be somewhat counterintuitive, so we can work through an example. Imagine we have a SurfaceControl with a 100x100 buffer which is occluded by (10x100) pixels on the left, and cropped by (100x10) pixels on the top. Furthermore imagine this SurfaceControl is scaled by 0.9 in both dimensions. (c=crop,o=occluded,b=both,x=none)
>
> |---|---|---|---|
> | b | c | c | c |
> | o | x | x | x |
> | o | x | x | x |
> | o | x | x | x |
> [ ]

We first start by computing fr=xscale\*yscale=0.9\*0.9=0.81, indicating that "81%" of the pixels were rendered. This corresponds to what was 100 pixels being displayed in 81 pixels. This is somewhat of an abuse of language, as the information of merged pixels isn't totally lost, but we err on the conservative side.

We then repeat a similar process for the crop and covered regions and accumulate the results: fr = fr \* (fractionNotCropped) \* (fractionNotCovered) So for this example we would get 0.9\*0.9\*0.9\*0.9=0.65...

Notice that this is not completely accurate, as we have double counted the region marked as b. However we only wanted a "lower bound" and so it is ok to err in this direction. Selection of the threshold will ultimately be somewhat arbitrary, and so there are some somewhat arbitrary decisions in this API as well.

<br />

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The `https://developer.android.com/reference/android/view/SurfaceControl` to set the callback on. This value cannot be `null`. <br /> |
| `thresholds` | `SurfaceControl.TrustedPresentationThresholds`: The `https://developer.android.com/reference/android/view/SurfaceControl.TrustedPresentationThresholds` that will specify when the to invoke the callback. This value cannot be `null`. <br /> |
| `executor` | `Executor`: The `https://developer.android.com/reference/java/util/concurrent/Executor` where the callback will be invoked on. This value cannot be `null`. <br /> |
| `listener` | `Consumer`: The `https://developer.android.com/reference/java/util/function/Consumer` that will receive the callbacks when entered or exited the threshold. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceControl.TrustedPresentationThresholds`

### setVisibility

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurfaceControl.Transaction setVisibility (SurfaceControl sc, 
                boolean visible)
```

Toggle the visibility of a given Layer and it's sub-tree.

<br />

| Parameters ||
|---|---|
| `sc` | `SurfaceControl`: The SurfaceControl for which to set the visibility. This value cannot be `null`. <br /> |
| `visible` | `boolean`: The new visibility <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` | This transaction object. This value cannot be `null`. <br /> |

### writeToParcel

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Writes the transaction to parcel, clearing the transaction as if it had been applied so it can be used to store future transactions. It's the responsibility of the parcel reader to apply the original transaction.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: parcel to write the transaction to. This value cannot be `null`. <br /> |
| `flags` | `int`: Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |