Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync changes from mozilla-central #3813

Merged
merged 8 commits into from Dec 13, 2019
Next

Bug 1602458 - Avoid reallocating opacity bindings and tiles hash maps…

  • Loading branch information
nical authored and moz-gfx committed Dec 12, 2019
commit 7c069f9dfde55a03b962e729b22051f5499def6f
@@ -1435,13 +1435,17 @@ pub struct TileCacheInstance {
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>,
@@ -1507,6 +1511,7 @@ impl TileCacheInstance {
slice,
spatial_node_index,
tiles: FastHashMap::default(),
old_tiles: FastHashMap::default(),
map_local_to_surface: SpaceMapper::new(
ROOT_SPATIAL_NODE_INDEX,
PictureRect::zero(),
@@ -1516,6 +1521,7 @@ impl TileCacheInstance {
PictureRect::zero(),
),
opacity_bindings: FastHashMap::default(),
old_opacity_bindings: FastHashMap::default(),
spatial_nodes: FastHashMap::default(),
used_spatial_nodes: FastHashSet::default(),
dirty_region: DirtyRegion::new(),
@@ -1732,10 +1738,11 @@ impl TileCacheInstance {
// 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,
};
@@ -1795,10 +1802,7 @@ impl TileCacheInstance {

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,
@@ -1809,11 +1813,12 @@ impl TileCacheInstance {
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));
@@ -1861,7 +1866,7 @@ impl TileCacheInstance {
// 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,
);

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.