Glint specification /spec/streams/

Glint frame streams

Status
NORMATIVE for format version 8
Draft
Draft 00, 2026-11-26
Markdown
/spec/streams.md
Record tables
/spec/records.json, 35 tables
Contents

Status: NORMATIVE for format version 8. This document is part of the Glint stream format specification. It defines the bytes of the six streams of a frame, and the rules that make a frame valid.

A Keyframe carries the six streams. A Delta writes them from the streams of a base frame (see “Delta operations” in the specification). The streams are the inputs of the client’s raster plan:

IndexStreamContent
0CommandsPaint commands in paint order
1GlyphsGlyph entries that the text commands address
2Scroll tableScroll offsets that the commands and clip entries select
3Gradient stopsStop entries that the gradient extensions address
4Scrollbar rowsScrollbar parts that the scrollbar markers paint
5Resource requestsThe glyphs and paths that the frame draws

Conventions

  • All integers are little-endian. An f32 is an IEEE 754 binary32 value and an f64 is an IEEE 754 binary64 value, little-endian.
  • An offset is a decimal byte offset from the start of the record. A record has no padding that a table does not show. The format requires no alignment of a record or of a field.
  • A byte that no table defines is reserved. A producer writes 0 there. A client ignores it.
  • A flag bit that no table defines is reserved. A producer writes 0. A client ignores it.
  • “Must” is a rule for the producer. A client rejects a frame that breaks a rule of this document: it reports the error and closes the connection. “Validation” gives the checks of a client and the rules that a client need not check.
  • s is the device scale of the Configuration message. (vx, vy) is the origin of the visible rectangle of the Configuration message, in CSS px.
  • “The raster plan” is the work of the client that turns the streams of a frame and its resources into draws, in the order of the commands.

Machine-read tables

Each table that follows a marker <!-- record: NAME SIZE --> gives the fields of record NAME, which is SIZE bytes. The columns are Offset, Size, Type, Field and Meaning. A type is u8, u16, u32, f32 or f64, or an array such as f32[4]. The field name is an identifier in code style. The site publishes them as JSON at /spec/records.json.

Coordinates and colors

Spaces

SpaceDefinition
Local spaceThe space of the geometry of a command. Unit: CSS px. The y axis points down. Without a transform extension, local space is layer space.
Layer spaceThe canvas of the document in CSS px, origin at the canvas origin, y down, without the scroll offsets of the current scroll scope (“unshifted”).
Device spaceThe pixels of the frame raster. Origin: the top-left pixel of the visible rectangle. The y axis points down.

A layer-space point P of a command under scroll reference r maps to device space as:

device = s × (P + T[r]) − s × (vx, vy)

T[r] is scroll entry r of stream 2. For r = 0, T[r] = (0, 0).

Transform extension

A command whose transform flag is set carries this 24-byte block after its base record. A later extension of the command follows the block.

transform24 bytes
OffsetSizeTypeFieldMeaning
024f32[6]matrixThe affine matrix(a, b, c, d, e, f) of CSS: x' = a·x + c·y + e, y' = b·x + d·y + f. It maps local space to layer space. a to d have no unit; e and f are CSS px in layer space.

The client draws a command with a transform at device = s × (M · local + (e, f) + T[r]) − s × (vx, vy), where M is the linear part. Without a transform, M is the identity and (e, f) is 0. The raster plan does not check that the matrix is invertible or finite. A transform also turns off the pixel snapping of a rect and of a box shadow; an image snaps also with a transform.

Color encoding

A color is four f32 values: red, green, blue, alpha.

  • Red, green and blue are encoded sRGB (the sRGB transfer function is applied). The range is extended: a value can be less than 0 or more than 1.
  • Alpha is straight (not premultiplied), 0 to 1.
  • In render mode 0 the client uses the values as they are. In render mode 1 (high dynamic range) the client decodes the three components with the extended sRGB transfer function and converts them from linear sRGB to linear Rec. 2020; alpha stays.

Pixel snapping

A rect, a box shadow, an image and a clip entry snap their box when the rules of the record say so. The client then snaps the box to whole CSS px before it scales: x' = round(x), w' = round(x + w) − round(x), and the same for y and h, with round(v) = floor(v + 0.5). Border widths and radii do not snap.

Stream 0: commands

Stream 0 is a sequence of commands without separators. A command starts at the byte after the end of the previous command. The commands must end exactly at the end of the stream. Every command size is a multiple of 4.

Command header

Every command starts with a 4-byte header.

OffsetSizeTypeFieldMeaning
01u8opcodeThe command kind (see “Command opcodes”).
11u8flagsFlags that each command defines. The flags that select extensions also select the size. 0 when the command defines no flags.
22u16wordA value that each command defines. 0 when the command defines none.

Command opcodes

OpcodeRecordSize in bytesMeaning
1rect148, + 24 with a transform, + 40 with a gradientA rectangle with a fill, a border and radii
2text56, + 24 with a transform, + 24 with a shadowA run of glyphs
3image40, + 24 with a transformAn image or a color glyph bitmap
4box-shadow120, + 24 with a transformA box shadow
5push-clip4 + 80 × entry countReplace the clip state
6pop-clip4Restore the clip state
7push-group24 + 84 × segment countStart a compositing group
8pop-group4Composite the group
9svg-path40, + 24 with a transform, + 40 with a gradientA path from the path atlas
10push-backdrop-filter88 + 84 × segment countFilter the backdrop
11pop-backdrop-filter4End of a backdrop filter
12push-mask4Start a mask accumulator
13push-mask-layer4Start a mask layer
14pop-mask-layer4Add the layer to the accumulator
15push-background4Start a background accumulator
16push-blend-layer4Start a background layer with a blend mode
17pop-blend-layer4Blend the layer into the accumulator
18pop-background4Composite the accumulator
20set-scroll8Select the scroll entry of the next draws
22scrollbar8Paint the scrollbar rows of one scroller
23color-glyph12Draw a color glyph cache slot

