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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "Benchmark.h"
2 #include "SkPMFloat.h"
3 #include "SkRandom.h"
4
5 struct PMFloatBench : public Benchmark {
6 explicit PMFloatBench(bool clamp) : fClamp(clamp) {}
7
8 const char* onGetName() SK_OVERRIDE { return fClamp ? "SkPMFloat_clamp" : "S kPMFloat_get"; }
9 bool isSuitableFor(Backend backend) SK_OVERRIDE { return backend == kNonRend ering_Backend; }
10
11 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
12 SkRandom rand;
13 for (int i = 0; i < loops; i++) {
14 SkPMColor c = SkPreMultiplyColor(rand.nextU());
15 SkPMFloat pmf;
16 pmf.set(c);
17 SkPMColor back = fClamp ? pmf.clamped() : pmf.get();
18 if (c != back) { SkFAIL("no joy"); } // This conditional makes this not compile away.
19 }
20 }
21
22 bool fClamp;
23 };
24 DEF_BENCH(return new PMFloatBench( true);)
25 DEF_BENCH(return new PMFloatBench(false);)
OLDNEW
« 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