OLD | NEW |
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = NULL; | 105 fSrcMask.fImage = nullptr; |
106 } | 106 } |
107 | 107 |
108 ~BlurRectSeparableBench() { | 108 ~BlurRectSeparableBench() { |
109 SkMask::FreeImage(fSrcMask.fImage); | 109 SkMask::FreeImage(fSrcMask.fImage); |
110 } | 110 } |
111 | 111 |
112 protected: | 112 protected: |
113 void preBenchSetup(const SkRect& r) override { | 113 void preBenchSetup(const SkRect& r) override { |
114 SkMask::FreeImage(fSrcMask.fImage); | 114 SkMask::FreeImage(fSrcMask.fImage); |
115 | 115 |
(...skipping 21 matching lines...) Expand all Loading... |
137 name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad)); | 137 name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad)); |
138 } | 138 } |
139 | 139 |
140 this->setName(name); | 140 this->setName(name); |
141 } | 141 } |
142 | 142 |
143 protected: | 143 protected: |
144 | 144 |
145 void makeBlurryRect(const SkRect&) override { | 145 void makeBlurryRect(const SkRect&) override { |
146 SkMask mask; | 146 SkMask mask; |
147 mask.fImage = NULL; | 147 mask.fImage = nullptr; |
148 SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(th
is->radius()), | 148 SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(th
is->radius()), |
149 kNormal_SkBlurStyle, kHigh_SkBlurQuality); | 149 kNormal_SkBlurStyle, kHigh_SkBlurQuality); |
150 SkMask::FreeImage(mask.fImage); | 150 SkMask::FreeImage(mask.fImage); |
151 } | 151 } |
152 private: | 152 private: |
153 typedef BlurRectSeparableBench INHERITED; | 153 typedef BlurRectSeparableBench INHERITED; |
154 }; | 154 }; |
155 | 155 |
156 class BlurRectGaussianBench: public BlurRectSeparableBench { | 156 class BlurRectGaussianBench: public BlurRectSeparableBench { |
157 public: | 157 public: |
158 BlurRectGaussianBench(SkScalar rad) : INHERITED(rad) { | 158 BlurRectGaussianBench(SkScalar rad) : INHERITED(rad) { |
159 SkString name; | 159 SkString name; |
160 | 160 |
161 if (SkScalarFraction(rad) != 0) { | 161 if (SkScalarFraction(rad) != 0) { |
162 name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad)); | 162 name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad)); |
163 } else { | 163 } else { |
164 name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad)); | 164 name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad)); |
165 } | 165 } |
166 | 166 |
167 this->setName(name); | 167 this->setName(name); |
168 } | 168 } |
169 | 169 |
170 protected: | 170 protected: |
171 | 171 |
172 void makeBlurryRect(const SkRect&) override { | 172 void makeBlurryRect(const SkRect&) override { |
173 SkMask mask; | 173 SkMask mask; |
174 mask.fImage = NULL; | 174 mask.fImage = nullptr; |
175 SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radiu
s()), | 175 SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radiu
s()), |
176 &mask, fSrcMask, kNormal_SkBlurStyle); | 176 &mask, fSrcMask, kNormal_SkBlurStyle); |
177 SkMask::FreeImage(mask.fImage); | 177 SkMask::FreeImage(mask.fImage); |
178 } | 178 } |
179 private: | 179 private: |
180 typedef BlurRectSeparableBench INHERITED; | 180 typedef BlurRectSeparableBench INHERITED; |
181 }; | 181 }; |
182 | 182 |
183 DEF_BENCH(return new BlurRectBoxFilterBench(SMALL);) | 183 DEF_BENCH(return new BlurRectBoxFilterBench(SMALL);) |
184 DEF_BENCH(return new BlurRectBoxFilterBench(BIG);) | 184 DEF_BENCH(return new BlurRectBoxFilterBench(BIG);) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(12));) | 219 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(12));) |
220 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(13));) | 220 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(13));) |
221 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(14));) | 221 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(14));) |
222 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(15));) | 222 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(15));) |
223 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(16));) | 223 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(16));) |
224 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(17));) | 224 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(17));) |
225 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(18));) | 225 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(18));) |
226 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(19));) | 226 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(19));) |
227 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(20));) | 227 DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(20));) |
228 #endif | 228 #endif |
OLD | NEW |