diff --git a/webrender/src/spatial_tree.rs b/webrender/src/spatial_tree.rs index e95fa748e4..e6ab9fcfd6 100644 --- a/webrender/src/spatial_tree.rs +++ b/webrender/src/spatial_tree.rs @@ -265,7 +265,6 @@ impl SpatialTree { child_index: SpatialNodeIndex, parent_index: SpatialNodeIndex, ) -> CoordinateSpaceMapping { - assert!(child_index.0 >= parent_index.0); if child_index == parent_index { return CoordinateSpaceMapping::Local; } @@ -280,6 +279,26 @@ impl SpatialTree { return CoordinateSpaceMapping::ScaleOffset(scale_offset); } + if child_index.0 < parent_index.0 { + warn!("Unexpected transform queried from {:?} to {:?}, please call the graphics team!", child_index, parent_index); + let child_cs = &self.coord_systems[child.coordinate_system_id.0 as usize]; + let child_transform = child.content_transform + .to_transform::() + .post_transform(&child_cs.world_transform); + let parent_cs = &self.coord_systems[parent.coordinate_system_id.0 as usize]; + let parent_transform = parent.content_transform + .to_transform() + .post_transform(&parent_cs.world_transform); + + let result = parent_transform + .inverse() + .unwrap_or_default() + .post_transform(&child_transform) + .with_source::() + .with_destination::(); + return CoordinateSpaceMapping::Transform(result); + } + let mut coordinate_system_id = child.coordinate_system_id; let mut transform = child.content_transform.to_transform();