Layerize canvas

Note that this keeps using readback right now, `NativeSurface` painting
will be implemented soon.

Also see https://github.com/servo/servo/issues/6142
This commit is contained in:
ecoal95 2015-05-20 10:29:08 +02:00
parent 6481058309
commit 3350522306
35 changed files with 769 additions and 500 deletions

View file

@ -24,6 +24,7 @@ use sequential;
use wrapper::{LayoutNode, TLayoutNode};
use azure::azure::AzColor;
use canvas_traits::CanvasMsg;
use encoding::EncodingRef;
use encoding::all::UTF_8;
use geom::matrix2d::Matrix2D;
@ -31,7 +32,7 @@ use geom::point::Point2D;
use geom::rect::Rect;
use geom::scale_factor::ScaleFactor;
use geom::size::Size2D;
use gfx::color;
use gfx_traits::color;
use gfx::display_list::{ClippingRegion, DisplayItemMetadata, DisplayList, OpaqueNode};
use gfx::display_list::{StackingContext};
use gfx::font_cache_task::FontCacheTask;
@ -39,7 +40,7 @@ use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::{PaintChan, PaintLayer};
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
use log;
use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy};
use msg::compositor_msg::{Epoch, ScrollPolicy, LayerId};
use msg::constellation_msg::Msg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId};
use profile_traits::mem::{self, Report, ReportsChan};
@ -134,7 +135,7 @@ pub struct LayoutTaskData {
/// sent.
pub new_animations_sender: Sender<Animation>,
/// A counter for epoch messages.
/// A counter for epoch messages
epoch: Epoch,
/// The position and size of the visible rect for each layer. We do not build display lists
@ -195,6 +196,11 @@ pub struct LayoutTask {
/// Is this the first reflow in this LayoutTask?
pub first_reflow: Cell<bool>,
/// To receive a canvas renderer associated to a layer, this message is propagated
/// to the paint chan
pub canvas_layers_receiver: Receiver<(LayerId, Option<Arc<Mutex<Sender<CanvasMsg>>>>)>,
pub canvas_layers_sender: Sender<(LayerId, Option<Arc<Mutex<Sender<CanvasMsg>>>>)>,
/// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them.
///
@ -310,6 +316,7 @@ impl LayoutTask {
// Create the channel on which new animations can be sent.
let (new_animations_sender, new_animations_receiver) = channel();
let (image_cache_sender, image_cache_receiver) = channel();
let (canvas_layers_sender, canvas_layers_receiver) = channel();
LayoutTask {
id: id,
@ -329,6 +336,8 @@ impl LayoutTask {
first_reflow: Cell::new(true),
image_cache_receiver: image_cache_receiver,
image_cache_sender: ImageCacheChan(image_cache_sender),
canvas_layers_receiver: canvas_layers_receiver,
canvas_layers_sender: canvas_layers_sender,
rw_data: Arc::new(Mutex::new(
LayoutTaskData {
root_flow: None,
@ -375,6 +384,7 @@ impl LayoutTask {
constellation_chan: rw_data.constellation_chan.clone(),
layout_chan: self.chan.clone(),
font_cache_task: self.font_cache_task.clone(),
canvas_layers_sender: self.canvas_layers_sender.clone(),
stylist: &*rw_data.stylist,
url: (*url).clone(),
reflow_root: reflow_root.map(|node| OpaqueNodeMethods::from_layout_node(node)),
@ -960,6 +970,14 @@ impl LayoutTask {
animation::process_new_animations(&mut *rw_data, self.id);
}
// Send new canvas renderers to the paint task
while let Ok((layer_id, renderer)) = self.canvas_layers_receiver.try_recv() {
// Just send if there's an actual renderer
if let Some(renderer) = renderer {
self.paint_chan.send(PaintMsg::CanvasLayer(layer_id, renderer));
}
}
// Perform post-style recalculation layout passes.
self.perform_post_style_recalc_layout_passes(&data.reflow_info,
&mut rw_data,