Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: bench/SkBenchmark.h

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/ShaderMaskBench.cpp ('k') | bench/SkBenchmark.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // the rendering mode. 60 // the rendering mode.
61 virtual bool isSuitableFor(Backend backend) { 61 virtual bool isSuitableFor(Backend backend) {
62 return backend != kNonRendering_Backend; 62 return backend != kNonRendering_Backend;
63 } 63 }
64 64
65 // 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
66 // 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
67 // before the initial draw. 67 // before the initial draw.
68 void preDraw(); 68 void preDraw();
69 69
70 void draw(SkCanvas*); 70 // Bench framework can tune loops to be large enough for stable timing.
71 void draw(const int loops, SkCanvas*);
71 72
72 // Call after draw, allows the benchmark to do cleanup work outside of the 73 // Call after draw, allows the benchmark to do cleanup work outside of the
73 // timer. When a benchmark is repeatedly drawn, this is only called once 74 // timer. When a benchmark is repeatedly drawn, this is only called once
74 // after the last draw. 75 // after the last draw.
75 void postDraw(); 76 void postDraw();
76 77
77 void setForceAlpha(int alpha) { 78 void setForceAlpha(int alpha) {
78 fForceAlpha = alpha; 79 fForceAlpha = alpha;
79 } 80 }
80 81
(...skipping 16 matching lines...) Expand all
97 * uint32_t flags = paint.getFlags(); 98 * uint32_t flags = paint.getFlags();
98 * flags &= ~clearMask; 99 * flags &= ~clearMask;
99 * flags |= orMask; 100 * flags |= orMask;
100 * paint.setFlags(flags); 101 * paint.setFlags(flags);
101 */ 102 */
102 void setPaintMasks(uint32_t orMask, uint32_t clearMask) { 103 void setPaintMasks(uint32_t orMask, uint32_t clearMask) {
103 fOrMask = orMask; 104 fOrMask = orMask;
104 fClearMask = clearMask; 105 fClearMask = clearMask;
105 } 106 }
106 107
107 // The bench framework calls this to control the runtime of a bench.
108 void setLoops(int loops) {
109 fLoops = loops;
110 }
111
112 // Each bench should do its main work in a loop like this:
113 // for (int i = 0; i < this->getLoops(); i++) { <work here> }
114 int getLoops() const { return fLoops; }
115
116 static void SetResourcePath(const char* resPath) { gResourcePath.set(resPath ); } 108 static void SetResourcePath(const char* resPath) { gResourcePath.set(resPath ); }
117 109
118 static SkString& GetResourcePath() { return gResourcePath; } 110 static SkString& GetResourcePath() { return gResourcePath; }
119 111
120 protected: 112 protected:
121 virtual void setupPaint(SkPaint* paint); 113 virtual void setupPaint(SkPaint* paint);
122 114
123 virtual const char* onGetName() = 0; 115 virtual const char* onGetName() = 0;
124 virtual void onPreDraw() {} 116 virtual void onPreDraw() {}
125 virtual void onDraw(SkCanvas*) = 0; 117 // Each bench should do its main work in a loop like this:
118 // for (int i = 0; i < loops; i++) { <work here> }
119 virtual void onDraw(const int loops, SkCanvas*) = 0;
126 virtual void onPostDraw() {} 120 virtual void onPostDraw() {}
127 121
128 virtual SkIPoint onGetSize(); 122 virtual SkIPoint onGetSize();
129 123
130 private: 124 private:
131 int fForceAlpha; 125 int fForceAlpha;
132 bool fForceAA; 126 bool fForceAA;
133 bool fForceFilter; 127 bool fForceFilter;
134 SkTriState::State fDither; 128 SkTriState::State fDither;
135 uint32_t fOrMask, fClearMask; 129 uint32_t fOrMask, fClearMask;
136 int fLoops;
137 static SkString gResourcePath; 130 static SkString gResourcePath;
138 131
139 typedef SkRefCnt INHERITED; 132 typedef SkRefCnt INHERITED;
140 }; 133 };
141 134
142 typedef SkTRegistry<SkBenchmark*(*)()> BenchRegistry; 135 typedef SkTRegistry<SkBenchmark*(*)()> BenchRegistry;
143 136
144 #endif 137 #endif
OLDNEW
« no previous file with comments | « bench/ShaderMaskBench.cpp ('k') | bench/SkBenchmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698