diff --git a/Cargo.toml b/Cargo.toml index a5d4a43..78e49c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "layers" -version = "0.2.6" +version = "0.3.0" authors = ["The Servo Project Developers"] license = "MIT/Apache-2.0" @@ -14,9 +14,8 @@ libc = "0.2" rustc-serialize = "0.3.16" log = "0.3.4" gleam = "0.2" -euclid = ">=0.6.2, <0.8" -servo-skia = "0.20130412.8" -azure = { git = "https://github.com/servo/rust-azure" } +euclid = "0.8" +servo-skia = "0.20130412.16" [dependencies.heapsize] version = ">=0.2.2, <0.4" @@ -29,7 +28,7 @@ optional = true [target.x86_64-apple-darwin.dependencies] core-foundation = "0.2.0" cgl = "0.1" -io-surface = "0.2.0" +io-surface = "0.3.0" [target.'cfg(target_os = "linux")'.dependencies] glx = "0.1.0" diff --git a/src/layers.rs b/src/layers.rs index 8589433..a9518bd 100644 --- a/src/layers.rs +++ b/src/layers.rs @@ -74,13 +74,13 @@ pub struct Layer { tile_grid: RefCell, /// The boundaries of this layer in the coordinate system of the parent layer. - pub bounds: RefCell>, + pub bounds: RefCell>, /// A monotonically increasing counter that keeps track of the current content age. pub content_age: RefCell, /// The content offset for this layer in unscaled layer pixels. - pub content_offset: RefCell>, + pub content_offset: RefCell>, /// Whether this layer clips its children to its boundaries. pub masks_to_bounds: RefCell, @@ -99,7 +99,7 @@ pub struct Layer { } impl Layer { - pub fn new(bounds: TypedRect, + pub fn new(bounds: TypedRect, tile_size: usize, background_color: Color, opacity: f32, @@ -116,7 +116,7 @@ impl Layer { tile_grid: RefCell::new(TileGrid::new(tile_size)), content_age: RefCell::new(ContentAge::new()), masks_to_bounds: RefCell::new(false), - content_offset: RefCell::new(Point2D::zero()), + content_offset: RefCell::new(TypedPoint2D::zero()), background_color: RefCell::new(background_color), opacity: RefCell::new(opacity), establishes_3d_context: establishes_3d_context, @@ -139,9 +139,9 @@ impl Layer { /// Returns buffer requests inside the given dirty rect, and simultaneously throws out tiles /// outside the given viewport rect. pub fn get_buffer_requests(&self, - rect_in_layer: TypedRect, - viewport_in_layer: TypedRect, - scale: ScaleFactor) + rect_in_layer: TypedRect, + viewport_in_layer: TypedRect, + scale: ScaleFactor) -> Vec { let mut tile_grid = self.tile_grid.borrow_mut(); tile_grid.get_buffer_requests_in_rect(rect_in_layer * scale, @@ -153,7 +153,7 @@ impl Layer { *self.content_age.borrow()) } - pub fn resize(&self, new_size: TypedSize2D) { + pub fn resize(&self, new_size: TypedSize2D) { self.bounds.borrow_mut().size = new_size; } diff --git a/src/lib.rs b/src/lib.rs index 41f13cc..ce0d13c 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,6 @@ #![cfg_attr(feature = "plugins", plugin(heapsize_plugin))] -extern crate azure; extern crate euclid; #[cfg(feature = "plugins")] extern crate heapsize; diff --git a/src/scene.rs b/src/scene.rs index 9f507a2..f7158f2 100755 --- a/src/scene.rs +++ b/src/scene.rs @@ -7,24 +7,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use euclid::rect::{Rect, TypedRect}; +use euclid::rect::TypedRect; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; -use euclid::point::Point2D; +use euclid::point::TypedPoint2D; use geometry::{DevicePixel, LayerPixel}; use layers::{BufferRequest, Layer, LayerBuffer}; use std::rc::Rc; pub struct Scene { pub root: Option>>, - pub viewport: TypedRect, + pub viewport: TypedRect, /// The scene scale, to allow for zooming and high-resolution painting. - pub scale: ScaleFactor, + pub scale: ScaleFactor, } impl Scene { - pub fn new(viewport: TypedRect) -> Scene { + pub fn new(viewport: TypedRect) -> Scene { Scene { root: None, viewport: viewport, @@ -34,8 +34,8 @@ impl Scene { pub fn get_buffer_requests_for_layer(&mut self, layer: Rc>, - dirty_rect: TypedRect, - viewport_rect: TypedRect, + dirty_rect: TypedRect, + viewport_rect: TypedRect, layers_and_requests: &mut Vec<(Rc>, Vec)>, unused_buffers: &mut Vec>) { @@ -54,7 +54,7 @@ impl Scene { match layer.transform_state.borrow().screen_rect { Some(ref screen_rect) => { match dirty_rect.to_untyped().intersection(&screen_rect.rect) { - Some(ref child_dirty_rect) => Rect::from_untyped(child_dirty_rect), + Some(ref child_dirty_rect) => TypedRect::from_untyped(child_dirty_rect), None => return, // The layer is entirely outside the dirty rect. } }, @@ -101,9 +101,10 @@ impl Scene { self.mark_layer_contents_as_changed_recursively_for_layer(root_layer); } - pub fn set_root_layer_size(&self, new_size: TypedSize2D) { + pub fn set_root_layer_size(&self, new_size: TypedSize2D) { if let Some(ref root_layer) = self.root { - *root_layer.bounds.borrow_mut() = Rect::new(Point2D::zero(), new_size / self.scale); + *root_layer.bounds.borrow_mut() = TypedRect::new(TypedPoint2D::zero(), + new_size / self.scale); } } diff --git a/src/tiling.rs b/src/tiling.rs index 09ad2d1..f32cb1b 100644 --- a/src/tiling.rs +++ b/src/tiling.rs @@ -14,7 +14,7 @@ use texturegl::Texture; use util::project_rect_to_screen; use euclid::length::Length; -use euclid::{Matrix4D, Point2D}; +use euclid::{Matrix4D, Point2D, TypedPoint2D}; use euclid::rect::{Rect, TypedRect}; use euclid::size::{Size2D, TypedSize2D}; use std::collections::HashMap; @@ -33,7 +33,7 @@ pub struct Tile { pub texture: Texture, /// The tile boundaries in the parent layer coordinates. - pub bounds: Option>, + pub bounds: Option>, } impl Tile { @@ -80,7 +80,7 @@ impl Tile { buffer.native_surface.bind_to_texture(display, &self.texture); // Set the layer's rect. - self.bounds = Some(Rect::from_untyped(&buffer.rect)); + self.bounds = Some(TypedRect::from_untyped(&buffer.rect)); } } @@ -104,15 +104,15 @@ pub struct TileGrid { pub tiles: HashMap, Tile>, /// The size of tiles in this grid in device pixels. - tile_size: Length, + tile_size: Length, // Buffers that are currently unused. unused_buffers: Vec>, } pub fn rect_uint_as_rect_f32(rect: Rect) -> Rect { - Rect::new(Point2D::new(rect.origin.x as f32, rect.origin.y as f32), - Size2D::new(rect.size.width as f32, rect.size.height as f32)) + TypedRect::new(Point2D::new(rect.origin.x as f32, rect.origin.y as f32), + Size2D::new(rect.size.width as f32, rect.size.height as f32)) } impl TileGrid { @@ -126,21 +126,22 @@ impl TileGrid { pub fn get_rect_for_tile_index(&self, tile_index: Point2D, - current_layer_size: TypedSize2D) - -> TypedRect { + current_layer_size: TypedSize2D) + -> TypedRect { - let origin = Point2D::new(self.tile_size.get() * tile_index.x, - self.tile_size.get() * tile_index.y); + let origin : TypedPoint2D = + TypedPoint2D::new(self.tile_size.get() * tile_index.x, + self.tile_size.get() * tile_index.y); // Don't let tiles extend beyond the layer boundaries. let tile_size = self.tile_size.get() as f32; - let size = Size2D::new(tile_size.min(current_layer_size.width.get() - origin.x as f32), - tile_size.min(current_layer_size.height.get() - origin.y as f32)); + let size = Size2D::new(tile_size.min(current_layer_size.width - origin.x as f32), + tile_size.min(current_layer_size.height - origin.y as f32)); // Round up to texture pixels. - let size = Size2D::new(size.width.ceil() as usize, size.height.ceil() as usize); + let size = TypedSize2D::new(size.width.ceil() as usize, size.height.ceil() as usize); - Rect::from_untyped(&Rect::new(origin, size)) + TypedRect::new(origin, size) } pub fn take_unused_buffers(&mut self) -> Vec> { @@ -158,7 +159,7 @@ impl TileGrid { pub fn tile_intersects_rect(&self, tile_index: &Point2D, test_rect: &Rect, - current_layer_size: TypedSize2D, + current_layer_size: TypedSize2D, layer_world_origin: &Point2D, layer_transform: &Matrix4D) -> bool { let tile_rect = self.get_rect_for_tile_index(*tile_index, @@ -179,10 +180,10 @@ impl TileGrid { } pub fn mark_tiles_outside_of_rect_as_unused(&mut self, - rect: TypedRect, + rect: TypedRect, layer_world_origin: &Point2D, layer_transform: &Matrix4D, - current_layer_size: TypedSize2D) { + current_layer_size: TypedSize2D) { let mut tile_indexes_to_take = Vec::new(); for tile_index in self.tiles.keys() { @@ -204,7 +205,7 @@ impl TileGrid { pub fn get_buffer_request_for_tile(&mut self, tile_index: Point2D, - current_layer_size: TypedSize2D, + current_layer_size: TypedSize2D, current_content_age: ContentAge) -> Option { let tile_rect = self.get_rect_for_tile_index(tile_index, current_layer_size); @@ -231,9 +232,9 @@ impl TileGrid { /// Returns buffer requests inside the given dirty rect, and simultaneously throws out tiles /// outside the given viewport rect. pub fn get_buffer_requests_in_rect(&mut self, - dirty_rect: TypedRect, - viewport: TypedRect, - current_layer_size: TypedSize2D, + dirty_rect: TypedRect, + viewport: TypedRect, + current_layer_size: TypedSize2D, layer_world_origin: &Point2D, layer_transform: &Matrix4D, current_content_age: ContentAge)