Bug 1453935 - Ensure that we snap within the visible rect with WebRender. r=kvark
authorAndrew Osmond <aosmond@mozilla.com>
Thu, 07 Feb 2019 09:39:30 -0500
changeset 457716 87ad4b91e29fb9025d90ceb89a62b5a4eb7d584a
parent 457578 4e98200ee53017fe8cd037abf948ebaabd33f229
child 457717 6886438cfe00c633c14480173e1747e59319cb1d
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1453935
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453935 - Ensure that we snap within the visible rect with WebRender. r=kvark Differential Revision: https://phabricator.services.mozilla.com/D18869
gfx/wr/webrender/res/prim_shared.glsl
gfx/wr/webrender/src/prim_store/mod.rs
gfx/wr/wrench/reftests/border/reftest.list
gfx/wr/wrench/reftests/boxshadow/reftest.list
gfx/wr/wrench/reftests/transforms/reftest.list
layout/reftests/border-image/reftest.list
layout/reftests/bugs/reftest.list
layout/reftests/css-gradients/reftest.list
layout/reftests/w3c-css/submitted/images3/reftest.list
widget/reftests/reftest.list
--- a/gfx/wr/webrender/res/prim_shared.glsl
+++ b/gfx/wr/webrender/res/prim_shared.glsl
@@ -97,21 +97,25 @@ VertexInfo write_vertex(RectWithSize ins
                         RectWithSize snap_rect) {
 
     // Select the corner of the local rect that we are processing.
     vec2 local_pos = instance_rect.p0 + instance_rect.size * aPosition.xy;
 
     // Clamp to the two local clip rects.
     vec2 clamped_local_pos = clamp_rect(local_pos, local_clip_rect);
 
+    // Compute the visible rect to snap against. This ensures segments along the
+    // edges are snapped consistently with other nearby primitives.
+    RectWithSize visible_rect = intersect_rects(local_clip_rect, snap_rect);
+
     /// Compute the snapping offset.
     vec2 snap_offset = compute_snap_offset(
         clamped_local_pos,
         transform.m,
-        snap_rect,
+        visible_rect,
         task.common_data.device_pixel_scale
     );
 
     // Transform the current vertex to world space.
     vec4 world_pos = transform.m * vec4(clamped_local_pos, 0.0, 1.0);
 
     // Convert the world positions to device pixel space.
     vec2 device_pos = world_pos.xy * task.common_data.device_pixel_scale;
--- a/gfx/wr/webrender/src/prim_store/mod.rs
+++ b/gfx/wr/webrender/src/prim_store/mod.rs
@@ -46,17 +46,17 @@ use resource_cache::{ImageProperties, Im
 use scene::SceneProperties;
 use segment::SegmentBuilder;
 use std::{cmp, fmt, hash, ops, u32, usize, mem};
 #[cfg(debug_assertions)]
 use std::sync::atomic::{AtomicUsize, Ordering};
 use storage;
 use util::{ScaleOffset, MatrixHelpers, MaxRect, Recycler, TransformedRectKind};
 use util::{pack_as_float, project_rect, raster_rect_to_device_pixels};
-use util::{scale_factors, clamp_to_scale_factor, RectHelpers};
+use util::{scale_factors, clamp_to_scale_factor};
 use smallvec::SmallVec;
 
 pub mod borders;
 pub mod gradient;
 pub mod image;
 pub mod line_dec;
 pub mod picture;
 pub mod text_run;
@@ -3530,19 +3530,19 @@ fn compute_snap_offset_impl(
     );
 
     DeviceVector2D::new(
         mix(top_left.x, bottom_right.x, normalized_snap_pos.x),
         mix(top_left.y, bottom_right.y, normalized_snap_pos.y),
     )
 }
 
-/// Retrieve the exact device space rectangle for a primitive, taking
-/// into account the snapping that the shaders will apply if the transform
-/// is axis-aligned.
+/// Retrieve the exact unsnapped device space rectangle for a primitive.
+/// If the transform is axis-aligned, compute the snapping offsets that
+/// the shaders will apply.
 fn get_unclipped_device_rect(
     prim_spatial_node_index: SpatialNodeIndex,
     root_spatial_node_index: SpatialNodeIndex,
     prim_rect: PictureRect,
     map_to_raster: &SpaceMapper<PicturePixel, RasterPixel>,
     device_pixel_scale: DevicePixelScale,
     frame_context: &FrameBuildingContext,
     frame_state: &mut FrameBuildingState,
@@ -3577,21 +3577,17 @@ fn get_unclipped_device_rect(
                 unclipped_device_rect.bottom_right(),
             );
 
             let snap_offsets = SnapOffsets {
                 top_left,
                 bottom_right,
             };
 
-            let p0 = unclipped_device_rect.origin + top_left;
-            let p1 = unclipped_device_rect.bottom_right() + bottom_right;
-            let unclipped = DeviceRect::from_floats(p0.x, p0.y, p1.x, p1.y);
-
-            Some((unclipped, snap_offsets))
+            Some((unclipped_device_rect, snap_offsets))
         }
         TransformedRectKind::Complex => {
             Some((unclipped_device_rect, SnapOffsets::empty()))
         }
     }
 }
 
 /// Given an unclipped device rect, try to find a minimal device space
