forked from mirrors/gecko-dev
Bug 1898460 - Disambiguate some of the usage of 'surface' in coordinate spaces (Part 2). r=gw
Differential Revision: https://phabricator.services.mozilla.com/D211389
This commit is contained in:
parent
32537385b5
commit
309c5e0a36
3 changed files with 50 additions and 50 deletions
|
|
@ -521,9 +521,9 @@ impl Default for CompositeStatePreallocator {
|
||||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||||
pub struct CompositorTransform {
|
pub struct CompositorTransform {
|
||||||
// Map from local rect of a composite tile to the real backing surface coords
|
// Map from local rect of a composite tile to the real backing surface coords
|
||||||
local_to_surface: ScaleOffset,
|
local_to_raster: ScaleOffset,
|
||||||
// Map from surface coords to the final device space position
|
// Map from surface coords to the final device space position
|
||||||
surface_to_device: ScaleOffset,
|
raster_to_device: ScaleOffset,
|
||||||
// Combined local -> surface -> device transform
|
// Combined local -> surface -> device transform
|
||||||
local_to_device: ScaleOffset,
|
local_to_device: ScaleOffset,
|
||||||
}
|
}
|
||||||
|
|
@ -590,16 +590,16 @@ impl CompositeState {
|
||||||
/// Register use of a transform for a picture cache tile or external surface
|
/// Register use of a transform for a picture cache tile or external surface
|
||||||
pub fn register_transform(
|
pub fn register_transform(
|
||||||
&mut self,
|
&mut self,
|
||||||
local_to_surface: ScaleOffset,
|
local_to_raster: ScaleOffset,
|
||||||
surface_to_device: ScaleOffset,
|
raster_to_device: ScaleOffset,
|
||||||
) -> CompositorTransformIndex {
|
) -> CompositorTransformIndex {
|
||||||
let index = CompositorTransformIndex(self.transforms.len());
|
let index = CompositorTransformIndex(self.transforms.len());
|
||||||
|
|
||||||
let local_to_device = local_to_surface.accumulate(&surface_to_device);
|
let local_to_device = local_to_raster.accumulate(&raster_to_device);
|
||||||
|
|
||||||
self.transforms.push(CompositorTransform {
|
self.transforms.push(CompositorTransform {
|
||||||
local_to_surface,
|
local_to_raster,
|
||||||
surface_to_device,
|
raster_to_device,
|
||||||
local_to_device,
|
local_to_device,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -626,8 +626,8 @@ impl CompositeState {
|
||||||
) -> DeviceRect {
|
) -> DeviceRect {
|
||||||
let transform = &self.transforms[transform_index.0];
|
let transform = &self.transforms[transform_index.0];
|
||||||
|
|
||||||
let surface_bounds = transform.local_to_surface.map_rect(&local_bounds);
|
let surface_bounds = transform.local_to_raster.map_rect(&local_bounds);
|
||||||
let surface_rect = transform.local_to_surface.map_rect(&local_sub_rect);
|
let surface_rect = transform.local_to_raster.map_rect(&local_sub_rect);
|
||||||
|
|
||||||
surface_rect
|
surface_rect
|
||||||
.round_out()
|
.round_out()
|
||||||
|
|
@ -652,7 +652,7 @@ impl CompositeState {
|
||||||
transform_index: CompositorTransformIndex,
|
transform_index: CompositorTransformIndex,
|
||||||
) -> ScaleOffset {
|
) -> ScaleOffset {
|
||||||
let transform = &self.transforms[transform_index.0];
|
let transform = &self.transforms[transform_index.0];
|
||||||
transform.surface_to_device
|
transform.raster_to_device
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register an occluder during picture cache updates that can be
|
/// Register an occluder during picture cache updates that can be
|
||||||
|
|
|
||||||
|
|
@ -1829,12 +1829,12 @@ pub struct TileCacheInstance {
|
||||||
frame_id: FrameId,
|
frame_id: FrameId,
|
||||||
/// Registered transform in CompositeState for this picture cache
|
/// Registered transform in CompositeState for this picture cache
|
||||||
pub transform_index: CompositorTransformIndex,
|
pub transform_index: CompositorTransformIndex,
|
||||||
/// Current transform mapping local picture space to compositor surface space
|
/// Current transform mapping local picture space to compositor surface raster space
|
||||||
local_to_surface: ScaleOffset,
|
local_to_raster: ScaleOffset,
|
||||||
|
/// Current transform mapping compositor surface raster space to final device space
|
||||||
|
raster_to_device: ScaleOffset,
|
||||||
/// If true, we need to invalidate all tiles during `post_update`
|
/// If true, we need to invalidate all tiles during `post_update`
|
||||||
invalidate_all_tiles: bool,
|
invalidate_all_tiles: bool,
|
||||||
/// Current transform mapping compositor surface space to final device space
|
|
||||||
surface_to_device: ScaleOffset,
|
|
||||||
/// The current raster scale for tiles in this cache
|
/// The current raster scale for tiles in this cache
|
||||||
current_raster_scale: f32,
|
current_raster_scale: f32,
|
||||||
/// Depth of off-screen surfaces that are currently pushed during dependency updates
|
/// Depth of off-screen surfaces that are currently pushed during dependency updates
|
||||||
|
|
@ -1903,8 +1903,8 @@ impl TileCacheInstance {
|
||||||
external_native_surface_cache: FastHashMap::default(),
|
external_native_surface_cache: FastHashMap::default(),
|
||||||
frame_id: FrameId::INVALID,
|
frame_id: FrameId::INVALID,
|
||||||
transform_index: CompositorTransformIndex::INVALID,
|
transform_index: CompositorTransformIndex::INVALID,
|
||||||
surface_to_device: ScaleOffset::identity(),
|
raster_to_device: ScaleOffset::identity(),
|
||||||
local_to_surface: ScaleOffset::identity(),
|
local_to_raster: ScaleOffset::identity(),
|
||||||
invalidate_all_tiles: true,
|
invalidate_all_tiles: true,
|
||||||
current_raster_scale: 1.0,
|
current_raster_scale: 1.0,
|
||||||
current_surface_traversal_depth: 0,
|
current_surface_traversal_depth: 0,
|
||||||
|
|
@ -2189,29 +2189,29 @@ impl TileCacheInstance {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the compositor transform, which depends on pinch-zoom mode
|
// Get the compositor transform, which depends on pinch-zoom mode
|
||||||
let mut surface_to_device = local_to_device;
|
let mut raster_to_device = local_to_device;
|
||||||
|
|
||||||
if frame_context.config.low_quality_pinch_zoom {
|
if frame_context.config.low_quality_pinch_zoom {
|
||||||
surface_to_device.scale.x /= self.current_raster_scale;
|
raster_to_device.scale.x /= self.current_raster_scale;
|
||||||
surface_to_device.scale.y /= self.current_raster_scale;
|
raster_to_device.scale.y /= self.current_raster_scale;
|
||||||
} else {
|
} else {
|
||||||
surface_to_device.scale.x = 1.0;
|
raster_to_device.scale.x = 1.0;
|
||||||
surface_to_device.scale.y = 1.0;
|
raster_to_device.scale.y = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use that compositor transform to calculate a relative local to surface
|
// Use that compositor transform to calculate a relative local to surface
|
||||||
let local_to_surface = local_to_device.accumulate(&surface_to_device.inverse());
|
let local_to_raster = local_to_device.accumulate(&raster_to_device.inverse());
|
||||||
|
|
||||||
const EPSILON: f32 = 0.001;
|
const EPSILON: f32 = 0.001;
|
||||||
let compositor_translation_changed =
|
let compositor_translation_changed =
|
||||||
!surface_to_device.offset.x.approx_eq_eps(&self.surface_to_device.offset.x, &EPSILON) ||
|
!raster_to_device.offset.x.approx_eq_eps(&self.raster_to_device.offset.x, &EPSILON) ||
|
||||||
!surface_to_device.offset.y.approx_eq_eps(&self.surface_to_device.offset.y, &EPSILON);
|
!raster_to_device.offset.y.approx_eq_eps(&self.raster_to_device.offset.y, &EPSILON);
|
||||||
let compositor_scale_changed =
|
let compositor_scale_changed =
|
||||||
!surface_to_device.scale.x.approx_eq_eps(&self.surface_to_device.scale.x, &EPSILON) ||
|
!raster_to_device.scale.x.approx_eq_eps(&self.raster_to_device.scale.x, &EPSILON) ||
|
||||||
!surface_to_device.scale.y.approx_eq_eps(&self.surface_to_device.scale.y, &EPSILON);
|
!raster_to_device.scale.y.approx_eq_eps(&self.raster_to_device.scale.y, &EPSILON);
|
||||||
let surface_scale_changed =
|
let surface_scale_changed =
|
||||||
!local_to_surface.scale.x.approx_eq_eps(&self.local_to_surface.scale.x, &EPSILON) ||
|
!local_to_raster.scale.x.approx_eq_eps(&self.local_to_raster.scale.x, &EPSILON) ||
|
||||||
!local_to_surface.scale.y.approx_eq_eps(&self.local_to_surface.scale.y, &EPSILON);
|
!local_to_raster.scale.y.approx_eq_eps(&self.local_to_raster.scale.y, &EPSILON);
|
||||||
|
|
||||||
if compositor_translation_changed ||
|
if compositor_translation_changed ||
|
||||||
compositor_scale_changed ||
|
compositor_scale_changed ||
|
||||||
|
|
@ -2220,8 +2220,8 @@ impl TileCacheInstance {
|
||||||
frame_state.composite_state.dirty_rects_are_valid = false;
|
frame_state.composite_state.dirty_rects_are_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.surface_to_device = surface_to_device;
|
self.raster_to_device = raster_to_device;
|
||||||
self.local_to_surface = local_to_surface;
|
self.local_to_raster = local_to_raster;
|
||||||
self.invalidate_all_tiles = surface_scale_changed || frame_context.config.force_invalidation;
|
self.invalidate_all_tiles = surface_scale_changed || frame_context.config.force_invalidation;
|
||||||
|
|
||||||
// Do a hacky diff of opacity binding values from the last frame. This is
|
// Do a hacky diff of opacity binding values from the last frame. This is
|
||||||
|
|
@ -2264,8 +2264,8 @@ impl TileCacheInstance {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.tile_size = PictureSize::new(
|
self.tile_size = PictureSize::new(
|
||||||
world_tile_size.width / self.local_to_surface.scale.x,
|
world_tile_size.width / self.local_to_raster.scale.x,
|
||||||
world_tile_size.height / self.local_to_surface.scale.y,
|
world_tile_size.height / self.local_to_raster.scale.y,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Inflate the needed rect a bit, so that we retain tiles that we have drawn
|
// Inflate the needed rect a bit, so that we retain tiles that we have drawn
|
||||||
|
|
@ -2698,8 +2698,8 @@ impl TileCacheInstance {
|
||||||
|
|
||||||
let normalized_prim_to_device = prim_offset.accumulate(&local_prim_to_device);
|
let normalized_prim_to_device = prim_offset.accumulate(&local_prim_to_device);
|
||||||
|
|
||||||
let local_to_surface = ScaleOffset::identity();
|
let local_to_raster = ScaleOffset::identity();
|
||||||
let surface_to_device = normalized_prim_to_device;
|
let raster_to_device = normalized_prim_to_device;
|
||||||
|
|
||||||
// If this primitive is an external image, and supports being used
|
// If this primitive is an external image, and supports being used
|
||||||
// directly by a native compositor, then lookup the external image id
|
// directly by a native compositor, then lookup the external image id
|
||||||
|
|
@ -2717,14 +2717,14 @@ impl TileCacheInstance {
|
||||||
if let CompositorKind::Native { capabilities, .. } = composite_state.compositor_kind {
|
if let CompositorKind::Native { capabilities, .. } = composite_state.compositor_kind {
|
||||||
if external_image_id.is_some() &&
|
if external_image_id.is_some() &&
|
||||||
!capabilities.supports_external_compositor_surface_negative_scaling &&
|
!capabilities.supports_external_compositor_surface_negative_scaling &&
|
||||||
(surface_to_device.scale.x < 0.0 || surface_to_device.scale.y < 0.0) {
|
(raster_to_device.scale.x < 0.0 || raster_to_device.scale.y < 0.0) {
|
||||||
external_image_id = None;
|
external_image_id = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let compositor_transform_index = composite_state.register_transform(
|
let compositor_transform_index = composite_state.register_transform(
|
||||||
local_to_surface,
|
local_to_raster,
|
||||||
surface_to_device,
|
raster_to_device,
|
||||||
);
|
);
|
||||||
|
|
||||||
let surface_size = composite_state.get_surface_rect(
|
let surface_size = composite_state.get_surface_rect(
|
||||||
|
|
@ -2957,17 +2957,17 @@ impl TileCacheInstance {
|
||||||
|
|
||||||
// If the primitive is directly drawn onto this picture cache surface, then
|
// If the primitive is directly drawn onto this picture cache surface, then
|
||||||
// the pic_coverage_rect is in the same space. If not, we need to map it from
|
// the pic_coverage_rect is in the same space. If not, we need to map it from
|
||||||
// the surface space into the picture cache space.
|
// the intermediate picture space into the picture cache space.
|
||||||
let on_picture_surface = prim_surface_index == self.surface_index;
|
let on_picture_surface = prim_surface_index == self.surface_index;
|
||||||
let pic_coverage_rect = if on_picture_surface {
|
let pic_coverage_rect = if on_picture_surface {
|
||||||
prim_clip_chain.pic_coverage_rect
|
prim_clip_chain.pic_coverage_rect
|
||||||
} else {
|
} else {
|
||||||
// We want to get the rect in the tile cache surface space that this primitive
|
// We want to get the rect in the tile cache picture space that this primitive
|
||||||
// occupies, in order to enable correct invalidation regions. Each surface
|
// occupies, in order to enable correct invalidation regions. Each surface
|
||||||
// that exists in the chain between this primitive and the tile cache surface
|
// that exists in the chain between this primitive and the tile cache surface
|
||||||
// may have an arbitrary inflation factor (for example, in the case of a series
|
// may have an arbitrary inflation factor (for example, in the case of a series
|
||||||
// of nested blur elements). To account for this, step through the current
|
// of nested blur elements). To account for this, step through the current
|
||||||
// surface stack, mapping the primitive rect into each surface space, including
|
// surface stack, mapping the primitive rect into each picture space, including
|
||||||
// the inflation factor from each intermediate surface.
|
// the inflation factor from each intermediate surface.
|
||||||
let mut current_pic_coverage_rect = prim_clip_chain.pic_coverage_rect;
|
let mut current_pic_coverage_rect = prim_clip_chain.pic_coverage_rect;
|
||||||
let mut current_spatial_node_index = surfaces[prim_surface_index.0]
|
let mut current_spatial_node_index = surfaces[prim_surface_index.0]
|
||||||
|
|
@ -2977,7 +2977,7 @@ impl TileCacheInstance {
|
||||||
let surface = &surfaces[surface_index.0];
|
let surface = &surfaces[surface_index.0];
|
||||||
let pic = &pictures[pic_index.0];
|
let pic = &pictures[pic_index.0];
|
||||||
|
|
||||||
let map_local_to_picture = SpaceMapper::new_with_target(
|
let map_local_to_parent = SpaceMapper::new_with_target(
|
||||||
surface.surface_spatial_node_index,
|
surface.surface_spatial_node_index,
|
||||||
current_spatial_node_index,
|
current_spatial_node_index,
|
||||||
surface.unclipped_local_rect,
|
surface.unclipped_local_rect,
|
||||||
|
|
@ -2987,7 +2987,7 @@ impl TileCacheInstance {
|
||||||
// Map the rect into the parent surface, and inflate if this surface requires
|
// Map the rect into the parent surface, and inflate if this surface requires
|
||||||
// it. If the rect can't be mapping (e.g. due to an invalid transform) then
|
// it. If the rect can't be mapping (e.g. due to an invalid transform) then
|
||||||
// just bail out from the dependencies and cull this primitive.
|
// just bail out from the dependencies and cull this primitive.
|
||||||
current_pic_coverage_rect = match map_local_to_picture.map(¤t_pic_coverage_rect) {
|
current_pic_coverage_rect = match map_local_to_parent.map(¤t_pic_coverage_rect) {
|
||||||
Some(rect) => {
|
Some(rect) => {
|
||||||
// TODO(gw): The casts here are a hack. We have some interface inconsistencies
|
// TODO(gw): The casts here are a hack. We have some interface inconsistencies
|
||||||
// between layout/picture rects which don't really work with the
|
// between layout/picture rects which don't really work with the
|
||||||
|
|
@ -3638,10 +3638,10 @@ impl TileCacheInstance {
|
||||||
self.subpixel_mode = self.calculate_subpixel_mode();
|
self.subpixel_mode = self.calculate_subpixel_mode();
|
||||||
|
|
||||||
self.transform_index = frame_state.composite_state.register_transform(
|
self.transform_index = frame_state.composite_state.register_transform(
|
||||||
self.local_to_surface,
|
self.local_to_raster,
|
||||||
// TODO(gw): Once we support scaling of picture cache tiles during compositing,
|
// TODO(gw): Once we support scaling of picture cache tiles during compositing,
|
||||||
// that transform gets plugged in here!
|
// that transform gets plugged in here!
|
||||||
self.surface_to_device,
|
self.raster_to_device,
|
||||||
);
|
);
|
||||||
|
|
||||||
let map_pic_to_world = SpaceMapper::new_with_target(
|
let map_pic_to_world = SpaceMapper::new_with_target(
|
||||||
|
|
@ -3877,10 +3877,10 @@ pub struct SurfaceInfo {
|
||||||
/// Helper structs for mapping local rects in different
|
/// Helper structs for mapping local rects in different
|
||||||
/// coordinate systems into the picture coordinates.
|
/// coordinate systems into the picture coordinates.
|
||||||
pub map_local_to_picture: SpaceMapper<LayoutPixel, PicturePixel>,
|
pub map_local_to_picture: SpaceMapper<LayoutPixel, PicturePixel>,
|
||||||
/// Defines the positioning node for the surface itself,
|
/// The positioning node for the surface itself,
|
||||||
/// and the rasterization root for this surface.
|
|
||||||
pub raster_spatial_node_index: SpatialNodeIndex,
|
|
||||||
pub surface_spatial_node_index: SpatialNodeIndex,
|
pub surface_spatial_node_index: SpatialNodeIndex,
|
||||||
|
/// The rasterization root for this surface.
|
||||||
|
pub raster_spatial_node_index: SpatialNodeIndex,
|
||||||
/// The device pixel ratio specific to this surface.
|
/// The device pixel ratio specific to this surface.
|
||||||
pub device_pixel_scale: DevicePixelScale,
|
pub device_pixel_scale: DevicePixelScale,
|
||||||
/// The scale factors of the surface to world transform.
|
/// The scale factors of the surface to world transform.
|
||||||
|
|
|
||||||
|
|
@ -195,12 +195,12 @@ pub fn push_quad(
|
||||||
let clip_coverage_rect = surface
|
let clip_coverage_rect = surface
|
||||||
.map_to_device_rect(&clip_chain.pic_coverage_rect, frame_context.spatial_tree);
|
.map_to_device_rect(&clip_chain.pic_coverage_rect, frame_context.spatial_tree);
|
||||||
|
|
||||||
surface.map_local_to_surface.set_target_spatial_node(
|
surface.map_local_to_picture.set_target_spatial_node(
|
||||||
prim_spatial_node_index,
|
prim_spatial_node_index,
|
||||||
frame_context.spatial_tree,
|
frame_context.spatial_tree,
|
||||||
);
|
);
|
||||||
|
|
||||||
let Some(pic_rect) = surface.map_local_to_surface.map(local_rect) else { return };
|
let Some(pic_rect) = surface.map_local_to_picture.map(local_rect) else { return };
|
||||||
|
|
||||||
let unclipped_surface_rect = surface.map_to_device_rect(
|
let unclipped_surface_rect = surface.map_to_device_rect(
|
||||||
&pic_rect, frame_context.spatial_tree
|
&pic_rect, frame_context.spatial_tree
|
||||||
|
|
@ -321,7 +321,7 @@ pub fn push_quad(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !scratch.quad_direct_segments.is_empty() {
|
if !scratch.quad_direct_segments.is_empty() {
|
||||||
let local_to_device = map_prim_to_surface.as_2d_scale_offset()
|
let local_to_device = map_prim_to_raster.as_2d_scale_offset()
|
||||||
.expect("bug: nine-patch segments should be axis-aligned only")
|
.expect("bug: nine-patch segments should be axis-aligned only")
|
||||||
.scale(device_pixel_scale.0);
|
.scale(device_pixel_scale.0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue