OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 paint.setStrokeWidth(SkIntToScalar(2)); | 42 paint.setStrokeWidth(SkIntToScalar(2)); |
43 canvas->translate(0, SkIntToScalar(20)); | 43 canvas->translate(0, SkIntToScalar(20)); |
44 drawline(canvas, 4, 4, paint, SkIntToScalar(0)); | 44 drawline(canvas, 4, 4, paint, SkIntToScalar(0)); |
45 } | 45 } |
46 | 46 |
47 class DashingGM : public skiagm::GM { | 47 class DashingGM : public skiagm::GM { |
48 public: | 48 public: |
49 DashingGM() {} | 49 DashingGM() {} |
50 | 50 |
51 protected: | 51 protected: |
52 uint32_t onGetFlags() const SK_OVERRIDE { | |
53 return kSkipTiled_Flag; | |
54 } | |
55 | 52 |
56 SkString onShortName() { | 53 SkString onShortName() { |
57 return SkString("dashing"); | 54 return SkString("dashing"); |
58 } | 55 } |
59 | 56 |
60 SkISize onISize() { return SkISize::Make(640, 300); } | 57 SkISize onISize() { return SkISize::Make(640, 300); } |
61 | 58 |
62 virtual void onDraw(SkCanvas* canvas) { | 59 virtual void onDraw(SkCanvas* canvas) { |
63 static const struct { | 60 static const struct { |
64 int fOnInterval; | 61 int fOnInterval; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 SkMatrix matrix; | 126 SkMatrix matrix; |
130 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); | 127 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); |
131 path->transform(matrix); | 128 path->transform(matrix); |
132 } | 129 } |
133 | 130 |
134 class Dashing2GM : public skiagm::GM { | 131 class Dashing2GM : public skiagm::GM { |
135 public: | 132 public: |
136 Dashing2GM() {} | 133 Dashing2GM() {} |
137 | 134 |
138 protected: | 135 protected: |
139 uint32_t onGetFlags() const SK_OVERRIDE { | |
140 return kSkipTiled_Flag; | |
141 } | |
142 | 136 |
143 SkString onShortName() { | 137 SkString onShortName() { |
144 return SkString("dashing2"); | 138 return SkString("dashing2"); |
145 } | 139 } |
146 | 140 |
147 SkISize onISize() { return SkISize::Make(640, 480); } | 141 SkISize onISize() { return SkISize::Make(640, 480); } |
148 | 142 |
149 virtual void onDraw(SkCanvas* canvas) { | 143 virtual void onDraw(SkCanvas* canvas) { |
150 static const int gIntervals[] = { | 144 static const int gIntervals[] = { |
151 3, // 3 dashes: each count [0] followed by intervals [1..count] | 145 3, // 3 dashes: each count [0] followed by intervals [1..count] |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 }; | 185 }; |
192 | 186 |
193 ////////////////////////////////////////////////////////////////////////////// | 187 ////////////////////////////////////////////////////////////////////////////// |
194 | 188 |
195 // Test out the on/off line dashing Chrome if fond of | 189 // Test out the on/off line dashing Chrome if fond of |
196 class Dashing3GM : public skiagm::GM { | 190 class Dashing3GM : public skiagm::GM { |
197 public: | 191 public: |
198 Dashing3GM() {} | 192 Dashing3GM() {} |
199 | 193 |
200 protected: | 194 protected: |
201 uint32_t onGetFlags() const SK_OVERRIDE { | |
202 return kSkipTiled_Flag; | |
203 } | |
204 | 195 |
205 SkString onShortName() { | 196 SkString onShortName() { |
206 return SkString("dashing3"); | 197 return SkString("dashing3"); |
207 } | 198 } |
208 | 199 |
209 SkISize onISize() { return SkISize::Make(640, 480); } | 200 SkISize onISize() { return SkISize::Make(640, 480); } |
210 | 201 |
211 // Draw a 100x100 block of dashed lines. The horizontal ones are BW | 202 // Draw a 100x100 block of dashed lines. The horizontal ones are BW |
212 // while the vertical ones are AA. | 203 // while the vertical ones are AA. |
213 void drawDashedLines(SkCanvas* canvas, | 204 void drawDashedLines(SkCanvas* canvas, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 315 |
325 }; | 316 }; |
326 | 317 |
327 ////////////////////////////////////////////////////////////////////////////// | 318 ////////////////////////////////////////////////////////////////////////////// |
328 | 319 |
329 class Dashing4GM : public skiagm::GM { | 320 class Dashing4GM : public skiagm::GM { |
330 public: | 321 public: |
331 Dashing4GM() {} | 322 Dashing4GM() {} |
332 | 323 |
333 protected: | 324 protected: |
334 uint32_t onGetFlags() const SK_OVERRIDE { | |
335 return kSkipTiled_Flag; | |
336 } | |
337 | 325 |
338 SkString onShortName() { | 326 SkString onShortName() { |
339 return SkString("dashing4"); | 327 return SkString("dashing4"); |
340 } | 328 } |
341 | 329 |
342 SkISize onISize() { return SkISize::Make(640, 950); } | 330 SkISize onISize() { return SkISize::Make(640, 950); } |
343 | 331 |
344 virtual void onDraw(SkCanvas* canvas) { | 332 virtual void onDraw(SkCanvas* canvas) { |
345 static const struct { | 333 static const struct { |
346 int fOnInterval; | 334 int fOnInterval; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 395 } |
408 }; | 396 }; |
409 | 397 |
410 ////////////////////////////////////////////////////////////////////////////// | 398 ////////////////////////////////////////////////////////////////////////////// |
411 | 399 |
412 class Dashing5GM : public skiagm::GM { | 400 class Dashing5GM : public skiagm::GM { |
413 public: | 401 public: |
414 Dashing5GM(bool doAA) : fDoAA(doAA) {} | 402 Dashing5GM(bool doAA) : fDoAA(doAA) {} |
415 | 403 |
416 protected: | 404 protected: |
417 uint32_t onGetFlags() const SK_OVERRIDE { return kSkipTiled_Flag; } | |
418 | 405 |
419 bool runAsBench() const SK_OVERRIDE { return true; } | 406 bool runAsBench() const SK_OVERRIDE { return true; } |
420 | 407 |
421 SkString onShortName() SK_OVERRIDE { | 408 SkString onShortName() SK_OVERRIDE { |
422 if (fDoAA) { | 409 if (fDoAA) { |
423 return SkString("dashing5_aa"); | 410 return SkString("dashing5_aa"); |
424 } else { | 411 } else { |
425 return SkString("dashing5_bw"); | 412 return SkString("dashing5_bw"); |
426 } | 413 } |
427 } | 414 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 474 |
488 ////////////////////////////////////////////////////////////////////////////// | 475 ////////////////////////////////////////////////////////////////////////////// |
489 | 476 |
490 DEF_GM(return SkNEW(DashingGM);) | 477 DEF_GM(return SkNEW(DashingGM);) |
491 DEF_GM(return SkNEW(Dashing2GM);) | 478 DEF_GM(return SkNEW(Dashing2GM);) |
492 DEF_GM(return SkNEW(Dashing3GM);) | 479 DEF_GM(return SkNEW(Dashing3GM);) |
493 DEF_GM(return SkNEW(Dashing4GM);) | 480 DEF_GM(return SkNEW(Dashing4GM);) |
494 DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));) | 481 DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));) |
495 DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));) | 482 DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));) |
496 | 483 |
OLD | NEW |