Fixes a number of race conditions and reliability issues with reftests and compositor.

The basic idea is it's safe to output an image for reftest by testing:
 - That the compositor doesn't have any animations active.
 - That the compositor is not waiting on any outstanding paint messages to arrive.
 - That the script tasks are "idle" and therefore won't cause reflow.
    - This currently means page loaded, onload fired, reftest-wait not active, first reflow triggered.
    - It could easily be expanded to handle pending timers etc.
 - That the "epoch" that the layout tasks have last laid out after script went idle, is reflected by the compositor in all visible layers for that pipeline.
This commit is contained in:
Glenn Watson 2015-05-13 09:58:01 +10:00
parent b3b9deafa7
commit eec3fad93d
17 changed files with 363 additions and 390 deletions

View file

@ -13,27 +13,8 @@ use std::fmt;
use constellation_msg::PipelineId;
/// The status of the painter.
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum PaintState {
Idle,
Painting,
}
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Copy)]
pub enum ReadyState {
/// Informs the compositor that nothing has been done yet. Used for setting status
Blank,
/// Informs the compositor that a page is loading. Used for setting status
Loading,
/// Informs the compositor that a page is performing layout. Used for setting status
PerformingLayout,
/// Informs the compositor that a page is finished loading. Used for setting status
FinishedLoading,
}
/// A newtype struct for denoting the age of messages; prevents race conditions.
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord)]
pub struct Epoch(pub u32);
impl Epoch {
@ -82,11 +63,11 @@ pub enum ScrollPolicy {
/// All layer-specific information that the painting task sends to the compositor other than the
/// buffer contents of the layer itself.
#[derive(Copy, Clone)]
pub struct LayerMetadata {
pub struct LayerProperties {
/// An opaque ID. This is usually the address of the flow and index of the box within it.
pub id: LayerId,
/// The position and size of the layer in pixels.
pub position: Rect<i32>,
pub rect: Rect<f32>,
/// The background color of the layer.
pub background_color: Color,
/// The scrolling policy of this layer.
@ -102,7 +83,7 @@ pub trait PaintListener {
/// creating and/or destroying paint layers as necessary.
fn initialize_layers_for_pipeline(&mut self,
pipeline_id: PipelineId,
metadata: Vec<LayerMetadata>,
properties: Vec<LayerProperties>,
epoch: Epoch);
/// Sends new buffers for the given layers to the compositor.
@ -112,14 +93,11 @@ pub trait PaintListener {
replies: Vec<(LayerId, Box<LayerBufferSet>)>,
frame_tree_id: FrameTreeId);
fn paint_msg_discarded(&mut self);
fn set_paint_state(&mut self, PipelineId, PaintState);
}
/// The interface used by the script task to tell the compositor to update its ready state,
/// which is used in displaying the appropriate message in the window's title.
pub trait ScriptListener {
fn set_ready_state(&mut self, PipelineId, ReadyState);
fn scroll_fragment_point(&mut self,
pipeline_id: PipelineId,
layer_id: LayerId,