Kleidos API Search

In development. It changes without notice.

Topic

Render Canvas

The canvas over the display, the smooth shapes it draws, and the choice of how an e-paper panel refreshes.

Files

file src/ui/render/aa_shapes.cpp
Device implementation of the coverage-AA circle / annulus / line primitives.
file src/ui/render/aa_shapes.h
Coverage-based anti-aliased circle / disc / swept-annulus primitives.
file src/ui/render/epaper_render_mode.h
Per-screen render-mode policy and settle detector for the CoreInk e-paper.
file src/ui/render/raster_canvas.cpp
Pass-through kleidos::ui::Canvas implementation over the display:: HAL.
file src/ui/render/raster_canvas.h
Pass-through kleidos::ui::Canvas over the immediate-mode display:: HAL.

Classes

struct kleidos::ui::aa::Annulus
The ring a swept, gauge or sector annulus fill paints into. More about kleidos::ui::aa::Annulus
struct kleidos::ui::render::EpaperFrameDecision
What the orchestrator should do with the current tick. More about kleidos::ui::render::EpaperFrameDecision
class kleidos::ui::render::EpaperSettleController
Stateful settle detector that maps a screen's mode + activity to a plan. More about kleidos::ui::render::EpaperSettleController
class kleidos::ui::RasterCanvas
Concrete Canvas that delegates to the display:: HAL. More about kleidos::ui::RasterCanvas

Enumerations

enum class kleidos::ui::render::EpaperRenderMode : uint8_t { kleidos::ui::render::EpaperRenderMode::OneBitAlways, kleidos::ui::render::EpaperRenderMode::OneBitQuality, kleidos::ui::render::EpaperRenderMode::GrayStatic, kleidos::ui::render::EpaperRenderMode::GrayOnSettle, kleidos::ui::render::EpaperRenderMode::GrayOnEntry }
How a screen should be committed on the CoreInk e-paper. More about kleidos::ui::render::EpaperRenderMode
enum class kleidos::ui::render::EpaperSurface : uint8_t { kleidos::ui::render::EpaperSurface::NavigableList, kleidos::ui::render::EpaperSurface::LiveCountdown, kleidos::ui::render::EpaperSurface::PinDial, kleidos::ui::render::EpaperSurface::Animated, kleidos::ui::render::EpaperSurface::ReadPanel, kleidos::ui::render::EpaperSurface::IdentityCard, kleidos::ui::render::EpaperSurface::OnboardingStatic, kleidos::ui::render::EpaperSurface::Count }
What kind of surface a screen is, for the render-mode policy. More about kleidos::ui::render::EpaperSurface

Functions

