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

Side by Side Diff: bench/PMFloatBench.cpp

Issue 977773002: Update SkPMFloat API a bit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 32 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkPMFloat.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Benchmark.h" 1 #include "Benchmark.h"
2 #include "SkPMFloat.h" 2 #include "SkPMFloat.h"
3 3
4 // Used to prevent the compiler from optimizing away the whole loop. 4 // Used to prevent the compiler from optimizing away the whole loop.
5 volatile uint32_t blackhole = 0; 5 volatile uint32_t blackhole = 0;
6 6
7 // Not a great random number generator, but it's very fast. 7 // Not a great random number generator, but it's very fast.
8 // The code we're measuring is quite fast, so low overhead is essential. 8 // The code we're measuring is quite fast, so low overhead is essential.
9 static uint32_t lcg_rand(uint32_t* seed) { 9 static uint32_t lcg_rand(uint32_t* seed) {
10 *seed *= 1664525; 10 *seed *= 1664525;
(...skipping 12 matching lines...) Expand all
23 uint32_t junk = 0; 23 uint32_t junk = 0;
24 uint32_t seed = 0; 24 uint32_t seed = 0;
25 for (int i = 0; i < loops; i++) { 25 for (int i = 0; i < loops; i++) {
26 #ifdef SK_DEBUG 26 #ifdef SK_DEBUG
27 // Our SkASSERTs will remind us that it's technically required that we premultiply. 27 // Our SkASSERTs will remind us that it's technically required that we premultiply.
28 SkPMColor c = SkPreMultiplyColor(lcg_rand(&seed)); 28 SkPMColor c = SkPreMultiplyColor(lcg_rand(&seed));
29 #else 29 #else
30 // But it's a lot faster not to, and this code won't really mind the non-PM colors. 30 // But it's a lot faster not to, and this code won't really mind the non-PM colors.
31 SkPMColor c = lcg_rand(&seed); 31 SkPMColor c = lcg_rand(&seed);
32 #endif 32 #endif
33 SkPMFloat pmf; 33 SkPMFloat pmf = SkPMFloat::FromPMColor(c);
34 pmf.set(c);
35 SkPMColor back = fClamp ? pmf.clamped() : pmf.get(); 34 SkPMColor back = fClamp ? pmf.clamped() : pmf.get();
36 junk ^= back; 35 junk ^= back;
37 } 36 }
38 blackhole ^= junk; 37 blackhole ^= junk;
39 } 38 }
40 39
41 bool fClamp; 40 bool fClamp;
42 }; 41 };
43 DEF_BENCH(return new PMFloatBench( true);) 42 DEF_BENCH(return new PMFloatBench( true);)
44 DEF_BENCH(return new PMFloatBench(false);) 43 DEF_BENCH(return new PMFloatBench(false);)
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPMFloat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698