servo: Merge #14386 - Use new DisplayListBuilder improvements in Servo (from mrobinson:display-list-builder-updates); r=glennw

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they should not change behavior.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

In particular, we no longer to have a WebRenderFrameBuilder. All of the
complication is now handled by the DisplayListBuilder itself.

Source-Repo: https://github.com/servo/servo
Source-Revision: 1c6963144d0496d8dcbb7a7ca6782d01d3305441
This commit is contained in:
Martin Robinson 2016-11-29 02:36:05 -08:00
Родитель 4d50e21cf3
Коммит bd80dcc63d
3 изменённых файлов: 71 добавлений и 114 удалений

44
servo/Cargo.lock сгенерированный
Просмотреть файл

@ -246,7 +246,7 @@ dependencies = [
"offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1", "plugins 0.0.1",
"util 0.0.1", "util 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -262,7 +262,7 @@ dependencies = [
"plugins 0.0.1", "plugins 0.0.1",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -364,8 +364,8 @@ dependencies = [
"style_traits 0.0.1", "style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"webrender 0.10.0 (git+https://github.com/servo/webrender)", "webrender 0.11.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -398,7 +398,7 @@ dependencies = [
"servo_url 0.0.1", "servo_url 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"util 0.0.1", "util 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -911,7 +911,7 @@ dependencies = [
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1291,7 +1291,7 @@ dependencies = [
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1332,7 +1332,7 @@ dependencies = [
"servo_url 0.0.1", "servo_url 0.0.1",
"style 0.0.1", "style 0.0.1",
"util 0.0.1", "util 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1346,7 +1346,7 @@ dependencies = [
"profile_traits 0.0.1", "profile_traits 0.0.1",
"script_traits 0.0.1", "script_traits 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1437,8 +1437,8 @@ dependencies = [
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"webdriver_server 0.0.1", "webdriver_server 0.0.1",
"webrender 0.10.0 (git+https://github.com/servo/webrender)", "webrender 0.11.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1587,7 +1587,7 @@ dependencies = [
"plugins 0.0.1", "plugins 0.0.1",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1626,7 +1626,7 @@ dependencies = [
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1687,7 +1687,7 @@ dependencies = [
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -2226,7 +2226,7 @@ dependencies = [
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1", "util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -3057,8 +3057,8 @@ dependencies = [
[[package]] [[package]]
name = "webrender" name = "webrender"
version = "0.10.0" version = "0.11.0"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd" source = "git+https://github.com/servo/webrender#c4a0c01f7a249a5786a5f32922574feb56b370b2"
dependencies = [ dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3078,13 +3078,13 @@ dependencies = [
"offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.10.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
name = "webrender_traits" name = "webrender_traits"
version = "0.10.0" version = "0.11.0"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd" source = "git+https://github.com/servo/webrender#c4a0c01f7a249a5786a5f32922574feb56b370b2"
dependencies = [ dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3439,8 +3439,8 @@ dependencies = [
"checksum wayland-sys 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9633f7fe5de56544215f82eaf1b76bf1b584becf7f08b58cbef4c2c7d10e803a" "checksum wayland-sys 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9633f7fe5de56544215f82eaf1b76bf1b584becf7f08b58cbef4c2c7d10e803a"
"checksum wayland-window 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "309b69d3a863c9c21422d889fb7d98cf02f8a2ca054960a49243ce5b67ad884c" "checksum wayland-window 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "309b69d3a863c9c21422d889fb7d98cf02f8a2ca054960a49243ce5b67ad884c"
"checksum webdriver 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43d9121a4d0313abca5fb621f094791300176cac493ce74ad2cc188bddac29" "checksum webdriver 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43d9121a4d0313abca5fb621f094791300176cac493ce74ad2cc188bddac29"
"checksum webrender 0.10.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender 0.11.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum webrender_traits 0.10.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender_traits 0.11.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a1a6ea5ed0367f32eb3d94dcc58859ef4294b5f75ba983dbf56ac314af45d" "checksum websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a1a6ea5ed0367f32eb3d94dcc58859ef4294b5f75ba983dbf56ac314af45d"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

Просмотреть файл

@ -12,19 +12,18 @@ use euclid::{Point2D, Rect, Size2D};
use gfx::display_list::{BorderRadii, BoxShadowClipMode, ClippingRegion}; use gfx::display_list::{BorderRadii, BoxShadowClipMode, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, StackingContextType}; use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, StackingContextType};
use gfx_traits::{FragmentType, ScrollPolicy, ScrollRootId}; use gfx_traits::{FragmentType, ScrollPolicy, ScrollRootId};
use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode}; use style::computed_values::{image_rendering, mix_blend_mode};
use style::computed_values::filter::{self, Filter}; use style::computed_values::filter::{self, Filter};
use style::values::computed::BorderStyle; use style::values::computed::BorderStyle;
use webrender_traits::{self, AuxiliaryListsBuilder, BuiltDisplayList, DisplayListBuilder, PipelineId}; use webrender_traits::{self, DisplayListBuilder};
pub trait WebRenderDisplayListConverter { pub trait WebRenderDisplayListConverter {
fn convert_to_webrender(&self, frame_builder: &mut WebRenderFrameBuilder) -> BuiltDisplayList; fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
} }
trait WebRenderDisplayItemConverter { trait WebRenderDisplayItemConverter {
fn convert_to_webrender(&self, fn convert_to_webrender(&self, builder: &mut DisplayListBuilder);
builder: &mut DisplayListBuilder,
frame_builder: &mut WebRenderFrameBuilder);
} }
trait ToBorderStyle { trait ToBorderStyle {
@ -96,22 +95,19 @@ impl ToRectF for Rect<Au> {
} }
trait ToClipRegion { trait ToClipRegion {
fn to_clip_region(&self, frame_builder: &mut WebRenderFrameBuilder) fn to_clip_region(&self, builder: &mut DisplayListBuilder) -> webrender_traits::ClipRegion;
-> webrender_traits::ClipRegion;
} }
impl ToClipRegion for ClippingRegion { impl ToClipRegion for ClippingRegion {
fn to_clip_region(&self, frame_builder: &mut WebRenderFrameBuilder) fn to_clip_region(&self, builder: &mut DisplayListBuilder) -> webrender_traits::ClipRegion {
-> webrender_traits::ClipRegion { builder.new_clip_region(&self.main.to_rectf(),
webrender_traits::ClipRegion::new(&self.main.to_rectf(), self.complex.iter().map(|complex_clipping_region| {
self.complex.iter().map(|complex_clipping_region| { webrender_traits::ComplexClipRegion::new(
webrender_traits::ComplexClipRegion::new( complex_clipping_region.rect.to_rectf(),
complex_clipping_region.rect.to_rectf(), complex_clipping_region.radii.to_border_radius(),
complex_clipping_region.radii.to_border_radius(), )
) }).collect(),
}).collect(), None)
None,
&mut frame_builder.auxiliary_lists_builder)
} }
} }
@ -196,27 +192,24 @@ impl ToFilterOps for filter::T {
} }
impl WebRenderDisplayListConverter for DisplayList { impl WebRenderDisplayListConverter for DisplayList {
fn convert_to_webrender(&self, frame_builder: &mut WebRenderFrameBuilder) -> BuiltDisplayList { fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
let traversal = DisplayListTraversal::new(self); let traversal = DisplayListTraversal::new(self);
let mut builder = DisplayListBuilder::new(); let mut builder = DisplayListBuilder::new(pipeline_id.to_webrender());
for item in traversal { for item in traversal {
item.convert_to_webrender(&mut builder, frame_builder); item.convert_to_webrender(&mut builder);
} }
builder.finalize() builder
} }
} }
impl WebRenderDisplayItemConverter for DisplayItem { impl WebRenderDisplayItemConverter for DisplayItem {
fn convert_to_webrender(&self, fn convert_to_webrender(&self, builder: &mut DisplayListBuilder) {
builder: &mut DisplayListBuilder,
frame_builder: &mut WebRenderFrameBuilder) {
match *self { match *self {
DisplayItem::SolidColor(ref item) => { DisplayItem::SolidColor(ref item) => {
let color = item.color; let color = item.color;
if color.a > 0.0 { if color.a > 0.0 {
builder.push_rect(item.base.bounds.to_rectf(), let clip = item.base.clip.to_clip_region(builder);
item.base.clip.to_clip_region(frame_builder), builder.push_rect(item.base.bounds.to_rectf(), clip, color);
color);
} }
} }
DisplayItem::Text(ref item) => { DisplayItem::Text(ref item) => {
@ -244,22 +237,23 @@ impl WebRenderDisplayItemConverter for DisplayItem {
} }
if glyphs.len() > 0 { if glyphs.len() > 0 {
let clip = item.base.clip.to_clip_region(builder);
builder.push_text(item.base.bounds.to_rectf(), builder.push_text(item.base.bounds.to_rectf(),
item.base.clip.to_clip_region(frame_builder), clip,
glyphs, glyphs,
item.text_run.font_key, item.text_run.font_key,
item.text_color, item.text_color,
item.text_run.actual_pt_size, item.text_run.actual_pt_size,
item.blur_radius, item.blur_radius);
&mut frame_builder.auxiliary_lists_builder);
} }
} }
DisplayItem::Image(ref item) => { DisplayItem::Image(ref item) => {
if let Some(id) = item.webrender_image.key { if let Some(id) = item.webrender_image.key {
if item.stretch_size.width > Au(0) && if item.stretch_size.width > Au(0) &&
item.stretch_size.height > Au(0) { item.stretch_size.height > Au(0) {
let clip = item.base.clip.to_clip_region(builder);
builder.push_image(item.base.bounds.to_rectf(), builder.push_image(item.base.bounds.to_rectf(),
item.base.clip.to_clip_region(frame_builder), clip,
item.stretch_size.to_sizef(), item.stretch_size.to_sizef(),
item.tile_spacing.to_sizef(), item.tile_spacing.to_sizef(),
item.image_rendering.to_image_rendering(), item.image_rendering.to_image_rendering(),
@ -268,9 +262,8 @@ impl WebRenderDisplayItemConverter for DisplayItem {
} }
} }
DisplayItem::WebGL(ref item) => { DisplayItem::WebGL(ref item) => {
builder.push_webgl_canvas(item.base.bounds.to_rectf(), let clip = item.base.clip.to_clip_region(builder);
item.base.clip.to_clip_region(frame_builder), builder.push_webgl_canvas(item.base.bounds.to_rectf(), clip, item.context_id);
item.context_id);
} }
DisplayItem::Border(ref item) => { DisplayItem::Border(ref item) => {
let rect = item.base.bounds.to_rectf(); let rect = item.base.bounds.to_rectf();
@ -295,8 +288,9 @@ impl WebRenderDisplayItemConverter for DisplayItem {
style: item.style.bottom.to_border_style(), style: item.style.bottom.to_border_style(),
}; };
let radius = item.radius.to_border_radius(); let radius = item.radius.to_border_radius();
let clip = item.base.clip.to_clip_region(builder);
builder.push_border(rect, builder.push_border(rect,
item.base.clip.to_clip_region(frame_builder), clip,
left, left,
top, top,
right, right,
@ -307,12 +301,12 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let rect = item.base.bounds.to_rectf(); let rect = item.base.bounds.to_rectf();
let start_point = item.start_point.to_pointf(); let start_point = item.start_point.to_pointf();
let end_point = item.end_point.to_pointf(); let end_point = item.end_point.to_pointf();
let clip = item.base.clip.to_clip_region(builder);
builder.push_gradient(rect, builder.push_gradient(rect,
item.base.clip.to_clip_region(frame_builder), clip,
start_point, start_point,
end_point, end_point,
item.stops.clone(), item.stops.clone());
&mut frame_builder.auxiliary_lists_builder);
} }
DisplayItem::Line(..) => { DisplayItem::Line(..) => {
println!("TODO DisplayItem::Line"); println!("TODO DisplayItem::Line");
@ -320,8 +314,9 @@ impl WebRenderDisplayItemConverter for DisplayItem {
DisplayItem::BoxShadow(ref item) => { DisplayItem::BoxShadow(ref item) => {
let rect = item.base.bounds.to_rectf(); let rect = item.base.bounds.to_rectf();
let box_bounds = item.box_bounds.to_rectf(); let box_bounds = item.box_bounds.to_rectf();
let clip = item.base.clip.to_clip_region(builder);
builder.push_box_shadow(rect, builder.push_box_shadow(rect,
item.base.clip.to_clip_region(frame_builder), clip,
box_bounds, box_bounds,
item.offset.to_pointf(), item.offset.to_pointf(),
item.color, item.color,
@ -333,9 +328,8 @@ impl WebRenderDisplayItemConverter for DisplayItem {
DisplayItem::Iframe(ref item) => { DisplayItem::Iframe(ref item) => {
let rect = item.base.bounds.to_rectf(); let rect = item.base.bounds.to_rectf();
let pipeline_id = item.iframe.to_webrender(); let pipeline_id = item.iframe.to_webrender();
builder.push_iframe(rect, let clip = item.base.clip.to_clip_region(builder);
item.base.clip.to_clip_region(frame_builder), builder.push_iframe(rect, clip, pipeline_id);
pipeline_id);
} }
DisplayItem::PushStackingContext(ref item) => { DisplayItem::PushStackingContext(ref item) => {
let stacking_context = &item.stacking_context; let stacking_context = &item.stacking_context;
@ -346,58 +340,26 @@ impl WebRenderDisplayItemConverter for DisplayItem {
ScrollPolicy::FixedPosition => webrender_traits::ScrollPolicy::Fixed, ScrollPolicy::FixedPosition => webrender_traits::ScrollPolicy::Fixed,
}; };
let context = builder.push_stacking_context(webrender_scroll_policy,
webrender_traits::StackingContext::new( stacking_context.bounds.to_rectf(),
webrender_scroll_policy, stacking_context.overflow.to_rectf(),
stacking_context.bounds.to_rectf(), stacking_context.z_index,
stacking_context.overflow.to_rectf(), &stacking_context.transform,
stacking_context.z_index, &stacking_context.perspective,
&stacking_context.transform, stacking_context.blend_mode.to_blend_mode(),
&stacking_context.perspective, stacking_context.filters.to_filter_ops());
stacking_context.blend_mode.to_blend_mode(),
stacking_context.filters.to_filter_ops(),
&mut frame_builder.auxiliary_lists_builder);
builder.push_stacking_context(context);
} }
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(), DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
DisplayItem::PushScrollRoot(ref item) => { DisplayItem::PushScrollRoot(ref item) => {
builder.push_scroll_layer(item.scroll_root.clip.to_rectf(), builder.push_scroll_layer(item.scroll_root.clip.to_rectf(),
item.scroll_root.size.to_sizef(), item.scroll_root.size.to_sizef(),
frame_builder.next_scroll_layer_id(item.scroll_root.id)); item.scroll_root.id.convert_to_webrender());
} }
DisplayItem::PopScrollRoot(_) => builder.pop_scroll_layer(), DisplayItem::PopScrollRoot(_) => builder.pop_scroll_layer(),
} }
} }
} }
pub struct WebRenderFrameBuilder {
pub auxiliary_lists_builder: AuxiliaryListsBuilder,
pub root_pipeline_id: PipelineId,
pub next_scroll_layer_id: usize,
}
impl WebRenderFrameBuilder {
pub fn new(root_pipeline_id: PipelineId) -> WebRenderFrameBuilder {
WebRenderFrameBuilder {
auxiliary_lists_builder: AuxiliaryListsBuilder::new(),
root_pipeline_id: root_pipeline_id,
next_scroll_layer_id: 0,
}
}
pub fn next_scroll_layer_id(&mut self,
scroll_root_id: ScrollRootId)
-> webrender_traits::ScrollLayerId {
let scroll_layer_id = self.next_scroll_layer_id;
self.next_scroll_layer_id += 1;
webrender_traits::ScrollLayerId::new(self.root_pipeline_id,
scroll_layer_id,
scroll_root_id.convert_to_webrender())
}
}
trait WebRenderScrollRootIdConverter { trait WebRenderScrollRootIdConverter {
fn convert_to_webrender(&self) -> webrender_traits::ServoScrollRootId; fn convert_to_webrender(&self) -> webrender_traits::ServoScrollRootId;
} }

Просмотреть файл

@ -75,7 +75,7 @@ use layout::query::{process_node_geometry_request, process_node_scroll_area_requ
use layout::query::process_offset_parent_query; use layout::query::process_offset_parent_query;
use layout::sequential; use layout::sequential;
use layout::traversal::{ComputeAbsolutePositions, RecalcStyleAndConstructFlows}; use layout::traversal::{ComputeAbsolutePositions, RecalcStyleAndConstructFlows};
use layout::webrender_helpers::{WebRenderDisplayListConverter, WebRenderFrameBuilder}; use layout::webrender_helpers::WebRenderDisplayListConverter;
use layout::wrapper::LayoutNodeLayoutData; use layout::wrapper::LayoutNodeLayoutData;
use layout::wrapper::drop_style_and_layout_data; use layout::wrapper::drop_style_and_layout_data;
use layout_traits::LayoutThreadFactory; use layout_traits::LayoutThreadFactory;
@ -947,10 +947,7 @@ impl LayoutThread {
debug!("Layout done!"); debug!("Layout done!");
// TODO: Avoid the temporary conversion and build webrender sc/dl directly! // TODO: Avoid the temporary conversion and build webrender sc/dl directly!
let pipeline_id = self.id.to_webrender(); let builder = rw_data.display_list.as_ref().unwrap().convert_to_webrender(self.id);
let mut frame_builder = WebRenderFrameBuilder::new(pipeline_id);
let built_display_list = rw_data.display_list.as_ref().unwrap().convert_to_webrender(
&mut frame_builder);
let viewport_size = Size2D::new(self.viewport_size.width.to_f32_px(), let viewport_size = Size2D::new(self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px()); self.viewport_size.height.to_f32_px());
@ -961,10 +958,8 @@ impl LayoutThread {
self.webrender_api.set_root_display_list( self.webrender_api.set_root_display_list(
get_root_flow_background_color(layout_root), get_root_flow_background_color(layout_root),
webrender_traits::Epoch(epoch_number), webrender_traits::Epoch(epoch_number),
pipeline_id,
viewport_size, viewport_size,
built_display_list, builder);
frame_builder.auxiliary_lists_builder.finalize());
}); });
} }