| 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 return backend != kNonRendering_Backend; | 63 return backend != kNonRendering_Backend; |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual int calculateLoops(int defaultLoops) const { | 66 virtual int calculateLoops(int defaultLoops) const { |
| 67 return defaultLoops; | 67 return defaultLoops; |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Call before draw, allows the benchmark to do setup work outside of the | 70 // Call before draw, allows the benchmark to do setup work outside of the |
| 71 // timer. When a benchmark is repeatedly drawn, this should be called once | 71 // timer. When a benchmark is repeatedly drawn, this should be called once |
| 72 // before the initial draw. | 72 // before the initial draw. |
| 73 void preDraw(); | 73 void delayedSetup(); |
| 74 | 74 |
| 75 // Called once before and after a series of draw calls to a single canvas. | 75 // Called once before and after a series of draw calls to a single canvas. |
| 76 // The setup/break down in these calls is not timed. | 76 // The setup/break down in these calls is not timed. |
| 77 void perCanvasPreDraw(SkCanvas*); | 77 void perCanvasPreDraw(SkCanvas*); |
| 78 void perCanvasPostDraw(SkCanvas*); | 78 void perCanvasPostDraw(SkCanvas*); |
| 79 | 79 |
| 80 // Called just before and after each call to draw(). Not timed. |
| 81 void preDraw(SkCanvas*); |
| 82 void postDraw(SkCanvas*); |
| 83 |
| 80 // Bench framework can tune loops to be large enough for stable timing. | 84 // Bench framework can tune loops to be large enough for stable timing. |
| 81 void draw(const int loops, SkCanvas*); | 85 void draw(const int loops, SkCanvas*); |
| 82 | 86 |
| 83 void setForceAlpha(int alpha) { | 87 void setForceAlpha(int alpha) { |
| 84 fForceAlpha = alpha; | 88 fForceAlpha = alpha; |
| 85 } | 89 } |
| 86 | 90 |
| 87 void setDither(SkTriState::State state) { | 91 void setDither(SkTriState::State state) { |
| 88 fDither = state; | 92 fDither = state; |
| 89 } | 93 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 105 /* | 109 /* |
| 106 * Benches which support running in a visual mode can advertise this functio
nality | 110 * Benches which support running in a visual mode can advertise this functio
nality |
| 107 */ | 111 */ |
| 108 virtual bool isVisual() { return false; } | 112 virtual bool isVisual() { return false; } |
| 109 | 113 |
| 110 protected: | 114 protected: |
| 111 virtual void setupPaint(SkPaint* paint); | 115 virtual void setupPaint(SkPaint* paint); |
| 112 | 116 |
| 113 virtual const char* onGetName() = 0; | 117 virtual const char* onGetName() = 0; |
| 114 virtual const char* onGetUniqueName() { return this->onGetName(); } | 118 virtual const char* onGetUniqueName() { return this->onGetName(); } |
| 115 virtual void onPreDraw() {} | 119 virtual void onDelayedSetup() {} |
| 116 virtual void onPerCanvasPreDraw(SkCanvas*) {} | 120 virtual void onPerCanvasPreDraw(SkCanvas*) {} |
| 117 virtual void onPerCanvasPostDraw(SkCanvas*) {} | 121 virtual void onPerCanvasPostDraw(SkCanvas*) {} |
| 122 virtual void onPreDraw(SkCanvas*) {} |
| 123 virtual void onPostDraw(SkCanvas*) {} |
| 118 // Each bench should do its main work in a loop like this: | 124 // Each bench should do its main work in a loop like this: |
| 119 // for (int i = 0; i < loops; i++) { <work here> } | 125 // for (int i = 0; i < loops; i++) { <work here> } |
| 120 virtual void onDraw(const int loops, SkCanvas*) = 0; | 126 virtual void onDraw(const int loops, SkCanvas*) = 0; |
| 121 | 127 |
| 122 virtual SkIPoint onGetSize(); | 128 virtual SkIPoint onGetSize(); |
| 123 | 129 |
| 124 private: | 130 private: |
| 125 int fForceAlpha; | 131 int fForceAlpha; |
| 126 SkTriState::State fDither; | 132 SkTriState::State fDither; |
| 127 uint32_t fOrMask, fClearMask; | 133 uint32_t fOrMask, fClearMask; |
| 128 | 134 |
| 129 typedef SkRefCnt INHERITED; | 135 typedef SkRefCnt INHERITED; |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; | 138 typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; |
| 133 | 139 |
| 134 #endif | 140 #endif |
| OLD | NEW |