aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-03-31 08:17:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-31 08:17:00 -0700
commit0340df5b3698aff1c9540fcdbc3dafd9d5ddb0b0 (patch)
tree0988d6dd9faafdedb7954151838a2467c04f58c2 /src/effects
parent39383a194622a917dd2ae0c4b43e9c634d61e94a (diff)
back to Sk4f for SkPMColor
#floats BUG=skia: BUG=skia:3592 Review URL: https://codereview.chromium.org/1047823002
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkColorMatrixFilter.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index c2d4e48c75..fc8aba258e 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -255,9 +255,9 @@ uint32_t SkColorMatrixFilter::getFlags() const {
*/
static const float gInv255 = 0.0039215683f; // (1.0f / 255) - ULP == SkBits2Float(0x3B808080)
-static Sk4s premul(const Sk4s& x) {
+static Sk4f premul(const Sk4f& x) {
float scale = SkPMFloat(x).a() * gInv255;
- Sk4s pm = x * Sk4s(scale, scale, scale, 1);
+ Sk4f pm = x * Sk4f(scale, scale, scale, 1);
#ifdef SK_DEBUG
SkPMFloat pmf(pm);
@@ -267,9 +267,9 @@ static Sk4s premul(const Sk4s& x) {
return pm;
}
-static Sk4s unpremul(const SkPMFloat& pm) {
+static Sk4f unpremul(const SkPMFloat& pm) {
float scale = 255 / pm.a(); // candidate for fast/approx invert?
- return Sk4s(pm) * Sk4s(scale, scale, scale, 1);
+ return Sk4f(pm) * Sk4f(scale, scale, scale, 1);
}
static Sk4f clamp_0_255(const Sk4f& value) {
@@ -292,11 +292,11 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
#endif
if (use_floats) {
- const Sk4s c0 = Sk4s::Load(fTranspose + 0);
- const Sk4s c1 = Sk4s::Load(fTranspose + 4);
- const Sk4s c2 = Sk4s::Load(fTranspose + 8);
- const Sk4s c3 = Sk4s::Load(fTranspose + 12);
- const Sk4s c4 = Sk4s::Load(fTranspose + 16); // translates
+ const Sk4f c0 = Sk4f::Load(fTranspose + 0);
+ const Sk4f c1 = Sk4f::Load(fTranspose + 4);
+ const Sk4f c2 = Sk4f::Load(fTranspose + 8);
+ const Sk4f c3 = Sk4f::Load(fTranspose + 12);
+ const Sk4f c4 = Sk4f::Load(fTranspose + 16); // translates
// todo: we could cache this in the constructor...
SkPMColor matrix_translate_pmcolor = SkPMFloat(premul(clamp_0_255(c4))).clamped();
@@ -314,13 +314,13 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
srcf = unpremul(srcf);
}
- Sk4s r4 = Sk4s(srcf.r());
- Sk4s g4 = Sk4s(srcf.g());
- Sk4s b4 = Sk4s(srcf.b());
- Sk4s a4 = Sk4s(srcf.a());
+ Sk4f r4 = Sk4f(srcf.r());
+ Sk4f g4 = Sk4f(srcf.g());
+ Sk4f b4 = Sk4f(srcf.b());
+ Sk4f a4 = Sk4f(srcf.a());
// apply matrix
- Sk4s dst4 = c0 * r4 + c1 * g4 + c2 * b4 + c3 * a4 + c4;
+ Sk4f dst4 = c0 * r4 + c1 * g4 + c2 * b4 + c3 * a4 + c4;
// clamp, re-premul, and write
dst[i] = SkPMFloat(premul(clamp_0_255(dst4))).get();