Opcode 0, opcode 19, opcode 21 and opcodes 24 to 255 are not commands. A frame that holds one is invalid: the client reports error 18.

Rect (1)

A filled and bordered rectangle with elliptical corner radii.

rect148 bytes
OffsetSizeTypeFieldMeaning
01u8opcode1.
11u8flagsSee the flags below.
22u16borderStylesFour 4-bit border styles: bits 0–3 top, 4–7 right, 8–11 bottom, 12–15 left. 0 is solid on all sides.
44f32xLeft edge of the border box. CSS px, local space.
84f32yTop edge of the border box. CSS px, local space.
124f32widthWidth of the border box. CSS px.
164f32heightHeight of the border box. CSS px.
2016f32[4]fillFill color. With a gradient, the gradient replaces it; the producer still writes a solid color here.
3616f32[4]borderTopColorColor of the top border.
5216f32[4]borderRightColorColor of the right border.
6816f32[4]borderBottomColorColor of the bottom border.
8416f32[4]borderLeftColorColor of the left border.
1004f32borderTopWidth of the top border. CSS px.
1044f32borderRightWidth of the right border. CSS px.
1084f32borderBottomWidth of the bottom border. CSS px.
1124f32borderLeftWidth of the left border. CSS px.
11632f32[8]radiiCorner radii, CSS px, as (x, y) pairs: top-left, top-right, bottom-right, bottom-left. A circular corner has x = y; a square corner has 0, 0.

Extensions, in this order: the transform extension (flag 0x08), then the gradient extension (flag 0x04). The size is 148, 172, 188 or 212 bytes.

BitValueNameMeaning
00x01FILLPaint the fill.
10x02BORDERPaint the border ring.
20x04GRADIENTA gradient extension follows.
30x08TRANSFORMA transform extension follows.
40x10NO_PIXEL_SNAPDo not snap the box (SVG shape geometry).
50x20AREA_COVERAGEAntialias the edges by exact pixel area, not by the CSS ramp (SVG shape geometry).
60x40SVG_STROKEThe border ring is an SVG stroke: its contours are the offsets of the midline (the box inset by half the border width) by half the border width.

flags & 3 selects the paint: 3 fill and border in one draw, 1 the fill only (over the full outer shape; the producer writes border widths 0), 2 the border only. 0 is invalid: the client reports error 18. The box snaps (see “Pixel snapping”) unless TRANSFORM or NO_PIXEL_SNAP is set.

Border styles: 0 solid, 1 double, 2 dashed, 3 dotted, 4 inset, 5 outset, 6 groove, 7 ridge, 8 none, 9 hidden. A side with style 8 or 9 must have width 0. Values 10 to 15 are not defined; a client paints them solid.

Gradient extension

Rect (1) and SVG path (9) share this 40-byte block.

gradient40 bytes
OffsetSizeTypeFieldMeaning
01u8kindBits 0–5: the kind, 1 to 7. Bits 6–7: the extend mode: 0 pad, 1 repeat, 2 reflect. 3 is invalid.
11u8stopCountThe number of stop entries in stream 3, 1 to 255.
21u8flagsBit 0: TILED. The client wraps the position modulo the origin box (floor division). The producer sets it only when the origin box differs from the painted box. Bits 1–7 are 0.
31u8interpolationBits 0–3: the color space, 0 to 14. Bits 4–5: the hue method. See the tables below.
44u32stopIndexThe index of the first stop entry in stream 3. The stops are the entries stopIndex to stopIndex + stopCount − 1.
816f32[4]geometryFour values for each kind (see below).
2416f32[4]originCSS kinds: the origin box (dx, dy, width, height) in CSS px; dx and dy are from the top-left of the painted box. COLR kinds: e, f, parameter 0, parameter 1.
KindNamegeometryClient rule for the position t
1lineardx, dy (the unit direction, y down), length (CSS px), 0t = 0.5 + dot(p − S/2, (dx, dy)) / max(length, 1e−6), where p is the position in the origin box and S its size
2radialcx, cy, rx, ry (CSS px, origin-box space)t = √(((px − cx)/rx)² + ((py − cy)/ry)²)
3coniccx, cy (CSS px), the start angle (radians, 0 up, clockwise), 0t = fract((atan2(py − cy, px − cx) + π/2 − start) / 2π)
4COLR lineara, b, c, dt = u.x
5COLR radiala, b, c, dcircles with centers (0, 0) and (1, 0) and radii p0 + t·(p1 − p0); the larger root t with a radius of 0 or more; no root paints nothing
6COLR concentric radiala, b, c, das kind 5 with both centers at (0, 0)
7COLR sweepa, b, c, dt = (atan2(u.y, u.x) − p0)/(p1 − p0), the angle in [0, 2π), y up; t = 0 when |p1 − p0| < 1e−9

For the COLR kinds, u = (a·x + c·y + e, b·x + d·y + f) maps the position in the painted box (local units, origin at the top-left of the box) to the canonical space of the gradient. Kinds 1, 2 and 3 are for Rect; kinds 4 to 7 are for SVG path; kinds 1 and 2 are also for SVG path. The client reports error 18 for a kind that the opcode does not have and for a flag other than TILED.

An OKLCH colour plane of a colour picker is not a gradient kind: the producer sends the plane as an image (see “Color picker planes”).

The extend mode gives the color of a position t outside the span from the first to the last stop position:

ModeNameKindsClient rule
0pad1 to 7Before the first stop, the first stop color. After the last stop, the last stop color.
1repeat1 to 7t wraps into the span. For the CSS kinds 1 to 3, this is a repeating gradient.
2reflect4 to 7t reflects into the span: every second repeat of the span runs from the last stop to the first stop.

