SurfaceControl.Transaction
  public
  static
  
  
  class
  SurfaceControl.Transaction
  
    extends Object
  
  
  
  
  
      implements
      
        Closeable, 
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.view.SurfaceControl.Transaction | 
An atomic set of changes to a set of SurfaceControl.
Summary
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<SurfaceControl.Transaction> | CREATOR
 | 
| Public constructors | |
|---|---|
| 
      Transaction()
      Open a new transaction object. | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      addTransactionCommittedListener(Executor executor, SurfaceControl.TransactionCommittedListener listener)
      Request to add a  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      addTransactionCompletedListener(Executor executor, Consumer<SurfaceControl.TransactionStats> listener)
      Request to add a TransactionCompletedListener. | 
| 
        
        
        
        
        
        void | 
      apply()
      Apply the transaction, clearing its state, and making it usable as a new transaction. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      clearFrameRate(SurfaceControl sc)
      Clears the frame rate which was set for the surface  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      clearTrustedPresentationCallback(SurfaceControl sc)
      
      This method was deprecated
      in API level 35.
    Use  | 
| 
        
        
        
        
        
        void | 
      close()
      Release the native transaction object, without applying it. | 
| 
        
        
        
        
        
        int | 
      describeContents()
      Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      merge(SurfaceControl.Transaction other)
      Merge the other transaction into this transaction, clearing the other transaction as if it had been applied. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      reparent(SurfaceControl sc, SurfaceControl newParent)
      Re-parents a given layer to a new parent. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setAlpha(SurfaceControl sc, float alpha)
      Set the alpha for a given surface. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setBuffer(SurfaceControl sc, HardwareBuffer buffer, SyncFence fence)
      Updates the HardwareBuffer displayed for the SurfaceControl. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setBuffer(SurfaceControl sc, HardwareBuffer buffer)
      Updates the HardwareBuffer displayed for the SurfaceControl. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setBuffer(SurfaceControl sc, HardwareBuffer buffer, SyncFence fence, Consumer<SyncFence> releaseCallback)
      Updates the HardwareBuffer displayed for the SurfaceControl. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setBufferSize(SurfaceControl sc, int w, int h)
      Set the default buffer size for the SurfaceControl, if there is a
  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setBufferTransform(SurfaceControl sc, int transform)
      Sets the buffer transform that should be applied to the current buffer. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setContentPriority(SurfaceControl sc, int priority)
      Sets the importance the layer's contents has to the app's user experience. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setCrop(SurfaceControl sc, Rect crop)
      Bounds the surface and its children to the bounds specified. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setDamageRegion(SurfaceControl sc, Region region)
      Updates the region for the content on this surface updated in this transaction. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setDataSpace(SurfaceControl sc, int dataspace)
      Set the dataspace for the SurfaceControl. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setDesiredHdrHeadroom(SurfaceControl sc, float desiredRatio)
      Sets the desired HDR headroom for the layer. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setDesiredPresentTimeNanos(long desiredPresentTimeNanos)
      Specifies a desiredPresentTimeNanos for the transaction. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setExtendedRangeBrightness(SurfaceControl sc, float currentBufferRatio, float desiredRatio)
      Sets the desired extended range brightness for the layer. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setFrameRate(SurfaceControl sc, float frameRate, int compatibility)
      Sets the intended frame rate for this surface. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setFrameRate(SurfaceControl sc, float frameRate, int compatibility, int changeFrameRateStrategy)
      Sets the intended frame rate for the surface  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setFrameTimeline(long vsyncId)
      Sets the frame timeline to use in SurfaceFlinger. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setGeometry(SurfaceControl sc, Rect sourceCrop, Rect destFrame, int orientation)
      
      This method was deprecated
      in API level 33.
    Use  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setLayer(SurfaceControl sc, int z)
      Set the Z-order for a given SurfaceControl, relative to it's siblings. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setLuts(SurfaceControl sc, DisplayLuts displayLuts)
      Sets the Luts for the layer. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setOpaque(SurfaceControl sc, boolean isOpaque)
      Indicates whether the surface must be considered opaque, even if its pixel format is set to translucent. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setPosition(SurfaceControl sc, float x, float y)
      Sets the SurfaceControl to the specified position relative to the parent SurfaceControl | 
| 
        
        
        
        
        
        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. | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setTrustedPresentationCallback(SurfaceControl sc, SurfaceControl.TrustedPresentationThresholds thresholds, Executor executor, Consumer<Boolean> listener)
      
      This method was deprecated
      in API level 35.
    Use
  | 
| 
        
        
        
        
        
        SurfaceControl.Transaction | 
      setVisibility(SurfaceControl sc, boolean visible)
      Toggle the visibility of a given Layer and it's sub-tree. | 
| 
        
        
        
        
        
        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. | 
