GLFrameBufferRenderer.Builder


public final class GLFrameBufferRenderer.Builder


Builder used to create a GLFrameBufferRenderer with various configurations

Summary

Public constructors

Builder(
    @NonNull SurfaceView surfaceView,
    @NonNull GLFrameBufferRenderer.Callback callback
)

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

Public methods

final @NonNull GLFrameBufferRenderer

Create the GLFrameBufferRenderer with the specified parameters on this Builder instance

final @NonNull GLFrameBufferRenderer.Builder
setBufferFormat(int format)

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

final @NonNull GLFrameBufferRenderer.Builder

Configure the GLRenderer instance to be used by the GLFrameBufferRenderer.

final @NonNull GLFrameBufferRenderer.Builder
setMaxBuffers(@IntRange(from = 1, to = 64) int numBuffers)

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

final @NonNull GLFrameBufferRenderer.Builder

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

final @NonNull GLFrameBufferRenderer.Builder
setUsageFlags(long usageFlags)

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

Public constructors

Builder

Added in 1.0.2
public Builder(
    @NonNull SurfaceView surfaceView,
    @NonNull GLFrameBufferRenderer.Callback callback
)

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

Parameters
@NonNull SurfaceView surfaceView

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

@NonNull GLFrameBufferRenderer.Callback callback

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

Public methods

build

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer build()

Create the GLFrameBufferRenderer with the specified parameters on this Builder instance

setBufferFormat

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer.Builder setBufferFormat(int format)

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
int format

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

Returns
@NonNull GLFrameBufferRenderer.Builder

The builder instance

setGLRenderer

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer.Builder setGLRenderer(GLRenderer glRenderer)

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
@NonNull GLFrameBufferRenderer.Builder

The builder instance

setMaxBuffers

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer.Builder setMaxBuffers(@IntRange(from = 1, to = 64) int numBuffers)

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
@IntRange(from = 1, to = 64) int numBuffers

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
@NonNull GLFrameBufferRenderer.Builder

The builder instance

See also
setSyncStrategy

.

setSyncStrategy

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer.Builder setSyncStrategy(@NonNull SyncStrategy syncStrategy)

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
@NonNull 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
@NonNull GLFrameBufferRenderer.Builder

The builder instance

setUsageFlags

Added in 1.0.2
public final @NonNull GLFrameBufferRenderer.Builder setUsageFlags(long usageFlags)

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

Parameters
long usageFlags

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
@NonNull GLFrameBufferRenderer.Builder

The builder instance