CanvasFrontBufferedRenderer.Callback


interface CanvasFrontBufferedRenderer.Callback<T : Any?>


Provides callbacks for consumers to draw into the front and multi buffered layers as well as provide opportunities to synchronize SurfaceControlCompat.Transactions to submit the layers to the hardware compositor.

Summary

Public functions

Unit
@WorkerThread
onDrawFrontBufferedLayer(
    canvas: Canvas,
    bufferWidth: Int,
    bufferHeight: Int,
    param: T
)

Callback invoked to render content into the front buffered layer with the specified parameters.

Unit
@WorkerThread
onDrawMultiBufferedLayer(
    canvas: Canvas,
    bufferWidth: Int,
    bufferHeight: Int,
    params: Collection<T>
)

Callback invoked to render content into the front buffered layer with the specified parameters.

open Unit
@WorkerThread
onFrontBufferedLayerRenderComplete(
    frontBufferedLayerSurfaceControl: SurfaceControlCompat,
    transaction: SurfaceControlCompat.Transaction
)

Optional callback invoked when rendering to the front buffered layer is complete but before the buffers are submitted to the hardware compositor.

open Unit
@WorkerThread
onMultiBufferedLayerRenderComplete(
    frontBufferedLayerSurfaceControl: SurfaceControlCompat,
    multiBufferedLayerSurfaceControl: SurfaceControlCompat,
    transaction: SurfaceControlCompat.Transaction
)

Optional callback invoked when rendering to the multi buffered layer is complete but before the buffers are submitted to the hardware compositor.

Public functions

onDrawFrontBufferedLayer

Added in 1.0.0-rc01
@WorkerThread
fun onDrawFrontBufferedLayer(
    canvas: Canvas,
    bufferWidth: Int,
    bufferHeight: Int,
    param: T
): Unit

Callback invoked to render content into the front buffered layer with the specified parameters.

Parameters
canvas: Canvas

Canvas used to issue drawing instructions into the front buffered layer

bufferWidth: Int

Width of the buffer that is being rendered into.

bufferHeight: Int

Height of the buffer that is being rendered into.

param: T

optional parameter provided the corresponding CanvasFrontBufferedRenderer.renderFrontBufferedLayer method that triggered this request to render into the front buffered layer

onDrawMultiBufferedLayer

@WorkerThread
fun onDrawMultiBufferedLayer(
    canvas: Canvas,
    bufferWidth: Int,
    bufferHeight: Int,
    params: Collection<T>
): Unit

Callback invoked to render content into the front buffered layer with the specified parameters.

Parameters
canvas: Canvas

Canvas used to issue drawing instructions into the front buffered layer

bufferWidth: Int

Width of the buffer that is being rendered into.

bufferHeight: Int

Height of the buffer that is being rendered into.

params: Collection<T>

optional parameter provided to render the entire scene into the multi buffered layer. This is a collection of all parameters provided in consecutive invocations to CanvasFrontBufferedRenderer.renderFrontBufferedLayer since the last call to CanvasFrontBufferedRenderer.commit has been made. After CanvasFrontBufferedRenderer.commit is invoked, this collection is cleared and new parameters are added on each subsequent call to CanvasFrontBufferedRenderer.renderFrontBufferedLayer

onFrontBufferedLayerRenderComplete

Added in 1.0.0-rc01
@WorkerThread
open fun onFrontBufferedLayerRenderComplete(
    frontBufferedLayerSurfaceControl: SurfaceControlCompat,
    transaction: SurfaceControlCompat.Transaction
): Unit

Optional callback invoked when rendering to the front buffered layer is complete but before the buffers are submitted to the hardware compositor. This provides consumers a mechanism for synchronizing the transaction with other SurfaceControlCompat objects that maybe rendered within the scene.

Parameters
frontBufferedLayerSurfaceControl: SurfaceControlCompat

Handle to the SurfaceControlCompat where the front buffered layer content is drawn. This can be used to configure various properties of the SurfaceControlCompat like z-ordering or visibility with the corresponding SurfaceControlCompat.Transaction.

transaction: SurfaceControlCompat.Transaction

Current SurfaceControlCompat.Transaction to apply updated buffered content to the front buffered layer.

onMultiBufferedLayerRenderComplete

Added in 1.0.0-rc01
@WorkerThread
open fun onMultiBufferedLayerRenderComplete(
    frontBufferedLayerSurfaceControl: SurfaceControlCompat,
    multiBufferedLayerSurfaceControl: SurfaceControlCompat,
    transaction: SurfaceControlCompat.Transaction
): Unit

Optional callback invoked when rendering to the multi buffered layer is complete but before the buffers are submitted to the hardware compositor. This provides consumers a mechanism for synchronizing the transaction with other SurfaceControlCompat objects that maybe rendered within the scene.

Parameters
frontBufferedLayerSurfaceControl: SurfaceControlCompat

Handle to the SurfaceControlCompat where the front buffered layer content is drawn. This can be used to configure various properties of the SurfaceControlCompat like z-ordering or visibility with the corresponding SurfaceControlCompat.Transaction.

multiBufferedLayerSurfaceControl: SurfaceControlCompat

Handle to the SurfaceControlCompat where the multi-buffered layer content is drawn. This can be used to configure various properties of the SurfaceControlCompat like z-ordering or visibility with the corresponding SurfaceControlCompat.Transaction.

transaction: SurfaceControlCompat.Transaction

Current SurfaceControlCompat.Transaction to apply updated buffered content to the multi buffered layer.