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

Flatten the display list in the API #552

Merged
merged 2 commits into from
Nov 14, 2016
Merged

Conversation

mrobinson
Copy link
Member

@mrobinson mrobinson commented Nov 10, 2016

This changes brings the WebRender API more into line with the Servo
display list and also the frames generated inside WebRender itself.
Most intermediate display list representations are removed as well as
their place on the resource cache. Perhaps most notably, stacking
contexts are started via a PushStackingContext display item and ended
via a PopStackingContext item. Additionally, the flatten pass has been
significantly simplified to account for these changes.


This change is Reviewable

@mrobinson
Copy link
Member Author

@glennw r?

@mrobinson
Copy link
Member Author

The Servo part of this patch is here, which can be ready to go soon after this lands: https://github.com/mrobinson/servo/tree/display-list

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #549) made this pull request unmergeable. Please resolve the merge conflicts.

@glennw
Copy link
Member

glennw commented Nov 10, 2016

@mrobinson Wow, this is awesome! Will review today :)

@emilio
Copy link
Member

emilio commented Nov 10, 2016

@mrobinson I think you'll need to update the lockfiles, and potentially the callers in the other crates I guess, Travis is complaining :(

@glennw
Copy link
Member

glennw commented Nov 11, 2016

@mrobinson I've had a reasonable look over this - it looks great! I ran all the WPT tests on it locally, and I get the failures below. Once those are fixed up we'll try to finish up the review and get it merged before it bitrots too badly.


  ▶ FAIL [expected PASS] /_mozilla/css/iframe/hide_and_show.html
  └   → /_mozilla/css/iframe/hide_and_show.html 1b322aa260e8efcc96823b3616dec4048e764fd7
/_mozilla/css/iframe/hide_and_show_ref.html a588759663fe2c5184aba85f7ea89f48a5c2b38f
Testing 1b322aa260e8efcc96823b3616dec4048e764fd7 == a588759663fe2c5184aba85f7ea89f48a5c2b38f

  ▶ FAIL [expected PASS] /_mozilla/css/stacked_layers.html
  └   → /_mozilla/css/stacked_layers.html 47267c953cbf670c595a258334dff478f5c24369
/_mozilla/css/stacked_layers_ref.html 6955d0a11b580828a5e9a47926e22b577c48ee5f
Testing 47267c953cbf670c595a258334dff478f5c24369 == 6955d0a11b580828a5e9a47926e22b577c48ee5f

@mrobinson
Copy link
Member Author

@glennw Ack! Thanks for taking a look. I'll try to get the ref tests sorted today. Sorry for letting those slip by.

@mrobinson
Copy link
Member Author

@glennw Okay. Sorry for the failures. Things should be working now.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

I don't know much about this area of WR, but the change looks good to me!

for item in &display_list.items {
result.push(item.clone());
}
match first_item.item {
Copy link
Member

Choose a reason for hiding this comment

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

nit: could combine these matches into one

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm. I was hoping to keep the nesting level a bit shallower to make it easier to read. Is there a way to do that while taking your suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

That's really minor and doesn't need to be fixed! Could be done in a single match (like I specified in another comment), in nested matches, or even with and_then construct:

self.first().and_then(|item| match item.item {...})

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, that's a lot nicer! The latest version of the branch takes this suggestion.

@@ -190,6 +154,57 @@ impl StackingContextHelpers for StackingContext {
}
}

pub struct DisplayListTraversal<'a> {
pub display_list: &'a Vec<DisplayItem>,
Copy link
Member

Choose a reason for hiding this comment

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

do these have to be public?

Copy link
Member

Choose a reason for hiding this comment

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

As a uber-nit: this can probably be &'a [DisplayItem] to save an extra level of indirection.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay!


pub fn current_stacking_context_empty(&self) -> bool {
match self.peek() {
Some(item) if item.item == SpecificDisplayItem::PopStackingContext => true,
Copy link
Member

Choose a reason for hiding this comment

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

nit: could do Some(item) => item.item == SpecificDisplayItem::PopStackingContext,

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nice. Done.


let iframe_scroll_layer_id = iframe_stacking_context.scroll_layer_id.unwrap();
self.layers.insert(iframe_scroll_layer_id,
Layer::new(&iframe_rect,
Copy link
Member

Choose a reason for hiding this comment

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

nit: looks like the same layer as above, could clone() it

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. I've made Layer derive from Clone and done this. It made things quite a bit simpler.


impl DisplayListHelpers for Vec<DisplayItem> {
fn starting_stacking_context<'a>(&'a self) -> Option<&'a StackingContext> {
let first_item = match self.first() {
Copy link
Member

Choose a reason for hiding this comment

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

nit: same as the other implementation, could combine the two matches into one:

Some(SomethingSomething { item: SpecificDisplayItem::PushStackingContext(ref item), .. }) => ...

This changes brings the WebRender API more into line with the Servo
display list and also the frames generated inside WebRender itself.
Most intermediate display list representations are removed as well as
their place on the resource cache. Perhaps most notably, stacking
contexts are started via a PushStackingContext display item and ended
via a PopStackingContext item. Additionally, the flatten pass has been
significantly simplified to account for these changes.
@glennw
Copy link
Member

glennw commented Nov 14, 2016

@mrobinson r=me. I haven't merged this yet to minimize the amount of time that we have this merged in WR without the corresponding Servo PR. But feel free to merge this when the Servo PR is ready to go!

@mrobinson
Copy link
Member Author

@bors-servo r=glennw

@bors-servo
Copy link
Contributor

📌 Commit 3b139d2 has been approved by glennw

@bors-servo
Copy link
Contributor

⌛ Testing commit 3b139d2 with merge 087516e...

bors-servo pushed a commit that referenced this pull request Nov 14, 2016
Flatten the display list in the API

This changes brings the WebRender API more into line with the Servo
display list and also the frames generated inside WebRender itself.
Most intermediate display list representations are removed as well as
their place on the resource cache. Perhaps most notably, stacking
contexts are started via a PushStackingContext display item and ended
via a PopStackingContext item. Additionally, the flatten pass has been
significantly simplified to account for these changes.

<!-- 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/552)
<!-- Reviewable:end -->
@mrobinson
Copy link
Member Author

@glennw Thanks. I'll get the Servo bit up ASAP.

@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis

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.

5 participants