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