COLRv1 PaintGlyph with a transform above its fill takes the slow clip path instead of FillGlyphs
Categories
(Core :: Graphics, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: canova, Assigned: canova)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
I also noticed this while looking at the experimental Speedometer ChatRoom-React workload, similar to bug 2096434.
It looks like PaintGlyph::Paint in has a fast path: when the child paint is a plain pattern (solid or gradient), it fills the glyph directly with FillGlyphs. Otherwise it builds a clip from the glyph outline, pushes it, and fills the clip through PaintPatternBase::Paint.
Color-emoji fonts usually put a transform record between PaintGlyph and the gradient, so in practice they almost always take the clip path.
A profile from speedometer ChatRoom-React on Windows, PaintGlyph::Paint as the root: https://share.firefox.dev/4jwf1bQ
Of the 1937 samples in PaintGlyph::Paint (4.7% of the subtest), about 89% of the time goes to the clip path.
To fix this I believe in PaintGlyph::Paint, we can walk through consecutive transform records, accumulate their matrices, and if the chain ends in a single pattern, fold the combined matrix into the pattern's own matrix and use the direct fill. And singular or non-finite transforms would keep using the clip path.
| Assignee | ||
Comment 1•4 days ago
|
||
PaintGlyph::Paint uses FillGlyphs when its paint is a plain pattern, and
otherwise clips to the glyph outline, which is much slower. Emoji fonts
usually put a transform between the PaintGlyph and the pattern, so they
always took the slow path.
Fold the transforms into the pattern's matrix and fill directly. Singular
transforms still go through the clip.
The tests compare each gradient type under transforms against the same
gradient with the transforms applied to its control points. They also pass
without this patch, through the clip path.
| Assignee | ||
Comment 2•4 days ago
|
||
I measured the perf impact of this patch.
In the ChatRoom-React (speedometer-experimental workload) steps:
SkCanvas::onClipPathgoes from 195 samples to 0COLRFonts::PaintGlyphGraphgoes from 582 samples to 233, so rasterizing a glyph costs about 60% less
But it doesn't show up a lot in the score... ChatRoom-React goes from 188.4 ms to 185.7 ms (1.5%), but it might be noise as well, not 100% sure about it. Here's the comparison report. It shows 1.47% improvement but says that it can't tell if it's a real improvement or not. But I think it's worth having.
| Assignee | ||
Updated•1 day ago
|
Comment 4•1 day ago
|
||
| bugherder | ||
Description
•