aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkColorFilter.cpp18
-rw-r--r--src/effects/SkOverdrawColorFilter.cpp31
-rw-r--r--src/effects/SkOverdrawColorFilter.h2
3 files changed, 25 insertions, 26 deletions
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 9304c7c803..65b5c45308 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -48,24 +48,6 @@ void SkColorFilter::appendStages(SkRasterPipeline* p,
this->onAppendStages(p, dstCS, alloc, shaderIsOpaque);
}
-void SkColorFilter::onAppendStages(SkRasterPipeline* p,
- SkColorSpace* dstCS,
- SkArenaAlloc* alloc,
- bool) const {
- struct Ctx : SkJumper_CallbackCtx {
- sk_sp<SkColorFilter> cf;
- };
- auto ctx = alloc->make<Ctx>();
- ctx->cf = dstCS ? SkColorSpaceXformer::Make(sk_ref_sp(dstCS))->apply(this)
- : sk_ref_sp(const_cast<SkColorFilter*>(this));
- ctx->fn = [](SkJumper_CallbackCtx* arg, int active_pixels) {
- auto ctx = (Ctx*)arg;
- auto buf = (SkPM4f*)ctx->rgba;
- ctx->cf->onFilterStage(buf, active_pixels, buf);
- };
- p->append(SkRasterPipeline::callback, ctx);
-}
-
SkColor SkColorFilter::filterColor(SkColor c) const {
SkPMColor dst, src = SkPreMultiplyColor(c);
this->filterSpan(&src, 1, &dst);
diff --git a/src/effects/SkOverdrawColorFilter.cpp b/src/effects/SkOverdrawColorFilter.cpp
index bbeb028144..a4e13f9935 100644
--- a/src/effects/SkOverdrawColorFilter.cpp
+++ b/src/effects/SkOverdrawColorFilter.cpp
@@ -5,9 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkOverdrawColorFilter.h"
#include "SkPM4f.h"
+#include "SkRasterPipeline.h"
#include "SkReadBuffer.h"
+#include "../jumper/SkJumper.h"
void SkOverdrawColorFilter::filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const {
for (int x = 0; x < count; x++) {
@@ -20,14 +23,28 @@ void SkOverdrawColorFilter::filterSpan(const SkPMColor src[], int count, SkPMCol
}
}
-void SkOverdrawColorFilter::onFilterStage(const SkPM4f src[], int count, SkPM4f dst[]) const {
- for (int i = 0; i < count; ++i) {
- uint8_t alpha = (int)(src[i].a() * 255);
- if (alpha >= kNumColors) {
- alpha = kNumColors - 1;
+void SkOverdrawColorFilter::onAppendStages(SkRasterPipeline* p,
+ SkColorSpace* dstCS,
+ SkArenaAlloc* alloc,
+ bool shader_is_opaque) const {
+ struct Ctx : public SkJumper_CallbackCtx {
+ const SkPMColor* colors;
+ };
+ // TODO: do we care about transforming to dstCS?
+ auto ctx = alloc->make<Ctx>();
+ ctx->colors = fColors;
+ ctx->fn = [](SkJumper_CallbackCtx* arg, int active_pixels) {
+ auto ctx = (Ctx*)arg;
+ auto pixels = (SkPM4f*)ctx->rgba;
+ for (int i = 0; i < active_pixels; i++) {
+ uint8_t alpha = (int)(pixels[i].a() * 255);
+ if (alpha >= kNumColors) {
+ alpha = kNumColors - 1;
+ }
+ pixels[i] = SkPM4f::FromPMColor(ctx->colors[alpha]);
}
- dst[i] = SkPM4f::FromPMColor(fColors[alpha]);
- }
+ };
+ p->append(SkRasterPipeline::callback, ctx);
}
void SkOverdrawColorFilter::toString(SkString* str) const {
diff --git a/src/effects/SkOverdrawColorFilter.h b/src/effects/SkOverdrawColorFilter.h
index 09c5173bf6..41d7988577 100644
--- a/src/effects/SkOverdrawColorFilter.h
+++ b/src/effects/SkOverdrawColorFilter.h
@@ -46,7 +46,7 @@ private:
memcpy(fColors, colors, kNumColors * sizeof(SkPMColor));
}
- void onFilterStage(const SkPM4f src[], int count, SkPM4f result[]) const override;
+ void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool) const override;
SkPMColor fColors[kNumColors];