# 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)

*** ** * ** ***


```
public final class FrontBufferSyncStrategy implements SyncStrategy
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/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/androidx/graphics/lowlatency/FrontBufferSyncStrategy#FrontBufferSyncStrategy(kotlin.Long)(long usageFlags)` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/hardware/SyncFenceCompat` | `https://developer.android.com/reference/androidx/graphics/lowlatency/FrontBufferSyncStrategy#createSyncFence(androidx.graphics.opengl.egl.EGLSpec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec eglSpec)` Creates a `https://developer.android.com/reference/androidx/hardware/SyncFenceCompat` based on various conditions. |
| `final boolean` | `https://developer.android.com/reference/androidx/graphics/lowlatency/FrontBufferSyncStrategy#isVisible()()` Tells whether the corresponding front buffer layer is visible in its current state or not. |
| `final void` | `https://developer.android.com/reference/androidx/graphics/lowlatency/FrontBufferSyncStrategy#setVisible(kotlin.Boolean)(boolean visibility)` 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)

```
public FrontBufferSyncStrategy(long usageFlags)
```

| Parameters |
|---|---|
| `long usageFlags` | 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/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 methods

### createSyncFence

```
public SyncFenceCompat createSyncFence(@NonNull EGLSpec eglSpec)
```

Creates a `https://developer.android.com/reference/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.

### isVisible

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

```
public final boolean isVisible()
```

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/androidx/hardware/SyncFenceCompat` will be created when using `https://developer.android.com/reference/androidx/graphics/lowlatency/FrontBufferSyncStrategy#createSyncFence(androidx.graphics.opengl.egl.EGLSpec)`.

### setVisible

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

```
public final void setVisible(boolean visibility)
```

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/androidx/hardware/SyncFenceCompat` will be created when using `https://developer.android.com/reference/androidx/graphics/lowlatency/FrontBufferSyncStrategy#createSyncFence(androidx.graphics.opengl.egl.EGLSpec)`.