Extend mode 3 is invalid. Reflect is for the COLR kinds 4 to 7 only. The client decoder reports error 18 for extend mode 3 and for reflect on a CSS kind.

SpaceCSS nameSpaceCSS name
0srgb8oklch
1srgb-linear9display-p3
2lab10display-p3-linear
3oklab11a98-rgb
4xyz-d6512prophoto-rgb
5hsl13rec2020
6hwb14xyz-d50
7lch15not defined: the raster plan rejects the frame

Hue methods (spaces 5 to 8 only): 0 shorter, 1 longer, 2 increasing, 3 decreasing, as CSS Color 4 §12.4 defines them. The client interpolates in the space with premultiplied alpha and does not premultiply the hue. The producer writes interpolation 0 for a gradient without an in clause and for the COLR kinds.

Stops: stop i of the gradient is entry stopIndex + i of stream 3, at byte 28 × (stopIndex + i). The entries of each gradient must lie in stream 3. The client prepares the stops as “Stream 3: gradient stops” states.

Color picker planes

A producer that paints the OKLCH colour plane of a colour picker sends each plane as two commands in its place:

  1. An Image command (opcode 3) of the plane image, at the rect’s box, with the rect’s transform. Its NO_PIXEL_SNAP flag is set when the rect has a transform or NO_PIXEL_SNAP. Plane n of a frame (in the order of stream 0, from 0) is decoded image 0x7F00 + n; a frame has at most 256 planes.
  2. When the rect paints a border wider than 0, a Rect command of the border only, with a transparent fill. A rect that paints only its border paints no plane.

The producer sends the plane image as an Image message before the frame. It is 8-bit RGBA, straight alpha, encoded sRGB, at the rect’s size in device pixels (at most 1024 on a side). The producer sends it again only when the plane’s size, radii, device scale or parameters change, and releases it when no frame paints it. A client draws it as any decoded image.

Text (2)

One run of glyphs of one font at one size.

text56 bytes
OffsetSizeTypeFieldMeaning
01u8opcode2.
11u8flagsSee the flags below.
22u16glyphCountThe number of glyph entries, 0 to 65535.
44u32glyphOffsetThe byte offset of the first glyph entry in stream 1, a multiple of 14. The entries follow one another, 14 bytes each.
84f32xThe origin of the run. CSS px, local space. The pen of each glyph is from this origin.
124f32yThe top of the line box. CSS px, local space.
164f32fontSizeThe font size. CSS px. The client draws at floor(fontSize × 100) / 100.
204f32baselineThe distance from y down to the baseline. CSS px.
2416f32[4]colorThe fill color. A command with SHADOW uses the color of the shadow.
404f32opticalSizeThe size for the opsz axis of the outlines. CSS px at scale 1. It differs from fontSize for synthesized small capitals.
442u16unitsPerEmThe units per em of the font (head.unitsPerEm). Must not be 0.
462u16fontThe font number of the connection (see “Font numbers” in the resources).
482u16weightThe font weight in CSS units, 1 to 1000. The outlines use it for the wght axis.
502u16variationKey0, or a variation key of the connection, 1 to 255 (see “Variation key” in the resources).
521u8style0 normal, 1 italic. Another value is 0.

Bytes 53 to 55 are reserved.

BitValueNameMeaning
00x01TRANSFORMA transform extension follows.
10x02SHADOWA text-shadow extension follows.
20x04SYNTHETIC_OBLIQUEThe client shears the run (see “Synthetic oblique” below).

Extensions, in this order: the transform extension (flag 0x01), then the text-shadow extension (flag 0x02). The size is 56, 80 or 104 bytes.

text-shadow24 bytes
OffsetSizeTypeFieldMeaning
016f32[4]colorThe shadow color. It replaces color.
164f32offsetXAdded to x, before the transform. CSS px.
204f32offsetYAdded to y, before the transform. CSS px.

Glyph placement. With (dx, dy) the shadow offset (or 0), F = floor(fontSize × 100) / 100 × s and k = F / unitsPerEm:

  1. The origin of the run is ox = grid(x × s + dx × s); the baseline is by = grid(y × s + dy × s) + grid(baseline × s), where grid(v) rounds v to the nearest 1/256, ties to even.
  2. The origin of glyph entry i (font units (0, 0)) is at (ox + (penX + inkX) × k, by − inkY × k) device px of the local space; font units have y up.
  3. The transform and the scroll entry apply (see “Coordinates and colors”).

Synthetic oblique: with SYNTHETIC_OBLIQUE, the client shears the run by 0.25 about the baseline: a local point (x, y) draws at x − 0.25 × (y − by). The producer sets SYNTHETIC_OBLIQUE when style is 1 and the font is not italic: head.macStyle bit 1 and OS/2.fsSelection bit 0 of the font are both 0.

  • glyphOffset must be a multiple of 14. The glyph span (glyphOffset, glyphCount × 14 bytes) must lie in stream 1.
  • weight must be 1 to 1000. variationKey must be less than 256.
  • font must be less than the number of Font messages of the connection before the frame (error 8).
  • Stream 5 must hold a glyph row for each glyph of the span whose ID is not 65535 (see “Stream 5: resource requests”).
  • A run of more than 65535 glyphs takes several commands with the same x. A text shadow is a copy of the command with SHADOW, before the command, on the same glyph span; a blurred shadow is in a push group with one blur segment.

The weight is the CSS weight of the text, such as 450, unchanged in the command and in the glyph rows. The optical size is in CSS px at every device scale: the raster plan applies the device scale.

Image (3)

A textured quad.

