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 |
int
|
syncAndDraw()
Syncs the RenderNode tree to the render thread and requests a frame to be drawn. |
Inherited methods | |
---|---|
Public methods
setFrameCommitCallback
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
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
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
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.
Returns | |
---|---|
int |
The result of the sync operation.
Value is HardwareRenderer.SYNC_OK , HardwareRenderer.SYNC_REDRAW_REQUESTED , HardwareRenderer.SYNC_LOST_SURFACE_REWARD_IF_FOUND , HardwareRenderer.SYNC_CONTEXT_IS_STOPPED , or HardwareRenderer.SYNC_FRAME_DROPPED |