Remove page_size member from CompositorData

The page size is always the same as the layer boundaries since,
SetLayerClipRect was always called after layer creation.
This commit is contained in:
Martin Robinson 2014-07-08 16:58:01 -07:00
parent 601b8ec970
commit b743448b52
3 changed files with 7 additions and 37 deletions

View file

@ -368,16 +368,13 @@ impl IOCompositor {
};
let new_compositor_data = CompositorData::new_root(root_pipeline,
layer_properties.epoch,
layer_properties.rect.size,
self.opts.cpu_painting,
layer_properties.background_color);
let size = layer_properties.rect.size;
let new_root = Rc::new(Layer::new(layer_properties.rect,
size,
self.opts.tile_size,
new_compositor_data));
CompositorData::add_child(new_root.clone(), layer_properties, size);
CompositorData::add_child(new_root.clone(), layer_properties);
// Release all tiles from the layer before dropping it.
match self.scene.root {
@ -409,8 +406,7 @@ impl IOCompositor {
layer_properties.pipeline_id,
parent_layer_id) {
Some(ref mut parent_layer) => {
let page_size = root_layer.extra_data.borrow().page_size.unwrap();
CompositorData::add_child(parent_layer.clone(), layer_properties, page_size);
CompositorData::add_child(parent_layer.clone(), layer_properties);
}
None => {
fail!("Compositor: couldn't find parent layer");

View file

@ -41,10 +41,6 @@ pub struct CompositorData {
/// top left corner of the page.
pub scroll_offset: TypedPoint2D<PagePx, f32>,
/// The size of the underlying page in page coordinates. This is an option
/// because we may not know the size of the page until layout is finished completely.
pub page_size: Option<Size2D<f32>>,
/// The behavior of this layer when a scroll message is received.
pub wants_scroll_events: WantsScrollEventsFlag,
@ -72,7 +68,6 @@ impl CompositorData {
pub fn new(pipeline: CompositionPipeline,
layer_id: LayerId,
epoch: Epoch,
page_size: Option<Size2D<f32>>,
cpu_painting: bool,
wants_scroll_events: WantsScrollEventsFlag,
scroll_policy: ScrollPolicy,
@ -82,7 +77,6 @@ impl CompositorData {
pipeline: pipeline,
id: layer_id,
scroll_offset: TypedPoint2D(0f32, 0f32),
page_size: page_size,
wants_scroll_events: wants_scroll_events,
scroll_policy: scroll_policy,
cpu_painting: cpu_painting,
@ -93,13 +87,11 @@ impl CompositorData {
pub fn new_root(pipeline: CompositionPipeline,
epoch: Epoch,
page_size: Size2D<f32>,
cpu_painting: bool,
unrendered_color: Color) -> CompositorData {
CompositorData::new(pipeline,
LayerId::null(),
epoch,
Some(page_size),
cpu_painting,
WantsScrollEvents,
FixedPosition,
@ -110,18 +102,15 @@ impl CompositorData {
/// exist yet. The child layer will have the same pipeline, tile size, memory limit, and CPU
/// painting status as its parent.
pub fn add_child(layer: Rc<Layer<CompositorData>>,
layer_properties: LayerProperties,
page_size: Size2D<f32>) {
layer_properties: LayerProperties) {
let new_compositor_data = CompositorData::new(layer.extra_data.borrow().pipeline.clone(),
layer_properties.id,
layer_properties.epoch,
Some(page_size),
layer.extra_data.borrow().cpu_painting,
DoesntWantScrollEvents,
layer_properties.scroll_policy,
layer_properties.background_color);
let new_kid = Rc::new(Layer::new(layer_properties.rect,
page_size,
Layer::tile_size(layer.clone()),
new_compositor_data));
@ -210,23 +199,15 @@ impl CompositorData {
new_rect))
}
}
}
pub fn update_layer(layer: Rc<Layer<CompositorData>>, layer_properties: LayerProperties) {
layer.extra_data.borrow_mut().epoch = layer_properties.epoch;
layer.extra_data.borrow_mut().unrendered_color = layer_properties.background_color;
CompositorData::resize(layer.clone(), layer_properties.rect.size);
}
// Resize and unhide a pre-existing layer. A new layer's size is set during creation.
fn resize(layer: Rc<Layer<CompositorData>>,
new_size: Size2D<f32>) {
debug!("compositor_data: starting resize_helper()");
layer.extra_data.borrow_mut().page_size = Some(new_size);
let unused_buffers = Layer::resize(layer.clone(), new_size);
let unused_buffers = Layer::resize(layer.clone(), layer_properties.rect.size);
if !unused_buffers.is_empty() {
let msg = UnusedBufferMsg(unused_buffers);
let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg);

View file

@ -71,11 +71,7 @@ pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
layer.extra_data.borrow_mut().scroll_offset = old_origin + delta;
// bounds checking
let page_size = match layer.extra_data.borrow().page_size {
Some(size) => size,
None => fail!("CompositorData: tried to scroll with no page size set"),
};
let page_size = layer.bounds.borrow().size;
let window_size = window_size.to_untyped();
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();
@ -172,10 +168,7 @@ pub fn move(layer: Rc<Layer<CompositorData>>,
layer.extra_data.borrow_mut().scroll_offset = Point2D::from_untyped(&(origin * -1.0));
// bounds checking
let page_size = match layer.extra_data.borrow().page_size {
Some(size) => size,
None => fail!("CompositorData: tried to scroll with no page size set"),
};
let page_size = layer.bounds.borrow().size;
let window_size = window_size.to_untyped();
let scroll_offset = layer.extra_data.borrow().scroll_offset.to_untyped();