Skip to content

Commit

Permalink
Auto merge of #1806 - glennw:remove-nesting, r=mrobinson
Browse files Browse the repository at this point in the history
Remove the (now unused) nested display list APIs.

<!-- 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/1806)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Oct 5, 2017
2 parents cb06be0 + b4fbc86 commit a077be4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 351 deletions.
158 changes: 0 additions & 158 deletions webrender/examples/nested_display_list.rs

This file was deleted.

126 changes: 3 additions & 123 deletions webrender/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,80 +31,12 @@ static DEFAULT_SCROLLBAR_COLOR: ColorF = ColorF {
a: 0.6,
};

/// Nested display lists cause two types of replacements to ClipIds inside the nesting:
/// 1. References to the root scroll frame are replaced by the ClipIds that
/// contained the nested display list.
/// 2. Other ClipIds (that aren't custom or reference frames) are assumed to be
/// local to the nested display list and are converted to an id that is unique
/// outside of the nested display list as well.
///
/// This structure keeps track of what ids are the "root" for one particular level of
/// nesting as well as keeping and index, which can make ClipIds used internally unique
/// in the full ClipScrollTree.
#[derive(Debug)]
struct NestedDisplayListInfo {
/// The index of this nested display list, which is used to generate
/// new ClipIds for clips that are defined inside it.
nest_index: u64,

/// The ClipId of the scroll frame node which contains this nested
/// display list. This is used to replace references to the root with
/// the proper ClipId.
scroll_node_id: ClipId,

/// The ClipId of the clip node which contains this nested display list.
/// This is used to replace references to the root with the proper ClipId.
clip_node_id: ClipId,
}

impl NestedDisplayListInfo {
fn convert_id_to_nested(&self, id: &ClipId) -> ClipId {
match *id {
ClipId::Clip(id, _, pipeline_id) => ClipId::Clip(id, self.nest_index, pipeline_id),
_ => *id,
}
}

fn convert_scroll_id_to_nested(&self, id: &ClipId) -> ClipId {
if id.pipeline_id() != self.scroll_node_id.pipeline_id() {
return *id;
}

if id.is_root_scroll_node() {
self.scroll_node_id
} else {
self.convert_id_to_nested(id)
}
}

fn convert_clip_id_to_nested(&self, id: &ClipId) -> ClipId {
if id.pipeline_id() != self.clip_node_id.pipeline_id() {
return *id;
}

if id.is_root_scroll_node() {
self.clip_node_id
} else {
self.convert_id_to_nested(id)
}
}

fn convert_new_id_to_nested(&self, id: &ClipId) -> ClipId {
if id.pipeline_id() != self.clip_node_id.pipeline_id() {
return *id;
}
self.convert_id_to_nested(id)
}
}

struct FlattenContext<'a> {
scene: &'a Scene,
builder: &'a mut FrameBuilder,
resource_cache: &'a ResourceCache,
tiled_image_map: TiledImageMap,
replacements: Vec<(ClipId, ClipId)>,
nested_display_list_info: Vec<NestedDisplayListInfo>,
current_nested_display_list_index: u64,
}

impl<'a> FlattenContext<'a> {
Expand All @@ -119,49 +51,9 @@ impl<'a> FlattenContext<'a> {
resource_cache,
tiled_image_map: resource_cache.get_tiled_image_map(),
replacements: Vec::new(),
nested_display_list_info: Vec::new(),
current_nested_display_list_index: 0,
}
}

fn push_nested_display_list_ids(&mut self, info: ClipAndScrollInfo) {
self.current_nested_display_list_index += 1;
self.nested_display_list_info.push(NestedDisplayListInfo {
nest_index: self.current_nested_display_list_index,
scroll_node_id: info.scroll_node_id,
clip_node_id: info.clip_node_id(),
});
}

fn pop_nested_display_list_ids(&mut self) {
self.nested_display_list_info.pop();
}

fn convert_new_id_to_nested(&self, id: &ClipId) -> ClipId {
if let Some(nested_info) = self.nested_display_list_info.last() {
nested_info.convert_new_id_to_nested(id)
} else {
*id
}
}

