diff options
author | Mike Reed <reed@google.com> | 2017-02-02 17:45:56 -0800 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-03 15:19:05 +0000 |
commit | 0d7dac8fb8c404cada8d46646a980772b9dc55d6 (patch) | |
tree | 3aebab340b2369c39a02dbd50de770bdd2722c90 /bench/PathBench.cpp | |
parent | 113628d76176a1ab3e6719c59efff23cd10ab213 (diff) |
experimental tight-bounds
not sure about api -- perhaps it could just return the bounds, and make them 0,0,0,0 if the path
is empty -- the caller can trivially know if the path is empty themselves.
BUG=skia:
Change-Id: I2dbb861e8d981b27c5a6833643977f5bd6802217
Reviewed-on: https://skia-review.googlesource.com/7989
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'bench/PathBench.cpp')
-rw-r--r-- | bench/PathBench.cpp | 45 |
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. /* |