From 6cd2ae615b291c6598cf261fbd3ee2fc46edcc07 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 17 Jul 2023 23:52:06 +0000 Subject: [PATCH] Bug 1843622 - Better fix / workaround for invalid scale in ScaleOffset r=gfx-reviewers,lsalzman Differential Revision: https://phabricator.services.mozilla.com/D183698 --- gfx/tests/crashtests/1843622.html | 11 +++++++++++ gfx/tests/crashtests/crashtests.list | 1 + gfx/wr/webrender/src/util.rs | 9 ++++----- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 gfx/tests/crashtests/1843622.html diff --git a/gfx/tests/crashtests/1843622.html b/gfx/tests/crashtests/1843622.html new file mode 100644 index 000000000000..900a8e040a1a --- /dev/null +++ b/gfx/tests/crashtests/1843622.html @@ -0,0 +1,11 @@ + + + diff --git a/gfx/tests/crashtests/crashtests.list b/gfx/tests/crashtests/crashtests.list index 09e92b9cc284..d3c9efef11d5 100644 --- a/gfx/tests/crashtests/crashtests.list +++ b/gfx/tests/crashtests/crashtests.list @@ -227,4 +227,5 @@ load 1802382-1.html load 1808830.html load 1825450.html load 1683679.html +load 1843622.html diff --git a/gfx/wr/webrender/src/util.rs b/gfx/wr/webrender/src/util.rs index 727e444cc779..9b161313279f 100644 --- a/gfx/wr/webrender/src/util.rs +++ b/gfx/wr/webrender/src/util.rs @@ -197,13 +197,12 @@ impl ScaleOffset { } pub fn inverse(&self) -> Self { - // If either of the scale factors is 0, all we can do is - // return identity. + // If either of the scale factors is 0, inverse also has scale 0 // TODO(gw): Consider making this return Option in future // so that callers can detect and handle when inverse // fails here. if self.scale.x.approx_eq(&0.0) || self.scale.y.approx_eq(&0.0) { - return ScaleOffset::identity(); + return ScaleOffset::new(0.0, 0.0, 0.0, 0.0); } ScaleOffset { @@ -867,11 +866,11 @@ pub mod test { fn scale_offset_invalid_scale() { let s0 = ScaleOffset::new(0.0, 1.0, 10.0, 20.0); let i0 = s0.inverse(); - assert_eq!(i0, ScaleOffset::identity()); + assert_eq!(i0, ScaleOffset::new(0.0, 0.0, 0.0, 0.0)); let s1 = ScaleOffset::new(1.0, 0.0, 10.0, 20.0); let i1 = s1.inverse(); - assert_eq!(i1, ScaleOffset::identity()); + assert_eq!(i1, ScaleOffset::new(0.0, 0.0, 0.0, 0.0)); } #[test]