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

*** ** * ** ***


```
public interface CanvasFrontBufferedRenderer.Callback<T extends Object>
```

<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/androidx/graphics/surface/SurfaceControlCompat.Transaction`s to submit the layers to the hardware compositor.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onDrawFrontBufferedLayer(android.graphics.Canvas,kotlin.Int,kotlin.Int,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas, int bufferWidth, int bufferHeight, @https://developer.android.com/reference/androidx/annotation/NonNull T param )` Callback invoked to render content into the front buffered layer with the specified parameters. |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onDrawMultiBufferedLayer(android.graphics.Canvas,kotlin.Int,kotlin.Int,kotlin.collections.Collection)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas, int bufferWidth, int bufferHeight, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Collection.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> params )` Callback invoked to render content into the front buffered layer with the specified parameters. |
| `default void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onFrontBufferedLayerRenderComplete(androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat.Transaction)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat frontBufferedLayerSurfaceControl, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction transaction )` Optional callback invoked when rendering to the front buffered layer is complete but before the buffers are submitted to the hardware compositor. |
| `default void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer.Callback#onMultiBufferedLayerRenderComplete(androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat,androidx.graphics.surface.SurfaceControlCompat.Transaction)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat frontBufferedLayerSurfaceControl, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat multiBufferedLayerSurfaceControl, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction transaction )` Optional callback invoked when rendering to the multi buffered layer is complete but before the buffers are submitted to the hardware compositor. |

## Public methods

### onDrawFrontBufferedLayer

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

```
@WorkerThread
abstract void onDrawFrontBufferedLayer(
    @NonNull Canvas canvas,
    int bufferWidth,
    int bufferHeight,
    @NonNull T param
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas` | `https://developer.android.com/reference/android/graphics/Canvas.html` used to issue drawing instructions into the front buffered layer |
| `int bufferWidth` | Width of the buffer that is being rendered into. |
| `int bufferHeight` | Height of the buffer that is being rendered into. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T param` | optional parameter provided the corresponding `https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#renderFrontBufferedLayer(kotlin.Any)` method that triggered this request to render into the front buffered layer |

### onDrawMultiBufferedLayer

```
@WorkerThread
abstract void onDrawMultiBufferedLayer(
    @NonNull Canvas canvas,
    int bufferWidth,
    int bufferHeight,
    @NonNull Collection<@NonNull T> params
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas` | `https://developer.android.com/reference/android/graphics/Canvas.html` used to issue drawing instructions into the front buffered layer |
| `int bufferWidth` | Width of the buffer that is being rendered into. |
| `int bufferHeight` | Height of the buffer that is being rendered into. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Collection.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> params` | 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/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#renderFrontBufferedLayer(kotlin.Any)` since the last call to `https://developer.android.com/reference/androidx/graphics/lowlatency/CanvasFrontBufferedRenderer#commit()` has been made. After `https://developer.android.com/reference/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/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
default void onFrontBufferedLayerRenderComplete(
    @NonNull SurfaceControlCompat frontBufferedLayerSurfaceControl,
    @NonNull SurfaceControlCompat.Transaction transaction
)
```

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/androidx/graphics/surface/SurfaceControlCompat` objects that maybe rendered within the scene.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat frontBufferedLayerSurfaceControl` | Handle to the `https://developer.android.com/reference/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/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction transaction` | Current `https://developer.android.com/reference/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
default void onMultiBufferedLayerRenderComplete(
    @NonNull SurfaceControlCompat frontBufferedLayerSurfaceControl,
    @NonNull SurfaceControlCompat multiBufferedLayerSurfaceControl,
    @NonNull SurfaceControlCompat.Transaction transaction
)
```

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/androidx/graphics/surface/SurfaceControlCompat` objects that maybe rendered within the scene.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat frontBufferedLayerSurfaceControl` | Handle to the `https://developer.android.com/reference/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/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat multiBufferedLayerSurfaceControl` | Handle to the `https://developer.android.com/reference/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/androidx/graphics/surface/SurfaceControlCompat` like z-ordering or visibility with the corresponding `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction transaction` | Current `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat.Transaction` to apply updated buffered content to the multi buffered layer. |