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

Side by Side Diff: bench/ColorPrivBench.cpp

Issue 93933003: Add four_byte_interp benches. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: size_t Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/bench.gyp » ('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 "SkBenchmark.h"
2 #include "SkColorPriv.h"
3 #include "SkRandom.h"
4 #include "SkString.h"
5
6 template <bool kFast, bool kScale>
7 class FourByteInterpBench : public SkBenchmark {
8 public:
9 FourByteInterpBench() {
10 fName.set("four_byte_interp");
11 fName.append(kFast ? "_fast" : "_slow");
12 fName.append(kScale ? "_255" : "_256");
13
14 // We'll exhaustively test all scales instead of using random numbers.
15 for (int i = 0; i <= 256; i++) {
16 fScales[i] = i;
17 }
18 if (kScale) fScales[256] = 255; // We'll just do 255 twice if we're lim ited to [0,255].
19 }
20
21 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
22 return backend == kNonRendering_Backend;
23 }
24
25 virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
26
27 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
28 const SkPMColor src = 0xAB998877, dst = 0x66334455;
29 volatile SkPMColor junk = 0;
30 for (int i = 0; i < 10*this->getLoops(); ++i) {
31 for (size_t j = 0; j <= SK_ARRAY_COUNT(fScales); j++) {
32 const unsigned scale = fScales[j];
33 if (kFast && kScale) {
34 junk ^= SkFastFourByteInterp(src, dst, scale);
35 } else if (kFast) {
36 junk ^= SkFastFourByteInterp256(src, dst, scale);
37 } else if (kScale) {
38 junk ^= SkFourByteInterp(src, dst, scale);
39 } else {
40 junk ^= SkFourByteInterp256(src, dst, scale);
41 }
42 }
43 }
44 }
45
46 private:
47 SkString fName;
48 unsigned fScales[257]; // We need space for [0, 256].
49 };
50
51 #define COMMA ,
52 DEF_BENCH( return SkNEW(FourByteInterpBench<true COMMA true>); )
53 DEF_BENCH( return SkNEW(FourByteInterpBench<true COMMA false>); )
54 DEF_BENCH( return SkNEW(FourByteInterpBench<false COMMA true>); )
55 DEF_BENCH( return SkNEW(FourByteInterpBench<false COMMA false>); )
56 #undef COMMA
OLDNEW
« no previous file with comments | « no previous file | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698