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 upOptimize box shadows - only apply blurs where they can affect the shadow. #1896
Conversation
…dow. Add support for regions to blur render tasks. These allow render tasks to specifiy one or more regions where the blur should be applied. If no blur region is supplied, the entire render task is blurred. Also start expanding the Picture struct, with methods to prepare it for rendering etc. Finally, add the basic infrastructure for render tasks to specify what color they should be cleared to. This allows tasks to specify a non-default color, if required. This is useful for inset shadows where we will avoid blurring the inside of the shadow rect. For outset box shadows with a large blur radius and/or border radius this patch makes them ~3-4x faster than previously. A follow up will be to add the same blur regions for inset box shadows.
|
r? @kvark I still need to do a try run and WPT tests - but it should be OK to review this when you have time. |
|
Reviewed 9 of 9 files at r1. webrender/src/frame_builder.rs, line 581 at r1 (raw file):
I'm quite surprised to see this. If we just iterated on webrender/src/frame_builder.rs, line 590 at r1 (raw file):
all shadows are considered to be text shadows now? webrender/src/frame_builder.rs, line 1364 at r1 (raw file):
what is webrender/src/frame_builder.rs, line 1385 at r1 (raw file):
should we detect intersections here to avoid extra work on pixels covered by multiple regions? webrender/src/picture.rs, line 35 at r1 (raw file):
that's what I've been thinking of when reviewing the previous version of the PR, nice one! webrender/src/prim_store.rs, line 1060 at r1 (raw file):
neat! webrender/src/renderer.rs, line 2923 at r1 (raw file):
so we clear on top of the previous clear here? webrender/src/tiling.rs, line 1908 at r1 (raw file):
nit: could create a single Comments from Reviewable |
curious, what exactly made this case faster? Review status: all files reviewed at latest revision, 8 unresolved discussions. Comments from Reviewable |
|
Review status: 7 of 9 files reviewed at latest revision, 8 unresolved discussions. webrender/src/frame_builder.rs, line 581 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
It's the borrow on self for the call to add_primitive_to_draw_list() that is the problem. This could definitely be restructured and tidied up in the future though... webrender/src/frame_builder.rs, line 590 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
For now, yes. The box shadows don't currently make use of the offset field in Shadow. So to avoid confusion I'm not using the Shadow struct. We might end up changing how this works in the future though. webrender/src/frame_builder.rs, line 1364 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/renderer.rs, line 2923 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Yea. We might like to do something smarter here in the future. webrender/src/tiling.rs, line 1908 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. Comments from Reviewable |
|
@kvark The speed win comes because we only run the blur shader along the edges and corners of the mask rect. This won't be important once we have proper segmenting of the box shadows into a 9-patch (or even just a single corner in the case of uniform border radii), but it's a good win in the interim. I think the review comments are all addressed now. WPT tests on Servo are good and Gecko try run looks green: https://hg.mozilla.org/try/rev/d23b7c67075bf7d553dbad12fd0b7390f4bfcc77 |
|
Reviewed 2 of 2 files at r2. Comments from Reviewable |
|
thank you! |
|
|
Optimize box shadows - only apply blurs where they can affect the shadow. Add support for regions to blur render tasks. These allow render tasks to specify one or more regions where the blur should be applied. If no blur region is supplied, the entire render task is blurred. Also start expanding the Picture struct, with methods to prepare it for rendering etc. Finally, add the basic infrastructure for render tasks to specify what color they should be cleared to. This allows tasks to specify a non-default color, if required. This is useful for inset shadows where we will avoid blurring the inside of the shadow rect. For outset box shadows with a large blur radius and/or border radius this patch makes them ~3-4x faster than previously. A follow up will be to add the same blur regions for inset box shadows. <!-- 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/1896) <!-- Reviewable:end -->
|
|
764178a
into
servo:master
glennw commentedOct 19, 2017
•
edited by larsbergstrom
Add support for regions to blur render tasks. These allow render tasks
to specify one or more regions where the blur should be applied. If
no blur region is supplied, the entire render task is blurred.
Also start expanding the Picture struct, with methods to prepare
it for rendering etc.
Finally, add the basic infrastructure for render tasks to specify
what color they should be cleared to. This allows tasks to specify
a non-default color, if required. This is useful for inset shadows
where we will avoid blurring the inside of the shadow rect.
For outset box shadows with a large blur radius and/or border radius
this patch makes them ~3-4x faster than previously. A follow up will
be to add the same blur regions for inset box shadows.
This change is