Remove SetLayerClipRect and add SetLayerOrigin

The constallation has accurate information about iframe layer origins,
but not their size.
This commit is contained in:
Bryan Bell 2014-08-29 17:30:07 -07:00 committed by Martin Robinson
parent e17cc2d5e2
commit ff71c32218
4 changed files with 21 additions and 23 deletions

View file

@ -5,7 +5,7 @@
use compositor_data::{CompositorData, DoesntWantScrollEvents, WantsScrollEvents}; use compositor_data::{CompositorData, DoesntWantScrollEvents, WantsScrollEvents};
use compositor_task::{Msg, CompositorTask, Exit, ChangeReadyState, SetIds, LayerProperties}; use compositor_task::{Msg, CompositorTask, Exit, ChangeReadyState, SetIds, LayerProperties};
use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer}; use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer};
use compositor_task::{SetLayerClipRect, Paint, ScrollFragmentPoint, LoadComplete}; use compositor_task::{SetLayerOrigin, Paint, ScrollFragmentPoint, LoadComplete};
use compositor_task::{ShutdownComplete, ChangeRenderState, RenderMsgDiscarded}; use compositor_task::{ShutdownComplete, ChangeRenderState, RenderMsgDiscarded};
use constellation::SendableFrameTree; use constellation::SendableFrameTree;
use events; use events;
@ -312,8 +312,8 @@ impl IOCompositor {
self.create_or_update_descendant_layer(layer_properties); self.create_or_update_descendant_layer(layer_properties);
} }
(Ok(SetLayerClipRect(pipeline_id, layer_id, new_rect)), NotShuttingDown) => { (Ok(SetLayerOrigin(pipeline_id, layer_id, origin)), NotShuttingDown) => {
self.set_layer_clip_rect(pipeline_id, layer_id, new_rect); self.set_layer_origin(pipeline_id, layer_id, origin);
} }
(Ok(Paint(pipeline_id, epoch, replies)), NotShuttingDown) => { (Ok(Paint(pipeline_id, epoch, replies)), NotShuttingDown) => {
@ -558,17 +558,17 @@ impl IOCompositor {
self.recomposite_if(needs_recomposite); self.recomposite_if(needs_recomposite);
} }
fn set_layer_clip_rect(&mut self, fn set_layer_origin(&mut self,
pipeline_id: PipelineId, pipeline_id: PipelineId,
layer_id: LayerId, layer_id: LayerId,
new_rect_in_page_coordinates: Rect<f32>) { new_origin: Point2D<f32>) {
let new_rect_in_layer_coordinates = let new_origin_in_device_coordinates = new_origin * self.device_pixels_per_page_px().get();
self.convert_page_rect_to_layer_coordinates(new_rect_in_page_coordinates);
let new_rect_in_layer_coordinates = Rect::from_untyped(&new_rect_in_layer_coordinates);
match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) { match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) {
Some(ref layer) => *layer.bounds.borrow_mut() = new_rect_in_layer_coordinates, Some(ref layer) => {
None => fail!("compositor received SetLayerClipRect for nonexistent layer"), layer.bounds.borrow_mut().origin =
Point2D::from_untyped(&new_origin_in_device_coordinates)
}
None => fail!("Compositor received SetLayerOrigin for nonexistent layer"),
}; };
self.send_buffer_requests_for_all_layers(); self.send_buffer_requests_for_all_layers();

View file

@ -117,8 +117,6 @@ impl RenderListener for CompositorChan {
} else { } else {
self.chan.send(CreateOrUpdateDescendantLayer(layer_properties)); self.chan.send(CreateOrUpdateDescendantLayer(layer_properties));
} }
self.chan.send(SetLayerClipRect(pipeline_id, metadata.id, layer_properties.rect));
} }
} }
@ -167,8 +165,8 @@ pub enum Msg {
/// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no /// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no
/// layer with that ID exists). /// layer with that ID exists).
CreateOrUpdateDescendantLayer(LayerProperties), CreateOrUpdateDescendantLayer(LayerProperties),
/// Alerts the compositor that the specified layer's clipping rect has changed. /// Alerts the compositor that the specified layer's origin has changed.
SetLayerClipRect(PipelineId, LayerId, Rect<f32>), SetLayerOrigin(PipelineId, LayerId, Point2D<f32>),
/// Scroll a page in a window /// Scroll a page in a window
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>), ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>),
/// Requests that the compositor paint the given layer buffer set for the given page size. /// Requests that the compositor paint the given layer buffer set for the given page size.

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositor_task::{CompositorChan, LoadComplete, ShutdownComplete, SetLayerClipRect, SetIds}; use compositor_task::{CompositorChan, LoadComplete, ShutdownComplete, SetLayerOrigin, SetIds};
use std::collections::hashmap::{HashMap, HashSet}; use std::collections::hashmap::{HashMap, HashSet};
use geom::rect::{Rect, TypedRect}; use geom::rect::{Rect, TypedRect};
use geom::scale_factor::ScaleFactor; use geom::scale_factor::ScaleFactor;
@ -507,9 +507,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
initial_viewport: rect.size * ScaleFactor(1.0), initial_viewport: rect.size * ScaleFactor(1.0),
device_pixel_ratio: self.window_size.device_pixel_ratio, device_pixel_ratio: self.window_size.device_pixel_ratio,
})); }));
self.compositor_chan.send(SetLayerClipRect(pipeline.id, self.compositor_chan.send(SetLayerOrigin(pipeline.id,
LayerId::null(), LayerId::null(),
rect.to_untyped())); rect.to_untyped().origin));
} else { } else {
already_sent.insert(pipeline.id); already_sent.insert(pipeline.id);
} }

View file

@ -4,7 +4,7 @@
use compositor_task::{Msg, Exit, ChangeReadyState, SetIds}; use compositor_task::{Msg, Exit, ChangeReadyState, SetIds};
use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer}; use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer};
use compositor_task::{SetLayerClipRect, Paint, ScrollFragmentPoint, LoadComplete}; use compositor_task::{SetLayerOrigin, Paint, ScrollFragmentPoint, LoadComplete};
use compositor_task::{ShutdownComplete, ChangeRenderState, RenderMsgDiscarded}; use compositor_task::{ShutdownComplete, ChangeRenderState, RenderMsgDiscarded};
use geom::scale_factor::ScaleFactor; use geom::scale_factor::ScaleFactor;
@ -90,7 +90,7 @@ impl NullCompositor {
CreateOrUpdateRootLayer(..) | CreateOrUpdateRootLayer(..) |
CreateOrUpdateDescendantLayer(..) | CreateOrUpdateDescendantLayer(..) |
SetLayerClipRect(..) | Paint(..) | SetLayerOrigin(..) | Paint(..) |
ChangeReadyState(..) | ChangeRenderState(..) | ScrollFragmentPoint(..) | ChangeReadyState(..) | ChangeRenderState(..) | ScrollFragmentPoint(..) |
LoadComplete(..) | RenderMsgDiscarded(..) => () LoadComplete(..) | RenderMsgDiscarded(..) => ()
} }