ListenableGlesRenderer


public abstract class ListenableGlesRenderer extends Renderer.GlesRenderer


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

Summary

Public constructors

ListenableGlesRenderer(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull WatchState watchState,
    @IntRange(from = 0, to = 60000) long interactiveDrawModeUpdateDelayMillis,
    @NonNull int[] eglConfigAttribList,
    @NonNull int[] eglSurfaceAttribList
)

This method is deprecated. Use ListenableGlesRenderer2 instead

Public methods

void

This method is deprecated. Use ListenableGlesRenderer2 instead

void
onUiThreadGlSurfaceCreated(@Px int width, @Px int height)

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

Protected methods

@NonNull ListenableFuture<Unit>

This method is deprecated. Use ListenableGlesRenderer2 instead

@NonNull ListenableFuture<Unit>
@UiThread
onUiThreadGlSurfaceCreatedFuture(@Px int width, @Px int height)

This method is deprecated. Use ListenableGlesRenderer2 instead

Inherited methods

From androidx.wear.watchface.Renderer
final @NonNull Collection<@NonNull Pair<@NonNull Integer, @NonNull ContentDescriptionLabel>>

This method is deprecated. Use ListenableGlesRenderer2 instead

final float

This method is deprecated. Use ListenableGlesRenderer2 instead

final float

This method is deprecated. Use ListenableGlesRenderer2 instead

final long

This method is deprecated. Use ListenableGlesRenderer2 instead

@NonNull Rect

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull RenderParameters

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull Rect

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull SurfaceHolder

This method is deprecated. Use ListenableGlesRenderer2 instead

final WatchFaceColors

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void
setInteractiveDrawModeUpdateDelayMillis(
    long interactiveDrawModeUpdateDelayMillis
)

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

boolean

This method is deprecated. Use ListenableGlesRenderer2 instead

From androidx.wear.watchface.Renderer.GlesRenderer
final @NonNull EGLContext

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull EGLConfig

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull EGLDisplay

This method is deprecated. Use ListenableGlesRenderer2 instead

final @NonNull EGLContext

This method is deprecated. Use ListenableGlesRenderer2 instead

void

This method is deprecated. Use ListenableGlesRenderer2 instead

void

This method is deprecated. Use ListenableGlesRenderer2 instead

abstract void

This method is deprecated. Use ListenableGlesRenderer2 instead

abstract void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. Use ListenableGlesRenderer2 instead

final void
runUiThreadGlCommands(@NonNull SuspendFunction0<Unit> commands)

This method is deprecated. Use ListenableGlesRenderer2 instead

final void

This method is deprecated. It's not intended for eglConfig to be set

final void

This method is deprecated. It's not intended for eglDisplay to be set

Public constructors

ListenableGlesRenderer

Added in 1.0.0
Deprecated in 1.1.0
public ListenableGlesRenderer(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull WatchState watchState,
    @IntRange(from = 0, to = 60000) long interactiveDrawModeUpdateDelayMillis,
    @NonNull int[] eglConfigAttribList,
    @NonNull int[] eglSurfaceAttribList
)

Public methods

onBackgroundThreadGlContextCreated

Added in 1.0.0
Deprecated in 1.1.0
public void onBackgroundThreadGlContextCreated()

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
public void onUiThreadGlSurfaceCreated(@Px int width, @Px int height)

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
@Px int width

width of surface in pixels

@Px int height

height of surface in pixels

runBackgroundThreadGlCommands

Added in 1.0.0
Deprecated in 1.1.0
@WorkerThread
public final void runBackgroundThreadGlCommands(@NonNull Runnable runnable)

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
public final void runUiThreadGlCommands(@NonNull Runnable runnable)

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 methods

onBackgroundThreadGlContextCreatedFuture

Added in 1.0.0
Deprecated in 1.1.0
protected @NonNull ListenableFuture<UnitonBackgroundThreadGlContextCreatedFuture()

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
@NonNull 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 @NonNull ListenableFuture<UnitonUiThreadGlSurfaceCreatedFuture(@Px int width, @Px int height)

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
@Px int width

width of surface in pixels

@Px int height

height of surface in pixels

Returns
@NonNull ListenableFuture<Unit>

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