Bug 1817826 - Fix rendering of reversed (clockwise) sweep gradients. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D173746
This commit is contained in:
Jonathan Kew 2023-03-28 21:08:31 +00:00
parent b2d2b75a5f
commit 2b5cfb7a38

View File

@ -1218,10 +1218,10 @@ struct PaintSweepGradient : public PaintPatternBase {
if (solidColor) {
return solidColor;
}
// ConicGradientPattern works counterclockwise. If the gradient is defined
// clockwise (with aStart greater than aEnd), we'll reverse the color line
// and swap the start and end angles.
bool reverse = aEnd < aStart;
if (reverse) {
std::swap(aStart, aEnd);
}
float firstStop, lastStop;
RefPtr stops =
aColorLine->MakeGradientStops(aState, &firstStop, &lastStop, reverse);
@ -1239,6 +1239,9 @@ struct PaintSweepGradient : public PaintPatternBase {
aEnd = aStart + sweep * (lastStop - firstStop);
}
}
if (reverse) {
std::swap(aStart, aEnd);
}
return MakeUnique<ConicGradientPattern>(aCenter, M_PI / 2.0, aStart / 2.0,
aEnd / 2.0, std::move(stops),
Matrix::Scaling(1.0, -1.0));