Kleidos API Search

In development. It changes without notice.

Topic

Brand Lookup & Logo Atlas

From the address or the name in a login to the service's logo.

A domain or a name is brought to one form, hashed, and looked up in an atlas generated from the logos' sources and kept in flash. It draws nothing: the vault asks it which brand a login has, and Brand Logos draws it.

See also
Brand Logos

Files

file src/brands/brand_registry.h
Domain→brand-logo registry: canonicalization, hashing, and lookup.

Classes

struct kleidos::brands::BrandEntry
One brand-atlas record. Kept exactly 16 bytes for compact flash storage. More about kleidos::brands::BrandEntry

Enumerations

enum class kleidos::brands::AssetFamily : uint8_t { kleidos::brands::AssetFamily::None , kleidos::brands::AssetFamily::Color , kleidos::brands::AssetFamily::Mono , kleidos::brands::AssetFamily::Palette4 }
Pixel encoding family of a stored brand asset. More about kleidos::brands::AssetFamily
enum class kleidos::brands::Style : uint8_t { kleidos::brands::Style::Auto , kleidos::brands::Style::Color , kleidos::brands::Style::Mono , kleidos::brands::Style::HighContrast }
Requested rendering style; Auto picks the best available family. More about kleidos::brands::Style
enum class kleidos::brands::Size : uint8_t { kleidos::brands::Size::S16 , kleidos::brands::Size::S24 , kleidos::brands::Size::S32 , kleidos::brands::Size::S48 }
Logical render size in logical pixels (square). More about kleidos::brands::Size

Functions

uint8_tkleidos::brands::sizePixels (Size size)
Pixel side length in pixels for a Size value.
uint32_tkleidos::brands::fnv1a32 (const char *text)
FNV-1a 32-bit hash of a NUL-terminated string.
boolkleidos::brands::canonicalizeDomain (const char *domainOrService, char *out, size_t outLen)
Canonicalize a domain/service string into out.
uint32_tkleidos::brands::hashDomain (const char *domainOrService)
Canonicalize then hash a domain/service in one step.
boolkleidos::brands::hasBrand (const char *domainOrService)
True if the registry has an asset for the given domain/service.
const BrandEntry *kleidos::brands::findBrand (const char *domainOrService, Size size, Style style=Style::Auto)
Resolve the best BrandEntry for a domain/service.

Variables

constexpr size_tkleidos::brands::kMaxCanonicalDomainLen
Max canonical-domain length (incl. NUL).
constexpr uint8_tkleidos::brands::kFlagHasAlphaMask
Entry carries a trailing alpha channel.
constexpr uint8_tkleidos::brands::kFlagHasPaletteHeader
Entry carries a palette header.
constexpr uint8_tkleidos::brands::kFlagDitherFs
Apply Floyd–Steinberg dithering.
constexpr uint8_tkleidos::brands::kFlagAvoidWhiteFill
Avoid filling with white on light themes.
constexpr uint8_tkleidos::brands::kFlagAlphaA4
Alpha channel is 4-bpp (A4) for AA blending.

Color payload layouts

A color entry (AssetFamily::Color, A4 alpha) names its payload layout in flags bits 5..6. Every layout stores each pixel's own A4 nibble and, where that nibble is not 0, its own RGB565 color; under a nibble of 0 the generator stores whatever color packs smallest, since such a pixel shows only the background (the brand generator's encode_color_mark()). Palettes and 16-bit values are big-endian RGB565.

constexpr uint8_tkleidos::brands::kColorCodecMask
constexpr uint8_tkleidos::brands::kColorCodecLegacy
Byte RLE of the RGB565 bytes, then byte RLE of the packed A4 nibbles.
constexpr uint8_tkleidos::brands::kColorCodecPalette16
[n-1][n palette colors][byte RLE of index << 4 | a4, one byte per pixel], n <= 16.
constexpr uint8_tkleidos::brands::kColorCodecRle16
constexpr uint8_tkleidos::brands::kColorCodecIndexed

