From: Florin Malita Date: Mon, 8 May 2017 13:53:11 +0000 (-0400) Subject: Remove Sk4fGradientInterval::fZeroRamp X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~36^2~401 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63f717da11c7dbb65cb05e97dac660bf505853a2;p=platform%2Fupstream%2FlibSkiaSharp.git 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 Reviewed-by: Herb Derby Reviewed-by: Mike Klein --- diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp index 81442df..e20f5f4 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 fcdcd9e..9209a90 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 fe900e8..49b98fd 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::load(fInterval->fCb); - - if (fInterval->fZeroRamp) { - fDcDx = 0; - } else { - const Sk4f dC = DstTraits::load(fInterval->fCg); - fCc = fCc + dC * Sk4f(t); - fDcDx = dC * fDx; - } + const Sk4f dc = DstTraits::load(fInterval->fCg); + fCc = DstTraits::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::load(i->fCb); - if (!i->fZeroRamp) { - c = c + DstTraits::load(i->fCg) * (i->fT0 + i->fT1) * 0.5f; - } + const auto c = DstTraits::load(i->fCb) + + DstTraits::load(i->fCg) * (i->fT0 + i->fT1) * 0.5f; fCc = fCc + c * (i->fT1 - i->fT0); } }