| author | Nicolas Silva <nsilva@mozilla.com> |
| Thu, 12 Dec 2019 09:08:58 +0000 | |
| changeset 506635 | 7f28f9e9ec258d9b35c62ff169e4cd42edf5fd69 |
| parent 506634 | c68fb518e696f153903156f8d65913e2f77ac2fa |
| child 506636 | afdbc174451905720fd9d9be93e402fc4793aba3 |
| push id | 36910 |
| push user | csabou@mozilla.com |
| push date | Thu, 12 Dec 2019 21:50:40 +0000 |
| treeherder | mozilla-central@0f6958f49842 [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| reviewers | gw |
| bugs | 1602458 |
| milestone | 73.0a1 |
| first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
| last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -1430,23 +1430,27 @@ pub struct TileCacheInstance { /// can be revisited if we ever notice that. pub slice: usize, /// The currently selected tile size to use for this cache pub current_tile_size: DeviceIntSize, /// The positioning node for this tile cache. pub spatial_node_index: SpatialNodeIndex, /// Hash of tiles present in this picture. pub tiles: FastHashMap<TileOffset, Tile>, + /// Switch back and forth between old and new tiles hashmaps to avoid re-allocating. + old_tiles: FastHashMap<TileOffset, Tile>, /// A helper struct to map local rects into surface coords. map_local_to_surface: SpaceMapper<LayoutPixel, PicturePixel>, /// A helper struct to map child picture rects into picture cache surface coords. map_child_pic_to_surface: SpaceMapper<PicturePixel, PicturePixel>, /// List of opacity bindings, with some extra information /// about whether they changed since last frame. opacity_bindings: FastHashMap<PropertyBindingId, OpacityBindingInfo>, + /// Switch back and forth between old and new bindings hashmaps to avoid re-allocating. + old_opacity_bindings: FastHashMap<PropertyBindingId, OpacityBindingInfo>, /// List of spatial nodes, with some extra information /// about whether they changed since last frame. spatial_nodes: FastHashMap<SpatialNodeIndex, SpatialNodeDependency>, /// A set of spatial nodes that primitives / clips depend on found /// during dependency creation. This is used to avoid trying to /// calculate invalid relative transforms when building the spatial /// nodes hash above. used_spatial_nodes: FastHashSet<SpatialNodeIndex>, @@ -1502,25 +1506,27 @@ impl TileCacheInstance { background_color: Option<ColorF>, shared_clips: Vec<ClipDataHandle>, shared_clip_chain: ClipChainId, ) -> Self { TileCacheInstance { slice, spatial_node_index, tiles: FastHashMap::default(), + old_tiles: FastHashMap::default(), map_local_to_surface: SpaceMapper::new( ROOT_SPATIAL_NODE_INDEX, PictureRect::zero(), ), map_child_pic_to_surface: SpaceMapper::new( ROOT_SPATIAL_NODE_INDEX, PictureRect::zero(), ), opacity_bindings: FastHashMap::default(), + old_opacity_bindings: FastHashMap::default(), spatial_nodes: FastHashMap::default(), used_spatial_nodes: FastHashSet::default(), dirty_region: DirtyRegion::new(), tile_size: PictureSize::zero(), tile_rect: TileRect::zero(), tile_bounds_p0: TileOffset::zero(), tile_bounds_p1: TileOffset::zero(), local_rect: PictureRect::zero(), @@ -1727,20 +1733,21 @@ impl TileCacheInstance { self.fract_offset = PictureVector2D::new( ref_point.x.fract(), ref_point.y.fract(), ); // Do a hacky diff of opacity binding values from the last frame. This is // used later on during tile invalidation tests. let current_properties = frame_context.scene_properties.float_properties(); - let old_properties = mem::replace(&mut self.opacity_bindings, FastHashMap::default()); - + mem::swap(&mut self.opacity_bindings, &mut self.old_opacity_bindings); + + self.opacity_bindings.clear(); for (id, value) in current_properties { - let changed = match old_properties.get(id) { + let changed = match self.old_opacity_bindings.get(id) { Some(old_property) => !old_property.value.approx_eq(value), None => true, }; self.opacity_bindings.insert(*id, OpacityBindingInfo { value: *value, changed, }); } @@ -1790,35 +1797,33 @@ impl TileCacheInstance { ); // This is duplicated information from tile_rect, but cached here to avoid // redundant calculations during get_tile_coords_for_rect self.tile_bounds_p0 = TileOffset::new(x0, y0); self.tile_bounds_p1 = TileOffset::new(x1, y1); let mut world_culling_rect = WorldRect::zero(); - let mut old_tiles = mem::replace( - &mut self.tiles, - FastHashMap::default(), - ); + mem::swap(&mut self.tiles, &mut self.old_tiles); let ctx = TilePreUpdateContext { local_rect: self.local_rect, local_clip_rect: self.local_clip_rect, pic_to_world_mapper, fract_offset: self.fract_offset, background_color: self.background_color, global_screen_world_rect: frame_context.global_screen_world_rect, }; + self.tiles.clear(); for y in y0 .. y1 { for x in x0 .. x1 { let key = TileOffset::new(x, y); - let mut tile = old_tiles + let mut tile = self.old_tiles .remove(&key) .unwrap_or_else(|| { let next_id = TileId(NEXT_TILE_ID.fetch_add(1, Ordering::Relaxed)); Tile::new(next_id) }); // Ensure each tile is offset by the appropriate amount from the // origin, such that the content origin will be a whole number and @@ -1856,17 +1861,17 @@ impl TileCacheInstance { } } // Any old tiles that remain after the loop above are going to be dropped. For // simple composite mode, the texture cache handle will expire and be collected // by the texture cache. For native compositor mode, we need to explicitly // invoke a callback to the client to destroy that surface. frame_state.composite_state.destroy_native_surfaces( - old_tiles.values(), + self.old_tiles.values(), frame_state.resource_cache, ); world_culling_rect } /// Update the dependencies for each tile for a given primitive instance. pub fn update_prim_dependencies(