Bug 1621758 - Fix occlusion rect of clipped compositor surfaces. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D66506

--HG--
extra : moz-landing-system : lando
This commit is contained in:
dev 2020-03-12 19:41:26 +00:00
Родитель 7e310ead8f
Коммит fbdb469ea6
6 изменённых файлов: 42 добавлений и 12 удалений

Просмотреть файл

@ -94,6 +94,7 @@ pub struct ExternalSurfaceDescriptor {
pub local_rect: PictureRect,
pub world_rect: WorldRect,
pub device_rect: DeviceRect,
pub local_clip_rect: PictureRect,
pub clip_rect: DeviceRect,
pub image_dependencies: [ImageDependency; 3],
pub image_rendering: ImageRendering,

Просмотреть файл

@ -3175,6 +3175,7 @@ impl TileCacheInstance {
self.external_surfaces.push(ExternalSurfaceDescriptor {
local_rect: prim_info.prim_clip_rect,
world_rect,
local_clip_rect: prim_info.prim_clip_rect,
image_dependencies,
image_rendering: prim_data.kind.image_rendering,
device_rect,
@ -3370,6 +3371,13 @@ impl TileCacheInstance {
};
}
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
);
// Register the opaque region of this tile cache as an occluder, which
// is used later in the frame to occlude other tiles.
if self.backdrop.rect.is_well_formed_and_nonempty() {
@ -3380,13 +3388,6 @@ impl TileCacheInstance {
});
if let Some(backdrop_rect) = backdrop_rect {
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
);
let world_backdrop_rect = map_pic_to_world
.map(&backdrop_rect)
.expect("bug: unable to map backdrop to world space");
@ -3405,11 +3406,23 @@ impl TileCacheInstance {
// able to occlude every background tile (avoiding allocation, rasterizion
// and compositing).
for external_surface in &self.external_surfaces {
let local_surface_rect = external_surface.local_rect
.intersection(&external_surface.local_clip_rect)
.and_then(|r| {
r.intersection(&self.local_clip_rect)
});
if let Some(local_surface_rect) = local_surface_rect {
let world_surface_rect = map_pic_to_world
.map(&local_surface_rect)
.expect("bug: unable to map external surface to world space");
frame_state.composite_state.register_occluder(
external_surface.z_id,
external_surface.world_rect,
world_surface_rect,
);
}
}
// A simple GC of the native external surface cache, to remove and free any
// surfaces that were not referenced during the update_prim_dependencies pass.

Двоичные данные
gfx/wr/wrench/reftests/image/occlusion.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 48 KiB

Просмотреть файл

@ -0,0 +1,15 @@
# Ensure that the clip rect of a primitive that is promoted to a compositor
# surface is correctly applied when registering it as an occlusion plane.
root:
items:
- type: rect
color: red
bounds: [50, 50, 200, 200]
- type: yuv-image
format: interleaved
src: spacex-yuv.png
bounds: [50, 50, 200, 200]
prefer-compositor-surface: true
clip-rect: [75, 75, 150, 150]

Просмотреть файл

@ -9,3 +9,4 @@ platform(linux,mac) == yuv.yaml yuv.png
skip_on(android,device) == tiled-clip-chain.yaml tiled-clip-chain-ref.yaml
skip_on(android,device) == tiled-complex-clip.yaml tiled-complex-clip-ref.yaml
platform(linux,mac) == texture-rect.yaml texture-rect-ref.yaml
platform(linux) == occlusion.yaml occlusion.png

Просмотреть файл

@ -10,7 +10,7 @@ platform(linux,mac) == rounded-corners.yaml rounded-corners.png
platform(linux,mac) fuzzy(1,17500) color_targets(3) alpha_targets(1) == mask-atomicity.yaml mask-atomicity-ref.yaml
platform(linux,mac) fuzzy(1,17500) == mask-atomicity-tiling.yaml mask-atomicity-ref.yaml
platform(linux,mac) == mask-perspective.yaml mask-perspective.png
== fuzzy(1,7) mask-perspective-tiling.yaml mask-perspective.yaml
== fuzzy(1,11) mask-perspective-tiling.yaml mask-perspective.yaml
platform(linux,mac) == checkerboard.yaml checkerboard.png
skip_on(android,device) == checkerboard.yaml checkerboard-tiling.yaml # Fails on a Pixel2
== missing-mask.yaml missing-mask-ref.yaml