| Inherited methods | |
|---|---|
Fields
Public constructors
Transaction
public Transaction ()
Open a new transaction object. The transaction may be filed with commands to
 manipulate SurfaceControl instances, and then applied atomically with
 apply(). Eventually the user should invoke 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.
Public methods
addTransactionCommittedListener
public SurfaceControl.Transaction addTransactionCommittedListener (Executor executor, SurfaceControl.TransactionCommittedListener listener)
Request to add a 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.
| Parameters | |
|---|---|
| executor | Executor: The executor that the callback should be invoked on.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| listener | SurfaceControl.TransactionCommittedListener: The callback that will be invoked when the transaction has been
                 committed.
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
addTransactionCompletedListener
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.
| Parameters | |
|---|---|
| executor | Executor: The executor that the callback should be invoked on.
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| listener | Consumer: The callback that will be invoked when the transaction has been
                 completed.
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
apply
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.
clearFrameRate
public SurfaceControl.Transaction clearFrameRate (SurfaceControl sc)
Clears the frame rate which was set for the surface SurfaceControl.
 
This is equivalent to calling setFrameRate(android.view.SurfaceControl, float, int, int)
 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to clear the frame rate of.
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction object.
 This value cannot be null. | 
See also:
clearTrustedPresentationCallback
public SurfaceControl.Transaction clearTrustedPresentationCallback (SurfaceControl sc)
      This method was deprecated
      in API level 35.
    Use WindowManager.unregisterTrustedPresentationListener(Consumer)
 instead.
  
Clears the callback for a specific SurfaceControl
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl that the callback should be cleared from
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction
 This value cannot be null. | 
close
public void close ()
Release the native transaction object, without applying it.
describeContents
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 writeToParcel(android.os.Parcel, int),
 the return value of this method must include the
 CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
| int | a bitmask indicating the set of special object types marshaled
 by this Parcelable object instance.
 Value is either 0orCONTENTS_FILE_DESCRIPTOR | 
merge
public SurfaceControl.Transaction merge (SurfaceControl.Transaction other)
Merge the other transaction into this transaction, clearing the other transaction as if it had been applied.
| Parameters | |
|---|---|
| other | SurfaceControl.Transaction: The transaction to merge in to this one.
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction.
 This value cannot be null. | 
reparent
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to reparent
 This value cannot benull. | 
| newParent | SurfaceControl: The new parent for the given control.
 This value may benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This Transaction
 This value cannot be null. | 
setAlpha
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The given SurfaceControl.
 This value cannot benull. | 
| alpha | float: The alpha to set.
 Value is between 0.0f and 1.0f inclusive | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