--- a/gfx/wr/wrench/reftests/border/reftest.list
+++ b/gfx/wr/wrench/reftests/border/reftest.list
@@ -9,17 +9,17 @@ fuzzy(1,68) == border-overlapping.yaml b
 == border-invisible.yaml border-invisible-ref.yaml
 platform(linux,mac) == border-suite.yaml border-suite.png
 platform(linux,mac) fuzzy(8,8) == border-suite-2.yaml border-suite-2.png
 platform(linux,mac) == border-suite-3.yaml border-suite-3.png
 == border-double-simple.yaml border-double-simple-ref.yaml
 == border-double-simple-2.yaml border-double-simple-2-ref.yaml
 fuzzy(64,24) == border-groove-simple.yaml border-groove-simple-ref.yaml
 fuzzy(64,24) == border-ridge-simple.yaml border-ridge-simple-ref.yaml
-platform(linux,mac) fuzzy(1,2) == degenerate-curve.yaml degenerate-curve.png
+platform(linux,mac) fuzzy(1,3) == degenerate-curve.yaml degenerate-curve.png
 platform(linux,mac) == border-image.yaml border-image-ref.png
 == border-image-crash.yaml border-image-crash-ref.yaml
 == border-image-fill.yaml border-image-fill-ref.png
 == border-no-bogus-line.yaml border-no-bogus-line-ref.png
 platform(linux,mac) == dotted-corner-small-radius.yaml dotted-corner-small-radius.png
 == overlapping.yaml overlapping.png
 == zero-width.yaml blank.yaml
 platform(linux,mac) == small-dotted-border.yaml small-dotted-border.png
--- a/gfx/wr/wrench/reftests/boxshadow/reftest.list
+++ b/gfx/wr/wrench/reftests/boxshadow/reftest.list
@@ -29,9 +29,9 @@ platform(linux,mac) fuzzy(1,9) == box-sh
 platform(linux,mac) fuzzy(1,41) == box-shadow-stretch-mode-y.yaml box-shadow-stretch-mode-y.png
 platform(linux,mac) fuzzy(1,14) == inset-mask-region.yaml inset-mask-region.png
 == box-shadow-blurred-overlapping-radii.yaml box-shadow-blurred-overlapping-radii-ref.yaml
 
 fuzzy(1,5) platform(linux,mac) == box-shadow-huge-radius.yaml box-shadow-huge-radius.png
 
 platform(linux,mac) == box-shadow-large-blur-radius-2.yaml box-shadow-large-blur-radius-2.png
 platform(linux,mac) == box-shadow-large-blur-radius-3.yaml box-shadow-large-blur-radius-3.png
-platform(linux,mac) == scale.yaml scale.png
+platform(linux,mac) fuzzy(1,79) == scale.yaml scale.png
--- a/gfx/wr/wrench/reftests/transforms/reftest.list
+++ b/gfx/wr/wrench/reftests/transforms/reftest.list
@@ -20,17 +20,17 @@ platform(linux,mac) == nested-rotate-x.y
 platform(linux,mac) != nested-rotate-x.yaml nested-rotate-x-flat.yaml
 platform(linux,mac) == nested-rotate-x-flat.yaml nested-rotate-x-flat.png
 platform(linux,mac) == nested-preserve-3d.yaml nested-preserve-3d.png
 platform(linux,mac) fuzzy(1,283) == near-plane-clip.yaml near-plane-clip.png
 platform(linux,mac) == perspective-mask.yaml perspective-mask.png
 rotate-clip.yaml rotate-clip-ref.yaml
 clip-translate.yaml clip-translate-ref.yaml
 platform(linux,mac) == perspective-clip.yaml perspective-clip.png
