Group ReRenderRequests by PipelineId

This commit is contained in:
Cameron Zwarich 2014-07-10 01:31:48 -07:00
parent 25e8077681
commit a378f3e680
2 changed files with 15 additions and 6 deletions

View file

@ -46,6 +46,7 @@ use servo_util::opts::Opts;
use servo_util::time::{profile, TimeProfilerChan}; use servo_util::time::{profile, TimeProfilerChan};
use servo_util::{memory, time, url}; use servo_util::{memory, time, url};
use std::io::timer::sleep; use std::io::timer::sleep;
use std::collections::hashmap::HashMap;
use std::path::Path; use std::path::Path;
use std::rc::Rc; use std::rc::Rc;
use time::precise_time_s; use time::precise_time_s;
@ -744,15 +745,17 @@ impl IOCompositor {
match self.scene.root { match self.scene.root {
Some(ref mut layer) => { Some(ref mut layer) => {
let rect = Rect(Point2D(0f32, 0f32), page_window.to_untyped()); let rect = Rect(Point2D(0f32, 0f32), page_window.to_untyped());
let mut requests = Vec::new(); let mut request_map = HashMap::new();
let recomposite = let recomposite =
CompositorData::get_buffer_requests_recursively(&mut requests, CompositorData::get_buffer_requests_recursively(&mut request_map,
layer.clone(), layer.clone(),
&self.graphics_context, &self.graphics_context,
rect, rect,
scale.get()); scale.get());
for (chan, request) in requests.move_iter() { for (_pipeline_id, requests) in request_map.move_iter() {
let _ = chan.send_opt(ReRenderMsg(request)); for (chan, request) in requests.move_iter() {
let _ = chan.send_opt(ReRenderMsg(request));
}
} }
self.recomposite = self.recomposite || recomposite; self.recomposite = self.recomposite || recomposite;
} }

View file

@ -20,6 +20,7 @@ use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId};
use servo_msg::compositor_msg::ScrollPolicy; use servo_msg::compositor_msg::ScrollPolicy;
use servo_msg::constellation_msg::PipelineId; use servo_msg::constellation_msg::PipelineId;
use servo_util::geometry::PagePx; use servo_util::geometry::PagePx;
use std::collections::hashmap::HashMap;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_os="macos")] #[cfg(target_os="macos")]
@ -120,7 +121,9 @@ impl CompositorData {
// Given the current window size, determine which tiles need to be (re-)rendered and sends them // Given the current window size, determine which tiles need to be (re-)rendered and sends them
// off the the appropriate renderer. Returns true if and only if the scene should be repainted. // off the the appropriate renderer. Returns true if and only if the scene should be repainted.
pub fn get_buffer_requests_recursively(requests: &mut Vec<(RenderChan, ReRenderRequest)>, pub fn get_buffer_requests_recursively(requests: &mut HashMap<PipelineId,
Vec<(RenderChan,
ReRenderRequest)>>,
layer: Rc<Layer<CompositorData>>, layer: Rc<Layer<CompositorData>>,
graphics_context: &NativeCompositingGraphicsContext, graphics_context: &NativeCompositingGraphicsContext,
window_rect: Rect<f32>, window_rect: Rect<f32>,
@ -138,13 +141,16 @@ impl CompositorData {
// //
// FIXME(#2003, pcwalton): We may want to batch these up in the case in which // FIXME(#2003, pcwalton): We may want to batch these up in the case in which
// one page has multiple layers, to avoid the user seeing inconsistent states. // one page has multiple layers, to avoid the user seeing inconsistent states.
let pipeline_id = layer.extra_data.borrow().pipeline.id;
let chan = layer.extra_data.borrow().pipeline.render_chan.clone();
let msg = ReRenderRequest { let msg = ReRenderRequest {
buffer_requests: request, buffer_requests: request,
scale: scale, scale: scale,
layer_id: layer.extra_data.borrow().id, layer_id: layer.extra_data.borrow().id,
epoch: layer.extra_data.borrow().epoch, epoch: layer.extra_data.borrow().epoch,
}; };
requests.push((layer.extra_data.borrow().pipeline.render_chan.clone(), msg)); let vec = requests.find_or_insert(pipeline_id, Vec::new());
vec.push((chan, msg));
} }
if redisplay { if redisplay {