Skip to content

Commit

Permalink
Bug 1697346 - Remove snapping of inflated surface rects. r=aosmond,gf…
Browse files Browse the repository at this point in the history
…x-reviewers

When an offscreen surface establishes a raster root, this code
was causing incorrect snapping / rounded (even on non-inflated
surfaces), resulting in test failures in some cases.

In theory, this should not be necessary, since scroll offsets are
snapped, and primitives are already snapped during scene building.
Additionally, the picture surface allocation code expects surfaces
with fractional offsets and handles this case (by rounding out the
allocation size, and creating a UV set that samples from the subpixel
offsets of the surface).

In practice, there may be content that relies on this which isn't
tested by CI, so let's land this as a separate patch and see if it
causes any real-world content regressions, before landing the
changes that rely on this.

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

[ghsync] From https://hg.mozilla.org/mozilla-central/rev/7647c3e90bedc40aca04283df9c74ec9da52ef18
  • Loading branch information
Glenn Watson committed Mar 11, 2021
1 parent 43ec2c3 commit 8ad8c25
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 31 deletions.
17 changes: 1 addition & 16 deletions webrender/src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ use crate::render_task::{BlurTask, RenderTask, RenderTaskLocation, BlurTaskCache
use crate::render_task::{StaticRenderTaskSurface, RenderTaskKind};
use crate::renderer::BlendMode;
use crate::resource_cache::{ResourceCache, ImageGeneration, ImageRequest};
use crate::space::{SpaceMapper, SpaceSnapper};
use crate::space::SpaceMapper;
use crate::scene::SceneProperties;
use smallvec::SmallVec;
use std::{mem, u8, marker, u32};
Expand Down Expand Up @@ -6247,23 +6247,8 @@ impl PicturePrimitive {
if let Some(ref mut raster_config) = self.raster_config {
let surface = state.current_surface_mut();
// Inflate the local bounding rect if required by the filter effect.
// This inflaction factor is to be applied to the surface itself.
if self.options.inflate_if_required {
surface.rect = raster_config.composite_mode.inflate_picture_rect(surface.rect, surface.scale_factors);

// The picture's local rect is calculated as the union of the
// snapped primitive rects, which should result in a snapped
// local rect, unless it was inflated. This is also done during
// update visibility when calculating the picture's precise
// local rect.
let snap_surface_to_raster = SpaceSnapper::new_with_target(
surface.raster_spatial_node_index,
self.spatial_node_index,
surface.device_pixel_scale,
frame_context.spatial_tree,
);

surface.rect = snap_surface_to_raster.snap_rect(&surface.rect);
}

let mut surface_rect = surface.rect * Scale::new(1.0);
Expand Down
16 changes: 1 addition & 15 deletions webrender/src/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::prim_store::{PrimitiveStore, PrimitiveInstance};
use crate::render_backend::{DataStores, ScratchBuffer};
use crate::resource_cache::ResourceCache;
use crate::scene::SceneProperties;
use crate::space::{SpaceMapper, SpaceSnapper};
use crate::space::SpaceMapper;
use crate::internal_types::Filter;
use crate::util::{MaxRect};

Expand Down Expand Up @@ -626,22 +626,8 @@ pub fn update_primitive_visibility(
// remove this invalidation here completely.
if let Some(ref rc) = pic.raster_config {
// Inflate the local bounding rect if required by the filter effect.
// This inflaction factor is to be applied to the surface itstore.
if pic.options.inflate_if_required {
// The picture's local rect is calculated as the union of the
// snapped primitive rects, which should result in a snapped
// local rect, unless it was inflated. This is also done during
// surface configuration when calculating the picture's
// estimated local rect.
let snap_pic_to_raster = SpaceSnapper::new_with_target(
surface.raster_spatial_node_index,
pic.spatial_node_index,
surface.device_pixel_scale,
frame_context.spatial_tree,
);

surface_rect = rc.composite_mode.inflate_picture_rect(surface_rect, surface.scale_factors);
surface_rect = snap_pic_to_raster.snap_rect(&surface_rect);
}

// Layout space for the picture is picture space from the
Expand Down
Binary file modified wrench/reftests/filters/filter-drop-shadow-clip-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions wrench/reftests/snap/reftest.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
platform(linux,mac) == snap.yaml snap.png
== transform.yaml transform.png
platform(linux,mac) == preserve-3d.yaml preserve-3d.png
fuzzy(128,200) == subpixel-raster-root.yaml subpixel-raster-root-ref.yaml
7 changes: 7 additions & 0 deletions wrench/reftests/snap/subpixel-raster-root-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
root:
items:
-
bounds: [0, 111, 200, 1]
type: rect
color: green
13 changes: 13 additions & 0 deletions wrench/reftests/snap/subpixel-raster-root.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Verify that we don't incorrectly snap surface rects with fractional pixel offsets
---
root:
items:
-
type: "stacking-context"
transform: translate(0, 100.5, 0)
transform-style: preserve-3d
items:
-
bounds: [0, 10.5, 200, 1]
type: rect
color: green
Binary file modified wrench/reftests/split/same-plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wrench/reftests/transforms/coord-system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wrench/reftests/transforms/perspective-clip-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wrench/reftests/transforms/perspective-origin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wrench/reftests/transforms/perspective.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified wrench/reftests/transforms/screen-space-blit-trivial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8ad8c25

Please sign in to comment.