setBuffer
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 HardwareBuffer.USAGE_COMPOSER_OVERLAY
 as well as 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
 EGLExt.eglDupNativeFenceFDANDROID(EGLDisplay, 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| buffer | HardwareBuffer: The buffer to be displayed. Pass in a null buffer to release the last
 displayed buffer. | 
| fence | SyncFence: The presentation fence. If null or invalid, this is equivalent tosetBuffer(android.view.SurfaceControl, android.hardware.HardwareBuffer) | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setBuffer
public SurfaceControl.Transaction setBuffer (SurfaceControl sc, HardwareBuffer buffer)
Updates the HardwareBuffer displayed for the SurfaceControl.
 Note that the buffer must be allocated with HardwareBuffer.USAGE_COMPOSER_OVERLAY
 as well as HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE as the surface control might
 be composited using either an overlay or using the GPU.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| buffer | HardwareBuffer: The buffer to be displayed
 This value may benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setBuffer
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 HardwareBuffer.USAGE_COMPOSER_OVERLAY
 as well as 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
 EGLExt.eglDupNativeFenceFDANDROID(EGLDisplay, 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 Surface, as it provides a safe & reliable way to know when
 a buffer can be re-used. The callback will be invoked with a SyncFence which,
 if valid, must be waited on prior to using the buffer. This
 can either be done directly with SyncFence.awaitForever() or it may be done
 indirectly such as passing it as a release fence to
 Image.setFence(SyncFence) when using
 ImageReader.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| buffer | HardwareBuffer: The buffer to be displayed
 This value may benull. | 
| fence | SyncFence: The presentation fence. If null or invalid, this is equivalent tosetBuffer(android.view.SurfaceControl, android.hardware.HardwareBuffer) | 
| 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 benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setBufferSize
public SurfaceControl.Transaction setBufferSize (SurfaceControl sc, int w, int h)
Set the default buffer size for the SurfaceControl, if there is a
 Surface associated with the control, then
 this will be the default size for buffers dequeued from it.
| Parameters | |
|---|---|
| sc | SurfaceControl: The surface to set the buffer size for.
 This value cannot benull. | 
| w | int: The default width
 Value is 0 or greater | 
| h | int: The default height
 Value is 0 or greater | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This Transaction
 This value cannot be null. | 
setBufferTransform
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
 AttachedSurfaceControl.addOnBufferTransformHintChangedListener(AttachedSurfaceControl.OnBufferTransformHintChangedListener)
 to pre-rotate the buffer for the current display orientation. This can
 improve the performance of displaying the associated buffer.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| transform | int: The transform to apply to the buffer.
 Value isSurfaceControl.BUFFER_TRANSFORM_IDENTITY,SurfaceControl.BUFFER_TRANSFORM_MIRROR_HORIZONTAL,SurfaceControl.BUFFER_TRANSFORM_MIRROR_VERTICAL,SurfaceControl.BUFFER_TRANSFORM_ROTATE_90,SurfaceControl.BUFFER_TRANSFORM_ROTATE_180,SurfaceControl.BUFFER_TRANSFORM_ROTATE_270, android.view.SurfaceControl.BUFFER_TRANSFORM_MIRROR_HORIZONTAL_ROTATE_90, or android.view.SurfaceControl.BUFFER_TRANSFORM_MIRROR_VERTICAL_ROTATE_90 | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setContentPriority
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 ERROR(/MediaCodec.KEY_PICTURE_PROFILE)
- Picture processing via ERROR(SurfaceControl.Transaction.setPictureProfileHandle/android.view.SurfaceControl.Transaction#setPictureProfileHandle SurfaceControl.Transaction.setPictureProfileHandle)
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl of the layer that should be updated
 This value cannot benull. | 
| priority | int: The priority this layer should have with respect to other layers in the
                 app. The default priority is zero. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
setCrop
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 an invalid Rect (0, 0, -1, -1)
| Parameters | |
|---|---|
| sc | SurfaceControl: SurfaceControl to set crop of.
 This value cannot benull. | 
| crop | Rect: Bounds of the crop to apply.
 This value may benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this This transaction for chaining
 This value cannot be null. | 
setDamageRegion
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl on which to set the damage region
 This value cannot benull. | 
| 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. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
setDataSpace
public SurfaceControl.Transaction setDataSpace (SurfaceControl sc, int dataspace)
Set the dataspace for the SurfaceControl. This will control how the buffer
 set with setBuffer(android.view.SurfaceControl, android.hardware.HardwareBuffer) is displayed.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| dataspace | int: The dataspace to set it to
 Value is either0or a combination ofDataSpace.DATASPACE_DEPTH,DataSpace.DATASPACE_DYNAMIC_DEPTH,DataSpace.DATASPACE_HEIF,DataSpace.DATASPACE_HEIF_ULTRAHDR,DataSpace.DATASPACE_JPEG_R,DataSpace.DATASPACE_UNKNOWN,DataSpace.DATASPACE_SCRGB_LINEAR,DataSpace.DATASPACE_SRGB,DataSpace.DATASPACE_SCRGB,DataSpace.DATASPACE_DISPLAY_P3,DataSpace.DATASPACE_BT2020_HLG,DataSpace.DATASPACE_BT2020_PQ,DataSpace.DATASPACE_ADOBE_RGB,DataSpace.DATASPACE_JFIF,DataSpace.DATASPACE_BT601_625,DataSpace.DATASPACE_BT601_525,DataSpace.DATASPACE_BT2020,DataSpace.DATASPACE_BT709,DataSpace.DATASPACE_DCI_P3,DataSpace.DATASPACE_SRGB_LINEAR, and android.hardware.DataSpace.DATASPACE_DISPLAY_BT2020 | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setDesiredHdrHeadroom
public SurfaceControl.Transaction setDesiredHdrHeadroom (SurfaceControl sc, float desiredRatio)
Sets the desired HDR headroom for the layer.
Prefer using this API over setExtendedRangeBrightness(SurfaceControl, float, float) 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The layer whose desired HDR headroom is being specified
 This value cannot benull. | 
| 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  Must be finite && >= 1.0f or 0.0f. Value is 0.0f or greater | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setDesiredPresentTimeNanos
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.
| Parameters | |
|---|---|
| desiredPresentTimeNanos | long: The desired time (in CLOCK_MONOTONIC) for the transaction. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction
 This value cannot be null. | 
setExtendedRangeBrightness
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The layer whose extended range brightness is being specified
 This value cannot benull. | 
| 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 | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setFrameRate
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: This value cannot benull. | 
| frameRate | float: Value is 0.0f or greater | 
| compatibility | int: Value isSurface.FRAME_RATE_COMPATIBILITY_DEFAULT,Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,Surface.FRAME_RATE_COMPATIBILITY_AT_LEAST, android.view.Surface.FRAME_RATE_COMPATIBILITY_EXACT, or android.view.Surface.FRAME_RATE_COMPATIBILITY_MIN | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
setFrameRate
public SurfaceControl.Transaction setFrameRate (SurfaceControl sc, float frameRate, int compatibility, int changeFrameRateStrategy)
Sets the intended frame rate for the surface 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to specify the frame rate of.
 This value cannot benull. | 
| 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. TheframeRateparam 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 | 
| 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 whenframeRateis 0.
 Value isSurface.FRAME_RATE_COMPATIBILITY_DEFAULT,Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,Surface.FRAME_RATE_COMPATIBILITY_AT_LEAST, android.view.Surface.FRAME_RATE_COMPATIBILITY_EXACT, or android.view.Surface.FRAME_RATE_COMPATIBILITY_MIN | 
| 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 whenframeRateis 0.
 Value isSurface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS, orSurface.CHANGE_FRAME_RATE_ALWAYS | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction object.
 This value cannot be null. | 
See also:
setFrameTimeline
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
 Choreographer.postVsyncCallback The vsyncId can then be extracted from the
 Choreographer.FrameTimeline.getVsyncId.
| 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. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This value cannot be null. | 
setGeometry
public SurfaceControl.Transaction setGeometry (SurfaceControl sc, Rect sourceCrop, Rect destFrame, int orientation)
      This method was deprecated
      in API level 33.
    Use setCrop(android.view.SurfaceControl, android.graphics.Rect),
 setBufferTransform(android.view.SurfaceControl, int),
 setPosition(android.view.SurfaceControl, float, float) and
 setScale(android.view.SurfaceControl, float, float) 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to specify the geometry of
 This value cannot benull. | 
| sourceCrop | Rect: The source rectangle in buffer space. Or null for the entire buffer. | 
| destFrame | Rect: The destination rectangle in parent space. Or null for the source frame. | 
| orientation | int: The buffer rotation
 Value isSurface.ROTATION_0,Surface.ROTATION_90,Surface.ROTATION_180, orSurface.ROTATION_270 | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction object.
 This value cannot be null. | 
setLayer
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to set the Z order on
 This value cannot benull. | 
| z | int: The Z-order
 Value is betweenInteger.MIN_VALUEandInteger.MAX_VALUEinclusive | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This Transaction.
 This value cannot be null. | 
setLuts
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 DisplayLuts instance.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| displayLuts | DisplayLuts: The selected Lut(s)
 This value may benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
See also:
setOpaque
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
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to update
 This value cannot benull. | 
| isOpaque | boolean: true if the buffer's alpha should be ignored, false otherwise | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this
 This value cannot be null. | 
setPosition
public SurfaceControl.Transaction setPosition (SurfaceControl sc, float x, float y)
Sets the SurfaceControl to the specified position relative to the parent SurfaceControl
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to change position
 This value cannot benull. | 
| x | float: the X position | 
| y | float: the Y position | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this transaction
 This value cannot be null. | 
setScale
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.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl to change scale
 This value cannot benull. | 
| scaleX | float: the X scale | 
| scaleY | float: the Y scale | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | this transaction
 This value cannot be null. | 
setTrustedPresentationCallback
public SurfaceControl.Transaction setTrustedPresentationCallback (SurfaceControl sc, SurfaceControl.TrustedPresentationThresholds thresholds, Executor executor, Consumer<Boolean> listener)
      This method was deprecated
      in API level 35.
    Use
 WindowManager.registerTrustedPresentationListener(IBinder,
 android.window.TrustedPresentationThresholds, Executor, Consumer) instead.
  
Sets a callback to receive feedback about the presentation of a SurfaceControl.
 When the SurfaceControl is presented according to the passed in
 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.
| Parameters | |
|---|---|
| sc | SurfaceControl: TheSurfaceControlto set the callback on
 This value cannot benull. | 
| thresholds | SurfaceControl.TrustedPresentationThresholds: TheTrustedPresentationThresholdsthat will specify when the to
                   invoke the callback.
 This value cannot benull. | 
| executor | Executor: TheExecutorwhere the callback will be invoked on.
 This value cannot benull. | 
| listener | Consumer: TheConsumerthat will receive the callbacks when entered or
                   exited the threshold.
 This value cannot benull. | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction
 This value cannot be null. | 
setVisibility
public SurfaceControl.Transaction setVisibility (SurfaceControl sc, boolean visible)
Toggle the visibility of a given Layer and it's sub-tree.
| Parameters | |
|---|---|
| sc | SurfaceControl: The SurfaceControl for which to set the visibility
 This value cannot benull. | 
| visible | boolean: The new visibility | 
| Returns | |
|---|---|
| SurfaceControl.Transaction | This transaction object.
 This value cannot be null. | 
writeToParcel
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.
| Parameters | |
|---|---|
| dest | Parcel: parcel to write the transaction to
 This value cannot benull. | 
| flags | int: Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
