OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "SkBlurMask.h" | 8 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 paint.setAntiAlias(true); | 91 paint.setAntiAlias(true); |
92 paint.setTextSize(25); | 92 paint.setTextSize(25); |
93 canvas->translate(-40, 0); | 93 canvas->translate(-40, 0); |
94 | 94 |
95 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; | 95 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; |
96 for (int j = 0; j < 2; j++) { | 96 for (int j = 0; j < 2; j++) { |
97 canvas->save(); | 97 canvas->save(); |
98 paint.setColor(SK_ColorBLUE); | 98 paint.setColor(SK_ColorBLUE); |
99 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { | 99 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { |
100 if (gRecs[i].fStyle != NONE) { | 100 if (gRecs[i].fStyle != NONE) { |
101 SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle, | 101 paint.setMaskFilter(SkBlurMaskFilter::Make(gRecs[i].fStyle, |
102 SkBlurMask::ConvertRadiusToSigma(SkIntToSc
alar(20)), | 102 SkBlurMask::ConvertRadiusToSigma(SkIntToSc
alar(20)), |
103 flags); | 103 flags)); |
104 paint.setMaskFilter(mf)->unref(); | |
105 } else { | 104 } else { |
106 paint.setMaskFilter(nullptr); | 105 paint.setMaskFilter(nullptr); |
107 } | 106 } |
108 canvas->drawCircle(200 + gRecs[i].fCx*100.f, | 107 canvas->drawCircle(200 + gRecs[i].fCx*100.f, |
109 200 + gRecs[i].fCy*100.f, 50, paint); | 108 200 + gRecs[i].fCy*100.f, 50, paint); |
110 } | 109 } |
111 // draw text | 110 // draw text |
112 { | 111 { |
113 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, | 112 paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, |
114 SkBlurMask::ConvertRadiusToSigma(SkIntToSc
alar(4)), | 113 SkBlurMask::ConvertRa
diusToSigma(4), |
115 flags); | 114 flags)); |
116 paint.setMaskFilter(mf)->unref(); | |
117 SkScalar x = SkIntToScalar(70); | 115 SkScalar x = SkIntToScalar(70); |
118 SkScalar y = SkIntToScalar(400); | 116 SkScalar y = SkIntToScalar(400); |
119 paint.setColor(SK_ColorBLACK); | 117 paint.setColor(SK_ColorBLACK); |
120 canvas->drawText("Hamburgefons Style", 18, x, y, paint); | 118 canvas->drawText("Hamburgefons Style", 18, x, y, paint); |
121 canvas->drawText("Hamburgefons Style", 18, x, y + SkIntToScalar(
50), paint); | 119 canvas->drawText("Hamburgefons Style", 18, x, y + SkIntToScalar(
50), paint); |
122 paint.setMaskFilter(nullptr); | 120 paint.setMaskFilter(nullptr); |
123 paint.setColor(SK_ColorWHITE); | 121 paint.setColor(SK_ColorWHITE); |
124 x -= SkIntToScalar(2); | 122 x -= SkIntToScalar(2); |
125 y -= SkIntToScalar(2); | 123 y -= SkIntToScalar(2); |
126 canvas->drawText("Hamburgefons Style", 18, x, y, paint); | 124 canvas->drawText("Hamburgefons Style", 18, x, y, paint); |
127 } | 125 } |
128 canvas->restore(); | 126 canvas->restore(); |
129 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; | 127 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; |
130 canvas->translate(350, 0); | 128 canvas->translate(350, 0); |
131 } | 129 } |
132 } | 130 } |
133 | 131 |
134 private: | 132 private: |
135 typedef SkView INHERITED; | 133 typedef SkView INHERITED; |
136 }; | 134 }; |
137 | 135 |
138 ////////////////////////////////////////////////////////////////////////////// | 136 ////////////////////////////////////////////////////////////////////////////// |
139 | 137 |
140 static SkView* MyFactory() { return new BlurView; } | 138 static SkView* MyFactory() { return new BlurView; } |
141 static SkViewRegister reg(MyFactory); | 139 static SkViewRegister reg(MyFactory); |
OLD | NEW |