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

Glyph snapping - revert of #1441 #1455

Merged
merged 1 commit into from Jul 7, 2017
Merged

Glyph snapping - revert of #1441 #1455

merged 1 commit into from Jul 7, 2017

Conversation

@kvark
Copy link
Member

kvark commented Jul 6, 2017

Fixes #1451
@staktrace I didn't see much of a difference locally. Would you be able to verify if this works?


This change is Reviewable

@glennw
Copy link
Member

glennw commented Jul 6, 2017

We definitely need to snap text glyphs. Otherwise fractional components in the text position result in blurry text.

@jrmuizel
Copy link
Contributor

jrmuizel commented Jul 6, 2017

@kvark kvark force-pushed the kvark:text-snap branch from 026e9fd to 63ee6f4 Jul 6, 2017
@kvark
Copy link
Member Author

kvark commented Jul 6, 2017

@glennw Here is how I see it, sorry if some parts are obvious :)

Glyph rasterization is hard, and we don't do it. Instead, we ask a platform-specific library to do the actual rasterization. That library works within an assumption that it renders on screen, and it takes into account all the details on how glyphs are placed, including sub-pixel offsets. If we do any sort of scaling, rotation, or translation by a fractional offset, after rasterization, we'll ruin the quality of rendered glyph.
Thus, we need to map the rasterized glyphs 1:1 to screen. This means that any transformations (#1453) should be applied prior to rasterization. Snapping, if any, should only be applied on the text run as a whole, and not ever try to scale it.

There is a simple way to ensure that snapping doesn't scale - just setting the snap rectangle size to 0. This PR has been updated to do it.

@kvark kvark changed the title Don't snap text glyphs Don't scale the text runs on snapping Jul 6, 2017
@staktrace
Copy link
Contributor

staktrace commented Jul 6, 2017

@kvark Sadly it doesn't look like this PR fixes the problem. The reftest looks about the same as without the patch. Try push not fully done yet but R7 is failing still: Reftest analyzer link

@kvark
Copy link
Member Author

kvark commented Jul 6, 2017

Thanks @staktrace ! I assume the test is done with the latest commit 63ee6f4

@kvark
Copy link
Member Author

kvark commented Jul 6, 2017

I just noticed why this change doesn't produce desired effect:

    // Ensure that the snap rect is at *least* one device pixel in size.
    // TODO(gw): It's not clear to me that this is "correct". Specifically,
    //           how should it interact with sub-pixel snap rects when there
    //           is a layer transform with scale present? But it does fix
    //           the test cases we have in Servo that are failing without it
    //           and seem better than not having this at all.
    snap_rect.size = max(snap_rect.size, vec2(1.0 / uDevicePixelRatio));

@glennw what tests exactly are affected? As you mention in the comments, it doesn't make sense to adjust the size in local space anyway.

@glennw
Copy link
Member

glennw commented Jul 6, 2017

I think that the simplest option for now is to revert that previous change which snaps to the primitive rect, and return it to how it was (snapping to the glyph rect). Then we can work out the "proper" solution after that, which will allow us to update WR in Gecko / Servo without reftest regressions?

@kvark kvark force-pushed the kvark:text-snap branch from 63ee6f4 to 44e22da Jul 6, 2017
@kvark kvark changed the title Don't scale the text runs on snapping Glyph snapping - revert of #1441 Jul 6, 2017
@glennw
Copy link
Member

glennw commented Jul 6, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2017

📌 Commit 44e22da has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2017

Testing commit 44e22da with merge 8ca0041...

bors-servo added a commit that referenced this pull request Jul 6, 2017
Glyph snapping - revert of #1441

Fixes #1451
@staktrace I didn't see much of a difference locally. Would you be able to verify if this works?

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

bors-servo commented Jul 7, 2017

☀️ Test successful - status-travis
Approved by: glennw
Pushing 8ca0041 to master...

@bors-servo bors-servo merged commit 44e22da into servo:master Jul 7, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@staktrace
Copy link
Contributor

staktrace commented Jul 7, 2017

Verified that the revert fixed the reftest failure - try push. Thanks!

@kvark kvark deleted the kvark:text-snap branch Jul 10, 2017
@kvark kvark restored the kvark:text-snap branch Jul 10, 2017
@kvark kvark deleted the kvark:text-snap branch Jul 10, 2017
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

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