mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Upgrade display list building for the WebRender update.
This commit is contained in:
parent
7915a7099f
commit
7ca570dd1d
3 changed files with 168 additions and 109 deletions
|
@ -13,7 +13,7 @@ use crate::context::LayoutContext;
|
||||||
use crate::display_list::background::{self, get_cyclic};
|
use crate::display_list::background::{self, get_cyclic};
|
||||||
use crate::display_list::border;
|
use crate::display_list::border;
|
||||||
use crate::display_list::gradient;
|
use crate::display_list::gradient;
|
||||||
use crate::display_list::items::{BaseDisplayItem, ClipScrollNode, BLUR_INFLATION_FACTOR};
|
use crate::display_list::items::{self, BaseDisplayItem, ClipScrollNode, BLUR_INFLATION_FACTOR};
|
||||||
use crate::display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
use crate::display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
||||||
use crate::display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
use crate::display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
||||||
use crate::display_list::items::{CommonDisplayItem, DisplayListSection};
|
use crate::display_list::items::{CommonDisplayItem, DisplayListSection};
|
||||||
|
@ -43,7 +43,7 @@ use net_traits::image_cache::UsePlaceholder;
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use script_traits::IFrameSize;
|
use script_traits::IFrameSize;
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_geometry::MaxRect;
|
use servo_geometry::{self, MaxRect};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::f32;
|
use std::f32;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -716,6 +716,7 @@ impl Fragment {
|
||||||
base,
|
base,
|
||||||
webrender_api::RectangleDisplayItem {
|
webrender_api::RectangleDisplayItem {
|
||||||
color: background_color.to_layout(),
|
color: background_color.to_layout(),
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
@ -854,6 +855,8 @@ impl Fragment {
|
||||||
state.add_image_item(
|
state.add_image_item(
|
||||||
base,
|
base,
|
||||||
webrender_api::ImageDisplayItem {
|
webrender_api::ImageDisplayItem {
|
||||||
|
bounds: placement.bounds.to_f32_px(),
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
image_key: webrender_image.key.unwrap(),
|
image_key: webrender_image.key.unwrap(),
|
||||||
stretch_size: placement.tile_size.to_layout(),
|
stretch_size: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing.to_layout(),
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
|
@ -976,6 +979,8 @@ impl Fragment {
|
||||||
);
|
);
|
||||||
let item = webrender_api::GradientDisplayItem {
|
let item = webrender_api::GradientDisplayItem {
|
||||||
gradient,
|
gradient,
|
||||||
|
bounds: placement.bounds.to_f32_px(),
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
tile_size: placement.tile_size.to_layout(),
|
tile_size: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing.to_layout(),
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
};
|
};
|
||||||
|
@ -992,6 +997,8 @@ impl Fragment {
|
||||||
);
|
);
|
||||||
let item = webrender_api::RadialGradientDisplayItem {
|
let item = webrender_api::RadialGradientDisplayItem {
|
||||||
gradient,
|
gradient,
|
||||||
|
bounds: placement.bounds.to_f32_px(),
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
tile_size: placement.tile_size.to_layout(),
|
tile_size: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing.to_layout(),
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
};
|
};
|
||||||
|
@ -1034,6 +1041,7 @@ impl Fragment {
|
||||||
state.add_display_item(DisplayItem::BoxShadow(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::BoxShadow(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::BoxShadowDisplayItem {
|
webrender_api::BoxShadowDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
box_bounds: absolute_bounds.to_layout(),
|
box_bounds: absolute_bounds.to_layout(),
|
||||||
color: style.resolve_color(box_shadow.base.color).to_layout(),
|
color: style.resolve_color(box_shadow.base.color).to_layout(),
|
||||||
offset: LayoutVector2D::new(
|
offset: LayoutVector2D::new(
|
||||||
|
@ -1157,9 +1165,12 @@ impl Fragment {
|
||||||
radius: border_radius,
|
radius: border_radius,
|
||||||
do_aa: true,
|
do_aa: true,
|
||||||
});
|
});
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: border_widths.to_layout(),
|
widths: border_widths.to_layout(),
|
||||||
details,
|
details,
|
||||||
},
|
},
|
||||||
|
@ -1261,9 +1272,12 @@ impl Fragment {
|
||||||
border_image_outset.left.to_f32_px(),
|
border_image_outset.left.to_f32_px(),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: border_image_width,
|
widths: border_image_width,
|
||||||
details,
|
details,
|
||||||
},
|
},
|
||||||
|
@ -1313,9 +1327,12 @@ impl Fragment {
|
||||||
get_cursor(&style, Cursor::Default),
|
get_cursor(&style, Cursor::Default),
|
||||||
DisplayListSection::Outlines,
|
DisplayListSection::Outlines,
|
||||||
);
|
);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: SideOffsets2D::new_all_same(width).to_layout(),
|
widths: SideOffsets2D::new_all_same(width).to_layout(),
|
||||||
details: BorderDetails::Normal(border::simple(color, outline_style.to_layout())),
|
details: BorderDetails::Normal(border::simple(color, outline_style.to_layout())),
|
||||||
},
|
},
|
||||||
|
@ -1344,9 +1361,12 @@ impl Fragment {
|
||||||
get_cursor(&style, Cursor::Default),
|
get_cursor(&style, Cursor::Default),
|
||||||
DisplayListSection::Content,
|
DisplayListSection::Content,
|
||||||
);
|
);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: SideOffsets2D::new_all_same(Au::from_px(1)).to_layout(),
|
widths: SideOffsets2D::new_all_same(Au::from_px(1)).to_layout(),
|
||||||
details: BorderDetails::Normal(border::simple(
|
details: BorderDetails::Normal(border::simple(
|
||||||
ColorU::new(0, 0, 200, 1).into(),
|
ColorU::new(0, 0, 200, 1).into(),
|
||||||
|
@ -1375,9 +1395,12 @@ impl Fragment {
|
||||||
);
|
);
|
||||||
// TODO(gw): Use a better estimate for wavy line thickness.
|
// TODO(gw): Use a better estimate for wavy line thickness.
|
||||||
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
|
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
|
||||||
|
let area = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::LineDisplayItem {
|
webrender_api::LineDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
|
area,
|
||||||
orientation: webrender_api::LineOrientation::Horizontal,
|
orientation: webrender_api::LineOrientation::Horizontal,
|
||||||
wavy_line_thickness,
|
wavy_line_thickness,
|
||||||
color: ColorU::new(0, 200, 0, 1).into(),
|
color: ColorU::new(0, 200, 0, 1).into(),
|
||||||
|
@ -1401,9 +1424,12 @@ impl Fragment {
|
||||||
get_cursor(&self.style, Cursor::Default),
|
get_cursor(&self.style, Cursor::Default),
|
||||||
DisplayListSection::Content,
|
DisplayListSection::Content,
|
||||||
);
|
);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: SideOffsets2D::new_all_same(Au::from_px(1)).to_layout(),
|
widths: SideOffsets2D::new_all_same(Au::from_px(1)).to_layout(),
|
||||||
details: BorderDetails::Normal(border::simple(
|
details: BorderDetails::Normal(border::simple(
|
||||||
ColorU::new(0, 0, 200, 1).into(),
|
ColorU::new(0, 0, 200, 1).into(),
|
||||||
|
@ -1446,6 +1472,7 @@ impl Fragment {
|
||||||
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::RectangleDisplayItem {
|
webrender_api::RectangleDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
color: background_color.to_layout(),
|
color: background_color.to_layout(),
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
@ -1492,6 +1519,7 @@ impl Fragment {
|
||||||
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::RectangleDisplayItem {
|
webrender_api::RectangleDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
color: self.style().get_inherited_text().color.to_layout(),
|
color: self.style().get_inherited_text().color.to_layout(),
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
@ -1676,6 +1704,7 @@ impl Fragment {
|
||||||
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::RectangleDisplayItem {
|
webrender_api::RectangleDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
color: ColorF::TRANSPARENT,
|
color: ColorF::TRANSPARENT,
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
@ -1824,9 +1853,12 @@ impl Fragment {
|
||||||
if let Some(ref image) = image_fragment.image {
|
if let Some(ref image) = image_fragment.image {
|
||||||
if let Some(id) = image.id {
|
if let Some(id) = image.id {
|
||||||
let base = create_base_display_item(state);
|
let base = create_base_display_item(state);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_image_item(
|
state.add_image_item(
|
||||||
base,
|
base,
|
||||||
webrender_api::ImageDisplayItem {
|
webrender_api::ImageDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
image_key: id,
|
image_key: id,
|
||||||
stretch_size: stacking_relative_content_box.size.to_layout(),
|
stretch_size: stacking_relative_content_box.size.to_layout(),
|
||||||
tile_spacing: LayoutSize::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
|
@ -1845,9 +1877,12 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::Media(ref fragment_info) => {
|
SpecificFragmentInfo::Media(ref fragment_info) => {
|
||||||
if let Some((ref image_key, _, _)) = fragment_info.current_frame {
|
if let Some((ref image_key, _, _)) = fragment_info.current_frame {
|
||||||
let base = create_base_display_item(state);
|
let base = create_base_display_item(state);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_image_item(
|
state.add_image_item(
|
||||||
base,
|
base,
|
||||||
webrender_api::ImageDisplayItem {
|
webrender_api::ImageDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
image_key: *image_key,
|
image_key: *image_key,
|
||||||
stretch_size: stacking_relative_border_box.size.to_layout(),
|
stretch_size: stacking_relative_border_box.size.to_layout(),
|
||||||
tile_spacing: LayoutSize::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
|
@ -1879,6 +1914,8 @@ impl Fragment {
|
||||||
|
|
||||||
let base = create_base_display_item(state);
|
let base = create_base_display_item(state);
|
||||||
let display_item = webrender_api::ImageDisplayItem {
|
let display_item = webrender_api::ImageDisplayItem {
|
||||||
|
bounds: base.bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
image_key,
|
image_key,
|
||||||
stretch_size: stacking_relative_content_box.size.to_layout(),
|
stretch_size: stacking_relative_content_box.size.to_layout(),
|
||||||
tile_spacing: LayoutSize::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
|
@ -2015,7 +2052,6 @@ impl Fragment {
|
||||||
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
|
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
|
||||||
color: self.style.resolve_color(shadow.color).to_layout(),
|
color: self.style.resolve_color(shadow.color).to_layout(),
|
||||||
blur_radius: shadow.blur.px(),
|
blur_radius: shadow.blur.px(),
|
||||||
should_inflate: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
@ -2075,6 +2111,8 @@ impl Fragment {
|
||||||
state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data(
|
||||||
base.clone(),
|
base.clone(),
|
||||||
webrender_api::TextDisplayItem {
|
webrender_api::TextDisplayItem {
|
||||||
|
bounds: base.bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
font_key: text_fragment.run.font_key,
|
font_key: text_fragment.run.font_key,
|
||||||
color: text_color.to_layout(),
|
color: text_color.to_layout(),
|
||||||
glyph_options: None,
|
glyph_options: None,
|
||||||
|
@ -2130,9 +2168,12 @@ impl Fragment {
|
||||||
|
|
||||||
// TODO(gw): Use a better estimate for wavy line thickness.
|
// TODO(gw): Use a better estimate for wavy line thickness.
|
||||||
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
|
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
|
||||||
|
let area = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
|
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
|
||||||
base,
|
base,
|
||||||
webrender_api::LineDisplayItem {
|
webrender_api::LineDisplayItem {
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
|
area,
|
||||||
orientation: webrender_api::LineOrientation::Horizontal,
|
orientation: webrender_api::LineOrientation::Horizontal,
|
||||||
wavy_line_thickness,
|
wavy_line_thickness,
|
||||||
color: color.to_layout(),
|
color: color.to_layout(),
|
||||||
|
@ -2843,9 +2884,12 @@ impl BaseFlow {
|
||||||
None,
|
None,
|
||||||
DisplayListSection::Content,
|
DisplayListSection::Content,
|
||||||
);
|
);
|
||||||
|
let bounds = base.bounds;
|
||||||
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
|
||||||
base,
|
base,
|
||||||
webrender_api::BorderDisplayItem {
|
webrender_api::BorderDisplayItem {
|
||||||
|
bounds,
|
||||||
|
common: items::empty_common_item_properties(),
|
||||||
widths: SideOffsets2D::new_all_same(Au::from_px(2)).to_layout(),
|
widths: SideOffsets2D::new_all_same(Au::from_px(2)).to_layout(),
|
||||||
details: BorderDetails::Normal(border::simple(
|
details: BorderDetails::Normal(border::simple(
|
||||||
color,
|
color,
|
||||||
|
@ -3011,3 +3055,15 @@ impl IndexableText {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait ToF32Px {
|
||||||
|
type Output;
|
||||||
|
fn to_f32_px(&self) -> Self::Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToF32Px for TypedRect<Au> {
|
||||||
|
type Output = LayoutRect;
|
||||||
|
fn to_f32_px(&self) -> LayoutRect {
|
||||||
|
LayoutRect::from_untyped(&servo_geometry::au_rect_to_f32_rect(*self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,10 +24,11 @@ use std::f32;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::computed_values::_servo_top_layer::T as InTopLayer;
|
use style::computed_values::_servo_top_layer::T as InTopLayer;
|
||||||
use webrender_api as wr;
|
use webrender_api as wr;
|
||||||
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D};
|
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
|
||||||
use webrender_api::{BorderRadius, ClipMode, ComplexClipRegion, ExternalScrollId, FilterOp};
|
use webrender_api::{BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion};
|
||||||
use webrender_api::{GlyphInstance, GradientStop, ImageKey, MixBlendMode, ScrollSensitivity};
|
use webrender_api::{ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey};
|
||||||
use webrender_api::{Shadow, StickyOffsetBounds, TransformStyle};
|
use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow, SpatialId};
|
||||||
|
use webrender_api::{StickyOffsetBounds, TransformStyle};
|
||||||
|
|
||||||
pub use style::dom::OpaqueNode;
|
pub use style::dom::OpaqueNode;
|
||||||
|
|
||||||
|
@ -466,6 +467,16 @@ impl BaseDisplayItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn empty_common_item_properties() -> CommonItemProperties {
|
||||||
|
CommonItemProperties {
|
||||||
|
clip_rect: LayoutRect::max_rect(),
|
||||||
|
clip_id: ClipId::root(wr::PipelineId::dummy()),
|
||||||
|
spatial_id: SpatialId::root_scroll_node(wr::PipelineId::dummy()),
|
||||||
|
hit_info: None,
|
||||||
|
is_backface_visible: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A clipping region for a display item. Currently, this can describe rectangles, rounded
|
/// A clipping region for a display item. Currently, this can describe rectangles, rounded
|
||||||
/// rectangles (for `border-radius`), or arbitrary intersections of the two. Arbitrary transforms
|
/// rectangles (for `border-radius`), or arbitrary intersections of the two. Arbitrary transforms
|
||||||
/// are not supported because those are handled by the higher-level `StackingContext` abstraction.
|
/// are not supported because those are handled by the higher-level `StackingContext` abstraction.
|
||||||
|
|
|
@ -7,15 +7,16 @@
|
||||||
// This might be achieved by sharing types between WR and Servo display lists, or
|
// This might be achieved by sharing types between WR and Servo display lists, or
|
||||||
// completely converting layout to directly generate WebRender display lists, for example.
|
// completely converting layout to directly generate WebRender display lists, for example.
|
||||||
|
|
||||||
use crate::display_list::items::{ClipScrollNode, ClipScrollNodeType};
|
use crate::display_list::items::{BaseDisplayItem, ClipScrollNode, ClipScrollNodeType};
|
||||||
use crate::display_list::items::{DisplayItem, DisplayList, StackingContextType};
|
use crate::display_list::items::{DisplayItem, DisplayList, StackingContextType};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use webrender_api::units::LayoutPoint;
|
use webrender_api::units::LayoutPoint;
|
||||||
use webrender_api::{self, ClipId, DisplayListBuilder, RasterSpace, ReferenceFrameKind};
|
use webrender_api::{self, ClipId, CommonItemProperties, DisplayItem as WrDisplayItem};
|
||||||
use webrender_api::{SpaceAndClipInfo, SpatialId, SpecificDisplayItem};
|
use webrender_api::{DisplayListBuilder, PropertyBinding, PushStackingContextDisplayItem};
|
||||||
|
use webrender_api::{RasterSpace, ReferenceFrameKind, SpaceAndClipInfo, SpatialId, StackingContext};
|
||||||
|
|
||||||
pub trait WebRenderDisplayListConverter {
|
pub trait WebRenderDisplayListConverter {
|
||||||
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
|
fn convert_to_webrender(&mut self, pipeline_id: PipelineId) -> DisplayListBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ClipScrollState {
|
struct ClipScrollState {
|
||||||
|
@ -26,9 +27,8 @@ struct ClipScrollState {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait WebRenderDisplayItemConverter {
|
trait WebRenderDisplayItemConverter {
|
||||||
fn prim_info(&self) -> webrender_api::LayoutPrimitiveInfo;
|
|
||||||
fn convert_to_webrender(
|
fn convert_to_webrender(
|
||||||
&self,
|
&mut self,
|
||||||
clip_scroll_nodes: &[ClipScrollNode],
|
clip_scroll_nodes: &[ClipScrollNode],
|
||||||
state: &mut ClipScrollState,
|
state: &mut ClipScrollState,
|
||||||
builder: &mut DisplayListBuilder,
|
builder: &mut DisplayListBuilder,
|
||||||
|
@ -36,7 +36,7 @@ trait WebRenderDisplayItemConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebRenderDisplayListConverter for DisplayList {
|
impl WebRenderDisplayListConverter for DisplayList {
|
||||||
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
|
fn convert_to_webrender(&mut self, pipeline_id: PipelineId) -> DisplayListBuilder {
|
||||||
let mut clip_ids = vec![None; self.clip_scroll_nodes.len()];
|
let mut clip_ids = vec![None; self.clip_scroll_nodes.len()];
|
||||||
let mut spatial_ids = vec![None; self.clip_scroll_nodes.len()];
|
let mut spatial_ids = vec![None; self.clip_scroll_nodes.len()];
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ impl WebRenderDisplayListConverter for DisplayList {
|
||||||
1024 * 1024, // 1 MB of space
|
1024 * 1024, // 1 MB of space
|
||||||
);
|
);
|
||||||
|
|
||||||
for item in &self.list {
|
for item in &mut self.list {
|
||||||
item.convert_to_webrender(&self.clip_scroll_nodes, &mut state, &mut builder);
|
item.convert_to_webrender(&self.clip_scroll_nodes, &mut state, &mut builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,22 +74,8 @@ impl WebRenderDisplayListConverter for DisplayList {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebRenderDisplayItemConverter for DisplayItem {
|
impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
fn prim_info(&self) -> webrender_api::LayoutPrimitiveInfo {
|
|
||||||
let tag = match self.base().metadata.pointing {
|
|
||||||
Some(cursor) => Some((self.base().metadata.node.0 as u64, cursor)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
webrender_api::LayoutPrimitiveInfo {
|
|
||||||
rect: self.base().bounds,
|
|
||||||
clip_rect: self.base().clip_rect,
|
|
||||||
// TODO(gw): Make use of the WR backface visibility functionality.
|
|
||||||
is_backface_visible: true,
|
|
||||||
tag,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn convert_to_webrender(
|
fn convert_to_webrender(
|
||||||
&self,
|
&mut self,
|
||||||
clip_scroll_nodes: &[ClipScrollNode],
|
clip_scroll_nodes: &[ClipScrollNode],
|
||||||
state: &mut ClipScrollState,
|
state: &mut ClipScrollState,
|
||||||
builder: &mut DisplayListBuilder,
|
builder: &mut DisplayListBuilder,
|
||||||
|
@ -117,92 +103,74 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
state.active_clip_id = cur_clip_id;
|
state.active_clip_id = cur_clip_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let space_clip_info = SpaceAndClipInfo {
|
|
||||||
spatial_id: state.active_spatial_id,
|
|
||||||
clip_id: state.active_clip_id,
|
|
||||||
};
|
|
||||||
match *self {
|
match *self {
|
||||||
DisplayItem::Rectangle(ref item) => {
|
DisplayItem::Rectangle(ref mut item) => {
|
||||||
builder.push_item(
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
&SpecificDisplayItem::Rectangle(item.item),
|
builder.push_item(&WrDisplayItem::Rectangle(item.item));
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::Text(ref item) => {
|
DisplayItem::Text(ref mut item) => {
|
||||||
builder.push_item(
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
&SpecificDisplayItem::Text(item.item),
|
builder.push_item(&WrDisplayItem::Text(item.item));
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
builder.push_iter(item.data.iter());
|
builder.push_iter(item.data.iter());
|
||||||
},
|
},
|
||||||
DisplayItem::Image(ref item) => {
|
DisplayItem::Image(ref mut item) => {
|
||||||
builder.push_item(
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
&SpecificDisplayItem::Image(item.item),
|
builder.push_item(&WrDisplayItem::Image(item.item));
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::Border(ref item) => {
|
DisplayItem::Border(ref mut item) => {
|
||||||
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
if !item.data.is_empty() {
|
if !item.data.is_empty() {
|
||||||
builder.push_stops(item.data.as_ref());
|
builder.push_stops(item.data.as_ref());
|
||||||
}
|
}
|
||||||
builder.push_item(
|
builder.push_item(&WrDisplayItem::Border(item.item));
|
||||||
&SpecificDisplayItem::Border(item.item),
|
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::Gradient(ref item) => {
|
DisplayItem::Gradient(ref mut item) => {
|
||||||
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
builder.push_stops(item.data.as_ref());
|
builder.push_stops(item.data.as_ref());
|
||||||
builder.push_item(
|
builder.push_item(&WrDisplayItem::Gradient(item.item));
|
||||||
&SpecificDisplayItem::Gradient(item.item),
|
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::RadialGradient(ref item) => {
|
DisplayItem::RadialGradient(ref mut item) => {
|
||||||
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
builder.push_stops(item.data.as_ref());
|
builder.push_stops(item.data.as_ref());
|
||||||
builder.push_item(
|
builder.push_item(&WrDisplayItem::RadialGradient(item.item));
|
||||||
&SpecificDisplayItem::RadialGradient(item.item),
|
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::Line(ref item) => {
|
DisplayItem::Line(ref mut item) => {
|
||||||
builder.push_item(
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
&SpecificDisplayItem::Line(item.item),
|
builder.push_item(&WrDisplayItem::Line(item.item));
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::BoxShadow(ref item) => {
|
DisplayItem::BoxShadow(ref mut item) => {
|
||||||
builder.push_item(
|
item.item.common = build_common_item_properties(&item.base, state);
|
||||||
&SpecificDisplayItem::BoxShadow(item.item),
|
builder.push_item(&WrDisplayItem::BoxShadow(item.item));
|
||||||
&self.prim_info(),
|
|
||||||
&space_clip_info,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
DisplayItem::PushTextShadow(ref item) => {
|
DisplayItem::PushTextShadow(ref mut item) => {
|
||||||
builder.push_shadow(&self.prim_info(), &space_clip_info, item.shadow);
|
let common = build_common_item_properties(&item.base, state);
|
||||||
|
builder.push_shadow(&SpaceAndClipInfo {
|
||||||
|
spatial_id: common.spatial_id,
|
||||||
|
clip_id: common.clip_id,
|
||||||
|
},
|
||||||
|
item.shadow,
|
||||||
|
true);
|
||||||
},
|
},
|
||||||
DisplayItem::PopAllTextShadows(_) => {
|
DisplayItem::PopAllTextShadows(_) => {
|
||||||
builder.pop_all_shadows();
|
builder.push_item(&WrDisplayItem::PopAllShadows);
|
||||||
},
|
},
|
||||||
DisplayItem::Iframe(ref item) => {
|
DisplayItem::Iframe(ref mut item) => {
|
||||||
builder.push_iframe(
|
let common = build_common_item_properties(&item.base, state);
|
||||||
&self.prim_info(),
|
builder.push_iframe(item.base.bounds,
|
||||||
&space_clip_info,
|
common.clip_rect,
|
||||||
item.iframe.to_webrender(),
|
&SpaceAndClipInfo {
|
||||||
true,
|
spatial_id: common.spatial_id,
|
||||||
);
|
clip_id: common.clip_id,
|
||||||
|
},
|
||||||
|
item.iframe.to_webrender(),
|
||||||
|
true);
|
||||||
},
|
},
|
||||||
DisplayItem::PushStackingContext(ref item) => {
|
DisplayItem::PushStackingContext(ref mut item) => {
|
||||||
let stacking_context = &item.stacking_context;
|
let stacking_context = &item.stacking_context;
|
||||||
debug_assert_eq!(stacking_context.context_type, StackingContextType::Real);
|
debug_assert_eq!(stacking_context.context_type, StackingContextType::Real);
|
||||||
|
|
||||||
let mut info = webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds);
|
//let mut info = webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds);
|
||||||
|
let mut bounds = stacking_context.bounds;
|
||||||
let spatial_id =
|
let spatial_id =
|
||||||
if let Some(frame_index) = stacking_context.established_reference_frame {
|
if let Some(frame_index) = stacking_context.established_reference_frame {
|
||||||
let (transform, ref_frame) =
|
let (transform, ref_frame) =
|
||||||
|
@ -224,7 +192,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
};
|
};
|
||||||
|
|
||||||
let spatial_id = builder.push_reference_frame(
|
let spatial_id = builder.push_reference_frame(
|
||||||
&stacking_context.bounds,
|
stacking_context.bounds.origin,
|
||||||
state.active_spatial_id,
|
state.active_spatial_id,
|
||||||
stacking_context.transform_style,
|
stacking_context.transform_style,
|
||||||
PropertyBinding::Value(transform),
|
PropertyBinding::Value(transform),
|
||||||
|
@ -234,27 +202,35 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
state.spatial_ids[frame_index.to_index()] = Some(spatial_id);
|
state.spatial_ids[frame_index.to_index()] = Some(spatial_id);
|
||||||
state.clip_ids[frame_index.to_index()] = Some(cur_clip_id);
|
state.clip_ids[frame_index.to_index()] = Some(cur_clip_id);
|
||||||
|
|
||||||
info.rect.origin = LayoutPoint::zero();
|
bounds.origin = LayoutPoint::zero();
|
||||||
info.clip_rect.origin = LayoutPoint::zero();
|
|
||||||
spatial_id
|
spatial_id
|
||||||
} else {
|
} else {
|
||||||
state.active_spatial_id
|
state.active_spatial_id
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.push_stacking_context(
|
if !stacking_context.filters.is_empty() {
|
||||||
&info,
|
builder.push_item(&WrDisplayItem::SetFilterOps);
|
||||||
|
builder.push_iter(&stacking_context.filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
let wr_item = PushStackingContextDisplayItem {
|
||||||
|
origin: bounds.origin,
|
||||||
spatial_id,
|
spatial_id,
|
||||||
None,
|
is_backface_visible: true,
|
||||||
stacking_context.transform_style,
|
stacking_context: StackingContext {
|
||||||
stacking_context.mix_blend_mode,
|
transform_style: stacking_context.transform_style,
|
||||||
&stacking_context.filters,
|
mix_blend_mode: stacking_context.mix_blend_mode,
|
||||||
&[],
|
clip_id: None,
|
||||||
RasterSpace::Screen,
|
raster_space: RasterSpace::Screen,
|
||||||
/* cache_tiles = */ false,
|
// TODO(pcwalton): Enable picture caching?
|
||||||
);
|
cache_tiles: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
builder.push_item(&WrDisplayItem::PushStackingContext(wr_item));
|
||||||
},
|
},
|
||||||
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
|
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
|
||||||
DisplayItem::DefineClipScrollNode(ref item) => {
|
DisplayItem::DefineClipScrollNode(ref mut item) => {
|
||||||
let node = &clip_scroll_nodes[item.node_index.to_index()];
|
let node = &clip_scroll_nodes[item.node_index.to_index()];
|
||||||
let item_rect = node.clip.main;
|
let item_rect = node.clip.main;
|
||||||
|
|
||||||
|
@ -290,7 +266,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
node.clip.complex.clone(),
|
node.clip.complex.clone(),
|
||||||
None,
|
None,
|
||||||
scroll_sensitivity,
|
scroll_sensitivity,
|
||||||
webrender_api::LayoutVector2D::zero(),
|
webrender_api::units::LayoutVector2D::zero(),
|
||||||
);
|
);
|
||||||
|
|
||||||
state.clip_ids[item.node_index.to_index()] = Some(space_clip_info.clip_id);
|
state.clip_ids[item.node_index.to_index()] = Some(space_clip_info.clip_id);
|
||||||
|
@ -319,3 +295,19 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_common_item_properties(base: &BaseDisplayItem, state: &ClipScrollState)
|
||||||
|
-> CommonItemProperties {
|
||||||
|
let tag = match base.metadata.pointing {
|
||||||
|
Some(cursor) => Some((base.metadata.node.0 as u64, cursor)),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
CommonItemProperties {
|
||||||
|
clip_rect: base.clip_rect,
|
||||||
|
spatial_id: state.active_spatial_id,
|
||||||
|
clip_id: state.active_clip_id,
|
||||||
|
// TODO(gw): Make use of the WR backface visibility functionality.
|
||||||
|
is_backface_visible: true,
|
||||||
|
hit_info: tag,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue