aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/DashBench.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-15 19:50:58 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-15 19:50:58 +0000
commit4ad22753504828342e47627b12210c2c47e7290a (patch)
tree1c05f1ad5ac0d6bdb7c3f799a83771f31cd7115c /bench/DashBench.cpp
parent97ecd1d454fc3fd3703724ae108a542f5f271fb0 (diff)
add clipped case for dashing to exercise quickReject
git-svn-id: http://skia.googlecode.com/svn/trunk@3961 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/DashBench.cpp')
-rw-r--r--bench/DashBench.cpp24
1 files changed, 19 insertions, 5 deletions
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<SkScalar> 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);