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

*** ** * ** ***


```
public final inner class CanvasBufferedRenderer.RenderRequest
```

<br />

*** ** * ** ***

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

## Summary

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

## Public methods

### draw

```
public final @NonNull CanvasBufferedRenderer.RenderResult draw(boolean waitForFence)
```

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/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/androidx/graphics/CanvasBufferedRenderer.RenderRequest` to reduce allocation churn.

| Parameters |
|---|---|
| `boolean waitForFence` | Optional flag to determine if the `https://developer.android.com/reference/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/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)

```
public final void drawAsync(
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull CanvasBufferedRenderer.RenderResult> callback
)
```

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/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/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/androidx/graphics/CanvasBufferedRenderer` has been closed. |

### preserveContents

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

```
public final @NonNull CanvasBufferedRenderer.RenderRequest preserveContents(boolean preserve)
```

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

```
public final @NonNull CanvasBufferedRenderer.RenderRequest setBufferTransform(int bufferTransform)
```

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/androidx/graphics/CanvasBufferedRenderer.RenderRequest#setBufferTransform(kotlin.Int)` is not one of: `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_IDENTITY()`, `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_ROTATE_90()`, `https://developer.android.com/reference/androidx/graphics/surface/SurfaceControlCompat#BUFFER_TRANSFORM_ROTATE_180()`, or `https://developer.android.com/reference/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)

```
public final @NonNull CanvasBufferedRenderer.RenderRequest setColorSpace(ColorSpace colorSpace)
```

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