mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
gfx: Rewrite display list construction to make stacking-contexts more
first-class. This implements the scheme described here: https://groups.google.com/forum/#!topic/mozilla.dev.servo/sZVPSfPVfkg This commit changes Servo to generate one display list per stacking context instead of one display list per layer. This is purely a refactoring; there are no functional changes. Performance is essentially the same as before. However, there should be numerous future benefits that this is intended to allow for: * It makes the code simpler to understand because the "new layer needed" vs. "no new layer needed" code paths are more consolidated. * It makes it easy to support CSS properties that did not fit into our previous flat display list model (without unconditionally layerizing them): o `opacity` should be easy to support because the stacking context provides the higher-level grouping of display items to which opacity is to be applied. o `transform` can be easily supported because the stacking context provides a place to stash the transformation matrix. This has the side benefit of nicely separating the transformation matrix from the clipping regions. * The `flatten` logic is now O(1) instead of O(n) and now only needs to be invoked for pseudo-stacking contexts (right now: just floats), instead of for every stacking context. * Layers are now a proper tree instead of a flat list as far as layout is concerned, bringing us closer to a production-quality compositing/layers framework. * This commit opens the door to incremental display list construction at the level of stacking contexts. Future performance improvements could come from optimizing allocation of display list items, and, of course, incremental display list construction.
This commit is contained in:
parent
0ab70dd539
commit
a4a9a46a87
13 changed files with 812 additions and 550 deletions
|
@ -96,3 +96,30 @@ pub fn append_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
|||
other.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepends the items in the other list to this one, leaving the other list empty.
|
||||
#[inline]
|
||||
pub fn prepend_from<T>(this: &mut DList<T>, other: &mut DList<T>) {
|
||||
unsafe {
|
||||
let this = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(this);
|
||||
let other = mem::transmute::<&mut DList<T>,&mut RawDList<T>>(other);
|
||||
if this.length == 0 {
|
||||
this.head = mem::replace(&mut other.head, ptr::null_mut());
|
||||
this.tail = mem::replace(&mut other.tail, ptr::null_mut());
|
||||
this.length = mem::replace(&mut other.length, 0);
|
||||
return
|
||||
}
|
||||
|
||||
let old_other_tail = mem::replace(&mut other.tail, ptr::null_mut());
|
||||
if old_other_tail.is_null() {
|
||||
return
|
||||
}
|
||||
(*old_other_tail).next = this.head;
|
||||
(*this.head).prev = old_other_tail;
|
||||
|
||||
this.head = mem::replace(&mut other.head, ptr::null_mut());
|
||||
this.length += other.length;
|
||||
other.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,11 @@ impl Default for Au {
|
|||
}
|
||||
}
|
||||
|
||||
pub static ZERO_POINT: Point2D<Au> = Point2D {
|
||||
x: Au(0),
|
||||
y: Au(0),
|
||||
};
|
||||
|
||||
pub static ZERO_RECT: Rect<Au> = Rect {
|
||||
origin: Point2D {
|
||||
x: Au(0),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue