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

Unified Diff: src/effects/SkArithmeticMode.cpp

Issue 2175133002: Arithmetic xfermode stage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: no clamp at all Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698