From 8d3196bdfcf478982bec9885d21e1d664ab9a72b Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 3 Feb 2017 11:34:13 -0500 Subject: expose new tight-bounds method on SkPath BUG=skia: Change-Id: Ie50df49c1758af203042a84dc2cd505046373d2c Reviewed-on: https://skia-review.googlesource.com/7996 Reviewed-by: Florin Malita Commit-Queue: Mike Reed --- bench/PathBench.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bench/PathBench.cpp') diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp index de8be6c758..10cffc20c2 100644 --- a/bench/PathBench.cpp +++ b/bench/PathBench.cpp @@ -1079,10 +1079,10 @@ private: 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 @@ protected: 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 @@ DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k #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. /* -- cgit v1.2.3