# LowLatencyCanvasView.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/LowLatencyCanvasView.kt+class:androidx.graphics.lowlatency.LowLatencyCanvasView.Callback) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
interface LowLatencyCanvasView.Callback
```

<br />

*** ** * ** ***

Provides callbacks for consumers to draw into the front buffered overlay 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/LowLatencyCanvasView.Callback#onDrawFrontBufferedLayer(android.graphics.Canvas,kotlin.Int,kotlin.Int)(canvas: https://developer.android.com/reference/android/graphics/Canvas.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` 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/LowLatencyCanvasView.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. |
| `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/LowLatencyCanvasView.Callback#onRedrawRequested(android.graphics.Canvas,kotlin.Int,kotlin.Int)(canvas: https://developer.android.com/reference/android/graphics/Canvas.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Callback invoked when the entire scene should be re-rendered. |

## Public functions

### onDrawFrontBufferedLayer

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

```
@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: 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 |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Logical width of the content that is being rendered. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Logical height of the content that is being rendered. |

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

### onRedrawRequested

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

```
@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: 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 |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Logical width of the content that is being rendered. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Logical height of the content that is being rendered. |