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

Draw text shadows in screen space. #2540

Merged
merged 1 commit into from
Mar 22, 2018

Conversation

glennw
Copy link
Member

@glennw glennw commented Mar 19, 2018

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:

  • Remove ContentOrigin enum.
  • Remove cs_text_run shader (use standard text shader).
  • Remove cache text run hash maps.
  • Remove local-space raster mode from brush primitive.
  • Don't fetch color from picture for text runs.
  • Allow primitive culling on all Picture types.
  • Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).


This change is Reviewable

@glennw glennw changed the title Draw text shadows in screen space. [WIP] Draw text shadows in screen space. Mar 19, 2018
@glennw
Copy link
Member Author

glennw commented Mar 19, 2018

This is not quite ready for merge yet - it can be reviewed if you have time, or can wait until the remaining work below is complete:

r? @kvark

@kvark
Copy link
Member

kvark commented Mar 19, 2018

Holy crab, this is indeed simplifying quite a bit of code!
I do worry though, why did you decide to spin 180 w.r.t. local-space render tasks? Didn't you put a ton of effort in a series of PRs during the past 2-3 months to support those properly? My understanding was that we want to have an ability to do this trade-off, based on how frequent are the local versus global space changes.


Reviewed 11 of 11 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@glennw glennw force-pushed the text-shadow-screen2 branch 5 times, most recently from 154bcc0 to 660f871 Compare March 20, 2018 00:48
@glennw
Copy link
Member Author

glennw commented Mar 20, 2018

I fixed the failure in R1 (disabling the local clip rect inside the text-shadow picture context).

Latest try is here:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2c46f56f830590a4e87bdc608138dcaee883333b&selectedJob=169088199

There's a couple of intermittent failures I haven't seen before, but I don't think any of them are related to this change. It'd be good to get @staktrace to confirm though. The Windows tests are still pending.

Apart from that, this should be ready for review / merge now, r? @kvark

@glennw glennw changed the title [WIP] Draw text shadows in screen space. Draw text shadows in screen space. Mar 20, 2018
@glennw
Copy link
Member Author

glennw commented Mar 20, 2018

I re-triggered each of the orange results, and they passed - so they do appear to be intermittent failures. I'm fairly confident they are all unrelated to this PR. The Windows tests also look green. 🎉

@staktrace
Copy link
Contributor

Try push looks good to me!

@glennw
Copy link
Member Author

glennw commented Mar 20, 2018

r? @mrobinson

Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. This seems like a nice simplification.

@@ -1552,13 +1559,13 @@ impl<'a> DisplayListFlattener<'a> {
self.shadow_prim_stack[idx].1.push((prim_index, clip_and_scroll));
}

let prim_index = self.create_primitive(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Out of curiosity, does this change allow for making this optimization or is it an unrelated change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change allows it - previously we would reference the same primitive in the slow shadow path below. Now we build a separate primitive there. There's a slight memory overhead to this for slow text shadows, which we might be able to improve on in the future, but it should be minor.

@glennw
Copy link
Member Author

glennw commented Mar 21, 2018

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

📌 Commit 660f871 has been approved by mrobinson

@bors-servo
Copy link
Contributor

⌛ Testing commit 660f871 with merge 9747cd0...

bors-servo pushed a commit that referenced this pull request Mar 21, 2018
Draw text shadows in screen space.

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:
 * Remove ContentOrigin enum.
 * Remove cs_text_run shader (use standard text shader).
 * Remove cache text run hash maps.
 * Remove local-space raster mode from brush primitive.
 * Don't fetch color from picture for text runs.
 * Allow primitive culling on all Picture types.
 * Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).

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

💔 Test failed - status-taskcluster

@glennw
Copy link
Member Author

glennw commented Mar 21, 2018

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

📌 Commit e508f86 has been approved by mrobinson

@bors-servo
Copy link
Contributor

⌛ Testing commit e508f86 with merge 14bb805...

bors-servo pushed a commit that referenced this pull request Mar 21, 2018
Draw text shadows in screen space.

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:
 * Remove ContentOrigin enum.
 * Remove cs_text_run shader (use standard text shader).
 * Remove cache text run hash maps.
 * Remove local-space raster mode from brush primitive.
 * Don't fetch color from picture for text runs.
 * Allow primitive culling on all Picture types.
 * Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).

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

💔 Test failed - status-taskcluster

@glennw
Copy link
Member Author

glennw commented Mar 22, 2018

Three tests fail on mac taskcluster.

I confirmed that one of them is a max difference of 1, so added fuzziness for that.

I confirmed that the other two are fixed when #2554 is applied locally. In the interests of getting this landed, I disabled those two tests on mac (they still run on Linux) for now. Once #2554 lands, we can re-enable those tests on mac.

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

📌 Commit 785d1af has been approved by mrobinson

@bors-servo
Copy link
Contributor

⌛ Testing commit 785d1af with merge 769acd6...

bors-servo pushed a commit that referenced this pull request Mar 22, 2018
Draw text shadows in screen space.

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:
 * Remove ContentOrigin enum.
 * Remove cs_text_run shader (use standard text shader).
 * Remove cache text run hash maps.
 * Remove local-space raster mode from brush primitive.
 * Don't fetch color from picture for text runs.
 * Allow primitive culling on all Picture types.
 * Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).

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

💔 Test failed - status-taskcluster

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:
 * Remove ContentOrigin enum.
 * Remove cs_text_run shader (use standard text shader).
 * Remove cache text run hash maps.
 * Remove local-space raster mode from brush primitive.
 * Don't fetch color from picture for text runs.
 * Allow primitive culling on all Picture types.
 * Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).
@glennw
Copy link
Member Author

glennw commented Mar 22, 2018

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

📌 Commit 1d65037 has been approved by mrobinson

@bors-servo
Copy link
Contributor

⌛ Testing commit 1d65037 with merge b954383...

bors-servo pushed a commit that referenced this pull request Mar 22, 2018
Draw text shadows in screen space.

With box shadows drawn via a clip source, the only picture type
that was drawing in local space was text shadows. Switching them
to draw in screen-space simplifies a lot of code, and also gives
a better quality result.

Specifically:
 * Remove ContentOrigin enum.
 * Remove cs_text_run shader (use standard text shader).
 * Remove cache text run hash maps.
 * Remove local-space raster mode from brush primitive.
 * Don't fetch color from picture for text runs.
 * Allow primitive culling on all Picture types.
 * Optimize allocated region for text-shadows.

There's one performance regression with this change - text shadows
which have large rotations will blur more pixels than previously.
This can be fixed in a follow up, by drawing the blur as a normal
primitive instead of a 2D rect. This will also optimize other blurs,
such as CSS filters.

This is preparation work for caching text shadows, and also some
other optimizations (such as drawing text decorations as clip
sources).

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

☀️ Test successful - status-appveyor, status-taskcluster, status-travis
Approved by: mrobinson
Pushing b954383 to master...

@bors-servo bors-servo merged commit 1d65037 into servo:master Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants