RenderParameters

public final class RenderParameters


Used to parameterize watch face rendering.

Watch face rendering is split up in a number of layers: the base layer WatchFaceLayer.BASE, the ComplicationSlots layer WatchFaceLayer.COMPLICATIONS, and the layer above the complicationSlots WatchFaceLayer.COMPLICATIONS_OVERLAY. These layers are always drawn in this order, one on top of the previous one. These are the layers that are used to render the watch face itself.

An additional layer, the highlight layer, can be drawn during editing the watch face to highlight different elements of the watch face, namely a set of ComplicationSlots (which may be a single ComplicationSlot) or the area of the watch face that is affected by a single user style setting.

The watch face should provide a way to highlight any of the above combinations so that its own editor, or the one provided by the Wear OS companion phone app is able to highlight the editable part of the watch face to the user. If an individual user style setting is meant to affect the entire watch face (e.g. an overall color setting),then the entire watch face should be highlighted.

The watch face layers and highlight layer can be configured independently, so that it is possible to draw only the highlight layer by passing an empty set of watchFaceLayers.

The semantics of rendering different layers is such that if each individual layer is rendered independently and the resulting images are composited with alpha blending, the result is identical to rendering all of the layers in a single request.

Summary

Nested types

The definition of what to include in the highlight layer.

An element of the watch face to highlight.

All ComplicationSlots will be highlighted.

A single androidx.wear.watchface.ComplicationSlot with the specified id will be highlighted.

A UserStyleSetting to highlight.

Public fields

static final @NonNull RenderParameters

Default RenderParameters which draws everything in interactive mode.

Public constructors

RenderParameters(
    @NonNull DrawMode drawMode,
    @NonNull Set<@NonNull WatchFaceLayer> watchFaceLayers,
    RenderParameters.HighlightLayer highlightLayer,
    @NonNull Map<@NonNull Integer, @NonNull TapEvent> lastComplicationTapDownEvents
)

Public methods

boolean
equals(Object other)
final @NonNull DrawMode

The overall drawing parameters based on system state.

final RenderParameters.HighlightLayer

Optional HighlightLayer used by editors to visually highlight an aspect of the watch face.

final @NonNull Map<@NonNull Integer, @NonNull TapEvent>

Map of ComplicationSlot id to the latest TapType.DOWN that ComplicationSlot received, if any.

final @NonNull Set<@NonNull WatchFaceLayer>

The parts of the watch face to draw.

int
final boolean

Whether or not we're rendering for a screenshot.

Public fields

DEFAULT_INTERACTIVE

public static final @NonNull RenderParameters DEFAULT_INTERACTIVE

Default RenderParameters which draws everything in interactive mode.

Public constructors

RenderParameters

public RenderParameters(
    @NonNull DrawMode drawMode,
    @NonNull Set<@NonNull WatchFaceLayer> watchFaceLayers,
    RenderParameters.HighlightLayer highlightLayer,
    @NonNull Map<@NonNull Integer, @NonNull TapEvent> lastComplicationTapDownEvents
)
Parameters
@NonNull DrawMode drawMode

The overall drawing parameters based on system state.

@NonNull Set<@NonNull WatchFaceLayer> watchFaceLayers

The parts of the watch face to draw.

RenderParameters.HighlightLayer highlightLayer

Optional HighlightLayer used by editors to visually highlight an aspect of the watch face. Rendered last on top of watchFaceLayers. If highlighting isn't needed this will be null.

@NonNull Map<@NonNull Integer, @NonNull TapEvent> lastComplicationTapDownEvents

Map of ComplicationSlot id to the latest TapType.DOWN that ComplicationSlot received, if any.

Public methods

equals

public boolean equals(Object other)

getDrawMode

Added in 1.0.0
public final @NonNull DrawMode getDrawMode()

The overall drawing parameters based on system state.

getHighlightLayer

Added in 1.0.0
public final RenderParameters.HighlightLayer getHighlightLayer()

Optional HighlightLayer used by editors to visually highlight an aspect of the watch face. Rendered last on top of watchFaceLayers. If highlighting isn't needed this will be null.

getLastComplicationTapDownEvents

Added in 1.0.0
public final @NonNull Map<@NonNull Integer, @NonNull TapEventgetLastComplicationTapDownEvents()

Map of ComplicationSlot id to the latest TapType.DOWN that ComplicationSlot received, if any.

getWatchFaceLayers

Added in 1.0.0
public final @NonNull Set<@NonNull WatchFaceLayergetWatchFaceLayers()

The parts of the watch face to draw.

hashCode

public int hashCode()

isForScreenshot

Added in 1.1.0
public final boolean isForScreenshot()

Whether or not we're rendering for a screenshot. Some watch faces with animations may need to make adjustments when a screen shot is taken to achieve the best result.

Note Renderer.CanvasRenderer2 and Renderer.CanvasRenderer always use software rendering for screenshots.