From e3515fc07f10b9621d287f4bbf7442ca291d03ca Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Fri, 25 Jul 2014 14:25:45 -0700 Subject: [PATCH 1/2] Add content_offset for storing the device pixel offset in content --- layers.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/layers.rs b/layers.rs index a203980..10116ed 100644 --- a/layers.rs +++ b/layers.rs @@ -11,6 +11,7 @@ use tiling::{Tile, TileGrid}; use geom::matrix::{Matrix4, identity}; use geom::size::Size2D; +use geom::point::Point2D; use geom::rect::Rect; use platform::surface::{NativeSurfaceMethods, NativeSurface}; use platform::surface::{NativeCompositingGraphicsContext, NativePaintingGraphicsContext}; @@ -43,6 +44,9 @@ pub struct Layer { /// A monotonically increasing counter that keeps track of the current content age. pub content_age: RefCell, + + /// The content offset for this layer in device pixels. + pub content_offset: RefCell>, } impl Layer { @@ -55,6 +59,7 @@ impl Layer { extra_data: RefCell::new(data), tile_grid: RefCell::new(TileGrid::new(tile_size)), content_age: RefCell::new(ContentAge::new()), + content_offset: RefCell::new(Point2D(0f32, 0f32)), } } From 4f1272f4f4fa706393a96b7abbaf2cf5b141d060 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Mon, 28 Jul 2014 17:09:14 -0700 Subject: [PATCH 2/2] No longer accept a scale argument to get_tile_rects_page In Servo layer bounds are now stored in layer/device coordinates and the Servo compositor takes care of converting buffer requests to page coordinates before passing them to the render task. --- layers.rs | 6 ++++-- tiling.rs | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/layers.rs b/layers.rs index 10116ed..9f9eb47 100644 --- a/layers.rs +++ b/layers.rs @@ -71,9 +71,11 @@ impl Layer { self.children().push(new_child); } - pub fn get_tile_rects_page(&self, window: Rect, scale: f32) -> (Vec, Vec>) { + pub fn get_tile_rects_page(&self, + window: Rect) + -> (Vec, Vec>) { let mut tile_grid = self.tile_grid.borrow_mut(); - (tile_grid.get_buffer_requests_in_rect(window, scale, *self.content_age.borrow()), + (tile_grid.get_buffer_requests_in_rect(window, *self.content_age.borrow()), tile_grid.take_unused_buffers()) } diff --git a/tiling.rs b/tiling.rs index 5872644..230e4d8 100644 --- a/tiling.rs +++ b/tiling.rs @@ -175,11 +175,10 @@ impl TileGrid { pub fn get_buffer_request_for_tile(&mut self, tile_index: Point2D, - scale: f32, current_content_age: ContentAge) -> Option { let tile_rect = self.get_rect_for_tile_index(tile_index); - let tile_screen_rect = rect_uint_as_rect_f32(tile_rect) / scale; + let tile_screen_rect = rect_uint_as_rect_f32(tile_rect); let mut tile = self.tiles.find_or_insert_with(tile_index, |_| Tile::new()); if !tile.should_request_buffer(current_content_age) { @@ -192,17 +191,16 @@ impl TileGrid { pub fn get_buffer_requests_in_rect(&mut self, screen_rect: Rect, - scale: f32, current_content_age: ContentAge) -> Vec { let mut buffer_requests = Vec::new(); - let rect_in_layer_pixels = screen_rect * scale; + let rect_in_layer_pixels = screen_rect; let (top_left_index, bottom_right_index) = self.get_tile_index_range_for_rect(rect_in_layer_pixels); for x in range_inclusive(top_left_index.x, bottom_right_index.x) { for y in range_inclusive(top_left_index.y, bottom_right_index.y) { - match self.get_buffer_request_for_tile(Point2D(x, y), scale, current_content_age) { + match self.get_buffer_request_for_tile(Point2D(x, y), current_content_age) { Some(buffer) => buffer_requests.push(buffer), None => {}, }