Skip to content

Commit 9b6c534

Browse files
author
bors-servo
authored
Auto merge of #3430 - gw3583:subpx-caching, r=kvark
Fix a couple of picture caching reftest issues with subpx offsets. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3430) <!-- Reviewable:end -->
2 parents 14df2e4 + 68250a6 commit 9b6c534

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

webrender/src/picture.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,14 @@ impl TileCache {
449449
.unmap(&world_tile_rect)
450450
.expect("bug: unable to get local tile size");
451451
self.local_tile_size = local_tile_rect.size;
452-
self.local_origin = pic_rect.origin;
452+
453+
// Round the local reference point down to a whole number. This ensures
454+
// that the bounding rect of the tile corresponds to a pixel boundary, and
455+
// the content is offset by a fractional amount inside the surface itself.
456+
// This means that when drawing the tile it's fine to use a simple 0-1
457+
// UV mapping, instead of trying to determine a fractional UV rect that
458+
// is slightly inside the allocated tile surface.
459+
self.local_origin = pic_rect.origin.floor();
453460

454461
// Walk the transforms and see if we need to rebuild the primitive
455462
// dependencies for each tile.
@@ -894,10 +901,23 @@ impl TileCache {
894901
}
895902
}
896903

904+
// For the primitive origin, store the local origin relative to
905+
// the local origin of the containing picture. This ensures that
906+
// a tile with primitives in the same coordinate system as the
907+
// container picture itself, but different offsets relative to
908+
// the containing picture are correctly invalidated. It does this
909+
// while still maintaining the property of keeping the same hash
910+
// for different display lists where the local origin is different
911+
// but the primitives themselves are at the same relative position.
912+
let origin = PointKey {
913+
x: prim_rect.origin.x - self.local_origin.x,
914+
y: prim_rect.origin.y - self.local_origin.y,
915+
};
916+
897917
// Update the tile descriptor, used for tile comparison during scene swaps.
898918
tile.descriptor.prims.push(PrimitiveDescriptor {
899919
prim_uid: prim_instance.uid(),
900-
origin: prim_instance.prim_origin.into(),
920+
origin,
901921
first_clip: tile.descriptor.clip_uids.len() as u16,
902922
clip_count: clip_chain_uids.len() as u16,
903923
});

webrender/src/prim_store/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ impl From<LayoutVector2D> for VectorKey {
657657
#[cfg_attr(feature = "replay", derive(Deserialize))]
658658
#[derive(Debug, Clone, PartialEq)]
659659
pub struct PointKey {
660-
x: f32,
661-
y: f32,
660+
pub x: f32,
661+
pub y: f32,
662662
}
663663

664664
impl Eq for PointKey {}

0 commit comments

Comments
 (0)