Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upround off subpixel offsets from scroll origins #2738
Conversation
|
Looks reasonable! Could you start a try push with this change? |
|
Is the rounded value in screen space or in local space? The rounding needs to happen in screen space. |
|
This does seem like the right place to do it, I think. I'm fairly certain at some point in the past WR used to do this already, maybe it got lost somewhere along the line. You should probably scale it by the device pixel ratio (should be available in a parent function somewhere), which will make the rounding to a single device pixel. |
|
Okay, this is v2. As the new commit message implies, there was a lot of messy uncertainty about glyph subpixel positioning going on, because we were treating them in local space. That really doesn't work well under transforms. Instead, I made GlyphKeys record subpixel positions in device-space. In the process I moved the nastiness of subpixel directions out of the API (as Skia does - you can only toggle it on or off, but the direction is automatic). Likewise, I made the axis handling of subpixel directions more like how Skia does it - unless the transform is axis-aligned, you get subpixel precision on all axes. Finally, the cherry on top, is that I am now handling snapping of the scroll node transform in the text shader itself. Any other approach that tried to modify the transform up front affected the other shaders in a way that made Gecko try very very unhappy with regressions. With this approach, all we have is some non-threatening fuzzable differences on a couple tests, but otherwise it still fixes the original bug in question here. |
|
|
|
Reviewed 28 of 28 files at r1. webrender/src/prim_store.rs, line 817 at r1 (raw file):
It seems like if there is a property animation occurring, this would never get the new transform, since this branch would be skipped by the glyph_keys.is_empty() check above. I guess we need to detect if this has changed since we last calculated the glyph keys to invalidate them. webrender/src/glyph_rasterizer/mod.rs, line 142 at r1 (raw file):
Should these be epsilon checks due to float precision? Comments from Reviewable |
|
This generally looks great to me. There's a couple of issues noted above, and then we'll need to get this rebased + do a gecko try run. Then this should be ready to get merged. |
|
Review status: 24 of 28 files reviewed at latest revision, 2 unresolved discussions. webrender/src/prim_store.rs, line 817 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
I made it remember the glyph transform and then compare that for invalidation. webrender/src/glyph_rasterizer/mod.rs, line 142 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
Modified these to use approx_eq Comments from Reviewable |
|
Okay, fixed the mentioned issues. Gecko try run was already done. Only some things I need to fuzz on the Gecko-side, but otherwise everything is okay. Review status: 24 of 28 files reviewed at latest revision, 2 unresolved discussions. Comments from Reviewable |
|
Looks like there are some CI failures (I haven't looked into them). It would be good to paste the try run results here, so that we know which tests are awaiting annotation updates while landing other PRs until the next WR update. |
|
It looks like the failing test is wrench rawtest which does not fail locally at all. The rawtest failure hypothetically seems unrelated to this, but I am not sure exactly what rawtest does? |
|
This is the rawtest failure:
I ran your branch locally on my machine, which also does not fail locally. @jrmuizel any ideas what the cause of this might be? |
|
Did a rebase and pushed again, and the rawtest didn't fail this time. Maybe that blob image rawtest is one of our first intermittent failures? :( Either way, I don't think I am necessarily the cause of it. |
|
Jeff made PR #2775 to hopefully catch the intermittent sooner so it can be investigated. |
|
@bors-servo r+ |
|
|
round off subpixel offsets from scroll origins This is to address downstream Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1458921 The problem is that when both the glyphs and the transform contain a subpixel offset, they can combine together to produce visual artifacts. If you imagine two glyphs, one with offset 0.3, and one with offset, 0.2, if positioned at scroll offset 0, they both round to device pixel 0. If the scroll offset becomes 0.2, suddenly the 0.3 rounds up to device pixel 1, while the 0.2 glyph still rounds to 0. So this can contribute to the appearance of a wavefront of messed up hinting as you slowly scroll along. We're not necessarily doing things differently in the text shader itself, as both Cairo and Skia round the position after the transform is applied. However, in Gecko, we ensure that never let Cairo or Skia see a subpixel offset from scrolling so this issue never arises, despite them handling rounding of glyph positioning at a similar time during rasterization. Thus, if we just ensure the scroll offset is rounded up front like in Gecko, the problem disappears. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2738) <!-- Reviewable:end -->
|
|
snap the text run offset and glyph offsets separately This fixes issues introduced by #2738. Since the transform offset was snapped separately from the text/glyph offsets, this led to problems where certain Servo reftests might migrate a subpixel offset between the transform and the text offset. As a compromise, Glenn and I agreed it would be best to combine the transform and text offset for snapping, then separately base the subpixel positioning off of only the glyph offset. This both keeps the resolution of Gecko's scrolling issue while addressing the Servo issue. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2830) <!-- Reviewable:end -->
lsalzman commentedMay 8, 2018
•
edited by larsbergstrom
This is to address downstream Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1458921
The problem is that when both the glyphs and the transform contain a subpixel offset, they can combine together to produce visual artifacts. If you imagine two glyphs, one with offset 0.3, and one with offset, 0.2, if positioned at scroll offset 0, they both round to device pixel 0. If the scroll offset becomes 0.2, suddenly the 0.3 rounds up to device pixel 1, while the 0.2 glyph still rounds to 0. So this can contribute to the appearance of a wavefront of messed up hinting as you slowly scroll along.
We're not necessarily doing things differently in the text shader itself, as both Cairo and Skia round the position after the transform is applied. However, in Gecko, we ensure that never let Cairo or Skia see a subpixel offset from scrolling so this issue never arises, despite them handling rounding of glyph positioning at a similar time during rasterization.
Thus, if we just ensure the scroll offset is rounded up front like in Gecko, the problem disappears.
This change is