image40 bytes
OffsetSizeTypeFieldMeaning
01u8opcode3.
11u8flagsSee the flags below.
22u16imageThe image index in the space of kind (see “Identities” in the resources).
44f32xLeft of the destination. CSS px, local space.
84f32yTop of the destination. CSS px, local space.
124f32widthWidth of the destination. CSS px.
164f32heightHeight of the destination. CSS px.
2016f32[4]sourceThe source rectangle (x, y, width, height) as fractions 0 to 1 of the image, origin at the top-left.
361u8kindThe image kind: 0 a decoded image, 1 a color glyph bitmap. Another value is error 18.
373u8[3]reserved0.

Extension: the transform extension (flag 0x01). The size is 40 or 64 bytes.

BitValueNameMeaning
00x01TRANSFORMA transform extension follows.
10x02PIXELATEDSample with the nearest texel at mip level 0.
20x04NO_PIXEL_SNAPDo not snap the destination.
30x08ABUT_LEFTThe left edge touches another draw: no antialiasing on it.
40x10ABUT_TOPThe same for the top edge.
50x20ABUT_RIGHTThe same for the right edge.
60x40ABUT_BOTTOMThe same for the bottom edge.
70x80—Reserved: 0. A client reports error 18 for bit 7.
  • An index outside the space of its kind is error 18 (the value is the index). The index of kind 0 is less than 32768; the index of kind 1 is less than 16384.
  • Kind 0, a decoded image: when flags & 0x04 is 0 the destination snaps (see “Pixel snapping”), also with a transform. The client samples the source rectangle into the destination.
  • Kind 1, a color glyph bitmap: x, y, width, height are the em square above the glyph origin: the origin is (x, y + height) and the font size is height. The glyph box of the Image message places the bitmap: left x + left × height, top y + height + top × height, size width × height by height × height in ems of the box. Without a transform the client snaps the origin: y to a whole device pixel, x to a whole device pixel when the box has whole pixel 1, else to a quarter device pixel. The destination does not snap by “Pixel snapping”.

Color glyph (23)

One color glyph cache slot, drawn from its cache page.

color-glyph12 bytes
OffsetSizeTypeFieldMeaning
01u8opcode23.
11u8flags0.
22u16slotA color glyph cache slot of the connection (see “Color glyph” in the resources). A slot that no Color glyph message installed is error 18.
44f32xThe x of the glyph origin. CSS px, local space.
84f32yThe y of the glyph origin. CSS px, local space.

The command has no extension. The client draws the slot from its cache page at the snapped origin (floor(sx + 1/8), floor(sy + 1/2)), where (sx, sy) is the device position of the origin: the device scale and the scroll entry apply. The draw covers the box of the slot from the origin. The producer writes this command only for axis-aligned text without a scale.

SVG path (9)

A path of the client’s path atlas, with one color or a gradient.

svg-path40 bytes
OffsetSizeTypeFieldMeaning
01u8opcode9.
11u8flagsSee the flags below.
22u16pathThe path index in the space of kind (see “Identities” in the resources).
44f32xLeft of the rectangle that the bounds of the path map to. CSS px, local space.
84f32yTop of that rectangle.
124f32widthWidth of that rectangle.
164f32heightHeight of that rectangle.
2016f32[4]colorThe fill color, with fill-opacity in its alpha.
361u8kindThe path kind: 0 an SVG path, 1 a color glyph layer, 2 a text stroke. 3 and above are error 18.
373u8[3]reserved0.

The 40 bytes of fields are followed by the transform extension (flag 0x01), then the gradient extension (flag 0x02): the transform extension starts at byte 40, the gradient extension at byte 40 or 64. The size is 40, 64, 80 or 104 bytes. An index outside the space of its kind is error 18 (the value is the index).

BitValueNameMeaning
00x01TRANSFORMA transform extension follows.
10x02GRADIENTA gradient extension follows. The gradient replaces the color.
20x04GLYPH_ORIGINA color glyph layer. With TRANSFORM, the client snaps the translation to (floor(E + 1/8), floor(F + 1/2)) device px.
30x08ENTRY_BOUNDSA path in local CSS px: a stroked glyph outline, or a stroke that does not scale, mapped into the host space. The client ignores x, y, width and height and draws the path at its own bounds; path units are CSS px. x, y, width and height bound the path.

The client maps a path point p with the bounds (bx0, by0, bx1, by1) of the path (in path units) to local space: (x + (p.x − bx0) × width / (bx1 − bx0), y + (p.y − by0) × height / (by1 − by0)). Then the transform and the scroll entry apply. The producer writes the bounds of the path after the SVG viewport mapping, so the map is the viewport map. Stream 5 must hold a path row for the path kind and the path index.

Box shadow (4)

One CSS box shadow. The producer resolves its offset, spread and radii.

box-shadow72 bytes
OffsetSizeTypeFieldMeaning
01u8opcode4.
11u8flagsBit 0 (0x01) INSET. Bit 1 (0x02) TRANSFORM: a transform extension follows. The other bits are reserved.
44f32xLeft of the shadow rectangle. CSS px, local space. Outset: the border box moved by the offset and grown by the spread. Inset: the hole, the border box moved by the offset and shrunk by the spread.
84f32yTop of the shadow rectangle. CSS px.
124f32widthWidth of the shadow rectangle. CSS px.
164f32heightHeight of the shadow rectangle. CSS px.
2032f32[8]radiiThe radii after the spread (CSS Backgrounds 3 §7.1), as Rect radii.
5216f32[4]colorShadow color.
684f32blurSigmaThe standard deviation of the blur: the CSS blur radius / 2. CSS px. 0 is no blur.

Extensions, in this order: the transform extension (flag 0x02), then the border-box extension. Every box shadow has the border-box extension. The size is 120 or 144 bytes.

