diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-05 19:07:21 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-05 19:07:21 +0000 |
commit | 935ad026826fb7d31d562ff7326b84ec3a827456 (patch) | |
tree | 3579e7292b147aa8cdb8cdc0182756087207be98 /bench | |
parent | f6c7e72c2c79537c4a56f5baefc79c073c80054e (diff) |
Add drawPoints dash bench
https://codereview.appspot.com/6866053/
git-svn-id: http://skia.googlecode.com/svn/trunk@6678 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r-- | bench/DashBench.cpp | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp index d766eb1cb0..e71773d891 100644 --- a/bench/DashBench.cpp +++ b/bench/DashBench.cpp @@ -220,7 +220,6 @@ private: */ class DashLineBench : public SkBenchmark { SkString fName; - SkPath fPath; SkScalar fStrokeWidth; bool fIsRound; SkAutoTUnref<SkPathEffect> fPE; @@ -260,6 +259,58 @@ private: typedef SkBenchmark INHERITED; }; +class DrawPointsDashingBench : public SkBenchmark { + SkString fName; + int fStrokeWidth; + bool fdoAA; + + SkAutoTUnref<SkPathEffect> fPathEffect; + + enum { + N = SkBENCHLOOP(480) + }; + +public: + DrawPointsDashingBench(void* param, int dashLength, int strokeWidth, bool doAA) + : INHERITED(param) { + fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" : "_bw"); + fStrokeWidth = strokeWidth; + fdoAA = doAA; + + SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) }; + fPathEffect.reset(new SkDashPathEffect(vals, 2, SK_Scalar1, false)); + } + +protected: + virtual const char* onGetName() SK_OVERRIDE { + return fName.c_str(); + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + + SkPaint p; + this->setupPaint(&p); + p.setColor(SK_ColorBLACK); + p.setStyle(SkPaint::kStroke_Style); + p.setStrokeWidth(SkIntToScalar(fStrokeWidth)); + p.setPathEffect(fPathEffect); + p.setAntiAlias(fdoAA); + + SkPoint pts[2] = { + { SkIntToScalar(10), 0 }, + { SkIntToScalar(640), 0 } + }; + + for (int i = 0; i < N; ++i) { + + pts[0].fY = pts[1].fY = SkIntToScalar(i % 480); + canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p); + } + } + +private: + typedef SkBenchmark INHERITED; +}; /////////////////////////////////////////////////////////////////////////////// static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 }; @@ -280,6 +331,13 @@ static SkBenchmark* gF701(void* p) { return new DashLineBench(p, 0, true); } static SkBenchmark* gF711(void* p) { return new DashLineBench(p, SK_Scalar1, true); } static SkBenchmark* gF721(void* p) { return new DashLineBench(p, 2 * SK_Scalar1, true); } +static SkBenchmark* gF8(void* p) { return new DrawPointsDashingBench(p, 1, 1, false); } +static SkBenchmark* gF9(void* p) { return new DrawPointsDashingBench(p, 1, 1, true); } +static SkBenchmark* gF10(void* p) { return new DrawPointsDashingBench(p, 3, 1, false); } +static SkBenchmark* gF11(void* p) { return new DrawPointsDashingBench(p, 3, 1, true); } +static SkBenchmark* gF12(void* p) { return new DrawPointsDashingBench(p, 5, 5, false); } +static SkBenchmark* gF13(void* p) { return new DrawPointsDashingBench(p, 5, 5, true); } + static BenchRegistry gR0(gF0); static BenchRegistry gR1(gF1); static BenchRegistry gR2(gF2); @@ -293,3 +351,10 @@ static BenchRegistry gR720(gF720); static BenchRegistry gR701(gF701); static BenchRegistry gR711(gF711); static BenchRegistry gR721(gF721); + +static BenchRegistry gR8(gF8); +static BenchRegistry gR9(gF9); +static BenchRegistry gR10(gF10); +static BenchRegistry gR11(gF11); +static BenchRegistry gR12(gF12); +static BenchRegistry gR13(gF13); |