Skip to content

Commit

Permalink
Bug 1517723 - Update webrender to commit a40a5ffd1649d6bf6f55b76c7d63…
Browse files Browse the repository at this point in the history
…3e4d157d4478 (WR PR #3467). r=kats

servo/webrender#3467

Differential Revision: https://phabricator.services.mozilla.com/D15722
  • Loading branch information
WR Updater Bot committed Jan 4, 2019
1 parent f56c98c commit c2053c0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/revision.txt
@@ -1 +1 @@
8a7212b628ae39e7251201b0a9761c74bab42c5d
a40a5ffd1649d6bf6f55b76c7d633e4d157d4478
60 changes: 46 additions & 14 deletions gfx/wr/webrender/src/picture.rs
Expand Up @@ -113,6 +113,9 @@ pub struct Tile {
pub local_rect: LayoutRect,
/// The valid rect within this tile.
valid_rect: WorldRect,
/// The currently visible rect within this tile, updated per frame.
/// If None, this tile is not currently visible.
visible_rect: Option<WorldRect>,
/// Uniquely describes the content of this tile, in a way that can be
/// (reasonably) efficiently hashed and compared.
descriptor: TileDescriptor,
Expand All @@ -136,6 +139,7 @@ impl Tile {
local_rect: LayoutRect::zero(),
world_rect: WorldRect::zero(),
valid_rect: WorldRect::zero(),
visible_rect: None,
handle: TextureCacheHandle::invalid(),
descriptor: TileDescriptor::new(),
is_valid: false,
Expand Down Expand Up @@ -491,6 +495,17 @@ impl TileCache {
.intersection(&device_world_rect)
.expect("todo: handle clipped device rect");

// Expand the needed device rect vertically by a small number of tiles. This
// ensures that as tiles are scrolled in/out of view, they are retained for
// a while before being discarded.
// TODO(gw): On some pages it might be worth also inflating horizontally.
// (is this locale specific?). It might be possible to make a good
// guess based on the size of the picture rect for the tile cache.
let needed_device_rect = needed_device_rect.inflate(
0.0,
3.0 * TILE_SIZE_HEIGHT as f32,
);

let p0 = needed_device_rect.origin;
let p1 = needed_device_rect.bottom_right();

Expand Down Expand Up @@ -554,6 +569,8 @@ impl TileCache {
.unmap(&tile.world_rect)
.expect("bug: can't unmap world rect");

tile.visible_rect = tile.world_rect.intersection(&frame_context.screen_world_rect);

self.tiles.push(tile);
}
}
Expand Down Expand Up @@ -610,7 +627,6 @@ impl TileCache {
resource_cache: &ResourceCache,
opacity_binding_store: &OpacityBindingStorage,
image_instances: &ImageInstanceStorage,
screen_world_rect: &WorldRect,
) {
if !self.needs_update {
return;
Expand Down Expand Up @@ -766,10 +782,13 @@ impl TileCache {
);

if let Some(clip_world_rect) = self.map_local_to_world.map(&local_rect) {
world_clip_rect = match world_clip_rect.intersection(&clip_world_rect) {
Some(rect) => rect,
None => return,
};
// Even if this ends up getting clipped out by the current clip
// stack, we want to ensure the primitive gets added to the tiles
// below, to ensure invalidation isn't tripped up by the wrong
// number of primitives that affect this tile.
world_clip_rect = world_clip_rect
.intersection(&clip_world_rect)
.unwrap_or(WorldRect::zero());
}

false
Expand Down Expand Up @@ -819,14 +838,31 @@ impl TileCache {
let index = (y * self.tile_count.width + x) as usize;
let tile = &mut self.tiles[index];

// TODO(gw): For now, we need to always build the dependencies each
// frame, so can't early exit here. In future, we should
// support retaining the tile descriptor from when the
// tile goes off-screen, which will mean we can then
// compare against that next time it becomes visible.
let visible_rect = match tile.visible_rect {
Some(visible_rect) => visible_rect,
None => WorldRect::zero(),
};

// Work out the needed rect for the primitive on this tile.
// TODO(gw): We should be able to remove this for any tile that is not
// a partially clipped tile, which would be a significant
// optimization for the common case (non-clipped tiles).
let needed_rect = match world_clip_rect.intersection(&tile.world_rect).and_then(|r| r.intersection(screen_world_rect)) {
Some(rect) => rect.translate(&-tile.world_rect.origin.to_vector()),
None => continue,
};

// Get the required tile-local rect that this primitive occupies.
// Ensure that even if it's currently clipped out of this tile,
// we still insert a rect of zero size, so that the tile descriptor's
// needed rects array matches.
let needed_rect = world_clip_rect
.intersection(&visible_rect)
.map(|rect| {
rect.translate(&-tile.world_rect.origin.to_vector())
})
.unwrap_or(WorldRect::zero());

tile.descriptor.needed_rects.push(needed_rect);

Expand Down Expand Up @@ -930,10 +966,7 @@ impl TileCache {
tile.is_valid = false;
}

let visible_rect = match tile
.world_rect
.intersection(&frame_context.screen_world_rect)
{
let visible_rect = match tile.visible_rect {
Some(rect) => rect,
None => continue,
};
Expand Down Expand Up @@ -2010,7 +2043,6 @@ impl PicturePrimitive {
resource_cache,
opacity_binding_store,
image_instances,
&frame_context.screen_world_rect,
);
}
}
Expand Down

0 comments on commit c2053c0

Please sign in to comment.