Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: src/effects/SkColorMatrixFilter.cpp

Issue 1047823002: back to Sk4f for SkPMColor (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkPMFloat_SSSE3.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkColorMatrixFilter.cpp
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index c2d4e48c7555b17f1f1f531f81388b0480886bb7..fc8aba258eb896b631bc2d26fb3bbe4e6feec6a8 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();
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkPMFloat_SSSE3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698