# CanvasFrontBufferedRenderer.Callback

Artifact: [androidx.graphics:graphics-core](https://developer.android.com/jetpack/androidx/releases/graphics) [View Source](https://cs.android.com/search?q=file:androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.kt+class:androidx.graphics.lowlatency.CanvasFrontBufferedRenderer.Callback) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
interface CanvasFrontBufferedRenderer.Callback<T : Any?>
```

<br />

*** ** * ** ***

Provides callbacks for consumers to draw into the front and multi buffered layers as well as provide opportunities to synchronize `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction`s to submit the layers to the hardware compositor.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onDrawFrontBufferedLayer(android.graphics.Canvas,kotlin.Int,kotlin.Int,kotlin.Any)( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, bufferWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, param: T )` Callback invoked to render content into the front buffered layer with the specified parameters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onDrawMultiBufferedLayer(android.graphics.Canvas,kotlin.Int,kotlin.Int,kotlin.collections.Collection)( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, bufferWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bufferHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, params: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T> )` Callback invoked to render content into the front buffered layer with the specified parameters. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onFrontBufferedLayerRenderComplete(androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat.Transaction)( frontBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat, transaction: https://developer.android.com/reference/kotlin/androidx/graphics/surface/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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onMultiBufferedLayerRenderComplete(androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat.Transaction)( frontBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat, multiBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat, transaction: https://developer.android.com/reference/kotlin/androidx/graphics/surface/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](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
@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: https://developer.android.com/reference/android/graphics/Canvas.html` | `https://developer.android.com/reference/android/graphics/Canvas.html` used to issue drawing instructions into the front buffered layer |
| `bufferWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Width of the buffer that is being rendered into. |
| `bufferHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Height of the buffer that is being rendered into. |
| `param: T` | optional parameter provided the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#renderFrontBufferedLayer(kotlin.Any)` 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: https://developer.android.com/reference/android/graphics/Canvas.html` | `https://developer.android.com/reference/android/graphics/Canvas.html` used to issue drawing instructions into the front buffered layer |
| `bufferWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Width of the buffer that is being rendered into. |
| `bufferHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Height of the buffer that is being rendered into. |
| `params: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<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 `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#renderFrontBufferedLayer(kotlin.Any)` since the last call to `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#commit()` has been made. After `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#commit()` is invoked, this collection is cleared and new parameters are added on each subsequent call to `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#renderFrontBufferedLayer(kotlin.Any)` |

### onFrontBufferedLayerRenderComplete

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
@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 `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` objects that maybe rendered within the scene.

| Parameters |
|---|---|
| `frontBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` | Handle to the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` where the front buffered layer content is drawn. This can be used to configure various properties of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `transaction: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction` | Current `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction` to apply updated buffered content to the front buffered layer. |

### onMultiBufferedLayerRenderComplete

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
@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 `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` objects that maybe rendered within the scene.

| Parameters |
|---|---|
| `frontBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` | Handle to the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` where the front buffered layer content is drawn. This can be used to configure various properties of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `multiBufferedLayerSurfaceControl: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` | Handle to the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` where the multi-buffered layer content is drawn. This can be used to configure various properties of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `transaction: https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction` | Current `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction` to apply updated buffered content to the multi buffered layer. |