# CanvasBufferedRenderer.RenderRequest

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.RenderRequest) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
inner class CanvasBufferedRenderer.RenderRequest
```

<br />

*** ** * ** ***

Sets the parameters that can be used to control a render request for a `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer`. This is not thread-safe and must not be held on to for longer than a single request.

## Summary

| ### Public functions |
|---|---|
| `suspend https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderResult` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#draw(kotlin.Boolean)(waitForFence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Syncs the `https://developer.android.com/reference/android/graphics/RenderNode.html` tree to the render thread and requests content to be drawn synchronously. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#drawAsync(java.util.concurrent.Executor,androidx.core.util.Consumer)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderResult> )` Syncs the `https://developer.android.com/reference/android/graphics/RenderNode.html` tree to the render thread and requests content to be drawn. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#preserveContents(kotlin.Boolean)(preserve: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Determines whether or not previous buffer contents will be persisted across render requests. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#setBufferTransform(kotlin.Int)(bufferTransform: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Specifies a transform to be applied before content is rendered. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` | `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#setColorSpace(android.graphics.ColorSpace)(colorSpace: https://developer.android.com/reference/android/graphics/ColorSpace.html?)` Configures the color space which the content should be rendered in. |

## Public functions

### draw

```
suspend fun draw(waitForFence: Boolean = true): CanvasBufferedRenderer.RenderResult
```

Syncs the `https://developer.android.com/reference/android/graphics/RenderNode.html` tree to the render thread and requests content to be drawn synchronously. This `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` instance should no longer be used after calling this method. The system internally may reuse instances of `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` to reduce allocation churn.

| Parameters |
|---|---|
| `waitForFence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Optional flag to determine if the `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` is also waited upon before returning as a convenience in order to enable callers to consume the `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` returned in the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderResult` immediately after this method returns. Passing `false` here on Android T and below is a no-op as the graphics rendering pipeline internally blocks on the fence before returning. |

### drawAsync

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

```
fun drawAsync(
    executor: Executor,
    callback: Consumer<CanvasBufferedRenderer.RenderResult>
): Unit
```

Syncs the `https://developer.android.com/reference/android/graphics/RenderNode.html` tree to the render thread and requests content to be drawn. This `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` instance should no longer be used after calling this method. The system internally may reuse instances of `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest` to reduce allocation churn.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if this method is invoked after the `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer` has been closed. |

### preserveContents

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

```
fun preserveContents(preserve: Boolean): CanvasBufferedRenderer.RenderRequest
```

Determines whether or not previous buffer contents will be persisted across render requests. If false then contents are cleared before issuing drawing instructions, otherwise contents will remain.

If contents are known in advance to be completely opaque and cover all pixels within the buffer, setting this flag to true will slightly improve performance as the clear operation will be skipped.

For low latency use cases (ex applications that support drawing with a stylus), setting this value to true alongside single buffered rendering by configuring `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.Builder#setMaxBuffers(kotlin.Int)` to 1 allows for reduced latency by allowing consumers to only render the deltas across frames as the previous content would be persisted.

The default setting is false.

### setBufferTransform

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

```
fun setBufferTransform(bufferTransform: Int): CanvasBufferedRenderer.RenderRequest
```

Specifies a transform to be applied before content is rendered. This is useful for pre-rotating content for the current display orientation to increase performance of displaying the associated buffer. This transformation will also adjust the light source position for the specified rotation.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/graphics/CanvasBufferedRenderer.RenderRequest#setBufferTransform(kotlin.Int)` is not one of: `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_IDENTITY()`, `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_ROTATE_90()`, `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_ROTATE_180()`, or `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_ROTATE_270()` |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl.Transaction.html` | #setBufferTransform(SurfaceControl, int) |

### setColorSpace

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

```
fun setColorSpace(colorSpace: ColorSpace?): CanvasBufferedRenderer.RenderRequest
```

Configures the color space which the content should be rendered in. This affects how the framework will interpret the color at each pixel. The color space provided here must be non-null, RGB based and leverage an ICC parametric curve. The min/max values of the components should not reduce the numerical range compared to the previously assigned color space. If left unspecified, the default color space of SRGB will be used.

**NOTE** this method is only supported on Android U and above and is ignored on older Android versions