Enumeration Type Documentation

AssetFamily #

enum class kleidos::brands::AssetFamily : uint8_t

Pixel encoding family of a stored brand asset.

Enumerator
None 

No asset present.

Color 

Full-color RGB565 asset.

Mono 

1-bpp monochrome asset.

Palette4 

Four grays at 2 bits per pixel, dithered on a 1-bit panel.

Size #

enum class kleidos::brands::Size : uint8_t

Logical render size in logical pixels (square).

Enumerator
S16 

16×16.

S24 

24×24.

S32 

32×32.

S48 

48×48.

Style #

enum class kleidos::brands::Style : uint8_t

Requested rendering style; Auto picks the best available family.

Enumerator
Auto 

Any asset the entry has.

Color 

Only the color asset.

Mono 

Only a monochrome or four-gray asset.

HighContrast 

A monochrome, four-gray or color asset.

Function Documentation

canonicalizeDomain() #

bool kleidos::brands::canonicalizeDomain(const char * domainOrService, char * out, size_t outLen)

Canonicalize a domain/service string into out.

The canonical form is the host alone, in lower case: leading spaces, the scheme (https://, or a bare //), any user info before an @, the port, the path, the query, the fragment, trailing dots and a leading www. are dropped.

Parameters
NameDirectionMeaning
domainOrServiceinInput domain or service name.
outoutOutput buffer for the canonical form.
outLeninCapacity of out including NUL.
Return values
ValueMeaning
trueCanonical form was written to out.
falseNo host was found, or it would overflow out; out holds an empty or partial string then.

findBrand() #

const BrandEntry * kleidos::brands::findBrand(const char * domainOrService, Size size, Style style = Style::Auto)

Resolve the best BrandEntry for a domain/service.

Looks up the canonical host first, then its registrable root (login.example.co.uk falls back to example.co.uk), at the exact size asked for and in a family the style accepts.

Parameters
NameDirectionMeaning
domainOrServiceinDomain or service name.
sizeinRequested logical size.
styleinRequested rendering style.
Returns
Pointer to the best matching entry, or nullptr if none.

fnv1a32() #

uint32_t kleidos::brands::fnv1a32(const char * text)

FNV-1a 32-bit hash of a NUL-terminated string.

Hashes the bytes as given, with no canonicalization; a null text hashes as the empty string (the offset basis).

Parameters
NameDirectionMeaning
textinNUL-terminated input string, or null.
Returns
32-bit FNV-1a hash.

hasBrand() #

bool kleidos::brands::hasBrand(const char * domainOrService)

True if the registry has an asset for the given domain/service.

Parameters
NameDirectionMeaning
domainOrServiceinDomain or service name to look up.
Return values
ValueMeaning
trueAt least one brand size is registered for the canonical form.
falseNo entry matches the canonical form.

hashDomain() #

uint32_t kleidos::brands::hashDomain(const char * domainOrService)

Canonicalize then hash a domain/service in one step.

Parameters
NameDirectionMeaning
domainOrServiceinInput domain or service name.
Returns
32-bit FNV-1a hash of the canonical form.

sizePixels() #

uint8_t kleidos::brands::sizePixels(Size size)

Pixel side length in pixels for a Size value.

Size Pixels
S16 16×16
S24 24×24
S32 32×32
S48 48×48
Parameters
NameDirectionMeaning
sizeinLogical size enum.
Returns
Side length in pixels.

Variable Documentation

kColorCodecIndexed #

uint8_t kleidos::brands::kColorCodecIndexed
constexpr

[n-1][n palette colors][byte RLE of one index per pixel], then byte RLE of the packed A4 nibbles, n <= 256.

kColorCodecMask #

uint8_t kleidos::brands::kColorCodecMask
constexpr

Flags bits that name the layout.

kColorCodecRle16 #

uint8_t kleidos::brands::kColorCodecRle16
constexpr

RLE of 16-bit RGB565 values (decodeRle()'s control byte, two bytes a value), then byte RLE of the packed A4 nibbles.