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 upRefactor shadow flattening to do work in pop_all_shadows. #3167
Conversation
|
r? @gankro Pending try: I think this makes the shadow handling code a bit conceptually simpler too, in addition to being useful for the reasons above. |
|
Actual details seem fine, but I'd prefer we remove the contortions to support the unused pattern I discuss in the review. |
| @@ -1207,7 +1183,7 @@ impl<'a> DisplayListFlattener<'a> { | |||
| } | |||
|
|
|||
| assert!( | |||
| self.shadow_stack.is_empty(), | |||
| self.pending_shadow_items.is_empty(), | |||
| "Found unpopped text shadows when popping stacking context!" | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| pub fn is_empty(&self) -> bool { | ||
| self.prim_instances.is_empty() | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
Gankra
Oct 5, 2018
Contributor
An idle reminder that this sort of thing can go awry if item culling is too aggressive -- e.g. transparent text can be dropped from rendering, but still casts a visible shadow.
(We have to explicitly prevent this optimization in gecko when building the wr DL)
This comment has been minimized.
This comment has been minimized.
gw3583
Oct 5, 2018
Author
Collaborator
I think that's not relevant in this case - because it's just checking if any primitives are present, and if not, they can't cast a shadow (e.g. if the alpha of the primitives was all zero so they weren't added).
This comment has been minimized.
This comment has been minimized.
Gankra
Oct 5, 2018
Contributor
yeah we have several tests that incidentally check that invisible things cast shadows anyway
| // - Add *any* primitives that remain in the item list to this shadow. | ||
| // If the item is a primitive: | ||
| // - Add that primitive as a normal item (if alpha > 0) | ||
| // |
This comment has been minimized.
This comment has been minimized.
Gankra
Oct 5, 2018
Contributor
This all seems a bit heavy-handed to explicitly support the (never emitted, and quite frankly low-value) pattern the display-list format incidentally implies of [shadow, item, shadow, item, pop-all]. I would prefer that we just write if off and do:
shadows: Vec<Shadow>,
shadow_prims: Vec<PendingItem>,fn add_shadow(..) { assert!(shadow_prims.is_empty(), "shadows and items being interleaved isn't supported"); ... }
This comment has been minimized.
This comment has been minimized.
Gankra
Oct 5, 2018
Contributor
(it's possible I checked in a test that checks this pattern works but i'm fully convinced that it's not worth our time anymore)
This comment has been minimized.
This comment has been minimized.
gw3583
Oct 5, 2018
Author
Collaborator
I'm fine with doing that, although hesitant to change that now without testing servo as well. Would you be fine with landing it like this and I'll file an issue to simplify this API in the future?
This comment has been minimized.
This comment has been minimized.
Gankra
Oct 5, 2018
Contributor
I'm fairly certain servo wouldn't emit it, but yeah I guess sure, I can do the followup to unblock you.
| let pipeline_id = self.sc_stack.last().unwrap().pipeline_id; | ||
| let max_clip = LayoutRect::max_rect(); | ||
| let mut items = mem::replace(&mut self.pending_shadow_items, VecDeque::new()); |
This comment has been minimized.
This comment has been minimized.
| // Add the new primitive to the shadow picture. | ||
| shadow_pic.add_primitive(shadow_prim_index); | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This simplifies how shadow contexts are handled, by deferring the work of adding shadows and primitives until pop_all_shadows. Longer explanation below: Instead of adding a picture primitive, and then adding primitives to it, the picture API will be modified to take an immutable list of primitives during construction. This will be part of the changes to support interning of primitives for picture caching. This patch allows all the primitives for a shadow to be created before the shadow picture itself is added / created, which is required to work with these planned changes. Additionally, we can now detect if the shadow ended up having no primitives in it, and skip adding the picture in this case. This is probably a small win in some cases.
|
OK, try run looks good. There is one failure, but that's due to the revert of the pre/post-translate patch by @staktrace . |
|
@bors-servo r+ |
|
|
Refactor shadow flattening to do work in pop_all_shadows. This simplifies how shadow contexts are handled, by deferring the work of adding shadows and primitives until pop_all_shadows. Longer explanation below: Instead of adding a picture primitive, and then adding primitives to it, the picture API will be modified to take an immutable list of primitives during construction. This will be part of the changes to support interning of primitives for picture caching. This patch allows all the primitives for a shadow to be created before the shadow picture itself is added / created, which is required to work with these planned changes. Additionally, we can now detect if the shadow ended up having no primitives in it, and skip adding the picture in this case. This is probably a small win in some cases. <!-- 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/3167) <!-- Reviewable:end -->
|
@gankro Sounds good, thanks! |
|
|
gw3583 commentedOct 4, 2018
•
edited by larsbergstrom
This simplifies how shadow contexts are handled, by deferring the
work of adding shadows and primitives until pop_all_shadows.
Longer explanation below:
Instead of adding a picture primitive, and then adding primitives
to it, the picture API will be modified to take an immutable list
of primitives during construction. This will be part of the changes
to support interning of primitives for picture caching. This patch
allows all the primitives for a shadow to be created before the
shadow picture itself is added / created, which is required to work
with these planned changes.
Additionally, we can now detect if the shadow ended up having no
primitives in it, and skip adding the picture in this case. This
is probably a small win in some cases.
This change is