-platform(linux,mac) == perspective-clip-1.yaml perspective-clip-1.png
+platform(linux,mac) fuzzy(1,2) == perspective-clip-1.yaml perspective-clip-1.png
 platform(linux,mac) fuzzy(1,2) == perspective-shadow.yaml perspective-shadow.png
 == complex-preserve-3d.yaml blank.yaml
 platform(linux,mac) fuzzy(9,348) == perspective-border-radius.yaml perspective-border-radius.png
 == snapped-preserve-3d.yaml snapped-preserve-3d-ref.yaml
 platform(linux,mac) fuzzy(1,122) == border-scale.yaml border-scale.png
 platform(linux,mac) fuzzy(1,16) == border-scale-2.yaml border-scale-2.png
 platform(linux,mac) fuzzy(1,69) == border-scale-3.yaml border-scale-3.png
 platform(linux,mac) fuzzy(1,74) == border-scale-4.yaml border-scale-4.png
--- a/layout/reftests/border-image/reftest.list
+++ b/layout/reftests/border-image/reftest.list
@@ -43,24 +43,24 @@ fuzzy-if(asyncPan&&!layersGPUAccelerated
 
 # border images with gradients
 fuzzy-if(webrender,1-3,1488-1804) == border-image-linear-gradient.html border-image-linear-gradient-ref.html
 fuzzy(0-1,0-98) fuzzy-if(skiaContent,0-1,0-350) fuzzy-if(webrender,1-2,37066-37537) == border-image-linear-gradient-slice-1.html border-image-linear-gradient-slice-1-ref.html
 fuzzy(0-1,0-149) fuzzy-if(OSX,0-1,0-10595) fuzzy-if(webrender,1-3,24999-25136) == border-image-linear-gradient-slice-2.html border-image-linear-gradient-slice-2-ref.html
 fuzzy(0-1,0-433) fuzzy-if(skiaContent,0-1,0-2500) fuzzy-if(webrender,1-3,84138-85584) == border-image-linear-gradient-slice-fill-1.html border-image-linear-gradient-slice-fill-1-ref.html
 fuzzy(0-1,0-177) fuzzy-if(OSX,0-1,0-25771) fuzzy-if(skiaContent&&!Android,0-1,0-400) fuzzy-if(Android,0-1,0-6093) fuzzy-if(webrender,1-3,57249-57464) == border-image-linear-gradient-slice-fill-2.html border-image-linear-gradient-slice-fill-2-ref.html
 fuzzy(0-1,0-48)  fuzzy-if(OSX,0-5,0-1676) fuzzy-if(webrender,1-1,4464-4537) == border-image-linear-gradient-width.html border-image-linear-gradient-width-ref.html
-fuzzy(0-1,0-5000) fuzzy-if(OSX,0-1,0-15000) fuzzy-if(webrender,2-2,58629-58936) == border-image-linear-gradient-slice-width.html border-image-linear-gradient-slice-width-ref.html
-fuzzy(0-1,0-3000) fuzzy-if(OSX,0-1,0-6000) fuzzy-if(webrender,1-3,26067-26413) == border-image-linear-gradient-outset.html border-image-linear-gradient-outset-ref.html
+fuzzy(0-1,0-5000) fuzzy-if(OSX,0-1,0-15000) fuzzy-if(webrender,2-2,58629-58939) == border-image-linear-gradient-slice-width.html border-image-linear-gradient-slice-width-ref.html
+fuzzy(0-1,0-3000) fuzzy-if(OSX,0-1,0-6000) fuzzy-if(webrender,1-3,25940-26413) == border-image-linear-gradient-outset.html border-image-linear-gradient-outset-ref.html
 fuzzy(0-1,0-12) fuzzy-if(skiaContent,0-1,0-400) fuzzy-if(webrender,1-3,26195-26872) == border-image-linear-gradient-repeat-repeat-1.html border-image-linear-gradient-repeat-repeat-1-ref.html
 fuzzy(0-1,0-13) fuzzy-if(skiaContent,0-1,0-300) fuzzy-if(webrender,1-3,26168-27131) == border-image-linear-gradient-repeat-round-1.html border-image-linear-gradient-repeat-round-1-ref.html
 fuzzy-if(webrender,1-3,64826-67805) == border-image-linear-gradient-repeat-repeat-2.html border-image-linear-gradient-repeat-repeat-2-ref.html
 fuzzy(0-1,0-576) fuzzy-if(skiaContent,0-1,0-2000) fuzzy-if(webrender,1-2,64575-68383) == border-image-linear-gradient-repeat-round-2.html border-image-linear-gradient-repeat-round-2-ref.html
 fuzzy(0-1,0-8533) fuzzy-if(webrender,1-3,84604-85925) == border-image-linear-gradient-repeat-repeat-3.html border-image-linear-gradient-repeat-repeat-3-ref.html
-fuzzy(0-1,0-7161) fuzzy-if(webrender,2-3,92540-93290) == border-image-linear-gradient-repeat-round-3.html border-image-linear-gradient-repeat-round-3-ref.html
+fuzzy(0-1,0-7161) fuzzy-if(webrender,1-3,85706-85864) == border-image-linear-gradient-repeat-round-3.html border-image-linear-gradient-repeat-round-3-ref.html
 
 fuzzy-if(webrender,0-1,0-2096) == border-image-radial-gradient.html border-image-radial-gradient-ref.html
 fuzzy(0-1,0-42) fuzzy-if(skiaContent,0-2,0-20) fuzzy-if(webrender,0-1,0-37818) == border-image-radial-gradient-slice-1.html border-image-radial-gradient-slice-1-ref.html
 fuzzy(0-1,0-46) fuzzy-if(OSX,0-2,0-4472) fuzzy-if(webrender,0-1,0-26363) == border-image-radial-gradient-slice-2.html border-image-radial-gradient-slice-2-ref.html
 fuzzy(0-1,0-105) fuzzy-if(webrender,0-1,0-90873) == border-image-radial-gradient-slice-fill-1.html border-image-radial-gradient-slice-fill-1-ref.html
 fuzzy(0-1,0-139) fuzzy-if(OSX,0-2,0-4478) fuzzy-if(skiaContent,0-2,0-120) fuzzy-if(webrender,0-1,0-61729) == border-image-radial-gradient-slice-fill-2.html border-image-radial-gradient-slice-fill-2-ref.html
 fuzzy-if(skiaContent,0-1,0-2) fuzzy-if(webrender,0-1,0-4894) == border-image-radial-gradient-width.html border-image-radial-gradient-width-ref.html
 fuzzy(0-1,0-9000) fuzzy-if(webrender,0-3,0-66698) == border-image-radial-gradient-slice-width.html border-image-radial-gradient-slice-width-ref.html
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -313,17 +313,17 @@ fuzzy-if(Android,0-3,0-50) fuzzy-if(skia
 == 280708-1a.html 280708-1-ref.html
 == 280708-1b.html 280708-1-ref.html
 == 281241-1.html 281241-1-ref.html
 == 281241-2.xhtml 281241-1-ref.html
 == 283686-1.html about:blank
 == 283686-2.html 283686-2-ref.html
 == 283686-3.html about:blank
 == 289384-1.xhtml 289384-ref.xhtml
-fails-if(webrender&&gtkWidget) random-if(d2d) fuzzy-if(webrender&&cocoaWidget,1-2,400-900) fuzzy-if(Android,0-8,0-1439) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 578114 for the d2d failures
+random-if(d2d) fuzzy-if(Android,0-8,0-1439) fuzzy-if(webrender,0-6,0-1124) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 578114 for the d2d failures
 == 290129-1.html 290129-1-ref.html
 == 291078-1.html 291078-1-ref.html
 == 291078-2.html 291078-2-ref.html
 == 291262-1.html 291262-1-ref.html
 == 294306-1.html 294306-1a-ref.html
 != 294306-1.html 294306-1b-ref.html
 == 296361-1.html 296361-ref.html
 == 296904-1.html 296904-1-ref.html
--- a/layout/reftests/css-gradients/reftest.list
+++ b/layout/reftests/css-gradients/reftest.list
@@ -22,17 +22,17 @@ fuzzy-if(winWidget,0-1,0-37800) fuzzy-if
 == linear-stops-1c.html linear-stops-1-ref.html
 == linear-stops-1d.html linear-stops-1-ref.html
 == linear-stops-1e.html linear-stops-1-ref.html
 == linear-stops-1f.html linear-stops-1-ref.html
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-3,0-88500) fuzzy-if(azureSkiaGL||skiaContent,0-3,0-89700) == linear-vertical-1a.html linear-vertical-1-ref.html
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-3,0-88500) fuzzy-if(azureSkiaGL||skiaContent,0-3,0-89700) == linear-vertical-1b.html linear-vertical-1-ref.html
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-3,0-88500) fuzzy-if(azureSkiaGL||skiaContent,0-3,0-89700) == linear-vertical-1c.html linear-vertical-1-ref.html
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-3,0-88500) fuzzy-if(azureSkiaGL||skiaContent,0-3,0-89700) == linear-vertical-1d.html linear-vertical-1-ref.html
-fuzzy-if(webrender&&cocoaWidget,0-1,0-98) == linear-vertical-subpixel-1.html linear-vertical-subpixel-1-ref.html
+fuzzy-if(webrender,0-3,0-21070) == linear-vertical-subpixel-1.html linear-vertical-subpixel-1-ref.html
 == linear-viewport.html linear-viewport-ref.html
 == nostops.html about:blank
 == onestop.html about:blank
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-1,0-5884) fuzzy-if(cocoaWidget,0-9,0-87824) fuzzy-if(azureSkiaGL,0-6,0-88024) random-if(d2d) fuzzy-if(skiaContent,0-4,0-6000) == radial-1a.html radial-1-ref.html
 fuzzy-if(!contentSameGfxBackendAsCanvas,0-1,0-5884) fuzzy-if(cocoaWidget,0-9,0-87824) fuzzy-if(azureSkiaGL,0-6,0-88024) random-if(d2d) fuzzy-if(skiaContent,0-4,0-6000) == radial-1b.html radial-1-ref.html
 fuzzy(0-3,0-7860) fuzzy-if(cocoaWidget,0-5,0-89041) fuzzy-if(azureSkiaGL,0-4,0-90000) == radial-2a.html radial-2-ref.html
 fuzzy(0-3,0-7860) fuzzy-if(cocoaWidget,0-5,0-89041) fuzzy-if(azureSkiaGL,0-4,0-90000) == radial-2b.html radial-2-ref.html
 fuzzy(0-3,0-7860) fuzzy-if(cocoaWidget,0-5,0-89041) fuzzy-if(azureSkiaGL,0-4,0-90000) == radial-2c.html radial-2-ref.html
