Added in API level 29

FrameRenderRequest


class FrameRenderRequest
kotlin.Any
   ↳ android.graphics.HardwareRenderer.FrameRenderRequest

Sets the parameters that can be used to control a render request for a HardwareRenderer. This is not thread-safe and must not be held on to for longer than a single frame request.

Summary

Public methods
HardwareRenderer.FrameRenderRequest
setFrameCommitCallback(executor: Executor, frameCommitCallback: Runnable)

Adds a frame commit callback.

HardwareRenderer.FrameRenderRequest
setVsyncTime(vsyncTime: Long)

Sets the vsync time that represents the start point of this frame.

HardwareRenderer.FrameRenderRequest

Sets whether or not syncAndDraw() should block until the frame has been presented.

Int

Syncs the RenderNode tree to the render thread and requests a frame to be drawn.

Public methods

setFrameCommitCallback

Added in API level 29
fun setFrameCommitCallback(
    executor: Executor,
    frameCommitCallback: Runnable
): HardwareRenderer.FrameRenderRequest

Adds a frame commit callback. This callback will be invoked when the current rendering content has been rendered into a frame and submitted to the swap chain. The frame may not currently be visible on the display when this is invoked, but it has been submitted. This callback is useful in combination with PixelCopy to capture the current rendered content of the UI reliably.

Parameters
executor Executor: The executor to run the callback on. It is strongly recommended that this executor post to a different thread, as the calling thread is highly sensitive to being blocked. This value cannot be null.
frameCommitCallback Runnable: The callback to invoke when the frame content has been drawn. Will be invoked on the given Executor. This value cannot be null.
Return
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

setVsyncTime

Added in API level 29
fun setVsyncTime(vsyncTime: Long): HardwareRenderer.FrameRenderRequest

Sets the vsync time that represents the start point of this frame. Typically this comes from android.view.Choreographer.FrameCallback. Other compatible time sources include System#nanoTime(), however if the result is being displayed on-screen then using android.view.Choreographer is strongly recommended to ensure smooth animations.

If the clock source is not from a CLOCK_MONOTONIC source then any animations driven directly by RenderThread will not be synchronized properly with the current frame.

Parameters
vsyncTime Long: The vsync timestamp for this frame. The timestamp is in nanoseconds and should come from a CLOCK_MONOTONIC source.
Return
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

setWaitForPresent

Added in API level 29
fun setWaitForPresent(shouldWait: Boolean): HardwareRenderer.FrameRenderRequest

Sets whether or not syncAndDraw() should block until the frame has been presented. If this is true and syncAndDraw() does not return SYNC_FRAME_DROPPED or an error then when syncAndDraw() has returned the frame has been submitted to the Surface. The default and typically recommended value is false, as blocking for present will prevent pipelining from happening, reducing overall throughput. This is useful for situations such as SurfaceHolder.Callback2#surfaceRedrawNeeded(SurfaceHolder) where it is desired to block until a frame has been presented to ensure first-frame consistency with other Surfaces.

Parameters
shouldWait Boolean: If true the next call to syncAndDraw() will block until completion.
Return
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

syncAndDraw

Added in API level 29
fun syncAndDraw(): Int

Syncs the RenderNode tree to the render thread and requests a frame to be drawn. This FrameRenderRequest instance should no longer be used after calling this method. The system internally may reuse instances of FrameRenderRequest to reduce allocation churn.

Return
Int The result of the sync operation. Value is android.graphics.HardwareRenderer#SYNC_OK, android.graphics.HardwareRenderer#SYNC_REDRAW_REQUESTED, android.graphics.HardwareRenderer#SYNC_LOST_SURFACE_REWARD_IF_FOUND, android.graphics.HardwareRenderer#SYNC_CONTEXT_IS_STOPPED, or android.graphics.HardwareRenderer#SYNC_FRAME_DROPPED