aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/gfx/display_list.rs
diff options
context:
space:
mode:
authorIsabelle Carter <thequeerpastry@gmail.com>2014-01-22 09:57:25 -0800
committerIsabelle Carter <thequeerpastry@gmail.com>2014-01-30 17:11:17 -0600
commit0892fada740f0030d544037621da8a20c7a60663 (patch)
tree44bfffda558acff3dc564b868d66ae4129407823 /src/components/gfx/display_list.rs
parent7e3075522dd7584f6f898041536e7706c4775f4d (diff)
downloadservo-0892fada740f0030d544037621da8a20c7a60663.tar.gz
servo-0892fada740f0030d544037621da8a20c7a60663.zip
Multiple display list support
Diffstat (limited to 'src/components/gfx/display_list.rs')
-rw-r--r--src/components/gfx/display_list.rs52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/components/gfx/display_list.rs b/src/components/gfx/display_list.rs
index 5c0df142302..bd61aa8aae8 100644
--- a/src/components/gfx/display_list.rs
+++ b/src/components/gfx/display_list.rs
@@ -27,11 +27,62 @@ use std::cast::transmute_region;
use std::vec::VecIterator;
use style::computed_values::border_style;
+pub struct DisplayListCollection<E> {
+ lists: ~[DisplayList<E>]
+}
+
+impl<E> DisplayListCollection<E> {
+ pub fn new() -> DisplayListCollection<E> {
+ DisplayListCollection {
+ lists: ~[]
+ }
+ }
+
+ pub fn iter<'a>(&'a self) -> DisplayListIterator<'a,E> {
+ ParentDisplayListIterator(self.lists.iter())
+ }
+
+ pub fn add_list(&mut self, list: DisplayList<E>) {
+ self.lists.push(list);
+ }
+
+ pub fn draw_lists_into_context(&self, render_context: &mut RenderContext) {
+ for list in self.lists.iter() {
+ list.draw_into_context(render_context);
+ }
+ debug!("{:?}", self.dump());
+ }
+
+ fn dump(&self) {
+ let mut index = 0;
+ for list in self.lists.iter() {
+ debug!("dumping display list {:d}:", index);
+ list.dump();
+ index = index + 1;
+ }
+ }
+}
+
/// A list of rendering operations to be performed.
pub struct DisplayList<E> {
list: ~[DisplayItem<E>]
}
+pub enum DisplayListIterator<'a,E> {
+ EmptyDisplayListIterator,
+ ParentDisplayListIterator(VecIterator<'a,DisplayList<E>>),
+}
+
+impl<'a,E> Iterator<&'a DisplayList<E>> for DisplayListIterator<'a,E> {
+ #[inline]
+ fn next(&mut self) -> Option<&'a DisplayList<E>> {
+ match *self {
+ EmptyDisplayListIterator => None,
+ ParentDisplayListIterator(ref mut subiterator) => subiterator.next(),
+ }
+ }
+}
+
impl<E> DisplayList<E> {
/// Creates a new display list.
pub fn new() -> DisplayList<E> {
@@ -62,7 +113,6 @@ impl<E> DisplayList<E> {
item.draw_into_context(render_context)
}
debug!("Ending display list.");
- debug!("{:?}", self.dump());
}
/// Returns a preorder iterator over the given display list.