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

Side by Side Diff: bench/SkBenchmark.h

Issue 16069010: extend SkBenchmark to allow a bench to return a durationScale, which allows it to perform fewer act… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months 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/BitmapBench.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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 doesn't, and so need not be re-run in every different rendering 99 doesn't, and so need not be re-run in every different rendering
100 mode. */ 100 mode. */
101 bool isRendering() { 101 bool isRendering() {
102 return fIsRendering; 102 return fIsRendering;
103 } 103 }
104 104
105 const char* findDefine(const char* key) const; 105 const char* findDefine(const char* key) const;
106 bool findDefine32(const char* key, int32_t* value) const; 106 bool findDefine32(const char* key, int32_t* value) const;
107 bool findDefineScalar(const char* key, SkScalar* value) const; 107 bool findDefineScalar(const char* key, SkScalar* value) const;
108 108
109 /** Assign masks for paint-flags. These will be applied when setupPaint()
110 * is called.
111 *
112 * Performs the following on the paint:
113 * uint32_t flags = paint.getFlags();
114 * flags &= ~clearMask;
115 * flags |= orMask;
116 * paint.setFlags(flags);
117 */
118 void setPaintMasks(uint32_t orMask, uint32_t clearMask) {
119 fOrMask = orMask;
120 fClearMask = clearMask;
121 }
122
123 float getDurationScale() { return this->onGetDurationScale(); }
124
109 protected: 125 protected:
110 virtual void setupPaint(SkPaint* paint); 126 virtual void setupPaint(SkPaint* paint);
111 127
112 virtual const char* onGetName() = 0; 128 virtual const char* onGetName() = 0;
113 virtual void onPreDraw() {} 129 virtual void onPreDraw() {}
114 virtual void onDraw(SkCanvas*) = 0; 130 virtual void onDraw(SkCanvas*) = 0;
115 virtual void onPostDraw() {} 131 virtual void onPostDraw() {}
132 // the caller will scale the computed duration by this value. It allows a
133 // slow bench to run fewer inner loops, but return the corresponding scale
134 // so that its reported duration can be compared against other benches.
135 // e.g.
136 // if I run 10x slower, I can run 1/10 the number of inner-loops, but
137 // return 10.0 for my durationScale, so I "report" the honest duration.
138 virtual float onGetDurationScale() { return 1; }
116 139
117 virtual SkIPoint onGetSize(); 140 virtual SkIPoint onGetSize();
118 /// Defaults to true. 141 /// Defaults to true.
119 bool fIsRendering; 142 bool fIsRendering;
120 143
121 private: 144 private:
122 const SkTDict<const char*>* fDict; 145 const SkTDict<const char*>* fDict;
123 int fForceAlpha; 146 int fForceAlpha;
124 bool fForceAA; 147 bool fForceAA;
125 bool fForceFilter; 148 bool fForceFilter;
126 SkTriState::State fDither; 149 SkTriState::State fDither;
127 bool fHasStrokeWidth; 150 bool fHasStrokeWidth;
128 SkScalar strokeWidth; 151 SkScalar strokeWidth;
152 uint32_t fOrMask, fClearMask;
129 153
130 typedef SkRefCnt INHERITED; 154 typedef SkRefCnt INHERITED;
131 }; 155 };
132 156
133 typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry; 157 typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
134 158
135 #endif 159 #endif
OLDNEW
« no previous file with comments | « bench/BitmapBench.cpp ('k') | bench/SkBenchmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698