GLFrameBufferRenderer


@RequiresApi(value = 29)
class GLFrameBufferRenderer


Class responsible for supporting rendering to frame buffer objects that are backed by HardwareBuffer instances. This provides for more flexibility in OpenGL rendering as it supports configuration of the number of buffers within the underlying swap chain, pixel format of the buffers as well as fine grained control over synchronization of buffer content.

Summary

Nested types

Builder used to create a GLFrameBufferRenderer with various configurations

GLFrameBufferRenderer callbacks that are invoked to render OpenGL content within the underlying buffers.

Public functions

Unit
execute(runnable: Runnable)

Queue a Runnable to be executed on the GL rendering thread.

Boolean

Determines whether or not the GLFrameBufferRenderer is in a valid state.

Unit
release(cancelPending: Boolean, onReleaseCallback: (() -> Unit)?)

Release resources associated with the GLFrameBufferRenderer.

Unit

Render content to a buffer and present the result to the display.

Public properties

Int

Returns the HardwareBufferFormat of the buffers that are being rendered into by this GLFrameBufferRenderer

GLRenderer

Returns the GLRenderer used for issuing requests to render into the underlying buffers with OpenGL.

Int

Returns the number of buffers within the swap chain used for rendering with this GLFrameBufferRenderer

SyncStrategy

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

Long

Returns the current usage flag hints of the buffers that are being rendered into by this GLFrameBufferRenderer

Public functions

execute

Added in 1.0.2
fun execute(runnable: Runnable): Unit

Queue a Runnable to be executed on the GL rendering thread. Note it is important this Runnable does not block otherwise it can stall the GL thread.

Parameters
runnable: Runnable

to be executed

isValid

Added in 1.0.2
fun isValid(): Boolean

Determines whether or not the GLFrameBufferRenderer is in a valid state. That is the release method has not been called. If this returns false, then subsequent calls to render, and release are ignored

Returns
Boolean

true if this GLFrameBufferRenderer has been released, false otherwise

release

Added in 1.0.2
fun release(cancelPending: Boolean, onReleaseCallback: (() -> Unit)? = null): Unit

Release resources associated with the GLFrameBufferRenderer. After this method is invoked, the GLFrameBufferRenderer is in an invalid state and can no longer handle rendering content.

Parameters
cancelPending: Boolean

Flag to indicate that in process requests should be completed before the GLFrameBufferRenderer is released.

onReleaseCallback: (() -> Unit)? = null

Optional callback to be invoked on the underlying OpenGL thread when releasing resources has been completed

render

Added in 1.0.2
fun render(): Unit

Render content to a buffer and present the result to the display.

If this GLFrameBufferRenderer has been released, that is isValid returns false, this call is ignored.

Public properties

bufferFormat

Added in 1.0.2
val bufferFormatInt

Returns the HardwareBufferFormat of the buffers that are being rendered into by this GLFrameBufferRenderer

glRenderer

Added in 1.0.2
val glRendererGLRenderer

Returns the GLRenderer used for issuing requests to render into the underlying buffers with OpenGL.

maxBuffers

Added in 1.0.2
val maxBuffersInt

Returns the number of buffers within the swap chain used for rendering with this GLFrameBufferRenderer

syncStrategy

Added in 1.0.2
val syncStrategySyncStrategy

Returns 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.

usageFlags

Added in 1.0.2
val usageFlagsLong

Returns the current usage flag hints of the buffers that are being rendered into by this GLFrameBufferRenderer