# HardwareRenderer.FrameRenderRequest

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# FrameRenderRequest

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/graphics/HardwareRenderer.FrameRenderRequest "View this page in Java")  

```
class FrameRenderRequest
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                               ||
| ↳ | [android.graphics.HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) |

Sets the parameters that can be used to control a render request for a[HardwareRenderer](https://developer.android.com/reference/kotlin/android/graphics/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](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | [setFrameCommitCallback](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#setFrameCommitCallback(java.util.concurrent.Executor,%20java.lang.Runnable))`(`executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `frameCommitCallback:` `[Runnable](https://developer.android.com/reference/kotlin/java/lang/Runnable.html#)`)` Adds a frame commit callback.  |
| [HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | [setVsyncTime](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#setVsyncTime(kotlin.Long))`(`vsyncTime:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets the vsync time that represents the start point of this frame.                                                                                                                                                        |
| [HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | [setWaitForPresent](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#setWaitForPresent(kotlin.Boolean))`(`shouldWait:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether or not[syncAndDraw()](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())should block until the frame has been presented. |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                                  | [syncAndDraw](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())`()` Syncs the RenderNode tree to the render thread and requests a frame to be drawn.                                                                                                                                                                                                                                                  |

## Public methods

### setFrameCommitCallback

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/view/PixelCopy.html#)to capture the current rendered content of the UI reliably.

|                                                                                                                                                            Parameters                                                                                                                                                            ||
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executor`            | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):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](https://developer.android.com/reference/kotlin/java/lang/Runnable.html#):The callback to invoke when the frame content has been drawn. Will be invoked on the given[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#). This value cannot be`null`. |

|                                                                                         Return                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | this instance This value cannot be`null`. |

### setVsyncTime

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/view/Choreographer.FrameCallback.html#). Other compatible time sources include[System.nanoTime()](https://developer.android.com/reference/kotlin/java/lang/System.html#nanoTime()), however if the result is being displayed on-screen then using[android.view.Choreographer](https://developer.android.com/reference/kotlin/android/view/Choreographer.html#)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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):The vsync timestamp for this frame. The timestamp is in nanoseconds and should come from a CLOCK_MONOTONIC source. |

|                                                                                         Return                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | this instance This value cannot be`null`. |

### setWaitForPresent

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setWaitForPresent(shouldWait: Boolean): HardwareRenderer.FrameRenderRequest
```

Sets whether or not[syncAndDraw()](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())should block until the frame has been presented. If this is true and[syncAndDraw()](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())does not return[SYNC_FRAME_DROPPED](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_FRAME_DROPPED:kotlin.Int)or an error then when[syncAndDraw()](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())has returned the frame has been submitted to the[Surface](https://developer.android.com/reference/kotlin/android/view/Surface.html#). 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)](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback2.html#surfaceRedrawNeeded(android.view.SurfaceHolder))where it is desired to block until a frame has been presented to ensure first-frame consistency with other Surfaces.

|                                                                                                                                       Parameters                                                                                                                                        ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `shouldWait` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):If true the next call to[syncAndDraw()](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#syncAndDraw())will block until completion. |

|                                                                                         Return                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [HardwareRenderer.FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#) | this instance This value cannot be`null`. |

### syncAndDraw

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun syncAndDraw(): Int
```

Syncs the RenderNode tree to the render thread and requests a frame to be drawn. This[FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#)instance should no longer be used after calling this method. The system internally may reuse instances of[FrameRenderRequest](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer.FrameRenderRequest#)to reduce allocation churn.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Return                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The result of the sync operation. Value is[android.graphics.HardwareRenderer#SYNC_OK](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_OK:kotlin.Int),[android.graphics.HardwareRenderer#SYNC_REDRAW_REQUESTED](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_REDRAW_REQUESTED:kotlin.Int),[android.graphics.HardwareRenderer#SYNC_LOST_SURFACE_REWARD_IF_FOUND](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_LOST_SURFACE_REWARD_IF_FOUND:kotlin.Int),[android.graphics.HardwareRenderer#SYNC_CONTEXT_IS_STOPPED](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_CONTEXT_IS_STOPPED:kotlin.Int), or[android.graphics.HardwareRenderer#SYNC_FRAME_DROPPED](https://developer.android.com/reference/kotlin/android/graphics/HardwareRenderer#SYNC_FRAME_DROPPED:kotlin.Int) |