diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-28 19:54:56 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-28 19:54:56 +0000 |
commit | a069c8ff9abf00efed85ca0a2df37a7a7f30390e (patch) | |
tree | 51f0e095b109ebe2bb3646897b677ad7e88d4670 /bench/AAClipBench.cpp | |
parent | 1271d78e8ff4cda0622a24dcec6063b50f6be051 (diff) |
speedup AAClip::setRegion (n^2 to n)
add bench for setRegion
git-svn-id: http://skia.googlecode.com/svn/trunk@2759 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/AAClipBench.cpp')
-rw-r--r-- | bench/AAClipBench.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bench/AAClipBench.cpp b/bench/AAClipBench.cpp index eca45184a6..39088c1a78 100644 --- a/bench/AAClipBench.cpp +++ b/bench/AAClipBench.cpp @@ -56,6 +56,38 @@ private: typedef SkBenchmark INHERITED; }; +class AAClipRegionBench : public SkBenchmark { +public: + AAClipRegionBench(void* param) : INHERITED(param) { + SkPath path; + // test conversion of a complex clip to a aaclip + path.addCircle(0, 0, SkIntToScalar(200)); + path.addCircle(0, 0, SkIntToScalar(180)); + // evenodd means we've constructed basically a stroked circle + path.setFillType(SkPath::kEvenOdd_FillType); + + SkIRect bounds; + path.getBounds().roundOut(&bounds); + fRegion.setPath(path, SkRegion(bounds)); + } + +protected: + virtual const char* onGetName() { return "aaclip_setregion"; } + virtual void onDraw(SkCanvas* canvas) { + for (int i = 0; i < N; ++i) { + SkAAClip clip; + clip.setRegion(fRegion); + } + } + +private: + enum { + N = SkBENCHLOOP(400), + }; + SkRegion fRegion; + typedef SkBenchmark INHERITED; +}; + /////////////////////////////////////////////////////////////////////////////// static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, false)); } @@ -67,3 +99,6 @@ static BenchRegistry gReg0(Fact0); static BenchRegistry gReg1(Fact1); static BenchRegistry gReg2(Fact2); static BenchRegistry gReg3(Fact3); + +static SkBenchmark* Fact01(void* p) { return SkNEW_ARGS(AAClipRegionBench, (p)); } +static BenchRegistry gReg01(Fact01); |