expose new tight-bounds method on SkPath
BUG=skia:
Change-Id: Ie50df49c1758af203042a84dc2cd505046373d2c
Reviewed-on: https://skia-review.googlesource.com/7996
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index de8be6c..10cffc2 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -1079,10 +1079,10 @@
class TightBoundsBench : public Benchmark {
SkPath fPath;
SkString fName;
- bool (*fProc)(const SkPath&, SkRect*);
+ SkRect (*fProc)(const SkPath&);
public:
- TightBoundsBench(bool (*proc)(const SkPath&, SkRect*), const char suffix[]) : fProc(proc) {
+ TightBoundsBench(SkRect (*proc)(const SkPath&), const char suffix[]) : fProc(proc) {
fName.printf("tight_bounds_%s", suffix);
const int N = 100;
@@ -1106,9 +1106,8 @@
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);
+ fProc(fPath);
}
}
@@ -1186,8 +1185,11 @@
#include "SkPathOps.h"
#include "SkPathPriv.h"
-DEF_BENCH( return new TightBoundsBench(SkPathPriv::ComputeTightBounds, "priv"); )
-DEF_BENCH( return new TightBoundsBench(TightBounds, "pathops"); )
+DEF_BENCH( return new TightBoundsBench([](const SkPath& path){ return path.computeTightBounds();},
+ "priv"); )
+DEF_BENCH( return new TightBoundsBench([](const SkPath& path) {
+ SkRect bounds; TightBounds(path, &bounds); return bounds;
+ }, "pathops"); )
// These seem to be optimized away, which is troublesome for timing.
/*