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

Unified Diff: src/core/SkXfermode.cpp

Issue 1061603002: Code's more readable when SkPMFloat is an Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix neon Created 5 years, 9 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 | « src/core/SkPMFloat.h ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkXfermode.cpp
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 5e9055c67dfeba94c4e4a5da90c255513a0e4407..1d502d987c7d7a1edd8bef0d2e0b40b48dc0bd9a 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -1236,9 +1236,7 @@ static inline SkPMFloat check_as_pmfloat(const Sk4f& value) {
struct SrcATop4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
const Sk4f inv255(gInv255);
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(d4 + (s4 * Sk4f(dst.a()) - d4 * Sk4f(src.a())) * inv255);
+ return check_as_pmfloat(dst + (src * Sk4f(dst.a()) - dst * Sk4f(src.a())) * inv255);
}
static const bool kFoldCoverageIntoSrcAlpha = true;
static const SkXfermode::Mode kMode = SkXfermode::kSrcATop_Mode;
@@ -1248,9 +1246,7 @@ struct SrcATop4f {
struct DstATop4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
const Sk4f inv255(gInv255);
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(s4 + (d4 * Sk4f(src.a()) - s4 * Sk4f(dst.a())) * inv255);
+ return check_as_pmfloat(src + (dst * Sk4f(src.a()) - src * Sk4f(dst.a())) * inv255);
}
static const bool kFoldCoverageIntoSrcAlpha = false;
static const SkXfermode::Mode kMode = SkXfermode::kDstATop_Mode;
@@ -1260,9 +1256,7 @@ struct DstATop4f {
struct Xor4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
const Sk4f inv255(gInv255);
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(s4 + d4 - (s4 * Sk4f(dst.a()) + d4 * Sk4f(src.a())) * inv255);
+ return check_as_pmfloat(src + dst - (src * Sk4f(dst.a()) + dst * Sk4f(src.a())) * inv255);
}
static const bool kFoldCoverageIntoSrcAlpha = true;
static const SkXfermode::Mode kMode = SkXfermode::kXor_Mode;
@@ -1271,9 +1265,7 @@ struct Xor4f {
// kPlus_Mode [Sa + Da, Sc + Dc]
struct Plus4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(clamp_255(s4 + d4));
+ return check_as_pmfloat(clamp_255(src + dst));
}
static const bool kFoldCoverageIntoSrcAlpha = true;
static const SkXfermode::Mode kMode = SkXfermode::kPlus_Mode;
@@ -1283,9 +1275,7 @@ struct Plus4f {
struct Modulate4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
const Sk4f inv255(gInv255);
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(s4 * d4 * inv255);
+ return check_as_pmfloat(src * dst * inv255);
}
static const bool kFoldCoverageIntoSrcAlpha = false;
static const SkXfermode::Mode kMode = SkXfermode::kModulate_Mode;
@@ -1295,9 +1285,7 @@ struct Modulate4f {
struct Screen4f {
static SkPMFloat Xfer(const SkPMFloat& src, const SkPMFloat& dst) {
const Sk4f inv255(gInv255);
- Sk4f s4 = src;
- Sk4f d4 = dst;
- return check_as_pmfloat(s4 + d4 - s4 * d4 * inv255);
+ return check_as_pmfloat(src + dst - src * dst * inv255);
}
static const bool kFoldCoverageIntoSrcAlpha = true;
static const SkXfermode::Mode kMode = SkXfermode::kScreen_Mode;
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698