OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBlurDrawLooper.h" | 9 #include "SkBlurDrawLooper.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 // position the current test on the canvas | 248 // position the current test on the canvas |
249 static void position(SkCanvas* canvas, int testCount) { | 249 static void position(SkCanvas* canvas, int testCount) { |
250 canvas->translate(SK_Scalar1 * 100 * (testCount % 10) + SK_Scalar1 / 4, | 250 canvas->translate(SK_Scalar1 * 100 * (testCount % 10) + SK_Scalar1 / 4, |
251 SK_Scalar1 * 100 * (testCount / 10) + 3 * SK_Scalar1 /
4); | 251 SK_Scalar1 * 100 * (testCount / 10) + 3 * SK_Scalar1 /
4); |
252 } | 252 } |
253 | 253 |
254 void onDraw(SkCanvas* canvas) override { | 254 void onDraw(SkCanvas* canvas) override { |
255 SkAutoCommentBlock acb(canvas, "onDraw"); | |
256 | |
257 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 255 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
258 | 256 |
259 int testCount = 0; | 257 int testCount = 0; |
260 | 258 |
261 canvas->addComment("Test", "Various Paints"); | |
262 | |
263 for (int i = 0; i < fPaints.count(); ++i) { | 259 for (int i = 0; i < fPaints.count(); ++i) { |
264 for (int j = 0; j < fRects.count(); ++j, ++testCount) { | 260 for (int j = 0; j < fRects.count(); ++j, ++testCount) { |
265 canvas->save(); | 261 canvas->save(); |
266 this->position(canvas, testCount); | 262 this->position(canvas, testCount); |
267 canvas->drawRect(fRects[j], fPaints[i]); | 263 canvas->drawRect(fRects[j], fPaints[i]); |
268 canvas->restore(); | 264 canvas->restore(); |
269 } | 265 } |
270 } | 266 } |
271 | 267 |
272 canvas->addComment("Test", "Matrices"); | |
273 | |
274 SkPaint paint; | 268 SkPaint paint; |
275 paint.setColor(SK_ColorWHITE); | 269 paint.setColor(SK_ColorWHITE); |
276 paint.setAntiAlias(true); | 270 paint.setAntiAlias(true); |
277 | 271 |
278 for (int i = 0; i < fMatrices.count(); ++i) { | 272 for (int i = 0; i < fMatrices.count(); ++i) { |
279 for (int j = 0; j < fRects.count(); ++j, ++testCount) { | 273 for (int j = 0; j < fRects.count(); ++j, ++testCount) { |
280 canvas->save(); | 274 canvas->save(); |
281 this->position(canvas, testCount); | 275 this->position(canvas, testCount); |
282 canvas->concat(fMatrices[i]); | 276 canvas->concat(fMatrices[i]); |
283 canvas->drawRect(fRects[j], paint); | 277 canvas->drawRect(fRects[j], paint); |
284 canvas->restore(); | 278 canvas->restore(); |
285 } | 279 } |
286 } | 280 } |
287 } | 281 } |
288 | 282 |
289 private: | 283 private: |
290 SkTArray<SkPaint> fPaints; | 284 SkTArray<SkPaint> fPaints; |
291 SkTArray<SkMatrix> fMatrices; | 285 SkTArray<SkMatrix> fMatrices; |
292 SkTArray<SkRect> fRects; | 286 SkTArray<SkRect> fRects; |
293 | 287 |
294 typedef GM INHERITED; | 288 typedef GM INHERITED; |
295 }; | 289 }; |
296 | 290 |
297 ////////////////////////////////////////////////////////////////////////////// | 291 ////////////////////////////////////////////////////////////////////////////// |
298 | 292 |
299 static GM* MyFactory(void*) { return new RectsGM; } | 293 static GM* MyFactory(void*) { return new RectsGM; } |
300 static GMRegistry reg(MyFactory); | 294 static GMRegistry reg(MyFactory); |
301 | 295 |
302 } | 296 } |
OLD | NEW |