OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef Benchmark_DEFINED | 8 #ifndef Benchmark_DEFINED |
9 #define Benchmark_DEFINED | 9 #define Benchmark_DEFINED |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // the rendering mode. | 63 // the rendering mode. |
64 virtual bool isSuitableFor(Backend backend) { | 64 virtual bool isSuitableFor(Backend backend) { |
65 return backend != kNonRendering_Backend; | 65 return backend != kNonRendering_Backend; |
66 } | 66 } |
67 | 67 |
68 // Call before draw, allows the benchmark to do setup work outside of the | 68 // Call before draw, allows the benchmark to do setup work outside of the |
69 // timer. When a benchmark is repeatedly drawn, this should be called once | 69 // timer. When a benchmark is repeatedly drawn, this should be called once |
70 // before the initial draw. | 70 // before the initial draw. |
71 void preDraw(); | 71 void preDraw(); |
72 | 72 |
| 73 // Called once before and after a series of draw calls to a single canvas. |
| 74 // The setup/break down in these calls is not timed. |
| 75 void perCanvasPreDraw(SkCanvas*); |
| 76 void perCanvasPostDraw(SkCanvas*); |
| 77 |
73 // Bench framework can tune loops to be large enough for stable timing. | 78 // Bench framework can tune loops to be large enough for stable timing. |
74 void draw(const int loops, SkCanvas*); | 79 void draw(const int loops, SkCanvas*); |
75 | 80 |
76 void setForceAlpha(int alpha) { | 81 void setForceAlpha(int alpha) { |
77 fForceAlpha = alpha; | 82 fForceAlpha = alpha; |
78 } | 83 } |
79 | 84 |
80 void setDither(SkTriState::State state) { | 85 void setDither(SkTriState::State state) { |
81 fDither = state; | 86 fDither = state; |
82 } | 87 } |
(...skipping 11 matching lines...) Expand all Loading... |
94 fOrMask = orMask; | 99 fOrMask = orMask; |
95 fClearMask = clearMask; | 100 fClearMask = clearMask; |
96 } | 101 } |
97 | 102 |
98 protected: | 103 protected: |
99 virtual void setupPaint(SkPaint* paint); | 104 virtual void setupPaint(SkPaint* paint); |
100 | 105 |
101 virtual const char* onGetName() = 0; | 106 virtual const char* onGetName() = 0; |
102 virtual const char* onGetUniqueName() { return this->onGetName(); } | 107 virtual const char* onGetUniqueName() { return this->onGetName(); } |
103 virtual void onPreDraw() {} | 108 virtual void onPreDraw() {} |
| 109 virtual void onPerCanvasPreDraw(SkCanvas*) {} |
| 110 virtual void onPerCanvasPostDraw(SkCanvas*) {} |
104 // Each bench should do its main work in a loop like this: | 111 // Each bench should do its main work in a loop like this: |
105 // for (int i = 0; i < loops; i++) { <work here> } | 112 // for (int i = 0; i < loops; i++) { <work here> } |
106 virtual void onDraw(const int loops, SkCanvas*) = 0; | 113 virtual void onDraw(const int loops, SkCanvas*) = 0; |
107 | 114 |
108 virtual SkIPoint onGetSize(); | 115 virtual SkIPoint onGetSize(); |
109 | 116 |
110 private: | 117 private: |
111 int fForceAlpha; | 118 int fForceAlpha; |
112 SkTriState::State fDither; | 119 SkTriState::State fDither; |
113 uint32_t fOrMask, fClearMask; | 120 uint32_t fOrMask, fClearMask; |
114 | 121 |
115 typedef SkRefCnt INHERITED; | 122 typedef SkRefCnt INHERITED; |
116 }; | 123 }; |
117 | 124 |
118 typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; | 125 typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; |
119 | 126 |
120 #endif | 127 #endif |
OLD | NEW |