OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 #ifndef SkBenchmark_DEFINED | |
9 #define SkBenchmark_DEFINED | |
10 | 7 |
| 8 #ifndef Benchmark_DEFINED |
| 9 #define Benchmark_DEFINED |
| 10 |
| 11 #include "SkPoint.h" |
11 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
12 #include "SkPoint.h" | |
13 #include "SkString.h" | 13 #include "SkString.h" |
14 #include "SkTRegistry.h" | 14 #include "SkTRegistry.h" |
15 | 15 |
16 #define DEF_BENCH(code) \ | 16 #define DEF_BENCH(code) \ |
17 namespace { \ | 17 namespace { \ |
18 static SkBenchmark* SK_MACRO_APPEND_LINE(factory)(void*) { code; } \ | 18 static Benchmark* SK_MACRO_APPEND_LINE(factory)(void*) { code; } \ |
19 BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(SK_MACRO_APPEND_LINE(factory)); \ | 19 BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(SK_MACRO_APPEND_LINE(factory)); \ |
20 } | 20 } |
21 | 21 |
22 /* | 22 /* |
23 * With the above macros, you can register benches as follows (at the bottom | 23 * With the above macros, you can register benches as follows (at the bottom |
24 * of your .cpp) | 24 * of your .cpp) |
25 * | 25 * |
26 * DEF_BENCH(return new MyBenchmark(...)) | 26 * DEF_BENCH(return new MyBenchmark(...)) |
27 * DEF_BENCH(return new MyBenchmark(...)) | 27 * DEF_BENCH(return new MyBenchmark(...)) |
28 * DEF_BENCH(return new MyBenchmark(...)) | 28 * DEF_BENCH(return new MyBenchmark(...)) |
29 */ | 29 */ |
30 | 30 |
31 | 31 |
32 class SkCanvas; | 32 class SkCanvas; |
33 class SkPaint; | 33 class SkPaint; |
34 | 34 |
35 class SkTriState { | 35 class SkTriState { |
36 public: | 36 public: |
37 enum State { | 37 enum State { |
38 kDefault, | 38 kDefault, |
39 kTrue, | 39 kTrue, |
40 kFalse | 40 kFalse |
41 }; | 41 }; |
42 static const char* Name[]; | 42 static const char* Name[]; |
43 }; | 43 }; |
44 | 44 |
45 class SkBenchmark : public SkRefCnt { | 45 class Benchmark : public SkRefCnt { |
46 public: | 46 public: |
47 SK_DECLARE_INST_COUNT(SkBenchmark) | 47 SK_DECLARE_INST_COUNT(Benchmark) |
48 | 48 |
49 SkBenchmark(); | 49 Benchmark(); |
50 | 50 |
51 const char* getName(); | 51 const char* getName(); |
52 SkIPoint getSize(); | 52 SkIPoint getSize(); |
53 | 53 |
54 enum Backend { | 54 enum Backend { |
55 kNonRendering_Backend, | 55 kNonRendering_Backend, |
56 kRaster_Backend, | 56 kRaster_Backend, |
57 kGPU_Backend, | 57 kGPU_Backend, |
58 kPDF_Backend, | 58 kPDF_Backend, |
59 }; | 59 }; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 private: | 116 private: |
117 int fForceAlpha; | 117 int fForceAlpha; |
118 bool fForceAA; | 118 bool fForceAA; |
119 bool fForceFilter; | 119 bool fForceFilter; |
120 SkTriState::State fDither; | 120 SkTriState::State fDither; |
121 uint32_t fOrMask, fClearMask; | 121 uint32_t fOrMask, fClearMask; |
122 | 122 |
123 typedef SkRefCnt INHERITED; | 123 typedef SkRefCnt INHERITED; |
124 }; | 124 }; |
125 | 125 |
126 typedef SkTRegistry<SkBenchmark*(*)(void*)> BenchRegistry; | 126 typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; |
127 | 127 |
128 #endif | 128 #endif |
OLD | NEW |