| 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 "SkTArray.h" | 9 #include "SkTArray.h" |
| 10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 // position the current test on the canvas | 203 // position the current test on the canvas |
| 204 static void position(SkCanvas* canvas, int testCount) { | 204 static void position(SkCanvas* canvas, int testCount) { |
| 205 canvas->translate(SK_Scalar1 * 100 * (testCount % 10) + SK_Scalar1 / 4, | 205 canvas->translate(SK_Scalar1 * 100 * (testCount % 10) + SK_Scalar1 / 4, |
| 206 SK_Scalar1 * 100 * (testCount / 10) + 3 * SK_Scalar1 /
4); | 206 SK_Scalar1 * 100 * (testCount / 10) + 3 * SK_Scalar1 /
4); |
| 207 } | 207 } |
| 208 | 208 |
| 209 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 209 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 210 SkAutoCommentBlock acb(canvas, "onDraw"); |
| 211 |
| 210 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 212 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
| 211 | 213 |
| 212 int testCount = 0; | 214 int testCount = 0; |
| 213 | 215 |
| 216 canvas->addComment("Test", "Various Paints"); |
| 217 |
| 214 for (int i = 0; i < fPaints.count(); ++i) { | 218 for (int i = 0; i < fPaints.count(); ++i) { |
| 215 for (int j = 0; j < fRects.count(); ++j, ++testCount) { | 219 for (int j = 0; j < fRects.count(); ++j, ++testCount) { |
| 216 canvas->save(); | 220 canvas->save(); |
| 217 this->position(canvas, testCount); | 221 this->position(canvas, testCount); |
| 218 canvas->drawRect(fRects[j], fPaints[i]); | 222 canvas->drawRect(fRects[j], fPaints[i]); |
| 219 canvas->restore(); | 223 canvas->restore(); |
| 220 } | 224 } |
| 221 } | 225 } |
| 222 | 226 |
| 227 canvas->addComment("Test", "Matrices"); |
| 228 |
| 223 SkPaint paint; | 229 SkPaint paint; |
| 224 paint.setColor(SK_ColorWHITE); | 230 paint.setColor(SK_ColorWHITE); |
| 225 paint.setAntiAlias(true); | 231 paint.setAntiAlias(true); |
| 226 | 232 |
| 227 for (int i = 0; i < fMatrices.count(); ++i) { | 233 for (int i = 0; i < fMatrices.count(); ++i) { |
| 228 for (int j = 0; j < fRects.count(); ++j, ++testCount) { | 234 for (int j = 0; j < fRects.count(); ++j, ++testCount) { |
| 229 canvas->save(); | 235 canvas->save(); |
| 230 this->position(canvas, testCount); | 236 this->position(canvas, testCount); |
| 231 canvas->concat(fMatrices[i]); | 237 canvas->concat(fMatrices[i]); |
| 232 canvas->drawRect(fRects[j], paint); | 238 canvas->drawRect(fRects[j], paint); |
| 233 canvas->restore(); | 239 canvas->restore(); |
| 234 } | 240 } |
| 235 } | 241 } |
| 236 } | 242 } |
| 237 | 243 |
| 238 private: | 244 private: |
| 239 SkTArray<SkPaint> fPaints; | 245 SkTArray<SkPaint> fPaints; |
| 240 SkTArray<SkMatrix> fMatrices; | 246 SkTArray<SkMatrix> fMatrices; |
| 241 SkTArray<SkRect> fRects; | 247 SkTArray<SkRect> fRects; |
| 242 | 248 |
| 243 typedef GM INHERITED; | 249 typedef GM INHERITED; |
| 244 }; | 250 }; |
| 245 | 251 |
| 246 ////////////////////////////////////////////////////////////////////////////// | 252 ////////////////////////////////////////////////////////////////////////////// |
| 247 | 253 |
| 248 static GM* MyFactory(void*) { return new RectsGM; } | 254 static GM* MyFactory(void*) { return new RectsGM; } |
| 249 static GMRegistry reg(MyFactory); | 255 static GMRegistry reg(MyFactory); |
| 250 | 256 |
| 251 } | 257 } |
| OLD | NEW |