# ListenableGlesRenderer2

Artifact: [androidx.wear.watchface:watchface-guava](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/ListenableGlesRenderer.kt+class:androidx.wear.watchface.ListenableGlesRenderer2) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

*** ** * ** ***


```
abstract class ListenableGlesRenderer2<SharedAssetsT : Renderer.SharedAssets> : Renderer.GlesRenderer2<SharedAssetsT>
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | [androidx.wear.watchface.Renderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer) ||||
|   | ↳ | [androidx.wear.watchface.Renderer.GlesRenderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer) |||
|   |   | ↳ | [androidx.wear.watchface.Renderer.GlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2)\<SharedAssetsT\> ||
|   |   |   | ↳ | [androidx.wear.watchface.ListenableGlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

`https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`-based compatibility wrapper around `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer`'s suspending methods.

use Watch Face Format instead

## Summary

| ### Public constructors |
|---|
| `<SharedAssetsT : https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.SharedAssets> [ListenableGlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#ListenableGlesRenderer2(android.view.SurfaceHolder,androidx.wear.watchface.style.CurrentUserStyleRepository,androidx.wear.watchface.WatchState,kotlin.Long,kotlin.IntArray,kotlin.IntArray))( surfaceHolder: https://developer.android.com/reference/android/view/SurfaceHolder.html, currentUserStyleRepository: https://developer.android.com/reference/kotlin/androidx/wear/watchface/style/CurrentUserStyleRepository, watchState: https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchState, interactiveDrawModeUpdateDelayMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 60000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, eglConfigAttribList: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html, eglSurfaceAttribList: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html )` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

| ### Public functions |
|---|---|
| `abstract https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<SharedAssetsT>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread [createSharedAssetsFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#createSharedAssetsFuture())()` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `final suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onBackgroundThreadGlContextCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onBackgroundThreadGlContextCreated())()` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `final suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onUiThreadGlSurfaceCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onUiThreadGlSurfaceCreated(kotlin.Int,kotlin.Int))(width: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread [runBackgroundThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runBackgroundThreadGlCommands(java.lang.Runnable))(runnable: https://developer.android.com/reference/java/lang/Runnable.html)` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread [runUiThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runUiThreadGlCommands(java.lang.Runnable))(runnable: https://developer.android.com/reference/java/lang/Runnable.html)` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

| ### Protected functions |
|---|---|
| `final suspend SharedAssetsT` | `[createSharedAssets](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#createSharedAssets())()` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html>` | `[onBackgroundThreadGlContextCreatedFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onBackgroundThreadGlContextCreatedFuture())()` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread [onUiThreadGlSurfaceCreatedFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onUiThreadGlSurfaceCreatedFuture(kotlin.Int,kotlin.Int))(width: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

### Inherited functions

From [androidx.wear.watchface.Renderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer) `open https://developer.android.com/reference/android/graphics/Rect.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[getMainClockElementBounds](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#getMainClockElementBounds())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[invalidate](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#invalidate())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[onRenderParametersChanged](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#onRenderParametersChanged(androidx.wear.watchface.RenderParameters))(renderParameters: https://developer.android.com/reference/kotlin/androidx/wear/watchface/RenderParameters)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[postInvalidate](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#postInvalidate())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[sendPreviewImageNeedsUpdateRequest](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#sendPreviewImageNeedsUpdateRequest())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[shouldAnimate](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#shouldAnimate())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
From [androidx.wear.watchface.Renderer.GlesRenderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
[onDestroy](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#onDestroy())()`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onDump](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#onDump(java.io.PrintWriter))(writer: https://developer.android.com/reference/java/io/PrintWriter.html)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread
[runBackgroundThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#runBackgroundThreadGlCommands(kotlin.coroutines.SuspendFunction0))(commands: suspend () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[runUiThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#runUiThreadGlCommands(kotlin.coroutines.SuspendFunction0))(commands: suspend () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
From [androidx.wear.watchface.Renderer.GlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2) `final https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[render](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#render(java.time.ZonedDateTime))(zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[render](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets))(zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html, sharedAssets: SharedAssetsT)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`final https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[renderHighlightLayer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#renderHighlightLayer(java.time.ZonedDateTime))(zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread
[renderHighlightLayer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#renderHighlightLayer(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets))(
zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html,
sharedAssets: SharedAssetsT
)`

**This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.

### Inherited properties

From [androidx.wear.watchface.Renderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://developer.android.com/reference/kotlin/androidx/wear/watchface/ContentDescriptionLabel>>` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#additionalContentDescriptionLabels()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`@https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#centerX()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`@https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#centerY()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`@https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 60000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#interactiveDrawModeUpdateDelayMillis()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/kotlin/androidx/wear/watchface/RenderParameters` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#renderParameters()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/android/graphics/Rect.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#screenBounds()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/android/view/SurfaceHolder.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#surfaceHolder()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceColors?` `@https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceExperimental
https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer#watchfaceColors()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
From [androidx.wear.watchface.Renderer.GlesRenderer](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer) `https://developer.android.com/reference/android/opengl/EGLContext.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#eglBackgroundThreadContext()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/android/opengl/EGLConfig.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#eglConfig()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/android/opengl/EGLDisplay.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#eglDisplay()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
`https://developer.android.com/reference/android/opengl/EGLContext.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#eglUiThreadContext()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.
From [androidx.wear.watchface.Renderer.GlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#selectedEglConfigAttribListIndex()`

**This property is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead.

## Public constructors

### ListenableGlesRenderer2

```
<SharedAssetsT : Renderer.SharedAssets> [ListenableGlesRenderer2](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#ListenableGlesRenderer2(android.view.SurfaceHolder,androidx.wear.watchface.style.CurrentUserStyleRepository,androidx.wear.watchface.WatchState,kotlin.Long,kotlin.IntArray,kotlin.IntArray))(
    surfaceHolder: SurfaceHolder,
    currentUserStyleRepository: CurrentUserStyleRepository,
    watchState: WatchState,
    interactiveDrawModeUpdateDelayMillis: @IntRange(from = 0, to = 60000) Long,
    eglConfigAttribList: IntArray = EGL_CONFIG_ATTRIB_LIST,
    eglSurfaceAttribList: IntArray = EGL_SURFACE_ATTRIB_LIST
)
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

## Public functions

### createSharedAssetsFuture

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@WorkerThread
abstract fun [createSharedAssetsFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#createSharedAssetsFuture())(): ListenableFuture<SharedAssetsT>
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

When editing multiple `https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceService` instances and hence Renderers can exist concurrently (e.g. a headless instance and an interactive instance) and using `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.SharedAssets` allows memory to be saved by sharing immutable data (e.g. Bitmaps, shaders, etc...) between them.

To take advantage of SharedAssets, override this method. The constructed SharedAssets are passed into the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` as an argument (NB you'll have to cast this to your type). It is safe to make GLES calls within this method.

When all instances using SharedAssets have been closed, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.SharedAssets#onDestroy()` will be called.

Note that while SharedAssets are constructed on a background thread, they'll typically be used on the main thread and subsequently destroyed there. The watch face library constructs shared GLES contexts to allow resource sharing between threads.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<SharedAssetsT>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2` that will be passed into `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` and `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#renderHighlightLayer(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` |

### onBackgroundThreadGlContextCreated

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
final suspend fun [onBackgroundThreadGlContextCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onBackgroundThreadGlContextCreated())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Called once a background thread when a new GL context is created on the background thread, before any subsequent calls to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#render(java.time.ZonedDateTime)`. Note this function is called inside a lambda passed to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#runBackgroundThreadGlCommands(kotlin.coroutines.SuspendFunction0)` which has synchronized access to the GL context.

If you need to override this method in java, consider using `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer` instead.

### onUiThreadGlSurfaceCreated

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
final suspend fun [onUiThreadGlSurfaceCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onUiThreadGlSurfaceCreated(kotlin.Int,kotlin.Int))(width: @Px Int, height: @Px Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Called when a new GL surface is created on the UiThread, before any subsequent calls to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#render(java.time.ZonedDateTime)` or in response to `https://developer.android.com/reference/android/view/SurfaceHolder.Callback.html#surfaceChanged(android.view.SurfaceHolder, int, int, int)`. Note this function is called inside a lambda passed to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#runUiThreadGlCommands(kotlin.coroutines.SuspendFunction0)` which has synchronized access to the GL context.

If you need to override this method in java, consider using `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer` instead.

| Parameters |
|---|---|
| `width: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | width of surface in pixels |
| `height: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | height of surface in pixels |

### runBackgroundThreadGlCommands

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@WorkerThread
fun [runBackgroundThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runBackgroundThreadGlCommands(java.lang.Runnable))(runnable: Runnable): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Inside of a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html` this function sets the GL context associated with the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceService#getBackgroundThreadHandler()`'s looper thread as the current one, executes `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runBackgroundThreadGlCommands(java.lang.Runnable)` and finally unsets the GL context.

Access to the GL context this way is necessary because GL contexts are not shared between renderers and there can be multiple watch face instances existing concurrently (e.g. headless and interactive, potentially from different watch faces if an APK contains more than one `https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceService`).

NB this function is called by the library before running `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runBackgroundThreadGlCommands(java.lang.Runnable)` so there's no need to use this directly in client code unless you need to make GL calls outside of those methods.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the calls to `https://developer.android.com/reference/android/opengl/EGL14.html#eglMakeCurrent(android.opengl.EGLDisplay, android.opengl.EGLSurface, android.opengl.EGLSurface, android.opengl.EGLContext)` fails |

### runUiThreadGlCommands

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@UiThread
fun [runUiThreadGlCommands](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runUiThreadGlCommands(java.lang.Runnable))(runnable: Runnable): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Inside of a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html` this function sets the UiThread GL context as the current one, executes `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runUiThreadGlCommands(java.lang.Runnable)` and finally unsets the GL context.

Access to the GL context this way is necessary because GL contexts are not shared between renderers and there can be multiple watch face instances existing concurrently (e.g. headless and interactive, potentially from different watch faces if an APK contains more than one `https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceService`).

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the calls to `https://developer.android.com/reference/android/opengl/EGL14.html#eglMakeCurrent(android.opengl.EGLDisplay, android.opengl.EGLSurface, android.opengl.EGLSurface, android.opengl.EGLContext)` fails |

## Protected functions

### createSharedAssets

```
protected final suspend fun [createSharedAssets](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#createSharedAssets())(): SharedAssetsT
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

When editing multiple `https://developer.android.com/reference/kotlin/androidx/wear/watchface/WatchFaceService` instances and hence Renderers can exist concurrently (e.g. a headless instance and an interactive instance) and using `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.SharedAssets` allows memory to be saved by sharing immutable data (e.g. Bitmaps, shaders, etc...) between them.

To take advantage of SharedAssets, override this method. The constructed SharedAssets are passed into the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` as an argument (NB you'll have to cast this to your type). It is safe to make GLES calls within this method.

When all instances using SharedAssets have been closed, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.SharedAssets#onDestroy()` will be called.

Note that while SharedAssets are constructed on a background thread, they'll typically be used on the main thread and subsequently destroyed there. The watch face library constructs shared GLES contexts to allow resource sharing between threads.

| Returns |
|---|---|
| `SharedAssetsT` | The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2` that will be passed into `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` and `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer2#renderHighlightLayer(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)`. |

### onBackgroundThreadGlContextCreatedFuture

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
protected open fun [onBackgroundThreadGlContextCreatedFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onBackgroundThreadGlContextCreatedFuture())(): ListenableFuture<Unit>
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Called once a background thread when a new GL context is created on the background thread, before any subsequent calls to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)`. Note this function is called inside a lambda passed to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#runBackgroundThreadGlCommands(java.lang.Runnable)` which has synchronized access to the GL context. Note cancellation of the returned future is not supported.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html>` | A ListenableFuture which is resolved when background thread work has completed. Rendering will be blocked until this has resolved. |

### onUiThreadGlSurfaceCreatedFuture

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.1.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@UiThread
protected open fun [onUiThreadGlSurfaceCreatedFuture](https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#onUiThreadGlSurfaceCreatedFuture(kotlin.Int,kotlin.Int))(width: @Px Int, height: @Px Int): ListenableFuture<Unit>
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Called when a new GL surface is created on the UiThread, before any subsequent calls to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ListenableGlesRenderer2#render(java.time.ZonedDateTime,androidx.wear.watchface.Renderer.SharedAssets)` and in response to `https://developer.android.com/reference/android/view/SurfaceHolder.Callback.html#surfaceChanged(android.view.SurfaceHolder, int, int, int)`. Note this function is called inside a lambda passed to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer.GlesRenderer#runUiThreadGlCommands(kotlin.coroutines.SuspendFunction0)` which has synchronized access to the GL context. Note cancellation of the returned future is not supported.

| Parameters |
|---|---|
| `width: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | width of surface in pixels |
| `height: @https://developer.android.com/reference/kotlin/androidx/annotation/Px https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | height of surface in pixels |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html>` | A ListenableFuture which is resolved when UI thread work has completed. Rendering will be blocked until this has resolved. |