OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkString.h" | 13 #include "SkString.h" |
14 | 14 |
15 class BlurCirclesGM : public skiagm::GM { | 15 class BlurCirclesGM : public skiagm::GM { |
16 public: | 16 public: |
17 BlurCirclesGM() | 17 BlurCirclesGM() |
18 : fName("blurcircles") { | 18 : fName("blurcircles") { |
19 } | 19 } |
20 | 20 |
21 protected: | 21 protected: |
22 | 22 |
23 SkString onShortName() SK_OVERRIDE { | 23 SkString onShortName() override { |
24 return fName; | 24 return fName; |
25 } | 25 } |
26 | 26 |
27 SkISize onISize() SK_OVERRIDE { | 27 SkISize onISize() override { |
28 return SkISize::Make(950, 950); | 28 return SkISize::Make(950, 950); |
29 } | 29 } |
30 | 30 |
31 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 31 void onDraw(SkCanvas* canvas) override { |
32 canvas->scale(1.5f, 1.5f); | 32 canvas->scale(1.5f, 1.5f); |
33 canvas->translate(50,50); | 33 canvas->translate(50,50); |
34 | 34 |
35 const float blurRadii[] = { 1,5,10,20 }; | 35 const float blurRadii[] = { 1,5,10,20 }; |
36 const int circleRadii[] = { 5,10,25,50 }; | 36 const int circleRadii[] = { 5,10,25,50 }; |
37 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { | 37 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { |
38 SkAutoCanvasRestore autoRestore(canvas, true); | 38 SkAutoCanvasRestore autoRestore(canvas, true); |
39 canvas->translate(0, SkIntToScalar(150*i)); | 39 canvas->translate(0, SkIntToScalar(150*i)); |
40 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) { | 40 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) { |
41 SkMaskFilter* filter = SkBlurMaskFilter::Create( | 41 SkMaskFilter* filter = SkBlurMaskFilter::Create( |
42 kNormal_SkBlurStyle, | 42 kNormal_SkBlurStyle, |
43 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])
), | 43 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])
), |
44 SkBlurMaskFilter::kHighQuality_BlurFlag); | 44 SkBlurMaskFilter::kHighQuality_BlurFlag); |
45 SkPaint paint; | 45 SkPaint paint; |
46 paint.setColor(SK_ColorBLACK); | 46 paint.setColor(SK_ColorBLACK); |
47 paint.setMaskFilter(filter)->unref(); | 47 paint.setMaskFilter(filter)->unref(); |
48 | 48 |
49 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc
alar(circleRadii[j]),paint); | 49 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc
alar(circleRadii[j]),paint); |
50 canvas->translate(SkIntToScalar(150), 0); | 50 canvas->translate(SkIntToScalar(150), 0); |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 private: | 54 private: |
55 const SkString fName; | 55 const SkString fName; |
56 | 56 |
57 typedef skiagm::GM INHERITED; | 57 typedef skiagm::GM INHERITED; |
58 }; | 58 }; |
59 | 59 |
60 DEF_GM(return new BlurCirclesGM();) | 60 DEF_GM(return new BlurCirclesGM();) |
OLD | NEW |