diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-08 16:40:14 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-08 16:40:14 +0000 |
commit | c3799ada5b291000b2adde57cc0fee734fd7e232 (patch) | |
tree | fbfa5e23d5f32221aac0580ce44688964bbd860b /bench | |
parent | ee235f90620b24c0f983bd3618103a3d6676f02b (diff) |
Add a bench for SkBicubicImageFilter.
Review URL: https://codereview.appspot.com/7312056
git-svn-id: http://skia.googlecode.com/svn/trunk@7668 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r-- | bench/BicubicBench.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/bench/BicubicBench.cpp b/bench/BicubicBench.cpp new file mode 100644 index 0000000000..a3a23180f9 --- /dev/null +++ b/bench/BicubicBench.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2013 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 "SkCanvas.h" +#include "SkRandom.h" +#include "SkShader.h" +#include "SkString.h" +#include "SkBicubicImageFilter.h" + +// This bench exercises SkBicubicImageFilter, upsampling a 40x40 input to +// 100x100, 400x100, 100x400, and 400x400. + +class BicubicBench : public SkBenchmark { + SkSize fScale; + SkString fName; + +public: + BicubicBench(void* param, float x, float y) + : INHERITED(param), fScale(SkSize::Make(SkFloatToScalar(x), SkFloatToScalar(y))) { + fName.printf("bicubic_%gx%g", + SkScalarToFloat(fScale.fWidth), SkScalarToFloat(fScale.fHeight)); + } + +protected: + virtual const char* onGetName() { + return fName.c_str(); + } + + virtual void onDraw(SkCanvas* canvas) { + SkPaint paint; + this->setupPaint(&paint); + + paint.setAntiAlias(true); + + SkRandom rand; + SkRect r = SkRect::MakeWH(40, 40); + SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell(fScale)); + paint.setImageFilter(bicubic); + canvas->save(); + canvas->clipRect(r); + canvas->drawOval(r, paint); + canvas->restore(); + } + +private: + typedef SkBenchmark INHERITED; +}; + +static SkBenchmark* Fact00(void* p) { return new BicubicBench(p, 10.0f, 10.0f); } +static SkBenchmark* Fact01(void* p) { return new BicubicBench(p, 2.5f, 10.0f); } +static SkBenchmark* Fact02(void* p) { return new BicubicBench(p, 10.0f, 2.5f); } +static SkBenchmark* Fact03(void* p) { return new BicubicBench(p, 2.5f, 2.5f); } + +static BenchRegistry gReg00(Fact00); +static BenchRegistry gReg01(Fact01); +static BenchRegistry gReg02(Fact02); +static BenchRegistry gReg03(Fact03); |