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

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

Issue 1471543002: use pinned value during lerp for vertical gradients (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add assert in lerp_color Created 5 years, 1 month 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 | « gm/gradients.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkLinearGradient.cpp
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 013c1f1ddea46b3c53a0627fc548a5fac30c90bc..bfa473c0123eefa1d2831953513eff65700bf8b8 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -727,6 +727,9 @@ template <bool apply_alpha> void fill(SkPMColor dst[], int count, const Sk4f& c4
*/
static Sk4f lerp_color(float fx, const SkLinearGradient::LinearGradientContext::Rec* rec) {
+ SkASSERT(fx >= rec[0].fPos);
+ SkASSERT(fx <= rec[1].fPos);
+
const float p0 = rec[0].fPos;
const Sk4f c0 = rec[0].fColor;
const Sk4f c1 = rec[1].fColor;
@@ -894,7 +897,8 @@ void SkLinearGradient::LinearGradientContext::shade4_clamp(int x, int y, SkPMCol
const float invDx = 1 / dx;
if (SkScalarNearlyZero(dx)) { // gradient is vertical
- Sk4f c = lerp_color(fx, find_forward(fRecs.begin(), SkTPin(fx, 0.0f, 1.0f)));
+ const float pinFx = SkTPin(fx, 0.0f, 1.0f);
+ Sk4f c = lerp_color(pinFx, find_forward(fRecs.begin(), pinFx));
if (fApplyAlphaAfterInterp) {
fill<true>(dstC, count, c + dither0, c + dither1);
} else {
« no previous file with comments | « gm/gradients.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698