2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "SkBlurMaskFilter.h"
16 class BlurRectsBench : public Benchmark {
18 BlurRectsBench(SkRect outer, SkRect inner, SkScalar radius) {
24 const char* onGetName() override {
28 void setName(const SkString& name) {
32 void onDraw(const int loops, SkCanvas* canvas) override {
34 paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fRadius))->unref();
37 path.addRect(fOuter, SkPath::kCW_Direction);
38 path.addRect(fInner, SkPath::kCW_Direction);
40 for (int i = 0; i < loops; i++) {
41 canvas->drawPath(path, paint);
51 typedef Benchmark INHERITED;
54 class BlurRectsNinePatchBench: public BlurRectsBench {
56 BlurRectsNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
57 : INHERITED(outer, inner, radius) {
58 this->setName(SkString("blurrectsninepatch"));
61 typedef BlurRectsBench INHERITED;
64 class BlurRectsNonNinePatchBench: public BlurRectsBench {
66 BlurRectsNonNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
67 : INHERITED(outer, inner, radius) {
69 this->setName(SkString("blurrectsnonninepatch"));
72 typedef BlurRectsBench INHERITED;
75 DEF_BENCH(return new BlurRectsNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
76 SkRect::MakeXYWH(20, 20, 60, 60),
78 DEF_BENCH(return new BlurRectsNonNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
79 SkRect::MakeXYWH(50, 50, 10, 10),