box-shadow-border-box48 bytes
OffsetSizeTypeFieldMeaning
016f32[4]boxThe border box of the element (x, y, width, height) without the offset and the spread. CSS px, local space.
1632f32[8]radiiThe border radii of the element without the spread, as Rect radii.
  • INSET: the shadow paints inside the border box and outside the hole.
  • Outset: the client clips the shadow out of the border box when the box has a width and a height above 0. The client does not clip an outset shadow whose box has a width or a height of 0.
  • The box snaps (see “Pixel snapping”) when TRANSFORM is clear.
  • The producer emits the shadows of one element in reverse list order, so that the first shadow paints on top.

Clip entry

Push clip (5) carries clip entries. Push backdrop filter (10) carries one.

clip-entry80 bytes
OffsetSizeTypeFieldMeaning
01u8flagsBit 0 (0x01) ENABLED_X: clip on x. Bit 1 (0x02) ENABLED_Y: clip on y. Bit 2 (0x04) AFFINE. Bit 3 (0x08) PATH_MASK: the path-mask fields replace the radii. Bit 4 (0x10) AREA. Bit 5 (0x20) GLYPH_ORIGIN.
44f32xLeft of the clip rectangle. CSS px; layer space without AFFINE, local space with it.
84f32yTop of the clip rectangle.
124f32widthWidth of the clip rectangle.
164f32heightHeight of the clip rectangle.
2032f32[8]radiiCorner radii, as Rect radii.
5224f32[6]affineWith AFFINE: a, b, c, d, e, f from local space to layer space, as the transform extension. Without AFFINE: 0.
762u16scrollReferenceThe scroll entry of this clip entry: an entry of stream 2. 0: no scroll offset.
clip-path-mask80 bytes
OffsetSizeTypeFieldMeaning
204u32pathThe path index of the mask, in the space of pathKind (see “Identities” in the resources).
244f32pathScaleLocal units for each path unit.
2816f32[4]pathBoxThe box of the path (x min, y min, x max, y max) in path units.
441u8pathKindThe path kind: 0 an SVG path, 1 a color glyph layer, 2 a text stroke. Another value is error 18.
457u8[7]reserved0.

The second table gives the fields of an entry with PATH_MASK at bytes 20 to 51. An index outside the space of pathKind is error 18. An entry without PATH_MASK keeps bytes 44 to 51 as radii.

  • A pixel is in the clip state when it is in every entry. The client tests each entry in its own space.
  • ENABLED_X clips to x .. x + width; ENABLED_Y clips to y .. y + height. An entry with neither bit clips nothing. The producer sets both bits on a rectangle entry and neither bit on a path-mask entry.
  • AREA (an SVG viewport): an axis-aligned entry clips each pixel by the area that it covers, not by the pixel center.
  • An entry without AFFINE, PATH_MASK and AREA snaps to whole CSS px (see “Pixel snapping”).
  • AFFINE: when b = c = 0, a > 0 and d > 0, the client folds the affine into an axis-aligned rectangle. Otherwise it tests the pixel in local space through the inverse affine. The affine must be invertible.
  • GLYPH_ORIGIN (with AFFINE only): the translation is a color glyph origin. The client snaps it in device px: E = floor(E + 1/8), F = floor(F + 1/2).
  • PATH_MASK: the path outline masks the content. Only the first push clip inside a push group gives the group its path mask; the group composites through it.

Push clip (5) and pop clip (6)

push-clip4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode5.
22u16entryCountThe number of clip entries that follow, 0 to 8. 0 is no clip.
pop-clip4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode6.

A push replaces the clip state with its entries; it does not intersect them with the earlier state. A pop restores the state before the matching push. More than 8 entries make the frame invalid; the raster plan rejects it.

Filter segment

Push group (7) and push backdrop filter (10) carry a list of filter segments. The client applies them in order.

filter-segment84 bytes
OffsetSizeTypeFieldMeaning
01u8kind1 matrix, 2 blur, 3 drop shadow.
480f32[20]valuesThe values of the kind (below).
Kindvalues
1 matrixA 4 × 5 color matrix, row major: rows R, G, B, A; columns R, G, B, A and a constant. out[r] = Σ m[r][c] × in[c] + m[r][4].
2 blur0: sigma x, 1: sigma y. CSS px, through the element transform. Values 2 to 19 are 0.
3 drop shadow0: dx, 1: dy (CSS px, through the linear part of the element transform), 2: sigma x, 3 to 6: color, 7: sigma y. Values 8 to 19 are 0.

The values that a kind does not use must be 0. The client draws a blur as three box blurs on each axis with the box width floor(σ × s × 1.8799712 + 0.5).

Push group (7) and pop group (8)

push-group24 bytes
OffsetSizeTypeFieldMeaning
01u8opcode7.
11u8flagsBits 1–4: the blend mode, 0 to 15. Bit 5 (0x20): MASK.
22u16segmentCountThe number of filter segments that follow. 0 is no filter.
41u8compositeThe composite operator, 0 to 13.
204f32alphaThe opacity of the group, 0 to 1.
pop-group4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode8.

The content until the matching pop draws into an offscreen target. The pop applies the filter segments, multiplies by the opacity and composites the target through the clip state of the push.

  • Composite 0 composites source-over with the blend mode. Another composite operator reads the target pixels and replaces them with the Porter-Duff result on premultiplied color; the clip coverage mixes the result with the target.
  • The blend modes plus-lighter and plus-darker do not fit in 4 bits. The producer writes blend mode 0 with composite 12 or 13 for them.
  • MASK: the pop multiplies the alpha of the group by the top mask accumulator and removes the accumulator.

Blend modes: 0 normal, 1 multiply, 2 screen, 3 overlay, 4 darken, 5 lighten, 6 color-dodge, 7 color-burn, 8 hard-light, 9 soft-light, 10 difference, 11 exclusion, 12 hue, 13 saturation, 14 color, 15 luminosity.

