OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 "inner" | 64 "inner" |
65 }; | 65 }; |
66 | 66 |
67 class BlurRectGM : public skiagm::GM { | 67 class BlurRectGM : public skiagm::GM { |
68 SkAutoTUnref<SkMaskFilter> fMaskFilter; | 68 SkAutoTUnref<SkMaskFilter> fMaskFilter; |
69 SkString fName; | 69 SkString fName; |
70 PaintProc fPProc; | 70 PaintProc fPProc; |
71 SkAlpha fAlpha; | 71 SkAlpha fAlpha; |
72 public: | 72 public: |
73 BlurRectGM(const char name[], PaintProc pproc, U8CPU alpha, | 73 BlurRectGM(const char name[], PaintProc pproc, U8CPU alpha, |
74 SkBlurMaskFilter::BlurStyle bs) : | 74 SkBlurMaskFilter::BlurStyle bs) |
75 fMaskFilter(SkBlurMaskFilter::Create(STROKE_WIDTH/2, bs, | 75 : fMaskFilter(SkBlurMaskFilter::Create(STROKE_WIDTH/2, bs, |
76 SkBlurMaskFilter::kHighQuality_BlurFlag)) | 76 SkBlurMaskFilter::kHighQuality_BlurFlag)) |
77 , fName(name) | 77 , fName(name) |
78 , fPProc(pproc) | 78 , fPProc(pproc) |
79 , fAlpha(SkToU8(alpha)) { | 79 , fAlpha(SkToU8(alpha)) { |
80 fName.appendf("_%s", gBlurStyle2Name[bs]); | 80 fName.appendf("_%s", gBlurStyle2Name[bs]); |
81 } | 81 } |
82 | 82 |
83 protected: | 83 protected: |
84 virtual SkString onShortName() { | 84 virtual SkString onShortName() { |
85 return fName; | 85 return fName; |
86 } | 86 } |
87 | 87 |
88 virtual SkISize onISize() { | 88 virtual SkISize onISize() { |
89 return SkISize::Make(640, 480); | 89 return SkISize::Make(640, 480); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 | 202 |
203 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | 203 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } |
204 | 204 |
205 private: | 205 private: |
206 typedef GM INHERITED; | 206 typedef GM INHERITED; |
207 }; | 207 }; |
208 | 208 |
209 class BlurRectFastGM: public BlurRectCompareGM { | 209 class BlurRectFastGM: public BlurRectCompareGM { |
210 public: | 210 public: |
211 BlurRectFastGM(const char name[], unsigned int rect_width, | 211 BlurRectFastGM(const char name[], unsigned int rectWidth, |
212 unsigned int rect_height, float blur_radius, | 212 unsigned int rectHeight, float blurRadius, |
213 SkBlurMask::Style style) : | 213 SkBlurMask::Style style) : |
214 INHERITED(name, rect_width, rect_height, blur_radius, style) | 214 INHERITED(name, rectWidth, rectHeight, blurRadius, style) { |
215 { | 215 } |
216 | 216 |
217 } | |
218 protected: | 217 protected: |
219 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { | 218 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { |
220 return SkBlurMask::BlurRect(m, r, this->radius(), this->style()); | 219 return SkBlurMask::BlurRect(m, r, this->radius(), this->style()); |
221 } | 220 } |
222 private: | 221 private: |
223 typedef BlurRectCompareGM INHERITED; | 222 typedef BlurRectCompareGM INHERITED; |
224 }; | 223 }; |
225 | 224 |
226 class BlurRectSlowGM: public BlurRectCompareGM { | 225 class BlurRectSlowGM: public BlurRectCompareGM { |
227 public: | 226 public: |
228 BlurRectSlowGM(const char name[], unsigned int rect_width, unsigned int rect
_height, | 227 BlurRectSlowGM(const char name[], unsigned int rect_width, unsigned int rect
_height, |
229 float blur_radius, SkBlurMask::Style style) : | 228 float blur_radius, SkBlurMask::Style style) : |
230 INHERITED(name, rect_width, rect_height, blur_radius, style) | 229 INHERITED(name, rect_width, rect_height, blur_radius, style) |
231 { | 230 { |
232 | 231 |
233 } | 232 } |
234 protected: | 233 protected: |
235 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { | 234 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { |
236 SkMask src; | 235 SkMask src; |
237 r.roundOut(&src.fBounds); | 236 r.roundOut(&src.fBounds); |
238 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o
rigin | 237 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o
rigin |
239 src.fFormat = SkMask::kA8_Format; | 238 src.fFormat = SkMask::kA8_Format; |
240 src.fRowBytes = src.fBounds.width(); | 239 src.fRowBytes = src.fBounds.width(); |
241 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); | 240 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); |
242 SkAutoMaskFreeImage amfi(src.fImage); | 241 SkAutoMaskFreeImage amfi(src.fImage); |
243 | 242 |
244 memset(src.fImage, 0xff, src.computeTotalImageSize()); | 243 memset(src.fImage, 0xff, src.computeTotalImageSize()); |
245 | 244 |
246 return SkBlurMask::Blur(m, src, this->radius(), this->style(), this->get
Quality()); | 245 return SkBlurMask::BoxBlur(m, src, this->radius(), this->style(), this->
getQuality()); |
247 } | 246 } |
248 | 247 |
249 virtual SkBlurMask::Quality getQuality() { | 248 virtual SkBlurMask::Quality getQuality() { |
250 return SkBlurMask::kHigh_Quality; | 249 return SkBlurMask::kHigh_Quality; |
251 } | 250 } |
252 private: | 251 private: |
253 typedef BlurRectCompareGM INHERITED; | 252 typedef BlurRectCompareGM INHERITED; |
254 }; | 253 }; |
255 | 254 |
256 class BlurRectSlowLowGM: public BlurRectSlowGM { | 255 class BlurRectSlowLowGM: public BlurRectSlowGM { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_11_simple", 25, 100, 11
);) | 369 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_11_simple", 25, 100, 11
);) |
371 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_12_simple", 25, 100, 12
);) | 370 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_12_simple", 25, 100, 12
);) |
372 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_13_simple", 25, 100, 13
);) | 371 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_13_simple", 25, 100, 13
);) |
373 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_14_simple", 25, 100, 14
);) | 372 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_14_simple", 25, 100, 14
);) |
374 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_15_simple", 25, 100, 15
);) | 373 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_15_simple", 25, 100, 15
);) |
375 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_16_simple", 25, 100, 16
);) | 374 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_16_simple", 25, 100, 16
);) |
376 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_17_simple", 25, 100, 17
);) | 375 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_17_simple", 25, 100, 17
);) |
377 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_18_simple", 25, 100, 18
);) | 376 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_18_simple", 25, 100, 18
);) |
378 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_19_simple", 25, 100, 19
);) | 377 DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_19_simple", 25, 100, 19
);) |
379 #endif | 378 #endif |
OLD | NEW |