--- a/layout/reftests/w3c-css/submitted/images3/reftest.list
+++ b/layout/reftests/w3c-css/submitted/images3/reftest.list
@@ -180,15 +180,15 @@ fails-if(!webrender) == object-position-
 == object-position-png-002e.html object-position-png-002-ref.html
 == object-position-png-002i.html object-position-png-002-ref.html
 == object-position-png-002o.html object-position-png-002-ref.html
 == object-position-png-002p.html object-position-png-002-ref.html
 fails-if(!webrender) random-if(webrender) == object-position-svg-001e.html object-position-svg-001-ref.html # bug 1103286
 == object-position-svg-001i.html object-position-svg-001-ref.html
 fails-if(!webrender) random-if(webrender) == object-position-svg-001o.html object-position-svg-001-ref.html # bug 1103286
 == object-position-svg-001p.html object-position-svg-001-ref.html
-fails-if(!webrender) == object-position-svg-002e.html object-position-svg-002-ref.html # bug 1103286
+fails == object-position-svg-002e.html object-position-svg-002-ref.html # bug 1103286
 == object-position-svg-002i.html object-position-svg-002-ref.html
-fails-if(!webrender) == object-position-svg-002o.html object-position-svg-002-ref.html # bug 1103286
+fails == object-position-svg-002o.html object-position-svg-002-ref.html # bug 1103286
 == object-position-svg-002p.html object-position-svg-002-ref.html
 
 # Tests for gradient color stops with 'currentcolor'
 == color-stop-currentcolor.html color-stop-currentcolor-ref.html
--- a/widget/reftests/reftest.list
+++ b/widget/reftests/reftest.list
@@ -1,5 +1,5 @@
 == progressbar-fallback-default-style.html progressbar-fallback-default-style-ref.html
-fuzzy-if(Android,0-17,0-1120) fuzzy-if(webrender&&winWidget,0-1,0-5) == meter-native-style.html meter-native-style-ref.html
+fuzzy-if(Android,0-17,0-1120) fuzzy-if(webrender,0-8,0-480) == meter-native-style.html meter-native-style-ref.html
 skip-if(!cocoaWidget) == meter-vertical-native-style.html meter-vertical-native-style-ref.html # dithering
 == meter-fallback-default-style.html meter-fallback-default-style-ref.html
 load 664925.xhtml