Added in API level 29

HardwareRenderer.FrameRenderRequest


public final class HardwareRenderer.FrameRenderRequest
extends Object

java.lang.Object
   ↳ 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, Runnable frameCommitCallback)

Adds a frame commit callback.

HardwareRenderer.FrameRenderRequest setVsyncTime(long vsyncTime)

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

HardwareRenderer.FrameRenderRequest setWaitForPresent(boolean shouldWait)

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

int syncAndDraw()

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

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

setFrameCommitCallback

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

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.

Returns
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

setVsyncTime

Added in API level 29
public HardwareRenderer.FrameRenderRequest setVsyncTime (long vsyncTime)

Sets the vsync time that represents the start point of this frame. Typically this comes from Choreographer.FrameCallback. Other compatible time sources include System.nanoTime(), however if the result is being displayed on-screen then using 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.

Returns
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

setWaitForPresent

Added in API level 29
public HardwareRenderer.FrameRenderRequest setWaitForPresent (boolean shouldWait)

Sets whether or not syncAndDraw() should block until the frame has been presented. If this is true and syncAndDraw() does not return HardwareRenderer.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.

Returns
HardwareRenderer.FrameRenderRequest this instance This value cannot be null.

syncAndDraw

Added in API level 29
public int syncAndDraw ()

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.