Skip to main content

Module colour

Module colour 

Source
Expand description

Colours of the sites on the screen, and calmer colours (docs/colour.md).

Chromium, inside Qt WebEngine, paints every page in sRGB numbers, and Qt Quick hands them to the screen as they are: on a screen wider than sRGB (an Adobe RGB panel, a P3 one) every colour comes out more saturated than its page meant. A site’s picture goes through a shader (shaders/colour.frag) that looks each pixel up in the two tables made here, once per screen and setting:

  • the cube, 33 × 33 × 33 entries over the sRGB numbers a page holds, each the colour the screen must show, as the screen’s own linear values, unclipped (a colour just outside the screen’s gamut keeps its small negative value, so that interpolating across the edge of the gamut stays smooth); packed in two dimensions, 33 tiles of 33 × 33 side by side, blue choosing the tile;
  • the curve, 1,024 entries per channel turning linear values into the screen’s numbers (the inverse of its tone curves), read at u = y^(1/2.4), which spreads the entries where the eye sees most.

“Calmer colours” softens loud colours before that: each colour’s chroma in OKLCh is limited softly, C' = k · tanh(C / k), its lightness and hue kept (OKLab: Björn Ottosson, “A perceptual color space for image processing”, 2020). Greys and soft tints barely move; a pure red becomes a brick red.

The screen’s profile is read by cpp/screencolours.cpp (the X11 atoms _ICC_PROFILE, matched to screens through colord), which calls sioul_colour_tables. Little CMS (lcms2) reads the profile, on Linux only: Sioul converts to the screen on X11 alone (macOS converts by itself, Windows and Wayland too or not at all), while calmer colours, computed here, work on every computer. Measured against Little CMS’s own transform, the tables give every colour within one 8-bit code (tests, and the research note docs/research/colour.md).

Structs§

Tables 🔒
The two tables the shader reads, as RGBA floats (alpha unused, 1).

Enums§

Calmer 🔒
How much calmer the sites’ colours are (Settings ▸ Display).
Said 🔒
What cpp/screencolours.cpp said last of the screen Sioul’s window is on, for the sentence under “Colours for this screen” in Settings ▸ Display.
Screen 🔒
What the screen does with linear values, as the tables need it.

Constants§

CUBE 🔒
Entries of the cube on each side.
CURVE 🔒
Entries of the curve.
FROM_LAB 🔒
FROM_LMS 🔒
TO_LAB 🔒
TO_LMS 🔒

Statics§

SAID 🔒

Functions§

curve_at 🔒
The curve at a linear value, as the shader reads it (linear interpolation in u).
from_oklab 🔒
OKLab to linear sRGB.
invert 🔒
is_identity 🔒
Whether the tables give back what they are given, within a fifth of an 8-bit code: an sRGB screen’s profile, calmer colours off.
make 🔒
The cube and the curve.
mul 🔒
oklab 🔒
Linear sRGB to OKLab.
profile_name 🔒
A profile’s own name (“Built-in display, calibrated”), for the sentence in Settings.
said 🔒
The last state said.
screen_of 🔒
The screen a profile describes.
sioul_colour_profile_name⚠
The profile’s name, written to out as UTF-8 with a final zero, cut to capacity; returns its length in bytes without the zero (0: no name).
sioul_colour_said⚠
What the screen Sioul’s window is on gets: 0 converted (to the profile name, UTF-8, may be null), 1 by the desktop, 2 nothing (no profile), 3 turned off.
sioul_colour_tables⚠
The tables for cpp/screencolours.cpp: the profile’s length bytes (none when null), how calm (0, 1, 2), and where to write them: cube_size³ × 4 floats at cube, curve_size × 4 at curve, which must be CUBE and CURVE. Returns 1 when written, 0 when they would change nothing, -1 when the profile cannot be used (then nothing is written), -2 for other sizes.
soften 🔒
A colour’s chroma softly limited at limit (OKLCh), its lightness and hue kept.
srgb_decode 🔒
sRGB’s numbers to linear light (IEC 61966-2-1).
srgb_encode 🔒
Linear light to sRGB’s numbers.
srgb_to_xyz 🔒
sRGB’s linear values to XYZ relative to D50: the colorants of Little CMS’s own sRGB profile, as every transform from sRGB uses them.
tables 🔒
The tables for a screen’s profile (none: sRGB) and calmer colours, or None when they would change nothing (an sRGB screen, calmer colours off). An error when the profile cannot be read, or is not an RGB one.