@@ -449,7 +449,14 @@ impl TileCache {
449
449
. unmap ( & world_tile_rect)
450
450
. expect ( "bug: unable to get local tile size" ) ;
451
451
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 ( ) ;
453
460
454
461
// Walk the transforms and see if we need to rebuild the primitive
455
462
// dependencies for each tile.
@@ -894,10 +901,23 @@ impl TileCache {
894
901
}
895
902
}
896
903
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
+
897
917
// Update the tile descriptor, used for tile comparison during scene swaps.
898
918
tile. descriptor . prims . push ( PrimitiveDescriptor {
899
919
prim_uid : prim_instance. uid ( ) ,
900
- origin : prim_instance . prim_origin . into ( ) ,
920
+ origin,
901
921
first_clip : tile. descriptor . clip_uids . len ( ) as u16 ,
902
922
clip_count : clip_chain_uids. len ( ) as u16 ,
903
923
} ) ;
0 commit comments