mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Store Compositor ReadyState per-pipeline
Instead of storing a single ReadyState, store one per pipeline and track the earliest one.
This commit is contained in:
parent
a2ab6f9799
commit
c182308350
5 changed files with 31 additions and 15 deletions
|
@ -21,6 +21,7 @@ use windowing::PinchZoomWindowEvent;
|
|||
|
||||
use azure::azure_hl::SourceSurfaceMethods;
|
||||
use azure::azure_hl;
|
||||
use std::cmp;
|
||||
use geom::matrix::identity;
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
use geom::rect::Rect;
|
||||
|
@ -100,8 +101,8 @@ pub struct IOCompositor {
|
|||
/// The time of the last zoom action has started.
|
||||
zoom_time: f64,
|
||||
|
||||
/// Current display/reflow status of the page
|
||||
ready_state: ReadyState,
|
||||
/// Current display/reflow status of each pipeline.
|
||||
ready_states: HashMap<PipelineId, ReadyState>,
|
||||
|
||||
/// Whether the page being rendered has loaded completely.
|
||||
/// Differs from ReadyState because we can finish loading (ready)
|
||||
|
@ -165,7 +166,7 @@ impl IOCompositor {
|
|||
viewport_zoom: ScaleFactor(1.0),
|
||||
zoom_action: false,
|
||||
zoom_time: 0f64,
|
||||
ready_state: Blank,
|
||||
ready_states: HashMap::new(),
|
||||
load_complete: false,
|
||||
constellation_chan: constellation_chan,
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
|
@ -275,9 +276,8 @@ impl IOCompositor {
|
|||
break;
|
||||
}
|
||||
|
||||
(Ok(ChangeReadyState(ready_state)), NotShuttingDown) => {
|
||||
self.window.set_ready_state(ready_state);
|
||||
self.ready_state = ready_state;
|
||||
(Ok(ChangeReadyState(pipeline_id, ready_state)), NotShuttingDown) => {
|
||||
self.change_ready_state(pipeline_id, ready_state);
|
||||
}
|
||||
|
||||
(Ok(ChangeRenderState(render_state)), NotShuttingDown) => {
|
||||
|
@ -333,6 +333,21 @@ impl IOCompositor {
|
|||
}
|
||||
}
|
||||
|
||||
fn change_ready_state(&mut self, pipeline_id: PipelineId, ready_state: ReadyState) {
|
||||
self.ready_states.insert_or_update_with(pipeline_id,
|
||||
ready_state,
|
||||
|_key, value| *value = ready_state);
|
||||
self.window.set_ready_state(self.get_earliest_pipeline_ready_state());
|
||||
}
|
||||
|
||||
fn get_earliest_pipeline_ready_state(&self) -> ReadyState {
|
||||
if self.ready_states.len() == 0 {
|
||||
return Blank;
|
||||
}
|
||||
return self.ready_states.values().fold(FinishedLoading, |a, &b| cmp::min(a, b));
|
||||
|
||||
}
|
||||
|
||||
fn change_render_state(&mut self, render_state: RenderState) {
|
||||
self.window.set_render_state(render_state);
|
||||
if render_state == IdleRenderState {
|
||||
|
@ -873,7 +888,7 @@ impl IOCompositor {
|
|||
|
||||
// Render to PNG. We must read from the back buffer (ie, before
|
||||
// self.window.present()) as OpenGL ES 2 does not have glReadBuffer().
|
||||
if self.load_complete && self.ready_state == FinishedLoading
|
||||
if self.load_complete && self.get_earliest_pipeline_ready_state() == FinishedLoading
|
||||
&& self.opts.output_file.is_some() && !self.has_outstanding_render_msgs() {
|
||||
let (width, height) = (self.window_size.width.get(), self.window_size.height.get());
|
||||
let path = from_str::<Path>(self.opts.output_file.get_ref().as_slice()).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue