Repository navigation
Commit be32f06
[WebParagraph] Fix text pixelation, glyph clipping, and snapping offsets to avoid subpixel raster caching (flutter#191736)
## Summary of Changes
This PR improves `WebParagraph` text rendering quality and caching on
CanvasKit:
1. **Fixes text blurriness / fractional distortion:** Snaps physical
screen offsets to whole integer device pixels and aligns the Canvas2D
context translation to integer coordinates. This guarantees a 1:1
physical device pixel blit with `FilterQuality.none`.
2. **Eliminates glyph clipping:** Adds 2 physical pixels of safety
antialiasing padding so glyph descenders/ascenders (e.g. `g`, `j`, `y`,
`_`) are no longer clipped at the paint boundary.
3. **Preserves fractional font sizes:** Removes `.floor()` when
generating CSS font strings (`cssFontSize.toStringAsFixed(2)`), allowing
fractional font sizes to render accurately.
4. **Simplifies caching (100% cache hit during scrolling):** By snapping
physical offsets to integer coordinates, text rendered on Canvas2D is
always at phase `(0.0, 0.0)`. As a result, the cached bitmap is valid
across **all** translations and scrolling movements. All complex motion
heuristics, frame sequence tracking, settle redraws, and 4-bin
quantization state machines have been removed in favor of pure
scale-based cache invalidation.
Fixes [flutter#188323](flutter#188323)
---------
Co-authored-by: Mouad Debbar <[email protected]>1 parent 3b3abd4 commit be32f06
5 files changed
Lines changed: 931 additions & 116 deletions
File tree
- engine/src/flutter/lib/web_ui
- lib/src/engine
- canvaskit
- web_paragraph
- test/webparagraph
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
14 | 37 | | |
15 | 38 | | |
16 | 39 | | |
17 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
18 | 46 | | |
19 | 47 | | |
20 | | - | |
| 48 | + | |
21 | 49 | | |
22 | 50 | | |
23 | 51 | | |
24 | | - | |
25 | | - | |
| 52 | + | |
| 53 | + | |
26 | 54 | | |
27 | 55 | | |
28 | | - | |
29 | | - | |
30 | 56 | | |
31 | 57 | | |
32 | 58 | | |
33 | 59 | | |
34 | 60 | | |
35 | 61 | | |
| 62 | + | |
| 63 | + | |
36 | 64 | | |
37 | | - | |
38 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
39 | 71 | | |
40 | 72 | | |
41 | | - | |
42 | 73 | | |
43 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
44 | 79 | | |
45 | 80 | | |
46 | 81 | | |
| |||
58 | 93 | | |
59 | 94 | | |
60 | 95 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
65 | 104 | | |
66 | 105 | | |
67 | 106 | | |
68 | 107 | | |
69 | | - | |
| 108 | + | |
70 | 109 | | |
71 | 110 | | |
72 | 111 | | |
| |||
0 commit comments