OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Intel Inc. | 3 * Copyright 2012 Intel 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 "SkBlurDrawLooper.h" | 9 #include "SkBlurDrawLooper.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 | 150 |
151 { | 151 { |
152 SkMatrix m; | 152 SkMatrix m; |
153 m.setRotate(SkIntToScalar(30)); | 153 m.setRotate(SkIntToScalar(30)); |
154 fMatrices.push_back(m); | 154 fMatrices.push_back(m); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 158 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
159 SkLCGRandom rand; | |
160 // Draw a giant AA circle as the background. | 159 // Draw a giant AA circle as the background. |
161 SkISize size = this->getISize(); | 160 SkISize size = this->getISize(); |
162 SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth), | 161 SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth), |
163 SkIntToScalar(size.fHeight)) / 2.f; | 162 SkIntToScalar(size.fHeight)) / 2.f; |
164 SkPoint giantCenter = SkPoint::Make(SkIntToScalar(size.fWidth/2), | 163 SkPoint giantCenter = SkPoint::Make(SkIntToScalar(size.fWidth/2), |
165 SkIntToScalar(size.fHeight/2)); | 164 SkIntToScalar(size.fHeight/2)); |
166 SkPaint giantPaint; | 165 SkPaint giantPaint; |
167 giantPaint.setAntiAlias(true); | 166 giantPaint.setAntiAlias(true); |
168 giantPaint.setColor(0x80808080); | 167 giantPaint.setColor(0x80808080); |
169 canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPai
nt); | 168 canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPai
nt); |
170 | 169 |
| 170 SkRandom rand; |
171 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 171 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
172 int i; | 172 int i; |
173 for (i = 0; i < fPaints.count(); ++i) { | 173 for (i = 0; i < fPaints.count(); ++i) { |
174 canvas->save(); | 174 canvas->save(); |
175 // position the path, and make it at off-integer coords. | 175 // position the path, and make it at off-integer coords. |
176 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 4, | 176 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 4, |
177 SK_Scalar1 * 200 * (i / 5) + 3 * SK_Scalar1 / 4); | 177 SK_Scalar1 * 200 * (i / 5) + 3 * SK_Scalar1 / 4); |
178 SkColor color = rand.nextU(); | 178 SkColor color = rand.nextU(); |
179 color |= 0xff000000; | 179 color |= 0xff000000; |
180 fPaints[i].setColor(color); | 180 fPaints[i].setColor(color); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 SkTArray<SkPaint> fPaints; | 213 SkTArray<SkPaint> fPaints; |
214 SkTArray<SkMatrix> fMatrices; | 214 SkTArray<SkMatrix> fMatrices; |
215 }; | 215 }; |
216 | 216 |
217 ////////////////////////////////////////////////////////////////////////////// | 217 ////////////////////////////////////////////////////////////////////////////// |
218 | 218 |
219 static GM* MyFactory(void*) { return new CircleGM; } | 219 static GM* MyFactory(void*) { return new CircleGM; } |
220 static GMRegistry reg(MyFactory); | 220 static GMRegistry reg(MyFactory); |
221 | 221 |
222 } | 222 } |
OLD | NEW |