Composite operators: 0 source-over, 1 clear, 2 source, 3 destination, 4 destination-over, 5 source-in, 6 destination-in, 7 source-out, 8 destination-out, 9 source-atop, 10 destination-atop, 11 xor, 12 plus, 13 plus-darker.

Push backdrop filter (10) and pop backdrop filter (11)

push-backdrop-filter8 bytes
OffsetSizeTypeFieldMeaning
01u8opcode10.
22u16segmentCountThe number of filter segments that follow.
pop-backdrop-filter4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode11.

The segments follow the 8-byte record. One clip entry follows the segments: the border box of the element with its radii. The client filters what is painted behind the element and composites the result back through that entry. The entry does not clip the content and is not part of the clip state. The pop does no work.

Mask commands (12, 13, 14)

push-mask4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode12.
push-mask-layer4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode13.
11u8mode0 match-source, 1 alpha, 2 luminance.
21u8composite0 add, 1 subtract, 2 intersect, 3 exclude.
pop-mask-layer4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode14.

Push mask starts a mask accumulator with coverage 0. The content of a mask layer draws into a scratch target. The pop converts the scratch to coverage by the mode (match-source is alpha) and composites it into the accumulator by the composite operator (CSS Masking 1 §5.7). A masked push group (MASK flag) uses and removes the accumulator.

Background commands (15, 16, 17, 18)

push-background4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode15.
push-blend-layer4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode16.
11u8modeThe blend mode of the layer, 0 to 15 (see “Push group”).
pop-blend-layer4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode17.
pop-background4 bytes
OffsetSizeTypeFieldMeaning
01u8opcode18.

The background layers of one element draw into an accumulator from push background to pop background. A layer between push blend layer and pop blend layer draws into a scratch target; the pop blends it over the accumulator with the mode. Pop background composites the accumulator over the target with blend mode normal (CSS Compositing 1 §5.2). The producer emits these commands only when a background layer has a blend mode other than normal.

Set scroll (20)

set-scroll8 bytes
OffsetSizeTypeFieldMeaning
01u8opcode20.
22u16scrollReferenceThe scroll entry of the draws that follow.

The current scroll reference is 0 at the start of the stream. Set scroll changes it; push and pop commands do not save or restore it. It applies to Rect, Text, Image, Color glyph, Box shadow and SVG path. A clip entry has its own reference. Scrollbar rows and filter values take no scroll offset.

Scrollbar (22)

scrollbar8 bytes
OffsetSizeTypeFieldMeaning
01u8opcode22.
44u32groupThe scrollbar group of the scroller whose scrollbar rows paint here, or 0xFFFFFFFF for the viewport.

The producer numbers the scrollbar groups of a frame from 0, in the order of the scrollbar commands of stream 0. The marker paints the scrollbar rows of stream 4 whose group is equal to this group, in row order, under the current clip state. A marker without rows paints nothing. The producer wraps each marker in the clips of its scroller; the viewport marker comes after all other paint, without a clip.

Order of the commands

The opening and closing commands nest on two stacks. The clips nest on the clip stack:

OpeningClosing
Push clip (5)Pop clip (6)

The other opening and closing commands nest on the group stack:

OpeningClosing
Push group (7)Pop group (8)
Push backdrop filter (10)Pop backdrop filter (11)
Push mask layer (13)Pop mask layer (14)
Push background (15)Pop background (18)
Push blend layer (16)Pop blend layer (17)
  • A pop clip closes the innermost open push clip. A closing command of the group stack must close the innermost open command of the group stack. A command of one stack does not close or check a command of the other stack: push group, push clip, pop group, pop clip is a valid sequence.
  • No command of either stack stays open at the end of the stream.
  • The clip state of a command is the clip state of the innermost open push clip (no clip when no push clip is open). A pop group composites through the clip state of its push group.
  • Push mask (12) has no closing command. The command after it must be push mask layer (13). A push mask layer must follow push mask or pop mask layer. A push group with MASK must follow pop mask layer, and the command after a pop mask layer must be push mask layer or a push group with MASK. Set scroll (20) between them does not count: the rule applies to the commands without it.
  • The producer orders the commands of one element as: push backdrop filter, the mask sequence, push group, push clip, the content, pop clip, pop group, pop backdrop filter.

The raster plan checks every rule of this section (failure 3, see “Validation”). A frame that breaks a rule of this section is invalid for every client.

Stream 1: glyphs

Stream 1 is an array of 14-byte glyph entries. The length must be a multiple of 14. The client limits the number of entries (see “Limits” in the specification).

glyph14 bytes
OffsetSizeTypeFieldMeaning
02u16glyphThe glyph ID in the font. 65535: no glyph; the client draws nothing for it.
24f32penXThe pen position from the x of the text command. Font units.
64f32inkXThe x offset of the glyph from its pen. Font units.
104f32inkYThe y offset of the glyph from its pen. Font units, y up.

Several text commands can address one span: a text shadow and its text, or the parts of a selected run.

Stream 2: scroll table

Stream 2 is an array of 8-byte entries. Entry k is at byte 8 × k. The length must be a multiple of 8 and at least 8.

scroll-entry8 bytes
OffsetSizeTypeFieldMeaning
04f32xThe shift that the client adds to an unshifted x. CSS px.
44f32yThe shift that the client adds to an unshifted y. CSS px.
  • An entry is the negative of the cumulative scroll offset of its scope: a scope scrolled down by 100 px has y = −100.
  • Entry 0 must be zero. Reference 0 gives no shift.
  • The producer numbers the scroll entries that stream 0 references (the set scroll commands and the clip entries) from 1, in the order of their first reference in stream 0. Stream 2 holds entry 0 and these entries: its length is 8 × (1 + n) for n referenced entries. A frame without references has a stream 2 of 8 bytes.
  • Every scroll reference of stream 0 must be less than the number of entries.
  • A frame that only scrolls changes only this stream.

