mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
gfx: Box stacking contexts to minimize memmove
traffic.
`memmove` was showing up high in the profile when concatenating and shorting display lists. This change drastically reduces the `memmove` cost in exchange for some minor additional allocation cost.
This commit is contained in:
parent
3ff5082798
commit
4233e0f163
15 changed files with 35 additions and 36 deletions
|
@ -508,7 +508,7 @@ pub struct StackingContext {
|
|||
pub layer_info: Option<LayerInfo>,
|
||||
|
||||
/// Children of this StackingContext.
|
||||
pub children: Vec<StackingContext>,
|
||||
pub children: Vec<Box<StackingContext>>,
|
||||
}
|
||||
|
||||
impl StackingContext {
|
||||
|
|
|
@ -2109,7 +2109,7 @@ impl Flow for BlockFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.collect_stacking_contexts_for_block(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -67,8 +67,7 @@ pub struct DisplayListBuildState<'a> {
|
|||
}
|
||||
|
||||
impl<'a> DisplayListBuildState<'a> {
|
||||
pub fn new(layout_context: &'a LayoutContext,
|
||||
stacking_context_id: StackingContextId)
|
||||
pub fn new(layout_context: &'a LayoutContext, stacking_context_id: StackingContextId)
|
||||
-> DisplayListBuildState<'a> {
|
||||
DisplayListBuildState {
|
||||
layout_context: layout_context,
|
||||
|
@ -287,7 +286,7 @@ pub trait FragmentDisplayListBuilding {
|
|||
base_flow: &BaseFlow,
|
||||
scroll_policy: ScrollPolicy,
|
||||
mode: StackingContextCreationMode)
|
||||
-> StackingContext;
|
||||
-> Box<StackingContext>;
|
||||
}
|
||||
|
||||
fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> BorderRadii<Au> {
|
||||
|
@ -1277,7 +1276,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
base_flow: &BaseFlow,
|
||||
scroll_policy: ScrollPolicy,
|
||||
mode: StackingContextCreationMode)
|
||||
-> StackingContext {
|
||||
-> Box<StackingContext> {
|
||||
let border_box = match mode {
|
||||
StackingContextCreationMode::InnerScrollWrapper => {
|
||||
Rect::new(Point2D::zero(), base_flow.overflow.scroll.size)
|
||||
|
@ -1411,18 +1410,18 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
_ => StackingContextType::Real,
|
||||
};
|
||||
|
||||
StackingContext::new(id,
|
||||
context_type,
|
||||
&border_box,
|
||||
&overflow,
|
||||
self.effective_z_index(),
|
||||
filters,
|
||||
self.style().get_effects().mix_blend_mode,
|
||||
transform,
|
||||
perspective,
|
||||
establishes_3d_context,
|
||||
scrolls_overflow_area,
|
||||
layer_info)
|
||||
Box::new(StackingContext::new(id,
|
||||
context_type,
|
||||
&border_box,
|
||||
&overflow,
|
||||
self.effective_z_index(),
|
||||
filters,
|
||||
self.style().get_effects().mix_blend_mode,
|
||||
transform,
|
||||
perspective,
|
||||
establishes_3d_context,
|
||||
scrolls_overflow_area,
|
||||
layer_info))
|
||||
}
|
||||
|
||||
fn clipping_region_for_children(&self,
|
||||
|
@ -1600,7 +1599,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
pub trait BlockFlowDisplayListBuilding {
|
||||
fn collect_stacking_contexts_for_block(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId;
|
||||
fn build_display_list_for_block(&mut self,
|
||||
state: &mut DisplayListBuildState,
|
||||
|
@ -1610,7 +1609,7 @@ pub trait BlockFlowDisplayListBuilding {
|
|||
impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||
fn collect_stacking_contexts_for_block(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
if !self.fragment.establishes_stacking_context() &&
|
||||
!self.establishes_pseudo_stacking_context() {
|
||||
|
@ -1742,7 +1741,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
pub trait InlineFlowDisplayListBuilding {
|
||||
fn collect_stacking_contexts_for_inline(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId;
|
||||
fn build_display_list_for_inline_fragment_at_index(&mut self,
|
||||
state: &mut DisplayListBuildState,
|
||||
|
@ -1753,7 +1752,7 @@ pub trait InlineFlowDisplayListBuilding {
|
|||
impl InlineFlowDisplayListBuilding for InlineFlow {
|
||||
fn collect_stacking_contexts_for_inline(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.base.stacking_context_id = parent_id;
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ impl Flow for FlexFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
_parent_id: StackingContextId,
|
||||
_: &mut Vec<StackingContext>)
|
||||
_: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId;
|
||||
|
||||
/// If this is a float, places it. The default implementation does nothing.
|
||||
|
@ -1203,7 +1203,7 @@ impl BaseFlow {
|
|||
|
||||
pub fn collect_stacking_contexts_for_children(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>) {
|
||||
contexts: &mut Vec<Box<StackingContext>>) {
|
||||
for kid in self.children.iter_mut() {
|
||||
kid.collect_stacking_contexts(parent_id, contexts);
|
||||
}
|
||||
|
|
|
@ -1750,7 +1750,7 @@ impl Flow for InlineFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.collect_stacking_contexts_for_inline(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ impl Flow for ListItemFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ impl Flow for MulticolFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ impl Flow for MulticolColumnFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ impl Flow for TableFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ impl Flow for TableCaptionFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ impl Flow for TableCellFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ impl Flow for TableColGroupFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
_: &mut Vec<StackingContext>)
|
||||
_: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
parent_id
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ impl Flow for TableRowFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ impl Flow for TableRowGroupFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ impl Flow for TableWrapperFlow {
|
|||
|
||||
fn collect_stacking_contexts(&mut self,
|
||||
parent_id: StackingContextId,
|
||||
contexts: &mut Vec<StackingContext>)
|
||||
contexts: &mut Vec<Box<StackingContext>>)
|
||||
-> StackingContextId {
|
||||
self.block_flow.collect_stacking_contexts(parent_id, contexts)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue