aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-02-19 13:38:53 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-19 13:38:53 -0800
commitc5b1228141bd26d4573552a00ebeb0b85a4768df (patch)
tree88de22419c96dcbb9f74c95216015483e5a6bd12
parent950fb1ca24cca9803eb29dc6aa5472b0f506a67f (diff)
remove supports4f flag for colorfilters
-rw-r--r--include/core/SkColorFilter.h5
-rw-r--r--src/core/SkColorFilter.cpp22
-rw-r--r--src/core/SkColorFilterShader.cpp3
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.cpp1
-rw-r--r--src/core/SkModeColorFilter.cpp2
-rw-r--r--tests/SkColor4fTest.cpp13
6 files changed, 21 insertions, 25 deletions
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index ea893e056f..4c9795c271 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -73,17 +73,12 @@ public:
/** If set the filter methods will not change the alpha channel of the colors.
*/
kAlphaUnchanged_Flag = 1 << 0,
- kSupports4f_Flag = 1 << 1,
};
/** Returns the flags for this filter. Override in subclasses to return custom flags.
*/
virtual uint32_t getFlags() const { return 0; }
- bool supports4f() const {
- return SkToBool(this->getFlags() & kSupports4f_Flag);
- }
-
/**
* If this subclass can optimally createa composition with the inner filter, return it as
* a new filter (which the caller must unref() when it is done). If no such optimization
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 7d11163474..dab4ccf7b5 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -13,6 +13,7 @@
#include "SkUnPreMultiply.h"
#include "SkWriteBuffer.h"
#include "SkPM4f.h"
+#include "SkNx.h"
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
@@ -30,11 +31,20 @@ bool SkColorFilter::asComponentTable(SkBitmap*) const {
return false;
}
-void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f[]) const {
- if (this->supports4f()) {
- SkASSERT(false && "colorfilter supports4f but didn't override");
- } else {
- SkASSERT(false && "filterSpan4f called but not supported");
+void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const {
+ const int N = 128;
+ SkPMColor tmp[N];
+ while (count > 0) {
+ int n = SkTMin(count, N);
+ for (int i = 0; i < n; ++i) {
+ SkNx_cast<uint8_t>(Sk4f::Load(span[i].fVec) * Sk4f(255) + Sk4f(0.5f)).store(&tmp[i]);
+ }
+ this->filterSpan(tmp, n, tmp);
+ for (int i = 0; i < n; ++i) {
+ span[i] = SkPM4f::FromPMColor(tmp[i]);
+ }
+ span += n;
+ count -= n;
}
}
@@ -75,8 +85,6 @@ public:
}
void filterSpan4f(const SkPM4f shader[], int count, SkPM4f result[]) const override {
- SkASSERT(fInner->supports4f());
- SkASSERT(fOuter->supports4f());
fInner->filterSpan4f(shader, count, result);
fOuter->filterSpan4f(result, count, result);
}
diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp
index 81123f6dff..618bf7191e 100644
--- a/src/core/SkColorFilterShader.cpp
+++ b/src/core/SkColorFilterShader.cpp
@@ -49,9 +49,6 @@ uint32_t SkColorFilterShader::FilterShaderContext::getFlags() const {
if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
shaderF &= ~SkShader::kOpaqueAlpha_Flag;
}
- if (!(filterF & SkColorFilter::kSupports4f_Flag)) {
- shaderF &= ~SkShader::kSupports4f_Flag;
- }
return shaderF;
}
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index de87913ace..ff95bf1ac5 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -47,7 +47,6 @@ void SkColorMatrixFilterRowMajor255::initState() {
} else {
fFlags = kAlphaUnchanged_Flag;
}
- fFlags |= kSupports4f_Flag;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index 574c1ce9f0..1e104d8dc7 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -38,7 +38,7 @@ bool SkModeColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) cons
}
uint32_t SkModeColorFilter::getFlags() const {
- uint32_t flags = kSupports4f_Flag;
+ uint32_t flags = 0;
switch (fMode) {
case SkXfermode::kDst_Mode: //!< [Da, Dc]
case SkXfermode::kSrcATop_Mode: //!< [Da, Sc * Da + (1 - Sa) * Dc]
diff --git a/tests/SkColor4fTest.cpp b/tests/SkColor4fTest.cpp
index 46c10f18f8..5700e4b79c 100644
--- a/tests/SkColor4fTest.cpp
+++ b/tests/SkColor4fTest.cpp
@@ -188,14 +188,11 @@ DEF_TEST(Color4f_colorfilter, reporter) {
for (const auto& rec : recs) {
SkAutoTUnref<SkColorFilter> filter(rec.fFact());
- REPORTER_ASSERT(reporter, filter->supports4f() == rec.fSupports4f);
- if (filter->supports4f()) {
- SkPMColor dst4b[N];
- filter->filterSpan(src4b, N, dst4b);
- SkPM4f dst4f[N];
- filter->filterSpan4f(src4f, N, dst4f);
- compare_spans(dst4f, dst4b, N, reporter);
- }
+ SkPMColor dst4b[N];
+ filter->filterSpan(src4b, N, dst4b);
+ SkPM4f dst4f[N];
+ filter->filterSpan4f(src4f, N, dst4f);
+ compare_spans(dst4f, dst4b, N, reporter);
}
}