Stream 3: gradient stops

Stream 3 is an array of 28-byte stop entries. Entry k is at byte 28 × k. The length must be a multiple of 28. A gradient extension addresses stopCount consecutive entries from entry stopIndex.

The producer writes the stops that the gradients of stream 0 use, in the order of their first use in stream 0. It writes each set of equal stops once: two gradients with equal stops address the same entries. Stream 3 holds no other entries.

gradient-stop28 bytes
OffsetSizeTypeFieldMeaning
04f32positionThe position on the gradient line, a fraction (CSS kinds), or the color line offset (COLR kinds). NaN: no position.
416f32[4]colorComponents 0, 1 and 2 of the stop color in the interpolation space of the gradient that addresses the entry (see the table below), then the straight alpha.
204u32missingBits 0–2: component 0, 1 or 2 of the interpolation space is missing (CSS none, or a powerless hue). Bit 3: alpha is missing. Bit 4: the entry is a color hint.
244f32lengthCSS px along the gradient line, added to the position. Kinds 1 and 2 only; 0 for the other kinds.
SpaceComponents 0, 1, 2
0 srgbr, g, b, encoded
1 srgb-linearr, g, b
2 labL (0 to 100), a, b; D50
3 oklabL (0 to 1), a, b
4 xyz-d65X, Y, Z
5 hslh (degrees, 0 to 360), s, l (fractions)
6 hwbh (degrees), w, b (fractions)
7 lchL, C, h (degrees); D50
8 oklchL, C, h (degrees)
9 display-p3r, g, b, sRGB transfer
10 display-p3-linearr, g, b
11 a98-rgbr, g, b, transfer 563/256
12 prophoto-rgbr, g, b
13 rec2020r, g, b, transfer 2.4
14 xyz-d50X, Y, Z

Two gradients in different spaces with equal colors address different entries, because their components differ.

The client prepares the stops of a gradient in this order:

  1. Position: position + length / L, where L is geometry[2] for kinds 1 and 2 (the length or rx, CSS px) when it is more than 0.
  2. Fix-up (CSS Images 3 §3.5.3): a first NaN position becomes 0, a last NaN position becomes 1, each position becomes the maximum of itself and the positions before it, and each run of NaN positions spreads evenly between its neighbors.
  3. Hints: the client replaces each hint with 9 stops between the entry before it (L) and the entry after it (R), with the colors ((x − L)/(R − L))^(log 0.5 / log((H − L)/(R − L))) of the mix of L and R, where H is the hint position. A hint must not be the first or the last entry, and two hints must not be neighbors.
  4. Missing components: in each pair of neighboring stops, a missing component takes the value of the other stop; a component that both stops miss is 0 (CSS Color 4 §12.2). The bits are authoritative: the producer sets the hue bit of a stop whose hue is powerless (CSS Color 4 §4.4.1). Bit 3 applies in every space.
  5. A repeating CSS gradient whose last position is not more than its first position paints the color of the last stop.

A client reads at most 64 prepared stops: n + 8 × hints stops, twice that minus 2 when a stop has a missing component. A producer keeps the prepared count at 64 or less.

Stream 4: scrollbar rows

Stream 4 is an array of 40-byte rows. The length must be a multiple of 40.

scrollbar-row40 bytes
OffsetSizeTypeFieldMeaning
04u32groupThe group of the scrollbar marker that paints the row; 0xFFFFFFFF for the viewport.
44f32xLeft. CSS px in the viewport; the scroll offset is already applied.
84f32yTop. CSS px in the viewport.
124f32widthCSS px.
164f32heightCSS px.
2016f32[4]colorThe color of the part, see “Color encoding”.
364f32radiusThe corner radius of all four corners. CSS px.

The client rounds the edges to device pixels: left floor(x × s + 0.5) − s × vx, right floor((x + width) × s + 0.5) − s × vx, and the same for y. A row with a width or a height of 0 or less after the rounding paints nothing. The radius is clamp(radius × s, 0, min(width, height) / 2). The rows of one marker paint in row order: the producer writes the track, the edge, the thumb and the corner, back to front.

Stream 5: resource requests

Stream 5 names the glyphs and the paths that the frame draws. The client prepares its glyph atlas and its path atlas from it. An empty stream has no rows. Otherwise it is a 4-byte header and count rows of 20 bytes; the length must be 4 + 20 × count.

request-header4 bytes
OffsetSizeTypeFieldMeaning
04u32countThe number of rows.

A row is a glyph row (kind 0) or a path row (kind 1). The u16 at row offset 14 is the kind.

glyph-request20 bytes
OffsetSizeTypeFieldMeaning
02u16fontThe font number of the text command.
22u16weightweight of the text command.
44f32opticalSizeopticalSize of the text command, 0 or more, +0 for zero.
84f32fontSizefontSize of the text command as written, 0 or more, +0 for zero.
122u16glyphThe glyph ID, not 65535.
142u16kind0.
162u16variationKeyvariationKey of the text command.
182u16reserved0.
path-request20 bytes
OffsetSizeTypeFieldMeaning
04u32pathThe path index in the space of pathKind (see “Identities” in the resources).
48f64screenSizeThe longest side of the drawn path on the target, device px at the device scale of the producer. 0 or more and finite, +0 for zero.
122u16coverage0: a distance-field entry. 1: a coverage entry.
142u16kind1.
161u8pathKindThe path kind: 0 an SVG path, 1 a color glyph layer, 2 a text stroke.
173u8[3]reserved0.

A path row whose pathKind is above 2, or whose path is outside the space of its kind, is error 21 (the offset is the byte offset of the field, the value is the field).

