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

Unified Diff: bench/PMFloatBench.cpp

Issue 936633002: Sketch SkPMFloat (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: explicit casts Created 5 years, 10 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 | gyp/bench.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PMFloatBench.cpp
diff --git a/bench/PMFloatBench.cpp b/bench/PMFloatBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8250c9e17c5385a8b9d27542b35e8c9f01edc181
--- /dev/null
+++ b/bench/PMFloatBench.cpp
@@ -0,0 +1,25 @@
+#include "Benchmark.h"
+#include "SkPMFloat.h"
+#include "SkRandom.h"
+
+struct PMFloatBench : public Benchmark {
+ explicit PMFloatBench(bool clamp) : fClamp(clamp) {}
+
+ const char* onGetName() SK_OVERRIDE { return fClamp ? "SkPMFloat_clamp" : "SkPMFloat_get"; }
+ bool isSuitableFor(Backend backend) SK_OVERRIDE { return backend == kNonRendering_Backend; }
+
+ void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ SkRandom rand;
+ for (int i = 0; i < loops; i++) {
+ SkPMColor c = SkPreMultiplyColor(rand.nextU());
+ SkPMFloat pmf;
+ pmf.set(c);
+ SkPMColor back = fClamp ? pmf.clamped() : pmf.get();
+ if (c != back) { SkFAIL("no joy"); } // This conditional makes this not compile away.
+ }
+ }
+
+ bool fClamp;
+};
+DEF_BENCH(return new PMFloatBench( true);)
+DEF_BENCH(return new PMFloatBench(false);)
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698