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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 // Call before draw, allows the benchmark to do setup work outside of the | 67 // Call before draw, allows the benchmark to do setup work outside of the |
68 // timer. When a benchmark is repeatedly drawn, this should be called once | 68 // timer. When a benchmark is repeatedly drawn, this should be called once |
69 // before the initial draw. | 69 // before the initial draw. |
70 void preDraw(); | 70 void preDraw(); |
71 | 71 |
72 // Bench framework can tune loops to be large enough for stable timing. | 72 // Bench framework can tune loops to be large enough for stable timing. |
73 void draw(const int loops, SkCanvas*); | 73 void draw(const int loops, SkCanvas*); |
74 | 74 |
75 // Call after draw, allows the benchmark to do cleanup work outside of the | |
76 // timer. When a benchmark is repeatedly drawn, this is only called once | |
77 // after the last draw. | |
78 void postDraw(); | |
79 | |
80 void setForceAlpha(int alpha) { | 75 void setForceAlpha(int alpha) { |
81 fForceAlpha = alpha; | 76 fForceAlpha = alpha; |
82 } | 77 } |
83 | 78 |
84 void setForceAA(bool aa) { | 79 void setForceAA(bool aa) { |
85 fForceAA = aa; | 80 fForceAA = aa; |
86 } | 81 } |
87 | 82 |
88 void setForceFilter(bool filter) { | 83 void setForceFilter(bool filter) { |
89 fForceFilter = filter; | 84 fForceFilter = filter; |
(...skipping 21 matching lines...) Expand all Loading... |
111 static SkString GetResourcePath(); | 106 static SkString GetResourcePath(); |
112 | 107 |
113 protected: | 108 protected: |
114 virtual void setupPaint(SkPaint* paint); | 109 virtual void setupPaint(SkPaint* paint); |
115 | 110 |
116 virtual const char* onGetName() = 0; | 111 virtual const char* onGetName() = 0; |
117 virtual void onPreDraw() {} | 112 virtual void onPreDraw() {} |
118 // Each bench should do its main work in a loop like this: | 113 // Each bench should do its main work in a loop like this: |
119 // for (int i = 0; i < loops; i++) { <work here> } | 114 // for (int i = 0; i < loops; i++) { <work here> } |
120 virtual void onDraw(const int loops, SkCanvas*) = 0; | 115 virtual void onDraw(const int loops, SkCanvas*) = 0; |
121 virtual void onPostDraw() {} | |
122 | 116 |
123 virtual SkIPoint onGetSize(); | 117 virtual SkIPoint onGetSize(); |
124 | 118 |
125 private: | 119 private: |
126 int fForceAlpha; | 120 int fForceAlpha; |
127 bool fForceAA; | 121 bool fForceAA; |
128 bool fForceFilter; | 122 bool fForceFilter; |
129 SkTriState::State fDither; | 123 SkTriState::State fDither; |
130 uint32_t fOrMask, fClearMask; | 124 uint32_t fOrMask, fClearMask; |
131 static const char* gResourcePath; | 125 static const char* gResourcePath; |
132 | 126 |
133 typedef SkRefCnt INHERITED; | 127 typedef SkRefCnt INHERITED; |
134 }; | 128 }; |
135 | 129 |
136 typedef SkTRegistry<SkBenchmark*(*)(void*)> BenchRegistry; | 130 typedef SkTRegistry<SkBenchmark*(*)(void*)> BenchRegistry; |
137 | 131 |
138 #endif | 132 #endif |
OLD | NEW |