Order: the glyph rows come first, in strictly increasing order of (font, variation key, weight, optical size, font size, glyph). The path rows follow, in strictly increasing order of (path kind, path, coverage). The optical size and the font size compare as numbers. Every producer writes this order. So each glyph row is unique, each path row is unique by path kind, path index and coverage, and one set of rows has one stream 5.

The rows of a frame:

  • one glyph row for each distinct (font, variation key, weight, optical size, font size, glyph ID) of the glyph entries of the text commands, without glyph ID 65535;
  • one path row with coverage 0 for each path kind and path index of an SVG path command or a path-mask clip entry, with the screen size of its last draw: max(width × s × √(a² + b²), height × s × √(c² + d²)) for a command, and the same with the path box, its scale and its affine for a clip entry.

The client makes one atlas for each (font, variation key) and one glyph for each glyph row, at the instance of the font with wght = weight and opsz = opticalSize (see “Font” in the resources). It makes one path atlas entry for each path row from the definition of its Path message, at a resolution for screenSize. A text command whose glyph has no row, or an SVG path or a path mask whose path has no row, makes the frame invalid; the raster plan rejects it (failures 11 and 12).

Validation

A client checks a frame in three steps. A frame that fails a check is not drawn: the client reports the error and closes the connection.

  1. Before it reads the glyphs, the client checks the lengths of the streams and the rows of stream 5 (error 21 in the specification, “Errors”): a stream 1 of whole 14-byte entries; a stream 2 of whole 8-byte entries and at least 8 bytes; a stream 3 of whole 28-byte entries; a stream 4 of whole rows; a stream 5 that is empty or 4 + 20 × count bytes; a row kind of 0 or 1; a glyph row with the font number of a Font message of the connection, a variation key less than 256 and a font size and optical size that are 0 or more and finite; a path row with a path kind of 0 to 2, a path index in the space of its kind and a screen size that is 0 or more and finite. A stream 1 of more than 161,319 entries gives error 14.
  2. The client checks each command of stream 0. Error 18: an opcode that is not a command, a command that the end of the stream cuts, a rect with flags & 3 = 0, a text glyph span outside stream 1, a glyphOffset that is not a multiple of 14, a text weight of 0 or above 1000, a variation key of 256 or more, a gradient stop span outside stream 3, an extend mode of 3 or reflect on a CSS kind, an image kind above 1, an image command with flag bit 7, a path kind above 2 in an SVG path command or a path-mask clip entry, an image index or a path index outside the space of its kind, and a Color glyph command whose slot no Color glyph message installed. Error 8: a font number without a Font message.
  3. The client plans the frame. A command that breaks a rule gives a raster plan failure: a code, the byte offset of the command in stream 0 (the length of the stream for a rule of the whole stream), the value that broke the rule and the limit of the rule. The client reports the failure with the rule and the remedy.

Raster plan failures

CodeNameRule that the frame breaksValueLimit
1COMMANDAn opcode that is not a command, or a command that the end of stream 0 cuts.The opcodeThe bytes that remain
2CLIP_ENTRIESA push clip with more than 8 entries.The entry count8
3ORDERA command that breaks “Order of the commands”.The opcodeThe opening opcode that the command needs, or the command before it in a mask sequence; at the end of the stream, the innermost open opcode or 0
4GLYPH_SPANA text glyph span outside stream 1.The glyph offsetThe length of stream 1
5SCROLL_REFERENCEA scroll reference (set scroll or clip entry) not less than the number of scroll entries.The referenceThe number of entries
6STOP_SPANA gradient stop span outside stream 3.The stop offsetThe length of stream 3
7STOP_HINTA hint at the first or the last stop, or after another hint.The stop indexThe stop count
8FONTA text font number of 512 or more.The font number512
9VARIATION_KEYA text variation key of 256 or more.The key256
10UNITS_PER_EMA text command with unitsPerEm 0.01
11GLYPH_ROWA glyph of a text command without a glyph row in stream 5.The glyph IDThe weight
12PATH_ROWAn SVG path or a path-mask entry without a path row in stream 5.The path index0
13CLIP_AFFINEA clip entry with AFFINE whose affine has no inverse.The entry index0
14IMAGE_INDEXAn Image command whose image index is outside the space of its image kind.The image indexThe size of the space
15FILTER_KINDA filter segment kind outside 1 to 3.The kind3
16MASK_LAYERA mask layer mode above 2 or a composite above 3.The mode or the composite2 or 3
17INTERPOLATIONA gradient interpolation space above 14.The space14
18PAYLOADA frame whose plan needs more bytes than a plan holds (2 GiB).The KiB that the frame needsThe KiB that a plan holds
19ALLOCATIONThe client could not allocate the plan.The byte count0
20COMPOSITEA push group composite operator above 13.The operator13
21SCROLLBAR_ROWSScrollbar rows that the client cannot address.The row count0

Failures 18, 19 and 21 come from the limits of the client, not from a rule of this document. Step 2 finds a break of the rules of failures 1, 4, 6, 8, 9 and 14 first, as error 18 or error 8.

Rules that a client need not check

These rules bind the producer. A client need not check them; a frame that breaks one can draw wrong pixels.

RuleA frame that breaks it
The values are finite; a transform is invertibleDraws NaN or infinite geometry.
The rows of stream 5 are unique and in the order of “Stream 5: resource requests”Can make the client prepare a glyph or a path twice.
A text command has SYNTHETIC_OBLIQUE exactly when its style is 1 and its font is not italicDraws the run upright, or slanted twice.
A text command’s unitsPerEm is head.unitsPerEm of its fontPlaces the glyphs at a wrong scale.
The client holds the file bytes of each glyph that a frame draws (“Glyphs (13)” in the resources)Draws nothing or a wrong outline for the glyph.