# Print output for @column tags ?> AttachedSurfaceControl - Android SDK | Android Developers

Most visited

Recently visited

AttachedSurfaceControl

public interface AttachedSurfaceControl

android.view.AttachedSurfaceControl


Provides an interface to the root-Surface of a View Hierarchy or Window. This is used in combination with the SurfaceControl API to enable attaching app created SurfaceControl to the SurfaceControl hierarchy used by the app, and enable SurfaceTransactions to be performed in sync with the View hierarchy drawing. This object is obtained from View.getRootSurfaceControl() and Window.getRootSurfaceControl(). It must be used from the UI thread of the object it was obtained from.

Summary

Nested classes

interface AttachedSurfaceControl.OnBufferTransformHintChangedListener

Buffer transform hint change listener. 

Public methods

default void addOnBufferTransformHintChangedListener(AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)

Registers a OnBufferTransformHintChangedListener to receive notifications about when the transform hint changes.

abstract boolean applyTransactionOnDraw(SurfaceControl.Transaction t)

Consume the passed in transaction, and request the View hierarchy to apply it atomically with the next draw.

abstract SurfaceControl.Transaction buildReparentTransaction(SurfaceControl child)

Create a transaction which will reparent to the View hierarchy root SurfaceControl.

default int getBufferTransformHint()

The transform hint can be used by a buffer producer to pre-rotate the rendering such that the final transformation in the system composer is identity.

default void removeOnBufferTransformHintChangedListener(AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)

Unregisters a OnBufferTransformHintChangedListener.

Public methods

addOnBufferTransformHintChangedListener

public void addOnBufferTransformHintChangedListener (AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)

Registers a OnBufferTransformHintChangedListener to receive notifications about when the transform hint changes.

Parameters
listener AttachedSurfaceControl.OnBufferTransformHintChangedListener: This value cannot be null.

See also:

applyTransactionOnDraw

public abstract boolean applyTransactionOnDraw (SurfaceControl.Transaction t)

Consume the passed in transaction, and request the View hierarchy to apply it atomically with the next draw. This transaction will be merged with the buffer transaction from the ViewRoot and they will show up on-screen atomically synced. This will not cause a draw to be scheduled, and if there are no other changes to the View hierarchy you may need to call View.invalidate()

Parameters
t SurfaceControl.Transaction: This value cannot be null.

Returns
boolean

buildReparentTransaction

public abstract SurfaceControl.Transaction buildReparentTransaction (SurfaceControl child)

Create a transaction which will reparent to the View hierarchy root SurfaceControl. See SurfaceControl.Transaction#reparent. This transacton must be applied or merged in to another transaction by the caller, otherwise it will have no effect.

Returns
SurfaceControl.Transaction A new transaction which performs the reparent operation when applied. This value may be null.

getBufferTransformHint

public int getBufferTransformHint ()

The transform hint can be used by a buffer producer to pre-rotate the rendering such that the final transformation in the system composer is identity. This can be very useful when used in conjunction with the h/w composer HAL in situations where it cannot handle rotations or handle them with an additional power cost. The transform hint should be used with ASurfaceControl APIs when submitting buffers. Example usage: 1. After a configuration change, before dequeuing a buffer, the buffer producer queries the function for the transform hint. 2. The desired buffer width and height is rotated by the transform hint. 3. The producer dequeues a buffer of the new pre-rotated size. 4. The producer renders to the buffer such that the image is already transformed, that is applying the transform hint to the rendering. 5. The producer applies the inverse transform hint to the buffer it just rendered. 6. The producer queues the pre-transformed buffer with the buffer transform. 7. The composer combines the buffer transform with the display transform. If the buffer transform happens to cancel out the display transform then no rotation is needed and there will be no performance penalties. Note, when using ANativeWindow APIs in conjunction with a NativeActivity Surface or SurfaceView Surface, the buffer producer will already have access to the transform hint and no additional work is needed.

Returns
int Value is SurfaceControl.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, BUFFER_TRANSFORM_MIRROR_HORIZONTAL | BUFFER_TRANSFORM_ROTATE_90, or BUFFER_TRANSFORM_MIRROR_VERTICAL | BUFFER_TRANSFORM_ROTATE_90

See also:

removeOnBufferTransformHintChangedListener

public void removeOnBufferTransformHintChangedListener (AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)

Unregisters a OnBufferTransformHintChangedListener.

Parameters
listener AttachedSurfaceControl.OnBufferTransformHintChangedListener: This value cannot be null.

See also: