diff options
author | Florin Malita <fmalita@chromium.org> | 2017-05-08 09:53:11 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-08 15:41:40 +0000 |
commit | 63f717da11c7dbb65cb05e97dac660bf505853a2 (patch) | |
tree | 834314982d49f1b9474969ba6b5f1acd1921ab34 | |
parent | 5bbd076c52a6cebff4a2d63edd027b0f31624287 (diff) |
Remove Sk4fGradientInterval::fZeroRamp
It's cheap enough to compute when needed, and we don't need it in hot
loops anyway.
Change-Id: Ib0242f98f8bee31bff939cfdc7356d51525092e4
Reviewed-on: https://skia-review.googlesource.com/15764
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | src/effects/gradients/Sk4fGradientBase.cpp | 7 | ||||
-rw-r--r-- | src/effects/gradients/Sk4fGradientBase.h | 1 | ||||
-rw-r--r-- | src/effects/gradients/Sk4fLinearGradient.cpp | 20 |
3 files changed, 9 insertions, 19 deletions
diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp index 81442df048..e20f5f4702 100644 --- a/src/effects/gradients/Sk4fGradientBase.cpp +++ b/src/effects/gradients/Sk4fGradientBase.cpp @@ -120,8 +120,7 @@ void addMirrorIntervals(const SkColor colors[], Sk4fGradientInterval::Sk4fGradientInterval(const Sk4f& c0, SkScalar t0, const Sk4f& c1, SkScalar t1) : fT0(t0) - , fT1(t1) - , fZeroRamp((c0 == c1).allTrue()) { + , fT1(t1) { SkASSERT(t0 != t1); // Either p0 or p1 can be (-)inf for synthetic clamp edge intervals. SkASSERT(SkScalarIsFinite(t0) || SkScalarIsFinite(t1)); @@ -129,8 +128,8 @@ Sk4fGradientInterval::Sk4fGradientInterval(const Sk4f& c0, SkScalar t0, const auto dt = t1 - t0; // Clamp edge intervals are always zero-ramp. - SkASSERT(SkScalarIsFinite(dt) || fZeroRamp); - SkASSERT(SkScalarIsFinite(t0) || fZeroRamp); + SkASSERT(SkScalarIsFinite(dt) || (c0 == c1).allTrue()); + SkASSERT(SkScalarIsFinite(t0) || (c0 == c1).allTrue()); const Sk4f dc = SkScalarIsFinite(dt) ? (c1 - c0) / dt : 0; const Sk4f bias = c0 - (SkScalarIsFinite(t0) ? t0 * dc : 0); diff --git a/src/effects/gradients/Sk4fGradientBase.h b/src/effects/gradients/Sk4fGradientBase.h index fcdcd9e8c7..9209a90637 100644 --- a/src/effects/gradients/Sk4fGradientBase.h +++ b/src/effects/gradients/Sk4fGradientBase.h @@ -33,7 +33,6 @@ struct Sk4fGradientInterval { // C = fCb + t * fCg; SkPM4f fCb, fCg; SkScalar fT0, fT1; - bool fZeroRamp; }; class Sk4fGradientIntervalBuffer { diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp index fe900e8d03..49b98fd86e 100644 --- a/src/effects/gradients/Sk4fLinearGradient.cpp +++ b/src/effects/gradients/Sk4fLinearGradient.cpp @@ -351,16 +351,10 @@ private: void compute_interval_props(SkScalar t) { SkASSERT(in_range(t, fInterval->fT0, fInterval->fT1)); - fZeroRamp = fIsVertical || fInterval->fZeroRamp; - fCc = DstTraits<dstType, premul>::load(fInterval->fCb); - - if (fInterval->fZeroRamp) { - fDcDx = 0; - } else { - const Sk4f dC = DstTraits<dstType, premul>::load(fInterval->fCg); - fCc = fCc + dC * Sk4f(t); - fDcDx = dC * fDx; - } + const Sk4f dc = DstTraits<dstType, premul>::load(fInterval->fCg); + fCc = DstTraits<dstType, premul>::load(fInterval->fCb) + dc * Sk4f(t); + fDcDx = dc * fDx; + fZeroRamp = fIsVertical || (dc == 0).allTrue(); } void init_average_props() { @@ -377,10 +371,8 @@ private: // // Avg += C * (t1 - t0) // - auto c = DstTraits<dstType, premul>::load(i->fCb); - if (!i->fZeroRamp) { - c = c + DstTraits<dstType, premul>::load(i->fCg) * (i->fT0 + i->fT1) * 0.5f; - } + const auto c = DstTraits<dstType, premul>::load(i->fCb) + + DstTraits<dstType, premul>::load(i->fCg) * (i->fT0 + i->fT1) * 0.5f; fCc = fCc + c * (i->fT1 - i->fT0); } } |