aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-03-08 10:20:49 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-08 10:20:49 -0800
commitd8a4f772115bbb9d50c0e73613bdd879833da690 (patch)
treeb03f71a5d06c7d5915ac804ca3dbaa3de49cb219
parent93bb080503eec5df5674a1bcfe4baaceced799ff (diff)
Fix 4f gradient swizzle post http://crrev.com/1774523002
* store interval colors in pm4f-natural/RGBA order * swizzle to dst order during interval advance Also remove an unused Interval ctor. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1770153002 Review URL: https://codereview.chromium.org/1770153002
-rw-r--r--src/effects/gradients/Sk4fGradientBase.cpp14
-rw-r--r--src/effects/gradients/Sk4fGradientBase.h2
-rw-r--r--src/effects/gradients/Sk4fLinearGradient.cpp24
3 files changed, 20 insertions, 20 deletions
diff --git a/src/effects/gradients/Sk4fGradientBase.cpp b/src/effects/gradients/Sk4fGradientBase.cpp
index bd3c51a035..76fb178776 100644
--- a/src/effects/gradients/Sk4fGradientBase.cpp
+++ b/src/effects/gradients/Sk4fGradientBase.cpp
@@ -28,24 +28,14 @@ Interval::Interval(SkPMColor c0, SkScalar p0,
, fZeroRamp(c0 == c1) {
SkASSERT(p0 != p1);
- const Sk4f c4f0 = SkNx_cast<float>(Sk4b::Load(&c0)) * componentScale;
- const Sk4f c4f1 = SkNx_cast<float>(Sk4b::Load(&c1)) * componentScale;
+ const Sk4f c4f0 = SkPM4f::FromPMColor(c0).to4f() * componentScale;
+ const Sk4f c4f1 = SkPM4f::FromPMColor(c1).to4f() * componentScale;
const Sk4f dc4f = (c4f1 - c4f0) / (p1 - p0);
c4f0.store(&fC0.fVec);
dc4f.store(&fDc.fVec);
}
-SkGradientShaderBase::GradientShaderBase4fContext::
-Interval::Interval(const Sk4f& c0, const Sk4f& dc,
- SkScalar p0, SkScalar p1)
- : fP0(p0)
- , fP1(p1)
- , fZeroRamp((dc == 0).allTrue()) {
- c0.store(fC0.fVec);
- dc.store(fDc.fVec);
-}
-
bool SkGradientShaderBase::GradientShaderBase4fContext::
Interval::contains(SkScalar fx) const {
return in_range(fx, fP0, fP1);
diff --git a/src/effects/gradients/Sk4fGradientBase.h b/src/effects/gradients/Sk4fGradientBase.h
index 1e65308f69..1fece72b52 100644
--- a/src/effects/gradients/Sk4fGradientBase.h
+++ b/src/effects/gradients/Sk4fGradientBase.h
@@ -29,8 +29,6 @@ protected:
Interval(SkPMColor c0, SkScalar p0,
SkPMColor c1, SkScalar p1,
const Sk4f& componentScale);
- Interval(const Sk4f& c0, const Sk4f& dc,
- SkScalar p0, SkScalar p1);
bool isZeroRamp() const { return fZeroRamp; }
diff --git a/src/effects/gradients/Sk4fLinearGradient.cpp b/src/effects/gradients/Sk4fLinearGradient.cpp
index 8478cb0be3..4a20a28b1f 100644
--- a/src/effects/gradients/Sk4fLinearGradient.cpp
+++ b/src/effects/gradients/Sk4fLinearGradient.cpp
@@ -161,6 +161,19 @@ float dst_component_scale<SkPMColor>() {
return 255;
}
+template<typename DstType>
+Sk4f dst_swizzle(const SkPM4f&);
+
+template<>
+Sk4f dst_swizzle<SkPM4f>(const SkPM4f& c) {
+ return c.to4f();
+}
+
+template<>
+Sk4f dst_swizzle<SkPMColor>(const SkPM4f& c) {
+ return c.to4f_pmorder();
+}
+
SkPMColor pack_color(SkColor c, bool premul) {
return premul
? SkPreMultiplyColor(c)
@@ -304,11 +317,10 @@ LinearGradient4fContext::LinearGradient4fContext(const SkLinearGradient& shader,
SkASSERT(shader.fColorCount > 1);
SkASSERT(shader.fOrigColors);
- const float kInv255Float = 1.0f / 255;
- const float paintAlpha = rec.fPaint->getAlpha() * kInv255Float;
+ const float paintAlpha = rec.fPaint->getAlpha() * (1.0f / 255);
const Sk4f componentScale = fColorsArePremul
- ? Sk4f(paintAlpha * kInv255Float)
- : Sk4f(kInv255Float, kInv255Float, kInv255Float, paintAlpha * kInv255Float);
+ ? Sk4f(paintAlpha)
+ : Sk4f(1.0f, 1.0f, 1.0f, paintAlpha);
const bool dx_is_pos = fDstToPos.getScaleX() >= 0;
const int first_index = dx_is_pos ? 0 : shader.fColorCount - 1;
const int last_index = shader.fColorCount - 1 - first_index;
@@ -562,8 +574,8 @@ public:
private:
void compute_interval_props(SkScalar t) {
- fDc = Sk4f::Load(fInterval->fDc.fVec);
- fCc = Sk4f::Load(fInterval->fC0.fVec);
+ fDc = dst_swizzle<DstType>(fInterval->fDc);
+ fCc = dst_swizzle<DstType>(fInterval->fC0);
fCc = fCc + fDc * Sk4f(t);
fCc = fCc * fDstComponentScale;
fDcDx = fDc * fDstComponentScale * Sk4f(fDx);