Renderer

public class Renderer

Known direct subclasses
Renderer.CanvasRenderer

Watch faces that require Canvas rendering should extend their Renderer from this class.

Renderer.GlesRenderer

Watch faces that require GLES20 rendering should extend their Renderer from this class.

Known indirect subclasses
ListenableCanvasRenderer

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

ListenableGlesRenderer

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


The base class for CanvasRenderer and GlesRenderer. Renderers are constructed on a background thread but all rendering is done on the UiThread. There is a memory barrier between construction and rendering so no special threading primitives are required.

Summary

Nested types

Renderer.CanvasRenderer

Watch faces that require Canvas rendering should extend their Renderer from this class.

Renderer.GlesRenderer

Watch faces that require GLES20 rendering should extend their Renderer from this class.

Renderer.GlesRenderer.GlesException

Exception thrown if a GL call fails

Public fields

final @NonNull Collection<@NonNull Pair<@NonNull Integer, @NonNull ContentDescriptionLabel>>

Accessibility ContentDescriptionLabel for any rendered watch face elements other than the time and ComplicationSlots which are generated automatically.

final @Px float

The center x coordinate of the SurfaceHolder this Renderer renders into.

final @Px float

The center y coordinate of the SurfaceHolder this Renderer renders into.

final long

The interval in milliseconds between frames in interactive DrawModes.

final @NonNull RenderParameters

The current RenderParameters.

final @NonNull Rect

The bounds of the SurfaceHolder this Renderer renders into.

final @NonNull SurfaceHolder

The SurfaceHolder that renderInternal will draw into.

Public methods

@UiThread @NonNull Rect

This method is used for accessibility support to describe the portion of the screen containing the main clock element.

final @UiThread void

Schedules a call to either CanvasRenderer.render or GlesRenderer.render to draw the next frame.

@UiThread void

Called when the Renderer is destroyed.

abstract @UiThread void

Called when adb shell dumpsys is invoked for the WatchFaceService, allowing the renderer to optionally record state for debugging purposes.

final void

Posts a message to schedule a call to either CanvasRenderer.render or GlesRenderer.render to draw the next frame.

@UiThread boolean

The system periodically (at least once per minute) calls onTimeTick() to trigger a display update.

Public fields

additionalContentDescriptionLabels

@NonNull
public final @NonNull Collection<@NonNull Pair<@NonNull Integer, @NonNull ContentDescriptionLabel>> additionalContentDescriptionLabels

Accessibility ContentDescriptionLabel for any rendered watch face elements other than the time and ComplicationSlots which are generated automatically.

The Int in the Pair<Int, ContentDescriptionLabel> is used to sort the ContentDescriptionLabels. Note the time piece has an accessibility traversal index of -1 and each ComplicationSlot's index is defined by its ComplicationSlot.accessibilityTraversalIndex.

centerX

@Px
@NonNull
public final @