# Print output for @column tags ?> SurfaceControl.Transaction - Android SDK | Android Developers

Most visited

Recently visited

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

void apply()

Apply the transaction, clearing it's state, and making it usable as a new transaction.

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 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.

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

Sets the intended frame rate for the surface SurfaceControl.

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

Specify how the buffer assosciated with this Surface is mapped in to the parent coordinate space.

SurfaceControl.Transaction setLayer(SurfaceControl sc, int z)

Set the Z-order for a given SurfaceControl, relative to it's siblings.

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

CREATOR

public static final Creator<SurfaceControl.Transaction> CREATOR

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

apply

public void apply ()

Apply the transaction, clearing it's state, and making it usable as a new transaction.

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 0 or CONTENTS_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 be null.

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 be null.

newParent SurfaceControl: The new parent for the given control. This value may be null.

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 be null.

alpha float: The alpha to set. Value is between 0.0 and 1.0 inclusive

Returns
SurfaceControl.Transaction 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 be null.

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.

setFrameRate

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

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.

Parameters
sc SurfaceControl: The SurfaceControl to specify the frame rate of. This value cannot be null.

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.0 or greater

compatibility int: The frame rate compatibility of this surface. The compatibility value may influence the system's choice of display frame rate. See the Surface.FRAME_RATE_COMPATIBILITY_* values for more info. Value is Surface.FRAME_RATE_COMPATIBILITY_DEFAULT, or Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE

Returns
SurfaceControl.Transaction This transaction object. This value cannot be null.

setGeometry

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

Specify how the buffer assosciated 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 be null.

sourceCrop Rect: The source rectangle in buffer space. Or null for the entire buffer. This value may be null.

destFrame Rect: The destination rectangle in parent space. Or null for the source frame. This value may be null.

orientation int: The buffer rotation Value is Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270

Returns
SurfaceControl.Transaction This transaction object.

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.

Parameters
sc SurfaceControl: The SurfaceControl to set the Z order on This value cannot be null.

z int: The Z-order Value is between Integer.MIN_VALUE and Integer.MAX_VALUE inclusive

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 be null.

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 be null.

flags int: Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES