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

Unified Diff: src/core/SkColorFilter.cpp

Issue 1720443002: remove supports4f flag for colorfilters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « include/core/SkColorFilter.h ('k') | src/core/SkColorFilterShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorFilter.cpp
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 7d1116347456fad5c4080c4661bd285dc61f77b7..dab4ccf7b55d09f8aa791804c3bb5e1bb176cf33 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);
}
« no previous file with comments | « include/core/SkColorFilter.h ('k') | src/core/SkColorFilterShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698