GLFrameBufferRenderer


@RequiresApi(value = 29)
public final 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 methods

final void

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

final int

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

final @NonNull GLRenderer

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

final int

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

final @NonNull SyncStrategy

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

final long

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

final boolean

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

final void
release(boolean cancelPending, Function0<Unit> onReleaseCallback)

Release resources associated with the GLFrameBufferRenderer.

final void

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

Public methods

execute

Added in 1.0.2
public final void execute(@NonNull Runnable runnable)

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
@NonNull Runnable runnable

to be executed

getBufferFormat

Added in 1.0.2
public final int getBufferFormat()

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

getGLRenderer

Added in 1.0.2
public final @NonNull GLRenderer getGLRenderer()

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

getMaxBuffers

Added in 1.0.2
public final int getMaxBuffers()

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

getSyncStrategy

Added in 1.0.2
public final @NonNull SyncStrategy getSyncStrategy()

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.

getUsageFlags

Added in 1.0.2
public final long getUsageFlags()

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

isValid

Added in 1.0.2
public final boolean isValid()

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
public final void release(boolean cancelPending, Function0<Unit> onReleaseCallback)

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
boolean cancelPending

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

Function0<Unit> onReleaseCallback

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

render

Added in 1.0.2
public final void render()

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.