GLFrameBufferRenderer.Builder


class GLFrameBufferRenderer.Builder


Builder used to create a GLFrameBufferRenderer with various configurations

Summary

Public constructors

Builder(
    surfaceView: SurfaceView,
    callback: GLFrameBufferRenderer.Callback
)

Create a new GLFrameBufferRenderer.Builder with the provided SurfaceView to be the parent of the SurfaceControlCompat that is presented on screen.

Public functions

GLFrameBufferRenderer

Create the GLFrameBufferRenderer with the specified parameters on this Builder instance

GLFrameBufferRenderer.Builder

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

GLFrameBufferRenderer.Builder
setGLRenderer(glRenderer: GLRenderer?)

Configure the GLRenderer instance to be used by the GLFrameBufferRenderer.

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

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

GLFrameBufferRenderer.Builder

Specify the SyncStrategy used for determining when to create SyncFenceCompat objects in order to handle synchronization.

GLFrameBufferRenderer.Builder
setUsageFlags(usageFlags: Long)

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

Public constructors

Builder

Added in 1.0.0-rc01
Builder(
    surfaceView: SurfaceView,
    callback: GLFrameBufferRenderer.Callback
)

Create a new GLFrameBufferRenderer.Builder with the provided SurfaceView to be the parent of the SurfaceControlCompat that is presented on screen.

Parameters
surfaceView: SurfaceView

SurfaceView to be the parent of the SurfaceControlCompat instance used for presenting rendered content on screen

callback: GLFrameBufferRenderer.Callback

Callback used to render content within the corresponding buffers as well as optionally configuring SurfaceControlCompat.Transaction to present contents to the display

Public functions

build

Added in 1.0.0-rc01
fun build(): GLFrameBufferRenderer

Create the GLFrameBufferRenderer with the specified parameters on this Builder instance

Returns
GLFrameBufferRenderer

The newly created GLFrameBufferRenderer

setBufferFormat

Added in 1.0.0-rc01
fun setBufferFormat(format: Int): GLFrameBufferRenderer.Builder

Specify the buffer format of the underlying buffers being rendered into by the created GLFrameBufferRenderer. The set of valid formats is implementation-specific and may depend on additional EGL extensions. 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.

See: khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_get_native_client_buffer.txt

Parameters
format: Int

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

Returns
GLFrameBufferRenderer.Builder

The builder instance

setGLRenderer

Added in 1.0.0-rc01
fun setGLRenderer(glRenderer: GLRenderer?): GLFrameBufferRenderer.Builder

Configure the GLRenderer instance to be used by the GLFrameBufferRenderer. By default this parameter is null indicating that the GLFrameBufferRenderer will create and manage its own GLRenderer. This is useful to share the same OpenGL resources and thread across multiple GLFrameBufferRenderer instances.

Parameters
glRenderer: GLRenderer?

The GLRenderer used for leveraging OpenGL resources including the GL thread

Returns
GLFrameBufferRenderer.Builder

The builder instance

setMaxBuffers

Added in 1.0.0-rc01
fun setMaxBuffers(numBuffers: @IntRange(from = 1, to = 64) Int): GLFrameBufferRenderer.Builder

Specify the maximum number of buffers used within the swap chain of the GLFrameBufferRenderer. If 1 is specified, then the created GLFrameBufferRenderer is running in "single buffer mode". In this case consumption of the buffer content would need to be coordinated with the SyncFenceCompat instance specified by the corresponding SyncStrategy algorithm

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

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

Returns
GLFrameBufferRenderer.Builder

The builder instance

See also
setSyncStrategy

.

setSyncStrategy

Added in 1.0.0-rc01
fun setSyncStrategy(syncStrategy: SyncStrategy): GLFrameBufferRenderer.Builder

Specify the SyncStrategy used for determining when to create SyncFenceCompat objects in order to handle synchronization. The SyncFenceCompat instance created according to the algorithm specified in the provided SyncStrategy will be passed to the corresponding SurfaceControlCompat.Transaction.setBuffer call in order to ensure the underlying buffer is not presented by the display until the fence signals.

Parameters
syncStrategy: SyncStrategy

SyncStrategy used to determine when to create synchronization boundaries for buffer consumption. The default is SyncStrategy.ALWAYS, indicating a fence should always be created after a request to render has been made.

Returns
GLFrameBufferRenderer.Builder

The builder instance

setUsageFlags

Added in 1.0.0-rc01
fun setUsageFlags(usageFlags: Long): GLFrameBufferRenderer.Builder

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

Parameters
usageFlags: Long

Usage flags to be configured on the created HardwareBuffer instances that the GLFrameBufferRenderer 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
GLFrameBufferRenderer.Builder

The builder instance