Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: src/effects/gradients/Sk4fGradientBase.cpp

Issue 1735773003: 4f gradient negative-dx interval fixup for kMirror_TileMode (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/Sk4fGradientBase.cpp
diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp
index 02b43fe08a9a9a9b459191bc7306ed8b6c02d944..442916638bc7642d1f9110c30b70abc28ace0a86 100644
--- a/src/effects/gradients/Sk4fGradientBase.cpp
+++ b/src/effects/gradients/Sk4fGradientBase.cpp
@@ -207,8 +207,9 @@ GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
clamp_color, clamp_pos,
componentScale);
} else if (shader.fTileMode == SkShader::kMirror_TileMode) {
+ const int count = fIntervals.count();
// synthetic flipped intervals in [1 .. 2)
- for (int i = fIntervals.count() - 1; i >= 0; --i) {
+ for (int i = count - 1; i >= 0; --i) {
const Interval& interval = fIntervals[i];
const SkScalar p0 = interval.fP0;
const SkScalar p1 = interval.fP1;
@@ -216,6 +217,19 @@ GradientShaderBase4fContext::GradientShaderBase4fContext(const SkGradientShaderB
Sk4f c = Sk4f::Load(interval.fC0.fVec) + dc * Sk4f(p1 - p0);
fIntervals.emplace_back(c, dc * Sk4f(-1), 2 - p1, 2 - p0);
}
+
+ if (!dx_is_pos) {
+ // When dx is negative, our initial invervals are in (1..0] order.
+ // The loop above appends their flipped counterparts, pivoted in 2: (1..0](2..1]
+ // To achieve the expected monotonic interval order, we need to
+ // swap the two halves: (2..1](1..0]
+ // TODO: we can probably avoid this late swap with some additional logic during
+ // the initial interval buildup.
+ SkASSERT(fIntervals.count() == count * 2)
+ for (int i = 0; i < count; ++i) {
+ SkTSwap(fIntervals[i], fIntervals[count + i]);
+ }
+ }
}
SkASSERT(fIntervals.count() > 0);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698