OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkBenchmark_DEFINED | 8 #ifndef SkBenchmark_DEFINED |
9 #define SkBenchmark_DEFINED | 9 #define SkBenchmark_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 class SkBenchmark : public SkRefCnt { | 43 class SkBenchmark : public SkRefCnt { |
44 public: | 44 public: |
45 SK_DECLARE_INST_COUNT(SkBenchmark) | 45 SK_DECLARE_INST_COUNT(SkBenchmark) |
46 | 46 |
47 SkBenchmark(); | 47 SkBenchmark(); |
48 | 48 |
49 const char* getName(); | 49 const char* getName(); |
50 SkIPoint getSize(); | 50 SkIPoint getSize(); |
51 | 51 |
| 52 enum Backend { |
| 53 kNonRendering_Backend, |
| 54 kRaster_Backend, |
| 55 kGPU_Backend, |
| 56 kPDF_Backend, |
| 57 }; |
| 58 |
| 59 // Call to determine whether the benchmark is intended for |
| 60 // the rendering mode. |
| 61 virtual bool isSuitableFor(Backend backend) { |
| 62 return backend != kNonRendering_Backend; |
| 63 } |
| 64 |
52 // Call before draw, allows the benchmark to do setup work outside of the | 65 // Call before draw, allows the benchmark to do setup work outside of the |
53 // timer. When a benchmark is repeatedly drawn, this should be called once | 66 // timer. When a benchmark is repeatedly drawn, this should be called once |
54 // before the initial draw. | 67 // before the initial draw. |
55 void preDraw(); | 68 void preDraw(); |
56 | 69 |
57 void draw(SkCanvas*); | 70 void draw(SkCanvas*); |
58 | 71 |
59 // Call after draw, allows the benchmark to do cleanup work outside of the | 72 // Call after draw, allows the benchmark to do cleanup work outside of the |
60 // timer. When a benchmark is repeatedly drawn, this is only called once | 73 // timer. When a benchmark is repeatedly drawn, this is only called once |
61 // after the last draw. | 74 // after the last draw. |
62 void postDraw(); | 75 void postDraw(); |
63 | 76 |
64 void setForceAlpha(int alpha) { | 77 void setForceAlpha(int alpha) { |
65 fForceAlpha = alpha; | 78 fForceAlpha = alpha; |
66 } | 79 } |
67 | 80 |
68 void setForceAA(bool aa) { | 81 void setForceAA(bool aa) { |
69 fForceAA = aa; | 82 fForceAA = aa; |
70 } | 83 } |
71 | 84 |
72 void setForceFilter(bool filter) { | 85 void setForceFilter(bool filter) { |
73 fForceFilter = filter; | 86 fForceFilter = filter; |
74 } | 87 } |
75 | 88 |
76 void setDither(SkTriState::State state) { | 89 void setDither(SkTriState::State state) { |
77 fDither = state; | 90 fDither = state; |
78 } | 91 } |
79 | 92 |
80 /** If true; the benchmark does rendering; if false, the benchmark | |
81 doesn't, and so need not be re-run in every different rendering | |
82 mode. */ | |
83 bool isRendering() { | |
84 return fIsRendering; | |
85 } | |
86 | |
87 /** Assign masks for paint-flags. These will be applied when setupPaint() | 93 /** Assign masks for paint-flags. These will be applied when setupPaint() |
88 * is called. | 94 * is called. |
89 * | 95 * |
90 * Performs the following on the paint: | 96 * Performs the following on the paint: |
91 * uint32_t flags = paint.getFlags(); | 97 * uint32_t flags = paint.getFlags(); |
92 * flags &= ~clearMask; | 98 * flags &= ~clearMask; |
93 * flags |= orMask; | 99 * flags |= orMask; |
94 * paint.setFlags(flags); | 100 * paint.setFlags(flags); |
95 */ | 101 */ |
96 void setPaintMasks(uint32_t orMask, uint32_t clearMask) { | 102 void setPaintMasks(uint32_t orMask, uint32_t clearMask) { |
(...skipping 16 matching lines...) Expand all Loading... |
113 | 119 |
114 protected: | 120 protected: |
115 virtual void setupPaint(SkPaint* paint); | 121 virtual void setupPaint(SkPaint* paint); |
116 | 122 |
117 virtual const char* onGetName() = 0; | 123 virtual const char* onGetName() = 0; |
118 virtual void onPreDraw() {} | 124 virtual void onPreDraw() {} |
119 virtual void onDraw(SkCanvas*) = 0; | 125 virtual void onDraw(SkCanvas*) = 0; |
120 virtual void onPostDraw() {} | 126 virtual void onPostDraw() {} |
121 | 127 |
122 virtual SkIPoint onGetSize(); | 128 virtual SkIPoint onGetSize(); |
123 /// Defaults to true. | |
124 bool fIsRendering; | |
125 | 129 |
126 private: | 130 private: |
127 int fForceAlpha; | 131 int fForceAlpha; |
128 bool fForceAA; | 132 bool fForceAA; |
129 bool fForceFilter; | 133 bool fForceFilter; |
130 SkTriState::State fDither; | 134 SkTriState::State fDither; |
131 uint32_t fOrMask, fClearMask; | 135 uint32_t fOrMask, fClearMask; |
132 int fLoops; | 136 int fLoops; |
133 static SkString gResourcePath; | 137 static SkString gResourcePath; |
134 | 138 |
135 typedef SkRefCnt INHERITED; | 139 typedef SkRefCnt INHERITED; |
136 }; | 140 }; |
137 | 141 |
138 typedef SkTRegistry<SkBenchmark*(*)()> BenchRegistry; | 142 typedef SkTRegistry<SkBenchmark*(*)()> BenchRegistry; |
139 | 143 |
140 #endif | 144 #endif |
OLD | NEW |