LowLatencyCanvasView.Callback


interface LowLatencyCanvasView.Callback


Provides callbacks for consumers to draw into the front buffered overlay 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, width: Int, height: Int)

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.

Unit
@WorkerThread
onRedrawRequested(canvas: Canvas, width: Int, height: Int)

Callback invoked when the entire scene should be re-rendered.

Public functions

onDrawFrontBufferedLayer

Added in 1.0.2
@WorkerThread
fun onDrawFrontBufferedLayer(canvas: Canvas, width: Int, height: Int): 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

width: Int

Logical width of the content that is being rendered.

height: Int

Logical height of the content that is being rendered.

onFrontBufferedLayerRenderComplete

Added in 1.0.2
@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.

onRedrawRequested

Added in 1.0.2
@WorkerThread
fun onRedrawRequested(canvas: Canvas, width: Int, height: Int): Unit

Callback invoked when the entire scene should be re-rendered. This is invoked during initialization and when the corresponding Activity is resumed from a background state.

Parameters
canvas: Canvas

Canvas used to issue drawing instructions into the front buffered layer

width: Int

Logical width of the content that is being rendered.

height: Int

Logical height of the content that is being rendered.