GLFrameBufferRenderer.Callback
public interface GLFrameBufferRenderer.Callback
GLFrameBufferRenderer callbacks that are invoked to render OpenGL content within the underlying buffers. This includes an optional callback to be used to configure the underlying SurfaceControlCompat.Transaction used to present content to the display
Summary
Public methods |
|
|---|---|
default void |
@WorkerThreadOptional callback invoked the thread backed by the |
default void |
@WorkerThreadOptional callback invoked the thread backed by the |
abstract void |
@WorkerThreadCallback invoked on the thread backed by the |
Public methods
onBufferReleased
@WorkerThread
default void onBufferReleased(
@NonNull FrameBuffer frameBuffer,
SyncFenceCompat releaseFence
)
Optional callback invoked the thread backed by the GLRenderer when the provided framebuffer is released. That is the given FrameBuffer instance is no longer being presented and is not visible.
| Parameters | |
|---|---|
@NonNull FrameBuffer frameBuffer |
The buffer that is no longer being presented and has returned to the buffer allocation pool |
SyncFenceCompat releaseFence |
Optional fence that must be waited upon before the |
onDrawComplete
@WorkerThread
default void onDrawComplete(
@NonNull SurfaceControlCompat targetSurfaceControl,
@NonNull SurfaceControlCompat.Transaction transaction,
@NonNull FrameBuffer frameBuffer,
SyncFenceCompat syncFence
)
Optional callback invoked the thread backed by the GLRenderer when rendering to a buffer is complete but before the buffer is submitted to the hardware compositor. This provides consumers a mechanism for synchronizing the transaction with other SurfaceControlCompat objects that maybe rendered within the scene.
| Parameters | |
|---|---|
@NonNull SurfaceControlCompat targetSurfaceControl |
Handle to the |
@NonNull SurfaceControlCompat.Transaction transaction |
Current |
@NonNull FrameBuffer frameBuffer |
The buffer that has been rendered into and is ready to be displayed. The |
SyncFenceCompat syncFence |
Optional |
onDrawFrame
@WorkerThread
abstract void onDrawFrame(
@NonNull EGLManager eglManager,
int width,
int height,
@NonNull BufferInfo bufferInfo,
@NonNull float[] transform
)
Callback invoked on the thread backed by the GLRenderer to render content into a buffer with the specified parameters.
import androidx.graphics.lowlatency.BufferInfo import androidx.graphics.opengl.GLFrameBufferRenderer import androidx.graphics.opengl.egl.EGLManager val surfaceView = SurfaceView(context) val renderer = GLFrameBufferRenderer.Builder(surfaceView, object : GLFrameBufferRenderer.Callback { val myMatrix = FloatArray(16) val result = FloatArray(16) override fun onDrawFrame( eglManager: EGLManager, width: Int, height: Int, bufferInfo: BufferInfo, transform: FloatArray ) { Matrix.orthoM( myMatrix, // matrix 0, // offset starting index into myMatrix 0f, // left bufferInfo.width.toFloat(), // right 0f, // bottom bufferInfo.width.toFloat(), // top -1f, // near 1f // far ) Matrix.multiplyMM(result, 0, myMatrix, 0, transform, 0) // pass result matrix as uniform to shader logic } }).build() renderer.render()
| Parameters | |
|---|---|
@NonNull EGLManager eglManager |
|
int width |
Logical width of the content to render. This dimension matches what is provided from |
int height |
Logical height of the content to render. This dimension matches what is provided from |
@NonNull BufferInfo bufferInfo |
|
@NonNull float[] transform |
Matrix that should be applied to the rendering in this callback. This should be consumed as input to any vertex shader implementations. Buffers are pre-rotated in advance in order to avoid unnecessary overhead of GPU composition to rotate content in the same install orientation of the display. This is a 4 x 4 matrix is represented as a flattened array of 16 floating point values. Consumers are expected to leverage val myMatrix = FloatArray(16) |