зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1707460 - Better handle reversed gradient stops. r=gfx-reviewers,bradwerth
The code that decompose linear gradients inserts fake gradient stops to deal with the potential constant color areas before and after the gradient endpoints. The offsets of these extra stops were computed without accounting for the transformation the loop does in the case of reversed stops. This patch fixes that. Differential Revision: https://phabricator.services.mozilla.com/D113290
This commit is contained in:
Родитель
4ae4ba4201
Коммит
28cb8bdbd1
|
@ -217,21 +217,24 @@ pub fn optimize_linear_gradient(
|
|||
|
||||
let reverse_stops = start.x > end.x;
|
||||
|
||||
// Handle reverse stops so we can assume stops are arranged in increasing x.
|
||||
if reverse_stops {
|
||||
stops.reverse();
|
||||
swap(start, end);
|
||||
}
|
||||
|
||||
// Use fake gradient stop to emulate the potential constant color sections
|
||||
// before and after the gradient endpoints.
|
||||
let mut prev = *stops.first().unwrap();
|
||||
let mut last = *stops.last().unwrap();
|
||||
|
||||
// Handle reverse stops so we can assume stops are arranged in increasing x.
|
||||
if reverse_stops {
|
||||
stops.reverse();
|
||||
swap(&mut prev, &mut last);
|
||||
swap(start, end);
|
||||
}
|
||||
|
||||
// Set the offsets of the fake stops to position them at the edges of the primitive.
|
||||
prev.offset = -start.x / length;
|
||||
last.offset = (tile_size.width - start.x) / length;
|
||||
if reverse_stops {
|
||||
prev.offset = 1.0 - prev.offset;
|
||||
last.offset = 1.0 - last.offset;
|
||||
}
|
||||
|
||||
for stop in stops.iter().chain((&[last]).iter()) {
|
||||
let prev_stop = prev;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
root:
|
||||
items:
|
||||
- type: gradient
|
||||
bounds: 50 50 200 200
|
||||
start: 50 100
|
||||
end: 150 100
|
||||
stops: [0.0, green, 0.5, blue,
|
||||
0.5, blue, 1.0, red]
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
root:
|
||||
items:
|
||||
- type: gradient
|
||||
bounds: 50 50 200 200
|
||||
start: 150 100
|
||||
end: 50 100
|
||||
stops: [0.0, red, 0.5, blue,
|
||||
0.5, blue, 1.0, green]
|
|
@ -10,6 +10,7 @@ platform(linux,mac) == premultiplied-conic-2.yaml premultiplied-conic-2.png
|
|||
|
||||
== linear.yaml linear-ref.png
|
||||
== linear-reverse.yaml linear-ref.png
|
||||
fuzzy(255,1200) == linear-reverse-2.yaml linear-reverse-2-ref.yaml
|
||||
platform(linux,mac) fuzzy(1,35000) == linear-stops.yaml linear-stops-ref.png
|
||||
|
||||
== linear-clamp-1a.yaml linear-clamp-1-ref.yaml
|
||||
|
|
Загрузка…
Ссылка в новой задаче