Index: bench/Xfer4fBench.cpp |
diff --git a/bench/Xfer4fBench.cpp b/bench/Xfer4fBench.cpp |
index 9c1b419ba5497f5e7d7040a4c2ea231a60d3f0d7..6b6bbc8d23bee61fb643ce9dd2b93153d9794035 100644 |
--- a/bench/Xfer4fBench.cpp |
+++ b/bench/Xfer4fBench.cpp |
@@ -10,6 +10,8 @@ |
#include "SkString.h" |
#include "SkXfermode.h" |
+#define USE_AA (1 << 31) // merge with Xfermode::PMFlags w/o conflict |
+ |
#define INNER_LOOPS 1000 |
// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode. |
@@ -17,17 +19,27 @@ class Xfer4fBench : public Benchmark { |
public: |
Xfer4fBench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t flags) |
: fDoN(doN) |
- , fFlags(flags) |
+ , fFlags(flags & ~USE_AA) |
{ |
- fProc1 = SkXfermode::GetPM4fProc1(mode, flags); |
- fProcN = SkXfermode::GetPM4fProcN(mode, flags); |
- fName.printf("xfer4f_%s_%c_%s_%s", name, fDoN ? 'N' : '1', |
+ fProc1 = SkXfermode::GetPM4fProc1(mode, fFlags); |
+ fProcN = SkXfermode::GetPM4fProcN(mode, fFlags); |
+ fName.printf("xfer4f_%s_%s_%c_%s_%s", |
+ name, |
+ (flags & USE_AA) ? "aa" : "bw", |
+ fDoN ? 'N' : '1', |
(flags & SkXfermode::kSrcIsOpaque_PM4fFlag) ? "opaque" : "alpha", |
(flags & SkXfermode::kDstIsSRGB_PM4fFlag) ? "srgb" : "linear"); |
for (int i = 0; i < N; ++i) { |
fSrc[i] = {{ 1, 1, 1, 1 }}; |
fDst[i] = 0; |
+ fAAStorage[i] = i * 255 / (N - 1); |
+ } |
+ |
+ if (flags & USE_AA) { |
+ fAA = fAAStorage; |
+ } else { |
+ fAA = nullptr; |
} |
} |
@@ -38,13 +50,12 @@ protected: |
void onDraw(int loops, SkCanvas*) override { |
const SkXfermode::PM4fState state{ nullptr, fFlags }; |
- const uint8_t* aa = nullptr; |
for (int i = 0; i < loops * INNER_LOOPS; ++i) { |
if (fDoN) { |
- fProcN(state, fDst, fSrc, N, aa); |
+ fProcN(state, fDst, fSrc, N, fAA); |
} else { |
- fProc1(state, fDst, fSrc[0], N, aa); |
+ fProc1(state, fDst, fSrc[0], N, fAA); |
} |
} |
} |
@@ -53,6 +64,7 @@ private: |
SkString fName; |
SkXfermode::PM4fProc1 fProc1; |
SkXfermode::PM4fProcN fProcN; |
+ const SkAlpha* fAA; |
bool fDoN; |
uint32_t fFlags; |
@@ -61,6 +73,7 @@ private: |
}; |
SkPM4f fSrc[N]; |
SkPMColor fDst[N]; |
+ uint8_t fAAStorage[N]; |
typedef Benchmark INHERITED; |
}; |
@@ -79,3 +92,13 @@ DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F |
DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F00); ) |
DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F11); ) |
DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F01); ) |
+ |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F10 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F00 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F11 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F01 | USE_AA); ) |
+ |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F10 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F00 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F11 | USE_AA); ) |
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F01 | USE_AA); ) |