Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: bench/BlurRectBench.cpp

Issue 1539553002: Add default ctor to SkMask (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gm/blurrect.cpp » ('j') | src/effects/SkBlurMask.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 this->setupPaint(&paint); 56 this->setupPaint(&paint);
57 57
58 paint.setAntiAlias(true); 58 paint.setAntiAlias(true);
59 59
60 SkScalar pad = fRadius*3/2 + SK_Scalar1; 60 SkScalar pad = fRadius*3/2 + SK_Scalar1;
61 SkRect r = SkRect::MakeWH(2 * pad + SK_Scalar1, 2 * pad + SK_Scalar1); 61 SkRect r = SkRect::MakeWH(2 * pad + SK_Scalar1, 2 * pad + SK_Scalar1);
62 62
63 preBenchSetup(r); 63 preBenchSetup(r);
64 64
65 for (int i = 0; i < loops; i++) { 65 for (int i = 0; i < loops; i++) {
66 makeBlurryRect(r); 66 this->makeBlurryRect(r);
67 } 67 }
68 } 68 }
69 69
70 virtual void makeBlurryRect(const SkRect&) = 0; 70 virtual void makeBlurryRect(const SkRect&) = 0;
71 virtual void preBenchSetup(const SkRect&) {} 71 virtual void preBenchSetup(const SkRect&) {}
72 private: 72 private:
73 typedef Benchmark INHERITED; 73 typedef Benchmark INHERITED;
74 }; 74 };
75 75
76 76
(...skipping 17 matching lines...) Expand all
94 &mask, r, kNormal_SkBlurStyle); 94 &mask, r, kNormal_SkBlurStyle);
95 SkMask::FreeImage(mask.fImage); 95 SkMask::FreeImage(mask.fImage);
96 } 96 }
97 private: 97 private:
98 typedef BlurRectBench INHERITED; 98 typedef BlurRectBench INHERITED;
99 }; 99 };
100 100
101 class BlurRectSeparableBench: public BlurRectBench { 101 class BlurRectSeparableBench: public BlurRectBench {
102 102
103 public: 103 public:
104 BlurRectSeparableBench(SkScalar rad) : INHERITED(rad) { 104 BlurRectSeparableBench(SkScalar rad) : INHERITED(rad) { }
105 fSrcMask.fImage = nullptr;
106 }
107 105
108 ~BlurRectSeparableBench() { 106 ~BlurRectSeparableBench() {
109 SkMask::FreeImage(fSrcMask.fImage); 107 SkMask::FreeImage(fSrcMask.fImage);
110 } 108 }
111 109
112 protected: 110 protected:
113 void preBenchSetup(const SkRect& r) override { 111 void preBenchSetup(const SkRect& r) override {
114 SkMask::FreeImage(fSrcMask.fImage); 112 SkMask::FreeImage(fSrcMask.fImage);
115 113
116 r.roundOut(&fSrcMask.fBounds); 114 r.roundOut(&fSrcMask.fBounds);
(...skipping 20 matching lines...) Expand all
137 name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad)); 135 name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad));
138 } 136 }
139 137
140 this->setName(name); 138 this->setName(name);
141 } 139 }
142 140
143 protected: 141 protected:
144 142
145 void makeBlurryRect(const SkRect&) override { 143 void makeBlurryRect(const SkRect&) override {
146 SkMask mask; 144 SkMask mask;
147 mask.fImage = nullptr;
148 SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(th is->radius()), 145 SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(th is->radius()),
149 kNormal_SkBlurStyle, kHigh_SkBlurQuality); 146 kNormal_SkBlurStyle, kHigh_SkBlurQuality);
150 SkMask::FreeImage(mask.fImage); 147 SkMask::FreeImage(mask.fImage);
151 } 148 }
152 private: 149 private:
153 typedef BlurRectSeparableBench INHERITED; 150 typedef BlurRectSeparableBench INHERITED;
154 }; 151 };
155 152
156 class BlurRectGaussianBench: public BlurRectSeparableBench { 153 class BlurRectGaussianBench: public BlurRectSeparableBench {
157 public: 154 public:
158 BlurRectGaussianBench(SkScalar rad) : INHERITED(rad) { 155 BlurRectGaussianBench(SkScalar rad) : INHERITED(rad) {
159 SkString name; 156 SkString name;
160 157
161 if (SkScalarFraction(rad) != 0) { 158 if (SkScalarFraction(rad) != 0) {
162 name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad)); 159 name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad));
163 } else { 160 } else {
164 name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad)); 161 name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad));
165 } 162 }
166 163
167 this->setName(name); 164 this->setName(name);
168 } 165 }
169 166
170 protected: 167 protected:
171 168
172 void makeBlurryRect(const SkRect&) override { 169 void makeBlurryRect(const SkRect&) override {
173 SkMask mask; 170 SkMask mask;
174 mask.fImage = nullptr;
175 SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radiu s()), 171 SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radiu s()),
176 &mask, fSrcMask, kNormal_SkBlurStyle); 172 &mask, fSrcMask, kNormal_SkBlurStyle);
177 SkMask::FreeImage(mask.fImage); 173 SkMask::FreeImage(mask.fImage);
178 } 174 }
179 private: 175 private:
180 typedef BlurRectSeparableBench INHERITED; 176 typedef BlurRectSeparableBench INHERITED;
181 }; 177 };
182 178
183 DEF_BENCH(return new BlurRectBoxFilterBench(SMALL);) 179 DEF_BENCH(return new BlurRectBoxFilterBench(SMALL);)
184 DEF_BENCH(return new BlurRectBoxFilterBench(BIG);) 180 DEF_BENCH(return new BlurRectBoxFilterBench(BIG);)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(12));) 215 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(12));)
220 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(13));) 216 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(13));)
221 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(14));) 217 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(14));)
222 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(15));) 218 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(15));)
223 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(16));) 219 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(16));)
224 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(17));) 220 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(17));)
225 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(18));) 221 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(18));)
226 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(19));) 222 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(19));)
227 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(20));) 223 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(20));)
228 #endif 224 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/blurrect.cpp » ('j') | src/effects/SkBlurMask.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698