# FrontBufferSyncStrategy

Artifact: [androidx.graphics:graphics-core](https://developer.android.com/jetpack/androidx/releases/graphics) [View Source](https://cs.android.com/search?q=file:androidx/graphics/lowlatency/FrontBufferSyncStrategy.kt+class:androidx.graphics.lowlatency.FrontBufferSyncStrategy) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
class FrontBufferSyncStrategy : SyncStrategy
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` implementation that optimizes for front buffered rendering use cases. More specifically this attempts to avoid unnecessary synchronization overhead wherever possible.

This will always provide a fence if the corresponding layer transitions from an invisible to a visible state. If the layer is already visible and front buffer usage flags are support on the device, then no fence is provided. If this flag is not supported, then a fence is created to ensure contents are flushed to the single buffer.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/FrontBufferSyncStrategy#FrontBufferSyncStrategy(kotlin.Long)(usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |

| ### Public functions |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat?` | `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/FrontBufferSyncStrategy#createSyncFence(androidx.graphics.opengl.egl.EGLSpec)(eglSpec: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec)` Creates a `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` based on various conditions. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/FrontBufferSyncStrategy#isVisible()` Tells whether the corresponding front buffer layer is visible in its current state or not. |

## Public constructors

### FrontBufferSyncStrategy

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
FrontBufferSyncStrategy(usageFlags: Long)
```

| Parameters |
|---|---|
| `usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | usage flags that describe the `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` that is used as the destination for rendering content within `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/FrameBufferRenderer`. The usage flags can be obtained via `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#getUsage()` or by passing in the same flags from `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#create(int, int, int, int, long)` |

## Public functions

### createSyncFence

```
open fun createSyncFence(eglSpec: EGLSpec): SyncFenceCompat?
```

Creates a `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` based on various conditions. If the layer is changing from invisible to visible, a fence is provided. If the layer is already visible and front buffer usage flag is supported on the device, then no fence is provided. If front buffer usage is not supported, then a fence is created and destroyed to flush contents to screen.

## Public properties

### isVisible

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
var isVisible: Boolean
```

Tells whether the corresponding front buffer layer is visible in its current state or not. Utilize this to dictate when a `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` will be created when using `https://developer.android.com/reference/kotlin/androidx/graphics/lowlatency/FrontBufferSyncStrategy#createSyncFence(androidx.graphics.opengl.egl.EGLSpec)`.