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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/BitmapBench.cpp ('k') | bench/SkBenchmark.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SkBenchmark.h
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 001b3ab679d0a9529b02ea098710ea3d3b7e8b7f..404d4c3e7e6ebd5e65a0c4119f624b4653dade5e 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -106,6 +106,22 @@ public:
bool findDefine32(const char* key, int32_t* value) const;
bool findDefineScalar(const char* key, SkScalar* value) const;
+ /** Assign masks for paint-flags. These will be applied when setupPaint()
+ * is called.
+ *
+ * Performs the following on the paint:
+ * uint32_t flags = paint.getFlags();
+ * flags &= ~clearMask;
+ * flags |= orMask;
+ * paint.setFlags(flags);
+ */
+ void setPaintMasks(uint32_t orMask, uint32_t clearMask) {
+ fOrMask = orMask;
+ fClearMask = clearMask;
+ }
+
+ float getDurationScale() { return this->onGetDurationScale(); }
+
protected:
virtual void setupPaint(SkPaint* paint);
@@ -113,6 +129,13 @@ protected:
virtual void onPreDraw() {}
virtual void onDraw(SkCanvas*) = 0;
virtual void onPostDraw() {}
+ // the caller will scale the computed duration by this value. It allows a
+ // slow bench to run fewer inner loops, but return the corresponding scale
+ // so that its reported duration can be compared against other benches.
+ // e.g.
+ // if I run 10x slower, I can run 1/10 the number of inner-loops, but
+ // return 10.0 for my durationScale, so I "report" the honest duration.
+ virtual float onGetDurationScale() { return 1; }
virtual SkIPoint onGetSize();
/// Defaults to true.
@@ -126,6 +149,7 @@ private:
SkTriState::State fDither;
bool fHasStrokeWidth;
SkScalar strokeWidth;
+ uint32_t fOrMask, fClearMask;
typedef SkRefCnt INHERITED;
};
« 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