Index: src/effects/SkArithmeticMode.cpp |
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp |
index bf17bb833dac5989b426d27eb0d2a71aef34f427..b8aa36853a52d33a2fe7718eb6eb39bfb637a98a 100644 |
--- a/src/effects/SkArithmeticMode.cpp |
+++ b/src/effects/SkArithmeticMode.cpp |
@@ -8,6 +8,7 @@ |
#include "SkArithmeticMode.h" |
#include "SkColorPriv.h" |
#include "SkNx.h" |
+#include "SkRasterPipeline.h" |
#include "SkReadBuffer.h" |
#include "SkString.h" |
#include "SkUnPreMultiply.h" |
@@ -29,6 +30,11 @@ public: |
void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) const override; |
+ bool onAppendStages(SkRasterPipeline* p) const override { |
+ p->append(&Stage, this); |
+ return true; |
+ } |
+ |
SK_TO_STRING_OVERRIDE() |
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) |
@@ -39,6 +45,10 @@ public: |
#endif |
private: |
+ static void SK_VECTORCALL Stage(SkRasterPipeline::Stage* st, size_t x, |
+ Sk4f r, Sk4f g, Sk4f b, Sk4f a, |
+ Sk4f dr, Sk4f dg, Sk4f db, Sk4f da); |
+ |
void flatten(SkWriteBuffer& buffer) const override { |
buffer.writeScalar(fK[0]); |
buffer.writeScalar(fK[1]); |
@@ -64,6 +74,26 @@ sk_sp<SkFlattenable> SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) { |
return SkArithmeticMode::Make(k1, k2, k3, k4, enforcePMColor); |
} |
+void SK_VECTORCALL SkArithmeticMode_scalar::Stage(SkRasterPipeline::Stage* st, size_t x, |
+ Sk4f r, Sk4f g, Sk4f b, Sk4f a, |
+ Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) { |
+ auto self = st->ctx<const SkArithmeticMode_scalar*>(); |
+ |
+ const Sk4f k1 = self->fK[0], |
+ k2 = self->fK[1], |
+ k3 = self->fK[2], |
+ k4 = self->fK[3]; |
+ |
+ r = k1*r*dr + k2*r + k3*dr + k4; |
+ g = k1*g*dg + k2*g + k3*dg + k4; |
+ b = k1*b*db + k2*b + k3*db + k4; |
+ a = k1*a*da + k2*a + k3*da + k4; |
+ |
+ // A later stage (clamp_01_premul) will pin and fEnforcePMColor for us. |
+ |
+ st->next(x, r,g,b,a, dr,dg,db,da); |
+} |
+ |
void SkArithmeticMode_scalar::xfer32(SkPMColor dst[], const SkPMColor src[], |
int count, const SkAlpha aaCoverage[]) const { |
const Sk4f k1 = fK[0] * (1/255.0f), |