boolkleidos::ui::aa::available ()
Whether the active display backend supports AA blending.
voidkleidos::ui::aa::setScanClip (int16_t x, int16_t y, int16_t w, int16_t h)
Cut every primitive's scan to a rectangle: the canvas clip.
voidkleidos::ui::aa::clearScanClip ()
Release the rectangle ui::aa::setScanClip armed, so scans reach the whole screen again.
voidkleidos::ui::aa::fillDiscAA (int16_t cx, int16_t cy, int16_t radius, uint16_t color, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased filled disc.
voidkleidos::ui::aa::strokeCircleAA (int16_t cx, int16_t cy, int16_t radius, int16_t thickness, uint16_t color, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased circle outline of a given stroke thickness.
voidkleidos::ui::aa::strokeLineAA (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t thickness, uint16_t color, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased thick line (round-capped) via coverage/SDF.
voidkleidos::ui::aa::strokeLineAAQ4 (int32_t x0q, int32_t y0q, int32_t x1q, int32_t y1q, int16_t thickness, uint16_t color, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased thick line (round-capped) with sub-pixel endpoints.
voidkleidos::ui::aa::fillRoundRectAA (const Rect &rect, int16_t radius, uint16_t color, uint16_t knownBg=theme::kBg565)
Fill an anti-aliased rounded rectangle.
voidkleidos::ui::aa::strokeRoundRectAA (const Rect &rect, int16_t radius, uint16_t color, int16_t thickness=1, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased rounded-rectangle outline of a given thickness.
voidkleidos::ui::aa::fillMarkBodyAA (const MarkBodyShape &shape, const MarkBodyInks &inks, uint16_t knownBg=theme::kBg565)
Draw the Kleidos mark's body, its outline and its keyhole in one coverage pass.
voidkleidos::ui::aa::fillAnnulusSweepAA (const Annulus &ring, int16_t sweepDeg, uint16_t color, uint16_t knownBg=theme::kBg565)
Draw an anti-aliased annulus sector ("pie band") swept from 12 o'clock.
voidkleidos::ui::aa::fillAnnulusGaugeAA (const Annulus &ring, int16_t sweepDeg, uint16_t trackColor, uint16_t fillColor, uint16_t knownBg=theme::kBg565)
Paint a gauge ring — a dim full-ring track with a bright [0, sweepDeg] progress wedge — in a single antialiased band pass.
voidkleidos::ui::aa::fillAnnulusSpanAA (const Annulus &ring, int16_t startDeg, int16_t sweepDeg, uint16_t trackColor, uint16_t fillColor, uint16_t knownBg=theme::kBg565)
Paint a gauge ring whose lit arc starts anywhere: a dim full-ring track with a bright [startDeg, startDeg + sweepDeg] arc, in one antialiased band pass.
voidkleidos::ui::aa::fillAnnulusSectorAA (const Annulus &ring, int16_t fromDeg, int16_t toDeg, uint16_t color, uint16_t knownBg=theme::kBg565)
Paint only the angular slice [fromDeg, toDeg] of an annulus band.
constexpr EpaperRenderModekleidos::ui::render::epaperModeFor (EpaperSurface surface)
The render mode surface is committed with.
constexpr boolkleidos::ui::render::entryFrameIsGray (EpaperRenderMode mode)
Whether mode commits its first frame of a visit in 6-tone gray.

Variables

constexpr std::array< EpaperRenderMode, static_cast< size_t >(EpaperSurface::Count)>kleidos::ui::render::kEpaperModeBySurface
How each surface is committed. Indexed by EpaperSurface.
constexpr uint32_tkleidos::ui::render::kEpaperSettleDelayMs
Default idle window before a settled list repaints in gray.

Back to the top

Enumeration Type Documentation

EpaperRenderMode #

enum class kleidos::ui::render::EpaperRenderMode : uint8_t

How a screen should be committed on the CoreInk e-paper.

Enumerator
OneBitAlways 

Always 1-bit, FAST partial (custom short animation LUT, ~245 ms). For genuinely animated sub-second surfaces: the PIN timing arc, bouncing demos. The fast LUT trades contrast for speed and does NOT hold retained pixels to full black across many partials, so it is wrong for a screen you READ.

OneBitQuality 

Always 1-bit, STANDARD partial (the manufacturer DC-balanced waveform, ~550 ms). For readable navigable screens (the vault list, TOTP tab, settings tree, host picker): moves are still dirty-region partials, but the balanced waveform holds retained content at full contrast instead of fading it.

GrayStatic 

Always 6-tone gray. For static screens: lock face, onboarding, splash.

GrayOnSettle 

1-bit while moving, one 6-tone repaint after input settles. Lists/settings.

GrayOnEntry 

One 6-tone repaint on entry, then 1-bit STANDARD partials for the rest of the visit. For a surface that is opened to be read and then left: an info panel, the credential identity card, an onboarding page. The entry frame is worth its cost because it is the frame the owner reads; everything after it — a page turn, a band step, a reveal — is a partial on the balanced waveform, which holds the retained frame at full contrast (the fast LUT would fade what is still on the glass). Unlike GrayOnSettle it never re-settles to gray, so no refresh ever blocks the loop mid-visit.

EpaperSurface #

enum class kleidos::ui::render::EpaperSurface : uint8_t

What kind of surface a screen is, for the render-mode policy.

A screen declares what it is; this module decides how it is committed. The rule lives in one table (ui::render::kEpaperModeBySurface) instead of a mode picked per handler, so the policy can be read and tested in one place.

Enumerator
NavigableList 

A screen the dial moves through: the vault list, the settings tree, the pickers and steppers, Set clock, the editors, the host picker, and the credential's second level. Every move is a partial, so it stays 1-bit.

LiveCountdown 

A screen that repaints on its own clock: the TOTP tab, the 2FA code and the PIN screen while the brute-force lockout counts down. Gray would refresh under the countdown it is drawing.

PinDial 

The PIN timing arc, the tutorial arc and the wipe dial: a gesture is read from the glass while it is happening, so speed beats contrast.

Animated 

A surface that animates: the BLE pairing spinner and its success frame, the component gallery, the hardware test.

ReadPanel 

A panel that is opened to be read and does not move under the reader: the info panels (About, the BLE identity, the diagnostics tables).

IdentityCard 

The credential identity card, while the dial has not yet acted on it.

OnboardingStatic 

An onboarding page that is read and then left: the welcome and the done pages, which have no timer and no moving content.

Count 

Number of surfaces; not a surface.

Back to the top

Function Documentation

available() #

bool kleidos::ui::aa::available()

Whether the active display backend supports AA blending.

True on every color panel — both the read-modify-write back-end (readable shadow buffer) and the known-background back-end (no shadow buffer, e.g. the 320x240 classic boards). The per-pixel path is chosen internally from display::canReadRect, so callers do not need to distinguish them.

Return values
ValueMeaning
trueColor panel (blending possible via either back-end).
falseE-paper / mono — use the crisp non-AA primitives.

entryFrameIsGray() #

bool kleidos::ui::render::entryFrameIsGray(EpaperRenderMode mode)
constexpr

Whether mode commits its first frame of a visit in 6-tone gray.

Parameters
NameDirectionMeaning
modeinThe mode a screen declared.
Returns
Whether entering the screen costs one gray frame.

epaperModeFor() #

EpaperRenderMode kleidos::ui::render::epaperModeFor(EpaperSurface surface)
constexpr

The render mode surface is committed with.

Parameters
NameDirectionMeaning
surfaceinThe kind of surface on the glass.
Returns
Its mode; OneBitQuality for a value outside the table, which is the mode that is always safe to read.

fillAnnulusGaugeAA() #

void kleidos::ui::aa::fillAnnulusGaugeAA(const Annulus & ring, int16_t sweepDeg, uint16_t trackColor, uint16_t fillColor, uint16_t knownBg = theme::kBg565)

Paint a gauge ring — a dim full-ring track with a bright [0, sweepDeg] progress wedge — in a single antialiased band pass.

Equivalent to a full-ring fillAnnulusSweepAA in trackColor followed by a sweepDeg one in fillColor, but computes the per-pixel distance and angle once (about half the work), so it is cheap enough to animate per frame.

Parameters
NameDirectionMeaning
ringinThe ring (center and radii); no-op when its outer radius is not past its inner one.
sweepDeginProgress wedge angle in degrees [0, 360]; 0 = track only.
trackColorinRGB565 dim full-ring color.
fillColorinRGB565 bright progress color, over the track.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

fillAnnulusSectorAA() #

void kleidos::ui::aa::fillAnnulusSectorAA(const Annulus & ring, int16_t fromDeg, int16_t toDeg, uint16_t color, uint16_t knownBg = theme::kBg565)

Paint only the angular slice [fromDeg, toDeg] of an annulus band.

The incremental sibling of fillAnnulusSweepAA — instead of repainting the whole [0, sweepDeg] wedge, it fills just the newly revealed angular band [fromDeg, toDeg] (clockwise from 12 o'clock) over the existing track — so a monotonically growing gauge can advance by drawing only the thin new slice each frame instead of the cumulative wedge. Both the curved radial boundaries and the two angular edges are antialiased; the trailing edge at fromDeg uses the same feather as the previous slice's leading edge so the seam between consecutive slices stays smooth (a small overlap is harmless). The bounding box is tightened to the slice's angular span where possible. A no-op for an empty span (toDeg <= fromDeg).

Parameters
NameDirectionMeaning
ringinThe ring (center and radii); no-op when its outer radius is not past its inner one.
fromDeginSlice start angle (degrees), 0..360.
toDeginSlice end angle (degrees), 0..360; <= fromDeg fills nothing.
colorinRGB565 fill color, blended over the destination.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

fillAnnulusSpanAA() #

void kleidos::ui::aa::fillAnnulusSpanAA(const Annulus & ring, int16_t startDeg, int16_t sweepDeg, uint16_t trackColor, uint16_t fillColor, uint16_t knownBg = theme::kBg565)

Paint a gauge ring whose lit arc starts anywhere: a dim full-ring track with a bright [startDeg, startDeg + sweepDeg] arc, in one antialiased band pass.

The general form of fillAnnulusGaugeAA (which is this span from 12 o'clock). The arc is measured clockwise from startDeg and may run on past 12 o'clock, which is what a turning segment does; its two radial edges get the same feather as the gauge's.

Parameters
NameDirectionMeaning
ringinThe ring (center and radii); no-op when its outer radius is not past its inner one.
startDeginWhere the lit arc begins, degrees clockwise from 12 o'clock (wrapped to [0, 360)).
sweepDeginThe lit arc's length in degrees [0, 360]; 0 = track only.
trackColorinRGB565 dim full-ring color.
fillColorinRGB565 bright arc color, over the track.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

fillAnnulusSweepAA() #

void kleidos::ui::aa::fillAnnulusSweepAA(const Annulus & ring, int16_t sweepDeg, uint16_t color, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased annulus sector ("pie band") swept from 12 o'clock.

Fills the area inside the annulus [rInner, rOuter] AND within the swept angle [0, sweepDeg], measured clockwise from straight up (top). Both the curved inner/outer boundaries and the radial leading edge are anti-aliased.

Parameters
NameDirectionMeaning
ringinThe ring (center and radii); no-op when its outer radius is not past its inner one.
sweepDeginSwept angle in degrees [0, 360]; 0 fills nothing.
colorinRGB565 fill color, blended over the destination.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

fillDiscAA() #

void kleidos::ui::aa::fillDiscAA(int16_t cx, int16_t cy, int16_t radius, uint16_t color, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased filled disc.

Parameters
NameDirectionMeaning
cxinCenter X (px).
cyinCenter Y (px).
radiusinDisc radius (px); no-op when <= 0.
colorinRGB565 fill color, blended over the destination at the edge.
knownBginRGB565 solid background to blend against on panels without a readable framebuffer; ignored on the read-modify-write path.

fillMarkBodyAA() #

void kleidos::ui::aa::fillMarkBodyAA(const MarkBodyShape & shape, const MarkBodyInks & inks, uint16_t knownBg = theme::kBg565)

Draw the Kleidos mark's body, its outline and its keyhole in one coverage pass.

Scans ui::markBodyBounds, cut to the screen and to the scan clip, one row at a time through its host-testable row shader, so the fill, the outline and the keyhole blend in the same row against the same pixels: on the known-background path the outline's inner edge blends over the fill, not over knownBg. The body's ends are exact semicircles, the outline is one width all round, and every length is sub-pixel, centered on the mark's center pixel.

Color-TFT only. No-op unless available().

Parameters
NameDirectionMeaning
shapeinThe mark's body and keyhole.
inksinTheir inks.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

fillRoundRectAA() #

void kleidos::ui::aa::fillRoundRectAA(const Rect & rect, int16_t radius, uint16_t color, uint16_t knownBg = theme::kBg565)

Fill an anti-aliased rounded rectangle.

Straight edges are exact (full-coverage) fills; only the four corner quarter-discs are coverage-anti-aliased over the destination — the highest visible win for cards / buttons / the popup modal / text fields. Clamps the corner radius to half the shorter side.

Color-TFT only. No-op unless available(); callers fall back to the crisp display::fillRoundRect otherwise.

Parameters
NameDirectionMeaning
rectinThe rectangle (px); no-op when empty.
radiusinCorner radius (px); clamped, <= 0 falls back to a plain rect.
colorinRGB565 fill color, blended over the destination at corners.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

setScanClip() #

void kleidos::ui::aa::setScanClip(int16_t x, int16_t y, int16_t w, int16_t h)

Cut every primitive's scan to a rectangle: the canvas clip.

The software clip already keeps every write inside it; this keeps the per-pixel coverage work inside it too, so a clipped draw costs what it can change, and each pixel inside comes out as an unclipped draw makes it. ui::RasterCanvas::clip arms it and ui::RasterCanvas::clipReset clears it.

Parameters
NameDirectionMeaning
xinLeft edge (px).
yinTop edge (px).
winWidth (px); a non-positive width scans nothing.
hinHeight (px); a non-positive height scans nothing.

strokeCircleAA() #

void kleidos::ui::aa::strokeCircleAA(int16_t cx, int16_t cy, int16_t radius, int16_t thickness, uint16_t color, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased circle outline of a given stroke thickness.

Parameters
NameDirectionMeaning
cxinCenter X (px).
cyinCenter Y (px).
radiusinMid-stroke radius (px); no-op when <= 0.
thicknessinStroke width (px), >= 1; the band spans radius±thickness/2.
colorinRGB565 stroke color, blended over the destination.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

strokeLineAA() #

void kleidos::ui::aa::strokeLineAA(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t thickness, uint16_t color, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased thick line (round-capped) via coverage/SDF.

Treats the stroke as every pixel within thickness / 2 of the segment [(x0,y0), (x1,y1)] and ramps coverage across the one-pixel edge band — the same analytic-coverage method as the disc / annulus primitives, so it unifies cleanly with the AA family. Round caps fall out of the point-to-segment distance for free. Integer / fixed-point throughout (no float in the per-pixel loop); blends over the live shadow framebuffer.

Color-TFT only. No-op unless available(); callers fall back to the crisp stacked-line primitive on e-paper / mono backends.

Parameters
NameDirectionMeaning
x0inSegment start X (px).
y0inSegment start Y (px).
x1inSegment end X (px).
y1inSegment end Y (px).
thicknessinStroke width (px), >= 1.
colorinRGB565 stroke color, blended over the destination.
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

strokeLineAAQ4() #

void kleidos::ui::aa::strokeLineAAQ4(int32_t x0q, int32_t y0q, int32_t x1q, int32_t y1q, int16_t thickness, uint16_t color, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased thick line (round-capped) with sub-pixel endpoints.

strokeLineAA with each endpoint in sixteenths of a pixel (a pixel's center on a whole multiple of 16), so a stroke that turns by a fraction of a pixel per frame moves by that fraction instead of jumping a whole pixel.

Color-TFT only. No-op unless available().

Parameters
NameDirectionMeaning
x0qinSegment start X (1/16 px).
y0qinSegment start Y (1/16 px).
x1qinSegment end X (1/16 px).
y1qinSegment end Y (1/16 px).
thicknessinStroke width (px), >= 1.
colorinRGB565 stroke color, blended over the destination.
knownBginRGB565 solid background for the no-readback path.

strokeRoundRectAA() #

void kleidos::ui::aa::strokeRoundRectAA(const Rect & rect, int16_t radius, uint16_t color, int16_t thickness = 1, uint16_t knownBg = theme::kBg565)

Draw an anti-aliased rounded-rectangle outline of a given thickness.

The whole contour band (all four straight edges and the four corner quarter-rings) is coverage-anti-aliased to equal weight — the stroke is the pixels whose distance to the rounded-rect contour is within thickness / 2, so every side renders at the same width with smooth corners (no off-by-one on the right / bottom edge, no jagged corner stubs). Mirrors fillRoundRectAA for outlined cards / fields / the focus box.

Color-TFT only. No-op unless available().

Parameters
NameDirectionMeaning
rectinThe rectangle the contour runs along (px); no-op when empty.
radiusinCorner radius (px); clamped, <= 0 falls back to a plain rect.
colorinRGB565 stroke color, blended over the destination.
thicknessinStroke width (px), >= 1 (defaults to a 1 px contour).
knownBginRGB565 solid background for the no-readback path (ignored on the read-modify-write path).

Back to the top