Skip to content

Commit b25732b

Browse files
nicalweb-flow
authored andcommitted
Bug 1898460 - Disambiguate some of the usage of 'surface' in coordinate spaces (Part 2). r=gw
Differential Revision: https://phabricator.services.mozilla.com/D211389
1 parent de00db1 commit b25732b

File tree

3 files changed

+50
-50
lines changed

3 files changed

+50
-50
lines changed

webrender/src/composite.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ impl Default for CompositeStatePreallocator {
521521
#[cfg_attr(feature = "replay", derive(Deserialize))]
522522
pub struct CompositorTransform {
523523
// Map from local rect of a composite tile to the real backing surface coords
524-
local_to_surface: ScaleOffset,
524+
local_to_raster: ScaleOffset,
525525
// Map from surface coords to the final device space position
526-
surface_to_device: ScaleOffset,
526+
raster_to_device: ScaleOffset,
527527
// Combined local -> surface -> device transform
528528
local_to_device: ScaleOffset,
529529
}
@@ -590,16 +590,16 @@ impl CompositeState {
590590
/// Register use of a transform for a picture cache tile or external surface
591591
pub fn register_transform(
592592
&mut self,
593-
local_to_surface: ScaleOffset,
594-
surface_to_device: ScaleOffset,
593+
local_to_raster: ScaleOffset,
594+
raster_to_device: ScaleOffset,
595595
) -> CompositorTransformIndex {
596596
let index = CompositorTransformIndex(self.transforms.len());
597597

598-
let local_to_device = local_to_surface.accumulate(&surface_to_device);
598+
let local_to_device = local_to_raster.accumulate(&raster_to_device);
599599

600600
self.transforms.push(CompositorTransform {
601-
local_to_surface,
602-
surface_to_device,
601+
local_to_raster,
602+
raster_to_device,
603603
local_to_device,
604604
});
605605

@@ -626,8 +626,8 @@ impl CompositeState {
626626
) -> DeviceRect {
627627
let transform = &self.transforms[transform_index.0];
628628

629-
let surface_bounds = transform.local_to_surface.map_rect(&local_bounds);
630-
let surface_rect = transform.local_to_surface.map_rect(&local_sub_rect);
629+
let surface_bounds = transform.local_to_raster.map_rect(&local_bounds);
630+
let surface_rect = transform.local_to_raster.map_rect(&local_sub_rect);
631631

632632
surface_rect
633633
.round_out()
@@ -652,7 +652,7 @@ impl CompositeState {
652652
transform_index: CompositorTransformIndex,
653653
) -> ScaleOffset {
654654
let transform = &self.transforms[transform_index.0];
655-
transform.surface_to_device
655+
transform.raster_to_device
656656
}
657657

658658
/// Register an occluder during picture cache updates that can be

webrender/src/picture.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,12 +1829,12 @@ pub struct TileCacheInstance {
18291829
frame_id: FrameId,
18301830
/// Registered transform in CompositeState for this picture cache
18311831
pub transform_index: CompositorTransformIndex,
1832-
/// Current transform mapping local picture space to compositor surface space
1833-
local_to_surface: ScaleOffset,
1832+
/// Current transform mapping local picture space to compositor surface raster space
1833+
local_to_raster: ScaleOffset,
1834+
/// Current transform mapping compositor surface raster space to final device space
1835+
raster_to_device: ScaleOffset,
18341836
/// If true, we need to invalidate all tiles during `post_update`
18351837
invalidate_all_tiles: bool,
1836-
/// Current transform mapping compositor surface space to final device space
1837-
surface_to_device: ScaleOffset,
18381838
/// The current raster scale for tiles in this cache
18391839
current_raster_scale: f32,
18401840
/// Depth of off-screen surfaces that are currently pushed during dependency updates
@@ -1903,8 +1903,8 @@ impl TileCacheInstance {
19031903
external_native_surface_cache: FastHashMap::default(),
19041904
frame_id: FrameId::INVALID,
19051905
transform_index: CompositorTransformIndex::INVALID,
1906-
surface_to_device: ScaleOffset::identity(),
1907-
local_to_surface: ScaleOffset::identity(),
1906+
raster_to_device: ScaleOffset::identity(),
1907+
local_to_raster: ScaleOffset::identity(),
19081908
invalidate_all_tiles: true,
19091909
current_raster_scale: 1.0,
19101910
current_surface_traversal_depth: 0,
@@ -2189,29 +2189,29 @@ impl TileCacheInstance {
21892189
);
21902190

21912191
// Get the compositor transform, which depends on pinch-zoom mode
2192-
let mut surface_to_device = local_to_device;
2192+
let mut raster_to_device = local_to_device;
21932193

21942194
if frame_context.config.low_quality_pinch_zoom {
2195-
surface_to_device.scale.x /= self.current_raster_scale;
2196-
surface_to_device.scale.y /= self.current_raster_scale;
2195+
raster_to_device.scale.x /= self.current_raster_scale;
2196+
raster_to_device.scale.y /= self.current_raster_scale;
21972197
} else {
2198-
surface_to_device.scale.x = 1.0;
2199-
surface_to_device.scale.y = 1.0;
2198+
raster_to_device.scale.x = 1.0;
2199+
raster_to_device.scale.y = 1.0;
22002200
}
22012201

22022202
// Use that compositor transform to calculate a relative local to surface
2203-
let local_to_surface = local_to_device.accumulate(&surface_to_device.inverse());
2203+
let local_to_raster = local_to_device.accumulate(&raster_to_device.inverse());
22042204

22052205
const EPSILON: f32 = 0.001;
22062206
let compositor_translation_changed =
2207-
!surface_to_device.offset.x.approx_eq_eps(&self.surface_to_device.offset.x, &EPSILON) ||
2208-
!surface_to_device.offset.y.approx_eq_eps(&self.surface_to_device.offset.y, &EPSILON);
2207+
!raster_to_device.offset.x.approx_eq_eps(&self.raster_to_device.offset.x, &EPSILON) ||
2208+
!raster_to_device.offset.y.approx_eq_eps(&self.raster_to_device.offset.y, &EPSILON);
22092209
let compositor_scale_changed =
2210-
!surface_to_device.scale.x.approx_eq_eps(&self.surface_to_device.scale.x, &EPSILON) ||
2211-
!surface_to_device.scale.y.approx_eq_eps(&self.surface_to_device.scale.y, &EPSILON);
2210+
!raster_to_device.scale.x.approx_eq_eps(&self.raster_to_device.scale.x, &EPSILON) ||
2211+
!raster_to_device.scale.y.approx_eq_eps(&self.raster_to_device.scale.y, &EPSILON);
22122212
let surface_scale_changed =
2213-
!local_to_surface.scale.x.approx_eq_eps(&self.local_to_surface.scale.x, &EPSILON) ||
2214-
!local_to_surface.scale.y.approx_eq_eps(&self.local_to_surface.scale.y, &EPSILON);
2213+
!local_to_raster.scale.x.approx_eq_eps(&self.local_to_raster.scale.x, &EPSILON) ||
2214+
!local_to_raster.scale.y.approx_eq_eps(&self.local_to_raster.scale.y, &EPSILON);
22152215

22162216
if compositor_translation_changed ||
22172217
compositor_scale_changed ||
@@ -2220,8 +2220,8 @@ impl TileCacheInstance {
22202220
frame_state.composite_state.dirty_rects_are_valid = false;
22212221
}
22222222

2223-
self.surface_to_device = surface_to_device;
2224-
self.local_to_surface = local_to_surface;
2223+
self.raster_to_device = raster_to_device;
2224+
self.local_to_raster = local_to_raster;
22252225
self.invalidate_all_tiles = surface_scale_changed || frame_context.config.force_invalidation;
22262226

22272227
// Do a hacky diff of opacity binding values from the last frame. This is
@@ -2264,8 +2264,8 @@ impl TileCacheInstance {
22642264
);
22652265

22662266
self.tile_size = PictureSize::new(
2267-
world_tile_size.width / self.local_to_surface.scale.x,
2268-
world_tile_size.height / self.local_to_surface.scale.y,
2267+
world_tile_size.width / self.local_to_raster.scale.x,
2268+
world_tile_size.height / self.local_to_raster.scale.y,
22692269
);
22702270

22712271
// Inflate the needed rect a bit, so that we retain tiles that we have drawn
@@ -2698,8 +2698,8 @@ impl TileCacheInstance {
26982698

26992699
let normalized_prim_to_device = prim_offset.accumulate(&local_prim_to_device);
27002700

2701-
let local_to_surface = ScaleOffset::identity();
2702-
let surface_to_device = normalized_prim_to_device;
2701+
let local_to_raster = ScaleOffset::identity();
2702+
let raster_to_device = normalized_prim_to_device;
27032703

27042704
// If this primitive is an external image, and supports being used
27052705
// directly by a native compositor, then lookup the external image id
@@ -2717,14 +2717,14 @@ impl TileCacheInstance {
27172717
if let CompositorKind::Native { capabilities, .. } = composite_state.compositor_kind {
27182718
if external_image_id.is_some() &&
27192719
!capabilities.supports_external_compositor_surface_negative_scaling &&
2720-
(surface_to_device.scale.x < 0.0 || surface_to_device.scale.y < 0.0) {
2720+
(raster_to_device.scale.x < 0.0 || raster_to_device.scale.y < 0.0) {
27212721
external_image_id = None;
27222722
}
27232723
}
27242724

27252725
let compositor_transform_index = composite_state.register_transform(
2726-
local_to_surface,
2727-
surface_to_device,
2726+
local_to_raster,
2727+
raster_to_device,
27282728
);
27292729

27302730
let surface_size = composite_state.get_surface_rect(
@@ -2957,17 +2957,17 @@ impl TileCacheInstance {
29572957

29582958
// If the primitive is directly drawn onto this picture cache surface, then
29592959
// the pic_coverage_rect is in the same space. If not, we need to map it from
2960-
// the surface space into the picture cache space.
2960+
// the intermediate picture space into the picture cache space.
29612961
let on_picture_surface = prim_surface_index == self.surface_index;
29622962
let pic_coverage_rect = if on_picture_surface {
29632963
prim_clip_chain.pic_coverage_rect
29642964
} else {
2965-
// We want to get the rect in the tile cache surface space that this primitive
2965+
// We want to get the rect in the tile cache picture space that this primitive
29662966
// occupies, in order to enable correct invalidation regions. Each surface
29672967
// that exists in the chain between this primitive and the tile cache surface
29682968
// may have an arbitrary inflation factor (for example, in the case of a series
29692969
// of nested blur elements). To account for this, step through the current
2970-
// surface stack, mapping the primitive rect into each surface space, including
2970+
// surface stack, mapping the primitive rect into each picture space, including
29712971
// the inflation factor from each intermediate surface.
29722972
let mut current_pic_coverage_rect = prim_clip_chain.pic_coverage_rect;
29732973
let mut current_spatial_node_index = surfaces[prim_surface_index.0]
@@ -2977,7 +2977,7 @@ impl TileCacheInstance {
29772977
let surface = &surfaces[surface_index.0];
29782978
let pic = &pictures[pic_index.0];
29792979

2980-
let map_local_to_picture = SpaceMapper::new_with_target(
2980+
let map_local_to_parent = SpaceMapper::new_with_target(
29812981
surface.surface_spatial_node_index,
29822982
current_spatial_node_index,
29832983
surface.unclipped_local_rect,
@@ -2987,7 +2987,7 @@ impl TileCacheInstance {
29872987
// Map the rect into the parent surface, and inflate if this surface requires
29882988
// it. If the rect can't be mapping (e.g. due to an invalid transform) then
29892989
// just bail out from the dependencies and cull this primitive.
2990-
current_pic_coverage_rect = match map_local_to_picture.map(&current_pic_coverage_rect) {
2990+
current_pic_coverage_rect = match map_local_to_parent.map(&current_pic_coverage_rect) {
29912991
Some(rect) => {
29922992
// TODO(gw): The casts here are a hack. We have some interface inconsistencies
29932993
// between layout/picture rects which don't really work with the
@@ -3638,10 +3638,10 @@ impl TileCacheInstance {
36383638
self.subpixel_mode = self.calculate_subpixel_mode();
36393639

36403640
self.transform_index = frame_state.composite_state.register_transform(
3641-
self.local_to_surface,
3641+
self.local_to_raster,
36423642
// TODO(gw): Once we support scaling of picture cache tiles during compositing,
36433643
// that transform gets plugged in here!
3644-
self.surface_to_device,
3644+
self.raster_to_device,
36453645
);
36463646

36473647
let map_pic_to_world = SpaceMapper::new_with_target(
@@ -3877,10 +3877,10 @@ pub struct SurfaceInfo {
38773877
/// Helper structs for mapping local rects in different
38783878
/// coordinate systems into the picture coordinates.
38793879
pub map_local_to_picture: SpaceMapper<LayoutPixel, PicturePixel>,
3880-
/// Defines the positioning node for the surface itself,
3881-
/// and the rasterization root for this surface.
3882-
pub raster_spatial_node_index: SpatialNodeIndex,
3880+
/// The positioning node for the surface itself,
38833881
pub surface_spatial_node_index: SpatialNodeIndex,
3882+
/// The rasterization root for this surface.
3883+
pub raster_spatial_node_index: SpatialNodeIndex,
38843884
/// The device pixel ratio specific to this surface.
38853885
pub device_pixel_scale: DevicePixelScale,
38863886
/// The scale factors of the surface to world transform.

webrender/src/quad.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ pub fn push_quad(
195195
let clip_coverage_rect = surface
196196
.map_to_device_rect(&clip_chain.pic_coverage_rect, frame_context.spatial_tree);
197197

198-
surface.map_local_to_surface.set_target_spatial_node(
198+
surface.map_local_to_picture.set_target_spatial_node(
199199
prim_spatial_node_index,
200200
frame_context.spatial_tree,
201201
);
202202

203-
let Some(pic_rect) = surface.map_local_to_surface.map(local_rect) else { return };
203+
let Some(pic_rect) = surface.map_local_to_picture.map(local_rect) else { return };
204204

205205
let unclipped_surface_rect = surface.map_to_device_rect(
206206
&pic_rect, frame_context.spatial_tree
@@ -321,7 +321,7 @@ pub fn push_quad(
321321
}
322322

323323
if !scratch.quad_direct_segments.is_empty() {
324-
let local_to_device = map_prim_to_surface.as_2d_scale_offset()
324+
let local_to_device = map_prim_to_raster.as_2d_scale_offset()
325325
.expect("bug: nine-patch segments should be axis-aligned only")
326326
.scale(device_pixel_scale.0);
327327

0 commit comments

Comments
 (0)