CanvasBufferedRenderer.Builder


class CanvasBufferedRenderer.Builder


Builder used to construct a CanvasBufferedRenderer instance.

Summary

Public constructors

Builder(width: Int, height: Int)

Public functions

CanvasBufferedRenderer

Create the CanvasBufferedRenderer with the specified parameters on this Builder instance.

CanvasBufferedRenderer.Builder

Specify the buffer format of the underlying buffers being rendered into by the created CanvasBufferedRenderer.

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

Specify the maximum number of buffers used within the swap chain of the CanvasBufferedRenderer.

CanvasBufferedRenderer.Builder
setUsageFlags(usageFlags: Long)

Specify the usage flags to be configured on the underlying HardwareBuffer instances created by the CanvasBufferedRenderer.

Public constructors

Builder

Added in 1.0.2
Builder(width: Int, height: Int)
Parameters
width: Int

Width of the buffers created by the CanvasBufferedRenderer instance

height: Int

Height of the buffers created by the CanvasBufferedRenderer instance

Public functions

build

Added in 1.0.2
fun build(): CanvasBufferedRenderer

Create the CanvasBufferedRenderer with the specified parameters on this Builder instance.

Returns
CanvasBufferedRenderer

The newly created CanvasBufferedRenderer instance.

setBufferFormat

Added in 1.0.2
fun setBufferFormat(format: Int): CanvasBufferedRenderer.Builder

Specify the buffer format of the underlying buffers being rendered into by the created 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.

HardwareBuffer.RGBA_8888 and HardwareBuffer.RGBX_8888 are guaranteed to be supported. However, consumers are recommended to query the desired HardwareBuffer configuration using HardwareBuffer.isSupported.

Parameters
format: Int

Pixel format of the buffers to be rendered into. The default is RGBA_8888.

Returns
CanvasBufferedRenderer.Builder

The builder instance

setMaxBuffers

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

Specify the maximum number of buffers used within the swap chain of the CanvasBufferedRenderer. If 1 is specified, then the created CanvasBufferedRenderer is running in "single buffer mode". In this case consumption of the buffer content would need to be coordinated with the SyncFenceCompat returned by the callback of RenderRequest.drawAsync.

Parameters
numBuffers: @IntRange(from = 1, to = 64) Int

The number of buffers within the swap chain to be consumed by the created CanvasBufferedRenderer. This must be greater than zero. The default number of buffers used is 3.

Returns
CanvasBufferedRenderer.Builder

The builder instance

See also
drawAsync

setUsageFlags

Added in 1.0.2
fun setUsageFlags(usageFlags: Long): CanvasBufferedRenderer.Builder

Specify the usage flags to be configured on the underlying HardwareBuffer instances created by the CanvasBufferedRenderer.

Parameters
usageFlags: Long

Usage flags to be configured on the created HardwareBuffer instances that the CanvasBufferedRenderer will render into. Must be one of HardwareBufferUsage. Note that the provided flags here are combined with the following mandatory default flags, HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE, HardwareBuffer.USAGE_GPU_COLOR_OUTPUT and HardwareBuffer.USAGE_COMPOSER_OVERLAY

Returns
CanvasBufferedRenderer.Builder

The builder instance