ListenableGlesRenderer


abstract class ListenableGlesRenderer : Renderer.GlesRenderer


ListenableFuture-based compatibility wrapper around Renderer.GlesRenderer's suspending methods.

Summary

Public constructors

ListenableGlesRenderer(
    surfaceHolder: SurfaceHolder,
    currentUserStyleRepository: CurrentUserStyleRepository,
    watchState: WatchState,
    interactiveDrawModeUpdateDelayMillis: @IntRange(from = 0, to = 60000) Long,
    eglConfigAttribList: IntArray,
    eglSurfaceAttribList: IntArray
)

This function is deprecated. Use ListenableGlesRenderer2 instead

Public functions

open suspend Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

open suspend Unit
onUiThreadGlSurfaceCreated(width: @Px Int, height: @Px Int)

This function is deprecated. Use ListenableGlesRenderer2 instead

Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

Protected functions

open ListenableFuture<Unit>

This function is deprecated. Use ListenableGlesRenderer2 instead

open ListenableFuture<Unit>

This function is deprecated. Use ListenableGlesRenderer2 instead

Inherited functions

From androidx.wear.watchface.Renderer
open Rect

This function is deprecated. Use ListenableGlesRenderer2 instead

Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

open Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

open Boolean

This function is deprecated. Use ListenableGlesRenderer2 instead

From androidx.wear.watchface.Renderer.GlesRenderer
open Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

open Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

abstract Unit
@UiThread
render(zonedDateTime: ZonedDateTime)

This function is deprecated. Use ListenableGlesRenderer2 instead

abstract Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

suspend Unit

This function is deprecated. Use ListenableGlesRenderer2 instead

suspend Unit
runUiThreadGlCommands(commands: suspend () -> Unit)

This function is deprecated. Use ListenableGlesRenderer2 instead

Inherited properties

From androidx.wear.watchface.Renderer
Collection<Pair<IntContentDescriptionLabel>>

This property is deprecated. Use ListenableGlesRenderer2 instead

@Px Float

This property is deprecated. Use ListenableGlesRenderer2 instead

@Px Float

This property is deprecated. Use ListenableGlesRenderer2 instead

Long

This property is deprecated. Use ListenableGlesRenderer2 instead

RenderParameters

This property is deprecated. Use ListenableGlesRenderer2 instead

Rect

This property is deprecated. Use ListenableGlesRenderer2 instead

SurfaceHolder

This property is deprecated. Use ListenableGlesRenderer2 instead

WatchFaceColors?

This property is deprecated. Use ListenableGlesRenderer2 instead

From androidx.wear.watchface.Renderer.GlesRenderer
EGLContext

This property is deprecated. Use ListenableGlesRenderer2 instead

EGLConfig

This property is deprecated. Use ListenableGlesRenderer2 instead

EGLDisplay

This property is deprecated. Use ListenableGlesRenderer2 instead

EGLContext

This property is deprecated. Use ListenableGlesRenderer2 instead

Public constructors

ListenableGlesRenderer

Added in 1.0.0
Deprecated in 1.1.0
ListenableGlesRenderer(
    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
)

Public functions

onBackgroundThreadGlContextCreated

Added in 1.0.0
Deprecated in 1.1.0
open suspend fun onBackgroundThreadGlContextCreated(): Unit

Called once a background thread when a new GL context is created on the background thread, before any subsequent calls to render. Note this function is called inside a lambda passed to runBackgroundThreadGlCommands which has synchronized access to the GL context.

If you need to override this method in java, consider using androidx.wear.watchface.ListenableGlesRenderer instead.

onUiThreadGlSurfaceCreated

Added in 1.0.0
Deprecated in 1.1.0
open suspend fun onUiThreadGlSurfaceCreated(width: @Px Int, height: @Px Int): Unit

Called when a new GL surface is created on the UiThread, before any subsequent calls to render or in response to SurfaceHolder.Callback.surfaceChanged. Note this function is called inside a lambda passed to runUiThreadGlCommands which has synchronized access to the GL context.

If you need to override this method in java, consider using androidx.wear.watchface.ListenableGlesRenderer instead.

Parameters
width: @Px Int

width of surface in pixels

height: @Px Int

height of surface in pixels

runBackgroundThreadGlCommands

Added in 1.0.0
Deprecated in 1.1.0
@WorkerThread
fun runBackgroundThreadGlCommands(runnable: Runnable): Unit

Inside of a Mutex this function sets the GL context associated with the WatchFaceService.getBackgroundThreadHandler's looper thread as the current one, executes 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 WatchFaceService).

NB this function is called by the library before running runBackgroundThreadGlCommands so there's no need to use this directly in client code unless you need to make GL calls outside of those methods.

Throws
kotlin.IllegalStateException

if the calls to EGL14.eglMakeCurrent fails

runUiThreadGlCommands

Added in 1.0.0
Deprecated in 1.1.0
@UiThread
fun runUiThreadGlCommands(runnable: Runnable): Unit

Inside of a Mutex this function sets the UiThread GL context as the current one, executes 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 WatchFaceService).

Throws
kotlin.IllegalStateException

if the calls to EGL14.eglMakeCurrent fails

Protected functions

onBackgroundThreadGlContextCreatedFuture

Added in 1.0.0
Deprecated in 1.1.0
protected open fun onBackgroundThreadGlContextCreatedFuture(): ListenableFuture<Unit>

Called once a background thread when a new GL context is created on the background thread, before any subsequent calls to render. Note this function is called inside a lambda passed to runBackgroundThreadGlCommands which has synchronized access to the GL context. Note cancellation of the returned future is not supported.

Returns
ListenableFuture<Unit>

A ListenableFuture which is resolved when background thread work has completed. Rendering will be blocked until this has resolved.

onUiThreadGlSurfaceCreatedFuture

Added in 1.0.0
Deprecated in 1.1.0
@UiThread
protected open fun onUiThreadGlSurfaceCreatedFuture(width: @Px Int, height: @Px Int): ListenableFuture<Unit>

Called when a new GL surface is created on the UiThread, before any subsequent calls to render and in response to SurfaceHolder.Callback.surfaceChanged. Note this function is called inside a lambda passed to Renderer.GlesRenderer.runUiThreadGlCommands which has synchronized access to the GL context. Note cancellation of the returned future is not supported.

Parameters
width: @Px Int

width of surface in pixels

height: @Px Int

height of surface in pixels

Returns
ListenableFuture<Unit>

A ListenableFuture which is resolved when UI thread work has completed. Rendering will be blocked until this has resolved.