From 32d212aa1f867a02ca386bd324e8180b61956913 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Thu, 10 Jun 2021 08:08:06 +0000 Subject: [PATCH] Bug 1711648 - Move TileRect to the Box2D representation. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D117290 --- gfx/wr/webrender/src/picture.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 8a203ea95c95..a4aab555124d 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -109,7 +109,7 @@ use crate::composite::{CompositorKind, CompositeState, NativeSurfaceId, NativeTi use crate::composite::{ExternalSurfaceDescriptor, ExternalSurfaceDependency, CompositeTileDescriptor, CompositeTile}; use crate::composite::{CompositorTransformIndex}; use crate::debug_colors; -use euclid::{vec2, vec3, Point2D, Scale, Size2D, Vector2D, Rect, Box2D, Transform3D, SideOffsets2D}; +use euclid::{vec2, vec3, Point2D, Scale, Vector2D, Box2D, Transform3D, SideOffsets2D}; use euclid::approxeq::ApproxEq; use crate::filterdata::SFilterData; use crate::intern::ItemUid; @@ -268,11 +268,7 @@ pub struct TileCoordinate; // Geometry types for tile coordinates. pub type TileOffset = Point2D; -// TileSize type is also used in used in lib.rs and cbindgen picks the wrong one when -// generating headers. -/// cbindgen:ignore -pub type TileSize = Size2D; -pub type TileRect = Rect; +pub type TileRect = Box2D; /// The maximum number of compositor surfaces that are allowed per picture cache. This /// is an arbitrary number that should be enough for common cases, but low enough to @@ -2219,10 +2215,10 @@ impl SubSlice { /// Resize the tile grid to match a new tile bounds fn resize(&mut self, new_tile_rect: TileRect) -> FastHashMap> { let mut old_tiles = mem::replace(&mut self.tiles, FastHashMap::default()); - self.tiles.reserve(new_tile_rect.size.area() as usize); + self.tiles.reserve(new_tile_rect.area() as usize); - for y in new_tile_rect.origin.y .. new_tile_rect.origin.y + new_tile_rect.size.height { - for x in new_tile_rect.origin.x .. new_tile_rect.origin.x + new_tile_rect.size.width { + for y in new_tile_rect.min.y .. new_tile_rect.max.y { + for x in new_tile_rect.min.x .. new_tile_rect.max.x { let key = TileOffset::new(x, y); let tile = old_tiles .remove(&key) @@ -2395,7 +2391,7 @@ impl TileCacheInstance { /// Return the total number of tiles allocated by this tile cache pub fn tile_count(&self) -> usize { - self.tile_rect.size.area() as usize * self.sub_slices.len() + self.tile_rect.area() as usize * self.sub_slices.len() } /// Reset this tile cache with the updated parameters from a new scene @@ -2739,12 +2735,10 @@ impl TileCacheInstance { let y0 = (p0.y / local_tile_rect.height()).floor() as i32; let y1 = (p1.y / local_tile_rect.height()).ceil() as i32; - let x_tiles = x1 - x0; - let y_tiles = y1 - y0; - let new_tile_rect = TileRect::new( - TileOffset::new(x0, y0), - TileSize::new(x_tiles, y_tiles), - ); + let new_tile_rect = TileRect { + min: TileOffset::new(x0, y0), + max: TileOffset::new(x1, y1), + }; // Determine whether the current bounds of the tile grid will exceed the // bounds of the DC virtual surface, taking into account the current