Flutter Engine
The Flutter Engine
BlurRectsBench.cpp
Go to the documentation of this file.
1/*
2* Copyright 2014 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#include "bench/Benchmark.h"
13#include "include/core/SkPath.h"
14#include "include/core/SkRect.h"
16
17class BlurRectsBench : public Benchmark {
18public:
19 BlurRectsBench(SkRect outer, SkRect inner, SkScalar radius) {
20 fRadius = radius;
21 fOuter = outer;
22 fInner = inner;
23 }
24
25 const char* onGetName() override {
26 return fName.c_str();
27 }
28
29 void setName(const SkString& name) {
30 fName = name;
31 }
32
33 void onDraw(int loops, SkCanvas* canvas) override {
35 paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, fRadius));
36
38 path.addRect(fOuter, SkPathDirection::kCW);
39 path.addRect(fInner, SkPathDirection::kCW);
40
41 for (int i = 0; i < loops; i++) {
42 canvas->drawPath(path, paint);
43 }
44 }
45
46private:
47 SkString fName;
48 SkRect fOuter;
49 SkRect fInner;
50 SkScalar fRadius;
51
52 using INHERITED = Benchmark;
53};
54
56public:
58 : INHERITED(outer, inner, radius) {
59 this->setName(SkString("blurrectsninepatch"));
60 }
61private:
62 using INHERITED = BlurRectsBench;
63};
64
66public:
68 : INHERITED(outer, inner, radius) {
70 this->setName(SkString("blurrectsnonninepatch"));
71 }
72private:
73 using INHERITED = BlurRectsBench;
74};
75
76DEF_BENCH(return new BlurRectsNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
77 SkRect::MakeXYWH(20, 20, 60, 60),
78 2.3f);)
79DEF_BENCH(return new BlurRectsNonNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
80 SkRect::MakeXYWH(50, 50, 10, 10),
81 4.3f);)
#define DEF_BENCH(code)
Definition: Benchmark.h:20
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
void onDraw(int loops, SkCanvas *canvas) override
void setName(const SkString &name)
BlurRectsBench(SkRect outer, SkRect inner, SkScalar radius)
const char * onGetName() override
BlurRectsNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
BlurRectsNonNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
Definition: SkPath.h:59
const char * c_str() const
Definition: SkString.h:133
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659