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>
diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp
index fe900e8..49b98fd 100644
--- a/src/effects/gradients/Sk4fLinearGradient.cpp
+++ b/src/effects/gradients/Sk4fLinearGradient.cpp
@@ -351,16 +351,10 @@
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 @@
//
// 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);
}
}