Re-break a text's lines for a new width instead of shaping it again
Only the line breaking depends on the width. The shaped runs under it --
the font selection, the unicode analysis, harfrust -- are a function of
the text and the attrs, and parley re-breaks them in place; its own
editor does exactly this on every resize. So a new width is a break and
a placement, not a shaping.
On the depth-8 tree that is 107 breaks at 0.119 ms where the shapings
they replace were 4.0 ms, and it holds however far the width moves,
which is what the store could not do: a width the layout has not seen
before is a miss, and a drag never sees one twice. Instructions per
frame over 500 resize frames of `tests/revision_cost.rs`, for widths
that alternate and widths that never repeat:
#18 head 124.2M 123.6M
a store of shapings 17.7M 45.9M
re-breaking alone 32.9M 32.8M
both 20.6M 24.2M
The store stays because re-breaking does not place the glyphs, so it now
holds those instead: fewer instructions than either alone in the case
that never repeats, and 3 MB rather than 4 MB on a tree of 4,000 texts,
against the 132 MB the code before #16 reaches after the same resizes.
The worst frame is 2.54 ms where that code's is 6.47 ms, and the two
gestures are within a millisecond of each other rather than a factor of
two apart.
Count the breaks and time them separately from shaping, since which of
the two a frame is doing is the whole question here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5f8b6b244
commit
2525637e26
2 files changed
+60
-36
No files matched your search
@@ -54,6 +54,7 @@ pub(crate) enum Counter {
|
||||
TextRenders,
|
||||
TextShapeHits,
|
||||
TextShapes,
|
||||
TextBreaks,
|
||||
GlyphPlacements,
|
||||
}
|
||||
|
||||
@@ -90,6 +91,7 @@ impl Counter {
|
||||
"text renders",
|
||||
"text shape hits",
|
||||
"text shapes",
|
||||
"text line breaks",
|
||||
"glyph placements",
|
||||
];
|
||||
}
|
||||
@@ -102,6 +104,7 @@ pub(crate) enum TimerKind {
|
||||
IncrementalLayout,
|
||||
TextRender,
|
||||
TextShape,
|
||||
TextBreak,
|
||||
GlyphPlacement,
|
||||
}
|
||||
|
||||
@@ -115,6 +118,7 @@ impl TimerKind {
|
||||
"incremental layout",
|
||||
"text render",
|
||||
"text shape",
|
||||
"text line break",
|
||||
"glyph placement",
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user