fn convert_clip_scroll_info_to_nested(&self, info: &mut ClipAndScrollInfo) {
if let Some(nested_info) = self.nested_display_list_info.last() {
info.scroll_node_id = nested_info.convert_scroll_id_to_nested(&info.scroll_node_id);
info.clip_node_id = info.clip_node_id
.map(|ref id| nested_info.convert_clip_id_to_nested(id));
}

// We only want to produce nested ClipIds if we are in a nested display
// list situation.
debug_assert!(
!info.scroll_node_id.is_nested() || !self.nested_display_list_info.is_empty()
);
debug_assert!(
!info.clip_node_id().is_nested() || !self.nested_display_list_info.is_empty()
);
}

/// Since WebRender still handles fixed position and reference frame content internally
/// we need to apply this table of id replacements only to the id that affects the
/// position of a node. We can eventually remove this when clients start handling
Expand Down Expand Up @@ -337,9 +229,8 @@ impl Frame {
new_clip_id: &ClipId,
clip_region: ClipRegion,
) {
let new_clip_id = context.convert_new_id_to_nested(new_clip_id);
context.builder.add_clip_node(
new_clip_id,
*new_clip_id,
*parent_id,
pipeline_id,
clip_region,
Expand Down Expand Up @@ -367,9 +258,8 @@ impl Frame {
&mut self.clip_scroll_tree,
);

let new_scroll_frame_id = context.convert_new_id_to_nested(new_scroll_frame_id);
context.builder.add_scroll_frame(
new_scroll_frame_id,
*new_scroll_frame_id,
clip_id,
pipeline_id,
&frame_rect,
Expand Down Expand Up @@ -555,7 +445,6 @@ impl Frame {
reference_frame_relative_offset: LayerVector2D,
) -> Option<BuiltDisplayListIter<'a>> {
let mut clip_and_scroll = item.clip_and_scroll();
context.convert_clip_scroll_info_to_nested(&mut clip_and_scroll);

let unreplaced_scroll_id = clip_and_scroll.scroll_node_id;
clip_and_scroll.scroll_node_id =
Expand Down Expand Up @@ -777,22 +666,13 @@ impl Frame {
}
SpecificDisplayItem::StickyFrame(ref info) => {
let frame_rect = item.rect().translate(&reference_frame_relative_offset);
let new_clip_id = context.convert_new_id_to_nested(&info.id);
self.clip_scroll_tree.add_sticky_frame(
new_clip_id,
info.id,
clip_and_scroll.scroll_node_id, /* parent id */
frame_rect,
info.sticky_frame_info,
);
}
SpecificDisplayItem::PushNestedDisplayList => {
// Using the clip and scroll already processed for nesting here
// means that in the case of multiple nested display lists, we
// will enter the outermost ids into the table and avoid having
// to do a replacement for every level of nesting.
context.push_nested_display_list_ids(clip_and_scroll);
}
SpecificDisplayItem::PopNestedDisplayList => context.pop_nested_display_list_ids(),

// Do nothing; these are dummy items for the display list parser
SpecificDisplayItem::SetGradientStops => {}
Expand Down
2 changes: 0 additions & 2 deletions webrender/src/render_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,6 @@ impl ToDebugString for SpecificDisplayItem {
SpecificDisplayItem::Clip(..) => String::from("clip"),
SpecificDisplayItem::ScrollFrame(..) => String::from("scroll_frame"),
SpecificDisplayItem::StickyFrame(..) => String::from("sticky_frame"),
SpecificDisplayItem::PushNestedDisplayList => String::from("push_nested_display_list"),
SpecificDisplayItem::PopNestedDisplayList => String::from("pop_nested_display_list"),
SpecificDisplayItem::SetGradientStops => String::from("set_gradient_stops"),
SpecificDisplayItem::PopStackingContext => String::from("pop_stacking_context"),
SpecificDisplayItem::PushShadow(..) => String::from("push_shadow"),
Expand Down
Loading

0 comments on commit a077be4

Please sign in to comment.