aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/PathBench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bench/PathBench.cpp')
-rw-r--r--bench/PathBench.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index 449d30558e..de8be6c758 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -1076,6 +1076,47 @@ private:
///////////////////////////////////////////////////////////////////////////////
+class TightBoundsBench : public Benchmark {
+ SkPath fPath;
+ SkString fName;
+ bool (*fProc)(const SkPath&, SkRect*);
+
+public:
+ TightBoundsBench(bool (*proc)(const SkPath&, SkRect*), const char suffix[]) : fProc(proc) {
+ fName.printf("tight_bounds_%s", suffix);
+
+ const int N = 100;
+ SkRandom rand;
+ for (int i = 0; i < N; ++i) {
+ fPath.moveTo(rand.nextF()*100, rand.nextF()*100);
+ fPath.lineTo(rand.nextF()*100, rand.nextF()*100);
+ fPath.quadTo(rand.nextF()*100, rand.nextF()*100, rand.nextF()*100, rand.nextF()*100);
+ fPath.conicTo(rand.nextF()*100, rand.nextF()*100, rand.nextF()*100, rand.nextF()*100,
+ rand.nextF()*10);
+ fPath.cubicTo(rand.nextF()*100, rand.nextF()*100, rand.nextF()*100, rand.nextF()*100,
+ rand.nextF()*100, rand.nextF()*100);
+ }
+ }
+
+protected:
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+
+ const char* onGetName() override { return fName.c_str(); }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ SkRect bounds;
+ for (int i = 0; i < loops*100; ++i) {
+ fProc(fPath, &bounds);
+ }
+ }
+
+private:
+ typedef Benchmark INHERITED;
+};
+
+
const SkRect ConservativelyContainsBench::kBounds = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
const SkSize ConservativelyContainsBench::kQueryMin = SkSize::Make(SkIntToScalar(1), SkIntToScalar(1));
const SkSize ConservativelyContainsBench::kQueryMax = SkSize::Make(SkIntToScalar(40), SkIntToScalar(40));
@@ -1143,6 +1184,10 @@ DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::kRoundRect_Type); )
DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::kOval_Type); )
+#include "SkPathOps.h"
+#include "SkPathPriv.h"
+DEF_BENCH( return new TightBoundsBench(SkPathPriv::ComputeTightBounds, "priv"); )
+DEF_BENCH( return new TightBoundsBench(TightBounds, "pathops"); )
// These seem to be optimized away, which is troublesome for timing.
/*