virtual void filterSpan4f(const SkPM4f src[], int count, SkPM4f result[]) const = 0;
- bool appendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
- bool shaderIsOpaque) const;
+ void appendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool shaderIsOpaque) const;
enum Flags {
/** If set the filter methods will not change the alpha channel of the colors.
protected:
SkColorFilter() {}
- virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
- bool shaderIsOpaque) const;
-
sk_sp<SkColorFilter> makeColorSpace(SkColorSpaceXformer* xformer) const {
return this->onMakeColorSpace(xformer);
}
return false;
}
+ virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
+ bool shaderIsOpaque) const;
+
+
friend class SkColorSpaceXformer;
friend class SkComposeColorFilter;
#include "SkColorSpaceXformer.h"
#include "SkNx.h"
#include "SkPM4f.h"
+#include "SkRasterPipeline.h"
#include "SkReadBuffer.h"
#include "SkRefCnt.h"
#include "SkString.h"
#include "SkTDArray.h"
#include "SkUnPreMultiply.h"
#include "SkWriteBuffer.h"
+#include "../jumper/SkJumper.h"
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
}
#endif
-bool SkColorFilter::appendStages(SkRasterPipeline* pipeline,
- SkColorSpace* dst,
- SkArenaAlloc* scratch,
+void SkColorFilter::appendStages(SkRasterPipeline* p,
+ SkColorSpace* dstCS,
+ SkArenaAlloc* alloc,
bool shaderIsOpaque) const {
- return this->onAppendStages(pipeline, dst, scratch, shaderIsOpaque);
+ SkRasterPipeline subclass;
+ if (this->onAppendStages(&subclass, dstCS, alloc, shaderIsOpaque)) {
+ p->extend(subclass);
+ return;
+ }
+
+ struct Ctx : SkJumper_CallbackCtx {
+ sk_sp<SkColorFilter> cf;
+ };
+ auto ctx = alloc->make<Ctx>();
+ ctx->cf = SkColorSpaceXformer::Make(sk_ref_sp(dstCS))->apply(this);
+ ctx->fn = [](SkJumper_CallbackCtx* arg, int active_pixels) {
+ auto ctx = (Ctx*)arg;
+ auto buf = (SkPM4f*)ctx->rgba;
+ ctx->cf->filterSpan4f(buf, active_pixels, buf);
+ };
+ p->append(SkRasterPipeline::callback, ctx);
}
bool SkColorFilter::onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool) const {
if (!(fInner->getFlags() & kAlphaUnchanged_Flag)) {
innerIsOpaque = false;
}
- return fInner->appendStages(p, dst, scratch, shaderIsOpaque) &&
- fOuter->appendStages(p, dst, scratch, innerIsOpaque);
+ fInner->appendStages(p, dst, scratch, shaderIsOpaque);
+ fOuter->appendStages(p, dst, scratch, innerIsOpaque);
+ return true;
}
#if SK_SUPPORT_GPU
}
bool onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkArenaAlloc* alloc,
bool shaderIsOpaque) const override {
- return fMatrixFilter->appendStages(p, cs, alloc, shaderIsOpaque);
+ fMatrixFilter->appendStages(p, cs, alloc, shaderIsOpaque);
+ return true;
}
// TODO: might want to remember we're a lighting color filter through serialization?