From 4ad22753504828342e47627b12210c2c47e7290a Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 15 May 2012 19:50:58 +0000 Subject: add clipped case for dashing to exercise quickReject git-svn-id: http://skia.googlecode.com/svn/trunk@3961 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/DashBench.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'bench/DashBench.cpp') diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp index a335c467b8..40fffe6dea 100644 --- a/bench/DashBench.cpp +++ b/bench/DashBench.cpp @@ -34,18 +34,21 @@ protected: SkString fName; SkTDArray fIntervals; int fWidth; + bool fDoClip; enum { N = SkBENCHLOOP(100) }; public: - DashBench(void* param, const SkScalar intervals[], int count, int width) : INHERITED(param) { + DashBench(void* param, const SkScalar intervals[], int count, int width, + bool doClip = false) : INHERITED(param) { fIntervals.append(count, intervals); for (int i = 0; i < count; ++i) { fIntervals[i] *= width; } fWidth = width; - fName.printf("dash_%d", width); + fName.printf("dash_%d_%s", width, doClip ? "clipped" : "noclip"); + fDoClip = doClip; } virtual void makePath(SkPath* path) { @@ -69,6 +72,15 @@ protected: paint.setPathEffect(new SkDashPathEffect(fIntervals.begin(), fIntervals.count(), 0))->unref(); + + if (fDoClip) { + SkRect r = path.getBounds(); + r.inset(-SkIntToScalar(20), -SkIntToScalar(20)); + // now move it so we don't intersect + r.offset(0, r.height() * 3 / 2); + canvas->clipRect(r); + } + this->handlePath(canvas, path, paint, N); } @@ -85,7 +97,7 @@ private: class RectDashBench : public DashBench { public: - RectDashBench(void* param, const SkScalar intervals[], int count, int width) + RectDashBench(void* param, const SkScalar intervals[], int count, int width, bool doClip = false) : INHERITED(param, intervals, count, width) { fName.append("_rect"); } @@ -132,10 +144,12 @@ static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 }; static SkBenchmark* gF0(void* p) { return new DashBench(p, PARAM(gDots), 0); } static SkBenchmark* gF1(void* p) { return new DashBench(p, PARAM(gDots), 1); } -static SkBenchmark* gF2(void* p) { return new DashBench(p, PARAM(gDots), 4); } -static SkBenchmark* gF3(void* p) { return new RectDashBench(p, PARAM(gDots), 4); } +static SkBenchmark* gF2(void* p) { return new DashBench(p, PARAM(gDots), 1, true); } +static SkBenchmark* gF3(void* p) { return new DashBench(p, PARAM(gDots), 4); } +static SkBenchmark* gF4(void* p) { return new RectDashBench(p, PARAM(gDots), 4); } static BenchRegistry gR0(gF0); static BenchRegistry gR1(gF1); static BenchRegistry gR2(gF2); static BenchRegistry gR3(gF3); +static BenchRegistry gR4(gF4); -- cgit v1.2.3