diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-31 14:33:35 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-31 14:33:35 +0000 |
commit | 57c4957604b9cb71acbc0db4a8e83701437e7fb1 (patch) | |
tree | 4806c1fd74e519933c5436a3ced3f0c55197720f | |
parent | 48dd1a26ec07c5baa04856202e4e7e2a53e4d7e5 (diff) |
add bench for building aaclips
git-svn-id: http://skia.googlecode.com/svn/trunk@2565 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/AAClipBench.cpp | 69 | ||||
-rw-r--r-- | gyp/bench.gyp | 6 | ||||
-rw-r--r-- | gyp/bench.gypi | 1 |
3 files changed, 75 insertions, 1 deletions
diff --git a/bench/AAClipBench.cpp b/bench/AAClipBench.cpp new file mode 100644 index 0000000000..eca45184a6 --- /dev/null +++ b/bench/AAClipBench.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkBenchmark.h" +#include "SkAAClip.h" +#include "SkPath.h" +#include "SkRegion.h" +#include "SkString.h" + +class AAClipBuilderBench : public SkBenchmark { + SkString fName; + SkPath fPath; + SkRect fRect; + SkRegion fRegion; + bool fDoPath; + bool fDoAA; + + enum { + N = SkBENCHLOOP(200), + }; + +public: + AAClipBuilderBench(void* param, bool doPath, bool doAA) : INHERITED(param) { + fDoPath = doPath; + fDoAA = doAA; + + fName.printf("aaclip_build_%s_%s", doPath ? "path" : "rect", + doAA ? "AA" : "BW"); + + fRegion.setRect(0, 0, 640, 480); + fRect.set(fRegion.getBounds()); + fRect.inset(SK_Scalar1/4, SK_Scalar1/4); + fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20)); + } + +protected: + virtual const char* onGetName() { return fName.c_str(); } + virtual void onDraw(SkCanvas* canvas) { + SkPaint paint; + this->setupPaint(&paint); + + for (int i = 0; i < N; ++i) { + SkAAClip clip; + if (fDoPath) { + clip.setPath(fPath, &fRegion, fDoAA); + } else { + clip.setRect(fRect, fDoAA); + } + } + } +private: + typedef SkBenchmark INHERITED; +}; + +/////////////////////////////////////////////////////////////////////////////// + +static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, false)); } +static SkBenchmark* Fact1(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, true)); } +static SkBenchmark* Fact2(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, false)); } +static SkBenchmark* Fact3(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, true)); } + +static BenchRegistry gReg0(Fact0); +static BenchRegistry gReg1(Fact1); +static BenchRegistry gReg2(Fact2); +static BenchRegistry gReg3(Fact3); diff --git a/gyp/bench.gyp b/gyp/bench.gyp index 73472a57a0..636158670c 100644 --- a/gyp/bench.gyp +++ b/gyp/bench.gyp @@ -9,8 +9,12 @@ { 'target_name': 'bench', 'type': 'executable', + 'include_dirs' : [ + '../src/core', + '../src/gpu', + ], 'includes': [ - 'bench.gypi' + 'bench.gypi' ], 'dependencies': [ 'core.gyp:core', diff --git a/gyp/bench.gypi b/gyp/bench.gypi index 879dee5f09..b8f3e58972 100644 --- a/gyp/bench.gypi +++ b/gyp/bench.gypi @@ -17,6 +17,7 @@ '../bench/SkBenchmark.h', '../bench/SkBenchmark.cpp', + '../bench/AAClipBench.cpp', '../bench/BitmapBench.cpp', '../bench/BlurBench.cpp', '../bench/ChromeBench.cpp', |