commit ba6969e6d43b9ffd94a81100f394484499e4daa7
parent f40595245bce88ce4b9b72f3556d4ff42e495392
Author: Nicolas Silva <nical@fastmail.com>
Date: Tue, 14 Oct 2025 09:30:55 +0000
Bug 1951113 - Fix quad pattern coordinate adjustment. r=gfx-reviewers,lsalzman
In some cofigurations the quad vertex shader maps its local pattern coordinate back to layout space so that it matches the coordinate space of the pattern's definition. Previously it would break when the transform had a negative scale because the resulting rectangle in the fragment shader would be flipped. This patch addresses that by ensuring that the transformed rectangle properly respects the top-left bottom-right representation.
Differential Revision: https://phabricator.services.mozilla.com/D268495
Diffstat:
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/gfx/wr/webrender/res/ps_quad.glsl b/gfx/wr/webrender/res/ps_quad.glsl
@@ -230,9 +230,11 @@ vec2 scale_offset_map_point(vec4 scale_offset, vec2 p) {
}
RectWithEndpoint scale_offset_map_rect(vec4 scale_offset, RectWithEndpoint r) {
+ vec2 p0 = scale_offset_map_point(scale_offset, r.p0);
+ vec2 p1 = scale_offset_map_point(scale_offset, r.p1);
return RectWithEndpoint(
- scale_offset_map_point(scale_offset, r.p0),
- scale_offset_map_point(scale_offset, r.p1)
+ min(p0, p1),
+ max(p0, p1)
);
}
diff --git a/gfx/wr/wrench/reftests/gradient/radial-negative-scale-ninepatch-ref.yaml b/gfx/wr/wrench/reftests/gradient/radial-negative-scale-ninepatch-ref.yaml
@@ -0,0 +1,17 @@
+---
+root:
+ items:
+ - type: clip
+ id: 5
+ complex:
+ - rect: [0, 0, 300, 300]
+ radius: 50
+ - type: rect
+ bounds: 10 10 10 10
+ color: white
+ - type: radial-gradient
+ bounds: 0 0 300 300
+ center: 300 0
+ radius: 500 600
+ stops: [0.0, red, 1.0, blue]
+ clip-chain: [5]
diff --git a/gfx/wr/wrench/reftests/gradient/radial-negative-scale-ninepatch.yaml b/gfx/wr/wrench/reftests/gradient/radial-negative-scale-ninepatch.yaml
@@ -0,0 +1,30 @@
+# This test contains a radial gradient with rounded corners.
+# The primitive is large enough to exercise the quad nine-patch
+# code path.
+# The primitive has a negative scale applied to it. The goal
+# of this test is to check that the fiddly coordinate space
+# handling of decomposed quads properly handles transforms that
+# can flip primitives.
+---
+root:
+ items:
+ - type: stacking-context
+ transform: scale-x(-1)
+ items:
+ - type: clip
+ id: 5
+ complex:
+ - rect: [-300, 0, 300, 300]
+ radius: 50
+ # A white square (that doesn't contribute to the output)
+ # to make sure that the clip is not lifted to the picture
+ # containing gradient primitive.
+ - type: rect
+ bounds: 10 10 10 10
+ color: white
+ - type: radial-gradient
+ bounds: -300 0 300 300
+ center: 0 0
+ radius: 500 600
+ stops: [0.0, red, 1.0, blue]
+ clip-chain: [5]
diff --git a/gfx/wr/wrench/reftests/gradient/reftest.list b/gfx/wr/wrench/reftests/gradient/reftest.list
@@ -32,6 +32,8 @@ platform(linux,mac) fuzzy(1,80000) == radial-ellipse.yaml radial-ellipse-ref.png
!= radial-circle.yaml radial-ellipse.yaml
+== radial-negative-scale-ninepatch.yaml radial-negative-scale-ninepatch-ref.yaml
+
== norm-linear-1.yaml norm-linear-1-ref.yaml
== norm-linear-2.yaml norm-linear-2-ref.yaml
== norm-linear-3.yaml norm-linear-3-ref.yaml