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

Unified Diff: src/effects/SkColorMatrixFilter.cpp

Issue 1308903003: Templatize SkPMFloat to support both 1 and 255 biases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pump the loops for Android Created 5 years, 4 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/SkXfermode.cpp ('k') | src/opts/SkColorCubeFilter_opts.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 8dc603042c9e10a2c0fc142533ebaedcd4877cd2..600a3992134f2ec7305da3c9a6a3566d1c523db7 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -240,20 +240,20 @@ uint32_t SkColorMatrixFilter::getFlags() const {
}
static Sk4f premul(const Sk4f& x) {
- float scale = SkPMFloat(x).a();
- Sk4f pm = x * SkPMFloat(1, scale, scale, scale);
+ float scale = SkPMFloat<1>(x).a();
reed1 2015/08/27 16:34:42 Hmmm, these use-cases are interesting / confusion.
mtklein_C 2015/08/27 17:07:40 Yep, pretty much. They're two distinct types now,
+ Sk4f pm = x * SkPMFloat<1>(1, scale, scale, scale);
#ifdef SK_DEBUG
- SkPMFloat pmf(pm);
+ SkPMFloat<1> pmf(pm);
SkASSERT(pmf.isValid());
#endif
return pm;
}
-static Sk4f unpremul(const SkPMFloat& pm) {
+static Sk4f unpremul(const SkPMFloat<1>& pm) {
float scale = 1 / pm.a(); // candidate for fast/approx invert?
- return pm * SkPMFloat(1, scale, scale, scale);
+ return pm * SkPMFloat<1>(1, scale, scale, scale);
}
static Sk4f clamp_0_1(const Sk4f& value) {
@@ -285,7 +285,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
const Sk4f c4 = Sk4f::Load(fTranspose + 16)*Sk4f(1.0f/255);
// todo: we could cache this in the constructor...
- SkPMColor matrix_translate_pmcolor = SkPMFloat(premul(clamp_0_1(c4))).round();
+ SkPMColor matrix_translate_pmcolor = SkPMFloat<1>(premul(clamp_0_1(c4))).round();
for (int i = 0; i < count; i++) {
const SkPMColor src_c = src[i];
@@ -294,7 +294,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
continue;
}
- SkPMFloat srcf(src_c);
+ SkPMFloat<1> srcf(src_c);
if (0xFF != SkGetPackedA32(src_c)) {
srcf = unpremul(srcf);
@@ -309,7 +309,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
Sk4f dst4 = c0 * r4 + c1 * g4 + c2 * b4 + c3 * a4 + c4;
// clamp, re-premul, and write
- dst[i] = SkPMFloat(premul(clamp_0_1(dst4))).round();
+ dst[i] = SkPMFloat<1>(premul(clamp_0_1(dst4))).round();
}
} else {
const State& state = fState;
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/opts/SkColorCubeFilter_opts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698