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 upAdd drop shadow support. #2091
Add drop shadow support. #2091
Conversation
|
|
|
I have some concerns over the hashmap - there's various assumptions built in that a primitive only exists in one picture. Sorry I didn't have a chance to write up more detailed notes yet - I'll write up some more info next week. |
|
Reviewed 9 of 13 files at r1. Comments from Reviewable |
|
Instead of having to draw the primitives in a drop shadow twice, how about something like this: The code for a drop shadow filter is very similar to a normal blur filter - that is, a normal Picture where the render_task_id for the picture points to the render task that contains the blur result, and the blur task points to a task which draws the contents of the Picture we are drop-shadowing. Then, the tricky part is being able to draw the normal Picture contents as well, since that will be done in a much earlier pass. However, if we extend the functionality of This would mean that we only ever have to draw the contents of a drop-shadow element once, which I think could be a good performance win in most cases. Although it might be a little complex to implement the support for Does that sound like it would work? |
|
Sounds like a very good solution. I'll start to implement it! Thanks. |
|
|
|
The long-chain.html failure looks like a known issue. Even if I remove the drop-shadow effect in long-chain, the result isn't correct. Looks like the result is wrong if filters contain opacity and other effects. |
|
The long-chain.html should be fixed by #2150 |
|
I think this is ready to review. r? @glennw |
| @@ -45,6 +45,8 @@ pub enum SourceTexture { | |||
| External(ExternalImageData), | |||
| CacheA8, | |||
| CacheRGBA8, | |||
| RenderTaskCacheA8(usize), | |||
This comment has been minimized.
This comment has been minimized.
glennw
Dec 4, 2017
Member
We could use a newtype here to give a bit of type safety, and more importantly, self-document what these fields are. For example:
struct RenderPassIndex(usize);
...
RenderTaskCacheA8(RenderPassIndex),
...
Or something like that?
| @@ -283,6 +283,7 @@ pub struct RenderTask { | |||
| pub children: Vec<RenderTaskId>, | |||
| pub kind: RenderTaskKind, | |||
| pub clear_mode: ClearMode, | |||
| pub pass_index: usize, | |||
This comment has been minimized.
This comment has been minimized.
glennw
Dec 4, 2017
Member
This could use the RenderPassIndex mentioned above. If we make it Option<RenderPassIndex> we can ensure that when the later code reads the value, it has been correctly assigned to a pass.
| @@ -564,6 +564,11 @@ struct SourceTextureResolver { | |||
| /// The current cache textures. | |||
| cache_rgba8_texture: Option<Texture>, | |||
| cache_a8_texture: Option<Texture>, | |||
|
|
|||
| pass_rgba8_textures: FastHashMap<usize, usize>, | |||
This comment has been minimized.
This comment has been minimized.
glennw
Dec 4, 2017
Member
We could use a stronger type here, or at least a comment to describe what this is mapping between.
| ) { | ||
| // If we have cache textures from previous pass, return them to the pool. | ||
| pool.extend(self.cache_rgba8_texture.take()); | ||
| pool.extend(self.cache_a8_texture.take()); | ||
| match self.cache_rgba8_texture { |
This comment has been minimized.
This comment has been minimized.
| } | ||
| _ => {} | ||
| } | ||
| match self.cache_a8_texture { |
This comment has been minimized.
This comment has been minimized.
|
Looks like this has a reftest failure on CI too, which will need investigation. It might just be a fuzziness issue that requires updating the PNG reference. |
|
|
|
|
|
Review status: 4 of 16 files reviewed at latest revision, 5 unresolved discussions. webrender/src/internal_types.rs, line 48 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Done. webrender/src/render_task.rs, line 286 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Done. webrender/src/renderer.rs, line 568 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Done. webrender/src/renderer.rs, line 632 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Done. webrender/src/renderer.rs, line 639 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Done. Comments from Reviewable |
|
Reviewed 4 of 13 files at r1, 3 of 11 files at r2, 8 of 9 files at r3, 1 of 1 files at r4. webrender/src/frame_builder.rs, line 1753 at r4 (raw file):
Is this intentionally not webrender/src/render_task.rs, line 20 at r4 (raw file):
nit: let's keep those imports alphabetically ordered webrender/src/renderer.rs, line 643 at r4 (raw file):
if let Some(texture) = self.cache_rgba8_texture.take() {...}webrender/src/renderer.rs, line 645 at r4 (raw file):
why does this have webrender/src/renderer.rs, line 689 at r4 (raw file):
is this legal? I'd expect us to panic here webrender/src/renderer.rs, line 4028 at r4 (raw file):
what is the reasoning behind moving the RT pool under webrender/src/tiling.rs, line 1806 at r4 (raw file):
would it be simpler to pass the index into webrender/src/tiling.rs, line 1866 at r4 (raw file):
wrench/reftests/filters/filter-drop-shadow.yaml, line 6 at r4 (raw file):
would be cleaner to keep the vector parts vectors, e.g. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 14 unresolved discussions. webrender/src/frame_builder.rs, line 1753 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I'll remove this line in next patch. webrender/src/render_task.rs, line 20 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/renderer.rs, line 643 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/renderer.rs, line 645 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I added a comment. This is because the cache textures that return to pool are last pass's result. So we need webrender/src/renderer.rs, line 689 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Not every pass generated cache_texture. For example, if a RenderTargetList didn't has any targets, we don't build a texture for them. webrender/src/renderer.rs, line 4028 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Because we don't need to pass RT poll when calling webrender/src/tiling.rs, line 1806 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/tiling.rs, line 1866 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. wrench/reftests/filters/filter-drop-shadow.yaml, line 6 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. Comments from Reviewable |
|
Reviewed 7 of 7 files at r5. webrender/src/render_task.rs, line 139 at r5 (raw file):
hmm, why is this needed? the caller should be able to use the array syntax webrender/src/renderer.rs, line 689 at r4 (raw file): Previously, mephisto41 (Morris Tseng) wrote…
Right, but we are also not calling wrench/src/parse_function.rs, line 21 at r5 (raw file):
that's not ideal to skip brackets with whitespace... perhaps we could parse the bracket-enclosed value separately as opposed to flattening the list? Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 8 unresolved discussions. webrender/src/render_task.rs, line 139 at r5 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/renderer.rs, line 689 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Ok, I got it. I added panic for it. wrench/src/parse_function.rs, line 21 at r5 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. Comments from Reviewable |
18e8c13
to
1370760
|
Thanks! Reviewed 7 of 7 files at r6. webrender/src/internal_types.rs, line 44 at r6 (raw file):
can we move it to the specified variant only (as opposed to the whole enum)? webrender/src/renderer.rs, line 689 at r4 (raw file): Previously, mephisto41 (Morris Tseng) wrote…
Thanks! nit: the webrender/src/tiling.rs, line 1862 at r6 (raw file):
does array syntax work here? wrench/src/yaml_helper.rs, line 571 at r6 (raw file):
looks much better Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 9 unresolved discussions. webrender/src/internal_types.rs, line 44 at r6 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/renderer.rs, line 689 at r4 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Thanks for suggestion. I use expect for this. webrender/src/tiling.rs, line 1862 at r6 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Ah, array syntax works!! Comments from Reviewable |
|
Review status: 14 of 17 files reviewed at latest revision, 6 unresolved discussions. Comments from Reviewable |
|
@bors-servo r+ |
|
|
Add drop shadow support. The major changes here are using hash map to store render_task_id in PicturePrimitive. In order to support drop shadow, we need add a primitive to multiple pictures. So, if we only stored one render_task_id, the result is wrong. Hence, I use a hash map to store multiple render_task_ids and use parent PrimitiveIndex as key. Another change is brush_image now has third configuration which is take color target as source, but only use alpha of this target and multiply color as result. This is because drop shadow is similar to box shadow which take a alpha mask and a color, but drop shadow's alpha mask is the alpha channel of color target. <!-- 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/2091) <!-- Reviewable:end -->
|
|
cf85e75
into
servo:master
mephisto41 commentedNov 23, 2017
•
edited by larsbergstrom
The major changes here are using hash map to store render_task_id in PicturePrimitive. In order to support drop shadow, we need add a primitive to multiple pictures. So, if we only stored one render_task_id, the result is wrong. Hence, I use a hash map to store multiple render_task_ids and use parent PrimitiveIndex as key.
Another change is brush_image now has third configuration which is take color target as source, but only use alpha of this target and multiply color as result. This is because drop shadow is similar to box shadow which take a alpha mask and a color, but drop shadow's alpha mask is the alpha channel of color target.
This change is