extend SkBenchmark to allow a bench to return a durationScale, which allows it to perform fewer actual interations, but report a scale factor to account for that. Thus a very slow bench can be compared head-to-head with a faster one, w/o actually forcing the tool to run for the full duration of the slower test.
Extend BitmapBench to time bicubic filtering, and use this durationScale for it.
Extend SkBenchmark to have setBitmapFlags(or, clear), allowing it to request a set of paint flags to be cleared, and set to be set.
BUG=
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/16069010
git-svn-id: http://skia.googlecode.com/svn/trunk@9315 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 001b3ab..404d4c3 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -106,6 +106,22 @@
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 @@
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 @@
SkTriState::State fDither;
bool fHasStrokeWidth;
SkScalar strokeWidth;
+ uint32_t fOrMask, fClearMask;
typedef SkRefCnt INHERITED;
};