Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clip text against the local clip rect after snapping rather than before #3048

Merged
merged 2 commits into from Sep 13, 2018

Conversation

@lsalzman
Copy link
Contributor

lsalzman commented Sep 12, 2018

This partially fixes Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1477625

Previously, we took the glyph rect within the atlas and then added the glyph offset with subpixel offset and all onto it, and critically, clipped it first, then snapped it second.

The problem is the glyph rect in the atlas represents a conservative bounding box of the glyph. So if you add an offset to it, which might cause it to go outside the clip and snip it. Then the snapping pushes it back inside the bounds, so that the snipped portion is actually still inside the clip, leaving the glyph wrongly snipped.

The way to fix this, while not quite as pretty as the previous code, is to ensure that we snap the glyph rect into place in device space first, then transform it back to local space to perform the clipping. This way, snapping is first, clipping is second. I've managed to keep the amount of math comparable for performance, and maybe the snapping code is even a bit simpler than before due to necessarily snapping the glyph rect origin rather than individual corners.


This change is Reviewable

@gw3583
gw3583 approved these changes Sep 12, 2018
Copy link
Collaborator

gw3583 left a comment

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@gw3583
Copy link
Collaborator

gw3583 commented Sep 12, 2018

@lsalzman Is there any way we can have reftest(s) for this - it'd be good to be able to pick up any regressions on this stuff in WR, where we can run tests with subpixel on/off on each platform etc.

webrender/res/ps_text_run.glsl Outdated Show resolved Hide resolved
webrender/res/ps_text_run.glsl Outdated Show resolved Hide resolved
webrender/res/ps_text_run.glsl Outdated Show resolved Hide resolved
webrender/res/ps_text_run.glsl Outdated Show resolved Hide resolved
@lsalzman
Copy link
Contributor Author

lsalzman commented Sep 13, 2018

Added a reftest

@kvark
Copy link
Member

kvark commented Sep 13, 2018

@lsalzman just to clarify, the test is failing without your changes, right?

@kvark
kvark approved these changes Sep 13, 2018
@lsalzman
Copy link
Contributor Author

lsalzman commented Sep 13, 2018

@lsalzman just to clarify, the test is failing without your changes, right?

Of course

@lsalzman lsalzman force-pushed the lsalzman:text-clip-fix branch from 5a92520 to 873cecd Sep 13, 2018
@lsalzman
Copy link
Contributor Author

lsalzman commented Sep 13, 2018

Did suggested cleanups.

@kvark
kvark approved these changes Sep 13, 2018
@kvark
Copy link
Member

kvark commented Sep 13, 2018

Thanks, shipit!
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2018

📌 Commit 873cecd has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2018

Testing commit 873cecd with merge 2cdac60...

bors-servo added a commit that referenced this pull request Sep 13, 2018
clip text against the local clip rect after snapping rather than before

This partially fixes Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1477625

Previously, we took the glyph rect within the atlas and then added the glyph offset with subpixel offset and all onto it, and critically, clipped it first, then snapped it second.

The problem is the glyph rect in the atlas represents a conservative bounding box of the glyph. So if you add an offset to it, which might cause it to go outside the clip and snip it. Then the snapping pushes it back inside the bounds, so that the snipped portion is actually still inside the clip, leaving the glyph wrongly snipped.

The way to fix this, while not quite as pretty as the previous code, is to ensure that we snap the glyph rect into place in device space first, then transform it back to local space to perform the clipping. This way, snapping is first, clipping is second. I've managed to keep the amount of math comparable for performance, and maybe the snapping code is even a bit simpler than before due to necessarily snapping the glyph rect origin rather than individual corners.

<!-- 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/3048)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing 2cdac60 to master...

@bors-servo bors-servo merged commit 873cecd into servo:master Sep 13, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 4 files, 4 discussions left (gw3583, kvark, lsalzman)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.