mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Multiple display list support
This commit is contained in:
parent
7e3075522d
commit
0892fada74
7 changed files with 172 additions and 103 deletions
|
@ -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.
|
||||
|
|
|
@ -24,13 +24,14 @@ use std::comm::{Chan, Port, SharedChan};
|
|||
use extra::arc::Arc;
|
||||
|
||||
use buffer_map::BufferMap;
|
||||
use display_list::DisplayList;
|
||||
use font_context::{FontContext, FontContextInfo};
|
||||
use display_list::DisplayListCollection;
|
||||
use font_context::{FontContext, FontContextInfo};
|
||||
use opts::Opts;
|
||||
use render_context::RenderContext;
|
||||
|
||||
pub struct RenderLayer<T> {
|
||||
display_list: Arc<DisplayList<T>>,
|
||||
display_list_collection: Arc<DisplayListCollection<T>>,
|
||||
size: Size2D<uint>,
|
||||
color: Color
|
||||
}
|
||||
|
@ -305,7 +306,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
|||
|
||||
// Draw the display list.
|
||||
profile(time::RenderingDrawingCategory, self.profiler_chan.clone(), || {
|
||||
render_layer.display_list.get().draw_into_context(&mut ctx);
|
||||
render_layer.display_list_collection.get().draw_lists_into_context(&mut ctx);
|
||||
ctx.draw_target.flush();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue