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

Unified Diff: bench/XfermodeBench.cpp

Issue 22918012: Add luminance mask transfer modes. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Dropped background texture handling, updated docs. Created 7 years, 4 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 | gm/lumamode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/XfermodeBench.cpp
diff --git a/bench/XfermodeBench.cpp b/bench/XfermodeBench.cpp
index 0d85fefe1fbb9bc48973b5bfe8a23351b1818d80..71cf0e69b5dc0d3f0b8062992dee72ea400687ba 100644
--- a/bench/XfermodeBench.cpp
+++ b/bench/XfermodeBench.cpp
@@ -12,6 +12,7 @@
#include "SkRandom.h"
#include "SkString.h"
#include "SkXfermode.h"
+#include "SkLumaXfermode.h"
// Benchmark that draws non-AA rects with an SkXfermode::Mode
class XfermodeBench : public SkBenchmark {
@@ -22,6 +23,13 @@ public:
fName.printf("Xfermode_%s", SkXfermode::ModeName(mode));
}
+ XfermodeBench(void* param, SkXfermode* xferMode, const char* name)
+ : SkBenchmark(param) {
+ SkASSERT(NULL != xferMode);
+ fXfermode.reset(xferMode);
+ fName.printf("Xfermode_%s", name);
+ }
+
protected:
virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
@@ -58,62 +66,44 @@ private:
//////////////////////////////////////////////////////////////////////////////
-static SkBenchmark* Fact00(void* p) { return new XfermodeBench(p, SkXfermode::kClear_Mode); }
-static SkBenchmark* Fact01(void* p) { return new XfermodeBench(p, SkXfermode::kSrc_Mode); }
-static SkBenchmark* Fact02(void* p) { return new XfermodeBench(p, SkXfermode::kDst_Mode); }
-static SkBenchmark* Fact03(void* p) { return new XfermodeBench(p, SkXfermode::kSrcOver_Mode); }
-static SkBenchmark* Fact04(void* p) { return new XfermodeBench(p, SkXfermode::kDstOver_Mode); }
-static SkBenchmark* Fact05(void* p) { return new XfermodeBench(p, SkXfermode::kSrcIn_Mode); }
-static SkBenchmark* Fact06(void* p) { return new XfermodeBench(p, SkXfermode::kDstIn_Mode); }
-static SkBenchmark* Fact07(void* p) { return new XfermodeBench(p, SkXfermode::kSrcOut_Mode); }
-static SkBenchmark* Fact08(void* p) { return new XfermodeBench(p, SkXfermode::kDstOut_Mode); }
-static SkBenchmark* Fact09(void* p) { return new XfermodeBench(p, SkXfermode::kSrcATop_Mode); }
-static SkBenchmark* Fact10(void* p) { return new XfermodeBench(p, SkXfermode::kDstATop_Mode); }
-static SkBenchmark* Fact11(void* p) { return new XfermodeBench(p, SkXfermode::kXor_Mode); }
-static SkBenchmark* Fact12(void* p) { return new XfermodeBench(p, SkXfermode::kPlus_Mode); }
-static SkBenchmark* Fact13(void* p) { return new XfermodeBench(p, SkXfermode::kModulate_Mode); }
-static SkBenchmark* Fact14(void* p) { return new XfermodeBench(p, SkXfermode::kScreen_Mode); }
-static SkBenchmark* Fact15(void* p) { return new XfermodeBench(p, SkXfermode::kOverlay_Mode); }
-static SkBenchmark* Fact16(void* p) { return new XfermodeBench(p, SkXfermode::kDarken_Mode); }
-static SkBenchmark* Fact17(void* p) { return new XfermodeBench(p, SkXfermode::kLighten_Mode); }
-static SkBenchmark* Fact18(void* p) { return new XfermodeBench(p, SkXfermode::kColorDodge_Mode); }
-static SkBenchmark* Fact19(void* p) { return new XfermodeBench(p, SkXfermode::kColorBurn_Mode); }
-static SkBenchmark* Fact20(void* p) { return new XfermodeBench(p, SkXfermode::kHardLight_Mode); }
-static SkBenchmark* Fact21(void* p) { return new XfermodeBench(p, SkXfermode::kSoftLight_Mode); }
-static SkBenchmark* Fact22(void* p) { return new XfermodeBench(p, SkXfermode::kDifference_Mode); }
-static SkBenchmark* Fact23(void* p) { return new XfermodeBench(p, SkXfermode::kExclusion_Mode); }
-static SkBenchmark* Fact24(void* p) { return new XfermodeBench(p, SkXfermode::kMultiply_Mode); }
-static SkBenchmark* Fact25(void* p) { return new XfermodeBench(p, SkXfermode::kHue_Mode); }
-static SkBenchmark* Fact26(void* p) { return new XfermodeBench(p, SkXfermode::kSaturation_Mode); }
-static SkBenchmark* Fact27(void* p) { return new XfermodeBench(p, SkXfermode::kColor_Mode); }
-static SkBenchmark* Fact28(void* p) { return new XfermodeBench(p, SkXfermode::kLuminosity_Mode); }
+#define CONCAT_I(x, y) x ## y
+#define CONCAT(x, y) CONCAT_I(x, y) // allow for macro expansion
+#define BENCH(...) \
+ static SkBenchmark* CONCAT(Fact, __LINE__)(void *p) { return new XfermodeBench(p, __VA_ARGS__); };\
+ static BenchRegistry CONCAT(gReg, __LINE__)(CONCAT(Fact, __LINE__));
+
+BENCH(SkXfermode::kClear_Mode)
+BENCH(SkXfermode::kSrc_Mode)
+BENCH(SkXfermode::kDst_Mode)
+BENCH(SkXfermode::kSrcOver_Mode)
+BENCH(SkXfermode::kDstOver_Mode)
+BENCH(SkXfermode::kSrcIn_Mode)
+BENCH(SkXfermode::kDstIn_Mode)
+BENCH(SkXfermode::kSrcOut_Mode)
+BENCH(SkXfermode::kDstOut_Mode)
+BENCH(SkXfermode::kSrcATop_Mode)
+BENCH(SkXfermode::kDstATop_Mode)
+BENCH(SkXfermode::kXor_Mode)
+
+BENCH(SkXfermode::kPlus_Mode)
+BENCH(SkXfermode::kModulate_Mode)
+BENCH(SkXfermode::kScreen_Mode)
+
+BENCH(SkXfermode::kOverlay_Mode)
+BENCH(SkXfermode::kDarken_Mode)
+BENCH(SkXfermode::kLighten_Mode)
+BENCH(SkXfermode::kColorDodge_Mode)
+BENCH(SkXfermode::kColorBurn_Mode)
+BENCH(SkXfermode::kHardLight_Mode)
+BENCH(SkXfermode::kSoftLight_Mode)
+BENCH(SkXfermode::kDifference_Mode)
+BENCH(SkXfermode::kExclusion_Mode)
+BENCH(SkXfermode::kMultiply_Mode)
+
+BENCH(SkXfermode::kHue_Mode)
+BENCH(SkXfermode::kSaturation_Mode)
+BENCH(SkXfermode::kColor_Mode)
+BENCH(SkXfermode::kLuminosity_Mode)
-static BenchRegistry gReg00(Fact00);
-static BenchRegistry gReg01(Fact01);
-static BenchRegistry gReg02(Fact02);
-static BenchRegistry gReg03(Fact03);
-static BenchRegistry gReg04(Fact04);
-static BenchRegistry gReg05(Fact05);
-static BenchRegistry gReg06(Fact06);
-static BenchRegistry gReg07(Fact07);
-static BenchRegistry gReg08(Fact08);
-static BenchRegistry gReg09(Fact09);
-static BenchRegistry gReg10(Fact10);
-static BenchRegistry gReg11(Fact11);
-static BenchRegistry gReg12(Fact12);
-static BenchRegistry gReg13(Fact13);
-static BenchRegistry gReg14(Fact14);
-static BenchRegistry gReg15(Fact15);
-static BenchRegistry gReg16(Fact16);
-static BenchRegistry gReg17(Fact17);
-static BenchRegistry gReg18(Fact18);
-static BenchRegistry gReg19(Fact19);
-static BenchRegistry gReg20(Fact20);
-static BenchRegistry gReg21(Fact21);
-static BenchRegistry gReg22(Fact22);
-static BenchRegistry gReg23(Fact23);
-static BenchRegistry gReg24(Fact24);
-static BenchRegistry gReg25(Fact25);
-static BenchRegistry gReg26(Fact26);
-static BenchRegistry gReg27(Fact27);
-static BenchRegistry gReg28(Fact28);
+BENCH(SkLumaMaskXfermode::Create(SkXfermode::kSrcIn_Mode), "SrcInLuma")
+BENCH(SkLumaMaskXfermode::Create(SkXfermode::kDstIn_Mode), "DstInLuma")
« no previous file with comments | « no previous file | gm/lumamode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698