OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
10 | 11 |
11 namespace skiagm { | 12 namespace skiagm { |
12 | 13 |
13 class BlursGM : public GM { | 14 class BlursGM : public GM { |
14 public: | 15 public: |
15 BlursGM() { | 16 BlursGM() { |
16 this->setBGColor(0xFFDDDDDD); | 17 this->setBGColor(0xFFDDDDDD); |
17 } | 18 } |
18 | 19 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 paint.setAntiAlias(true); | 53 paint.setAntiAlias(true); |
53 paint.setTextSize(SkIntToScalar(25)); | 54 paint.setTextSize(SkIntToScalar(25)); |
54 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0)); | 55 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0)); |
55 | 56 |
56 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; | 57 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; |
57 for (int j = 0; j < 2; j++) { | 58 for (int j = 0; j < 2; j++) { |
58 canvas->save(); | 59 canvas->save(); |
59 paint.setColor(SK_ColorBLUE); | 60 paint.setColor(SK_ColorBLUE); |
60 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { | 61 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { |
61 if (gRecs[i].fStyle != NONE) { | 62 if (gRecs[i].fStyle != NONE) { |
62 SkMaskFilter* mf = SkBlurMaskFilter::Create( | 63 SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle, |
63 SkIntToScalar(20), gRecs[i].fStyle, flags); | 64 SkBlurMask::ConvertRadiusToSigma(SkIn
tToScalar(20)), |
| 65 flags); |
64 paint.setMaskFilter(mf)->unref(); | 66 paint.setMaskFilter(mf)->unref(); |
65 } else { | 67 } else { |
66 paint.setMaskFilter(NULL); | 68 paint.setMaskFilter(NULL); |
67 } | 69 } |
68 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), | 70 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), |
69 SkIntToScalar(200 + gRecs[i].fCy*100), | 71 SkIntToScalar(200 + gRecs[i].fCy*100), |
70 SkIntToScalar(50), | 72 SkIntToScalar(50), |
71 paint); | 73 paint); |
72 } | 74 } |
73 // draw text | 75 // draw text |
74 { | 76 { |
75 SkMaskFilter* mf = SkBlurMaskFilter::Create( | 77 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN
ormal_BlurStyle, |
76 SkIntToScalar(4), | 78 SkBlurMask::ConvertRadiusToSigma(SkIn
tToScalar(4)), |
77 SkBlurMaskFilter::kNormal_BlurStyle, | 79 flags); |
78 flags); | |
79 paint.setMaskFilter(mf)->unref(); | 80 paint.setMaskFilter(mf)->unref(); |
80 SkScalar x = SkIntToScalar(70); | 81 SkScalar x = SkIntToScalar(70); |
81 SkScalar y = SkIntToScalar(400); | 82 SkScalar y = SkIntToScalar(400); |
82 paint.setColor(SK_ColorBLACK); | 83 paint.setColor(SK_ColorBLACK); |
83 canvas->drawText("Hamburgefons Style", 18, x, y, paint); | 84 canvas->drawText("Hamburgefons Style", 18, x, y, paint); |
84 canvas->drawText("Hamburgefons Style", 18, | 85 canvas->drawText("Hamburgefons Style", 18, |
85 x, y + SkIntToScalar(50), paint); | 86 x, y + SkIntToScalar(50), paint); |
86 paint.setMaskFilter(NULL); | 87 paint.setMaskFilter(NULL); |
87 paint.setColor(SK_ColorWHITE); | 88 paint.setColor(SK_ColorWHITE); |
88 x -= SkIntToScalar(2); | 89 x -= SkIntToScalar(2); |
89 y -= SkIntToScalar(2); | 90 y -= SkIntToScalar(2); |
90 canvas->drawText("Hamburgefons Style", 18, x, y, paint); | 91 canvas->drawText("Hamburgefons Style", 18, x, y, paint); |
91 } | 92 } |
92 canvas->restore(); | 93 canvas->restore(); |
93 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; | 94 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; |
94 canvas->translate(SkIntToScalar(350), SkIntToScalar(0)); | 95 canvas->translate(SkIntToScalar(350), SkIntToScalar(0)); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 private: | 99 private: |
99 typedef GM INHERITED; | 100 typedef GM INHERITED; |
100 }; | 101 }; |
101 | 102 |
102 ////////////////////////////////////////////////////////////////////////////// | 103 ////////////////////////////////////////////////////////////////////////////// |
103 | 104 |
104 static GM* MyFactory(void*) { return new BlursGM; } | 105 static GM* MyFactory(void*) { return new BlursGM; } |
105 static GMRegistry reg(MyFactory); | 106 static GMRegistry reg(MyFactory); |
106 | 107 |
107 } | 108 } |
OLD | NEW |