Expand description
Asking the Renderer how big something will be, while the Host is laying it out.
A Host that lays out a page itself (a flexbox, a grid, text flowing around a picture) needs to know how wide a run of text is before it can decide where anything goes, and only the side that draws the letters can say: the font, the density, the system’s font scale and the design system’s type scale are all the Renderer’s. So the Host asks, in the middle of its own work, and the Renderer answers on the same call stack.
One call carries many questions. A sidebar lays out a couple of hundred labels, and a flexbox asks each of them for its narrowest width, its widest width and its height at a given width, so one call per question would pay the crossing six hundred times.
The questions travel the way a batch does: fixed-length records first, then the strings and run lists they point at. The answers come back as fixed-length records in an array the Host owns. Nothing is serialised and nothing is copied on the way across.
Application code does not call the boundary. A layout engine asks measurer for a
Measurer, which it gets only while the Host is inside one of its own calls, which is
the only time the Renderer is standing still on the other end of the same thread.
Structs§
- Measure
Requests - A set of questions for one call, built up and then asked at once.
- Measure
Result - The Renderer’s answer to one request, in dp.
- Measurer
- The right to ask, for the length of one Host call.
- Node
Constraints - The size a node may take, in dp.
f32::INFINITYis no limit. - Text
Style - How a run of text is set, as the Renderer reads it.
Enums§
- Measure
Error - Why nothing was measured.
- Measure
Status - How one request went.
- Text
Constraint - How wide the text may be.
Constants§
- CONSTRAINT_
AT_ MOST - The text broken into lines no wider than the given width.
- CONSTRAINT_
MAX_ CONTENT - The text with no line broken except where it says so.
- CONSTRAINT_
MIN_ CONTENT - The narrowest the text can be: its longest piece that cannot be broken.
- FAKE_
FONT_ SIZE - The font size the mock takes for text that does not give one.
- FLAG_
TRUNCATED - The text had more lines than
max_linesallowed, and some were not shown. - MEASURE_
KIND_ AT - MEASURE_
NODE - A node the Renderer has already applied, and size constraints.
- MEASURE_
OFF_ UI_ THREAD - The call came from a thread other than the Renderer’s UI thread, and nothing was
measured. The same number
rungives for the same mistake. - MEASURE_
RECORD_ LEN - Bytes of one request record, whichever kind it is.
- MEASURE_
RESULT_ LEN - Bytes of one result record.
- MEASURE_
TEXT - A run of text, its style and a width constraint.
- MEASURE_
UNAVAILABLE - There is nothing to measure with yet: the Renderer has not composed its first frame, so it has no density, no fonts and no design system. Also what a build with no renderer answers.
- MEASURE_
UNREADABLE - The request buffer as a whole cannot be read: shorter than its records, or null.
- NODE_
ID_ AT - NODE_
MAX_ HEIGHT_ AT - NODE_
MAX_ WIDTH_ AT - NODE_
MIN_ HEIGHT_ AT - NODE_
MIN_ WIDTH_ AT - NODE_
ZOOM_ AT - RESULT_
FIRST_ BASELINE_ AT - RESULT_
FLAGS_ AT - RESULT_
HEIGHT_ AT - RESULT_
LAST_ BASELINE_ AT - RESULT_
LAST_ LINE_ WIDTH_ AT - RESULT_
LINE_ COUNT_ AT - RESULT_
MALFORMED - The record points outside the buffer, or is a kind or value the Renderer does not know.
- RESULT_
OK - RESULT_
STATUS_ AT - RESULT_
UNKNOWN_ NODE - The node is not in the Renderer’s table: never sent, removed, or sent in the batch the Host is computing right now, which the Renderer applies only once the call returns.
- RESULT_
WIDTH_ AT - TEXT_
ABSOLUTE_ SIZE_ AT - TEXT_
CONSTRAINT_ AT - TEXT_
FONT_ COUNT_ AT - TEXT_
FONT_ OFFSET_ AT - TEXT_
FONT_ SIZE_ AT - TEXT_
FONT_ WEIGHT_ AT - TEXT_
ITALIC_ AT - TEXT_
LETTER_ SPACING_ AT - TEXT_
LINE_ HEIGHT_ AT - TEXT_
MAX_ LINES_ AT - TEXT_
OVERFLOW_ WRAP_ AT - TEXT_
SPANS_ COUNT_ AT - TEXT_
SPANS_ OFFSET_ AT - TEXT_
SPAN_ FONTS_ COUNT_ AT - TEXT_
SPAN_ FONTS_ OFFSET_ AT - TEXT_
TAB_ SIZE_ AT - TEXT_
TEXT_ LENGTH_ AT - TEXT_
TEXT_ OFFSET_ AT - TEXT_
TYPE_ ROLE_ AT - TEXT_
WIDTH_ AT - TEXT_
WORD_ BREAK_ AT - TEXT_
WRAP_ AT - TEXT_
ZOOM_ AT
Functions§
- measurer
- A measurer, if the Host is inside one of its own calls on this thread, which is the only time there is a Renderer standing still to answer.