# CanvasBufferedRenderer.Builder

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

*** ** * ** ***


```
class CanvasBufferedRenderer.Builder
```

<br />

*** ** * ** ***

Builder used to construct a `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` instance.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#Builder(kotlin.Int,kotlin.Int)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#build()()` Create the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` with the specified parameters on this `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` instance. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#setBufferFormat(kotlin.Int)(format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#setMaxBuffers(kotlin.Int)(numBuffers: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1, to = 64) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#setUsageFlags(kotlin.Long)(usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Specify the usage flags to be configured on the underlying `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances created by the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. |

## Public constructors

### Builder

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

```
Builder(width: Int, height: Int)
```

| Parameters |
|---|---|
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Width of the buffers created by the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` instance |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Height of the buffers created by the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` instance |

## Public functions

### build

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

```
fun build(): CanvasBufferedRenderer
```

Create the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` with the specified parameters on this `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` | The newly created `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` instance. |

### setBufferFormat

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

```
fun setBufferFormat(format: Int): CanvasBufferedRenderer.Builder
```

Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. The set of valid formats is implementation-specific. The particular valid combinations for a given Android version and implementation should be documented by that version.

`https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBX_8888` are guaranteed to be supported. However, consumers are recommended to query the desired `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` configuration using `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#isSupported(int, int, int, int, long)`.

| Parameters |
|---|---|
| `format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Pixel format of the buffers to be rendered into. The default is RGBA_8888. Value is one of the following: - `1` - `22` - `43` - `2` - `3` - `4` - `33` - `35` - `48` - `49` - `50` - `51` - `52` - `53` - `54` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | The builder instance |

### setMaxBuffers

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

```
fun setMaxBuffers(numBuffers: @IntRange(from = 1, to = 64) Int): CanvasBufferedRenderer.Builder
```

Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. If 1 is specified, then the created `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` is running in "single buffer mode". In this case consumption of the buffer content would need to be coordinated with the `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` returned by the callback of `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#drawAsync(java.util.concurrent.Executor,androidx.core.util.Consumer)`.

| Parameters |
|---|---|
| `numBuffers: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1, to = 64) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of buffers within the swap chain to be consumed by the created `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. This must be greater than zero. The default number of buffers used is 3. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | The builder instance |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#drawAsync(java.util.concurrent.Executor,androidx.core.util.Consumer)` |   |

### setUsageFlags

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

```
fun setUsageFlags(usageFlags: Long): CanvasBufferedRenderer.Builder
```

Specify the usage flags to be configured on the underlying `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances created by the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`.

| Parameters |
|---|---|
| `usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Usage flags to be configured on the created `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances that the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` will render into. Must be one of `https://developer.android.com/reference/kotlin/androidx/hardware/HardwareBufferUsage`. Note that the provided flags here are combined with the following mandatory default flags, `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_GPU_SAMPLED_IMAGE`, `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_GPU_COLOR_OUTPUT` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_COMPOSER_OVERLAY` Value is one of the following: - `2` - `3` - `32` - `48` - `256` - `512` - `2048` - `16384` - `65536` - `16777216` - `8388608` - `33554432` - `67108864` - `4294967296` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder` | The builder instance |