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 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 52 uint32_t onGetFlags() const SK_OVERRIDE { |
53 return kSkipTiled_Flag; | 53 return kSkipTiled_Flag; |
54 } | 54 } |
55 | 55 |
56 SkString onShortName() { | 56 SkString onShortName() { |
57 return SkString("dashing"); | 57 return SkString("dashing"); |
58 } | 58 } |
59 | 59 |
60 SkISize onISize() { return SkISize::Make(640, 300); } | 60 SkISize onISize() { return SkISize::Make(640, 300); } |
61 | 61 |
62 virtual void onDraw(SkCanvas* canvas) { | 62 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 SkMatrix matrix; | 129 SkMatrix matrix; |
130 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); | 130 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); |
131 path->transform(matrix); | 131 path->transform(matrix); |
132 } | 132 } |
133 | 133 |
134 class Dashing2GM : public skiagm::GM { | 134 class Dashing2GM : public skiagm::GM { |
135 public: | 135 public: |
136 Dashing2GM() {} | 136 Dashing2GM() {} |
137 | 137 |
138 protected: | 138 protected: |
139 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 139 uint32_t onGetFlags() const SK_OVERRIDE { |
140 return kSkipTiled_Flag; | 140 return kSkipTiled_Flag; |
141 } | 141 } |
142 | 142 |
143 SkString onShortName() { | 143 SkString onShortName() { |
144 return SkString("dashing2"); | 144 return SkString("dashing2"); |
145 } | 145 } |
146 | 146 |
147 SkISize onISize() { return SkISize::Make(640, 480); } | 147 SkISize onISize() { return SkISize::Make(640, 480); } |
148 | 148 |
149 virtual void onDraw(SkCanvas* canvas) { | 149 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 }; | 191 }; |
192 | 192 |
193 ////////////////////////////////////////////////////////////////////////////// | 193 ////////////////////////////////////////////////////////////////////////////// |
194 | 194 |
195 // Test out the on/off line dashing Chrome if fond of | 195 // Test out the on/off line dashing Chrome if fond of |
196 class Dashing3GM : public skiagm::GM { | 196 class Dashing3GM : public skiagm::GM { |
197 public: | 197 public: |
198 Dashing3GM() {} | 198 Dashing3GM() {} |
199 | 199 |
200 protected: | 200 protected: |
201 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 201 uint32_t onGetFlags() const SK_OVERRIDE { |
202 return kSkipTiled_Flag; | 202 return kSkipTiled_Flag; |
203 } | 203 } |
204 | 204 |
205 SkString onShortName() { | 205 SkString onShortName() { |
206 return SkString("dashing3"); | 206 return SkString("dashing3"); |
207 } | 207 } |
208 | 208 |
209 SkISize onISize() { return SkISize::Make(640, 480); } | 209 SkISize onISize() { return SkISize::Make(640, 480); } |
210 | 210 |
211 // Draw a 100x100 block of dashed lines. The horizontal ones are BW | 211 // Draw a 100x100 block of dashed lines. The horizontal ones are BW |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 }; | 325 }; |
326 | 326 |
327 ////////////////////////////////////////////////////////////////////////////// | 327 ////////////////////////////////////////////////////////////////////////////// |
328 | 328 |
329 class Dashing4GM : public skiagm::GM { | 329 class Dashing4GM : public skiagm::GM { |
330 public: | 330 public: |
331 Dashing4GM() {} | 331 Dashing4GM() {} |
332 | 332 |
333 protected: | 333 protected: |
334 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 334 uint32_t onGetFlags() const SK_OVERRIDE { |
335 return kSkipTiled_Flag; | 335 return kSkipTiled_Flag; |
336 } | 336 } |
337 | 337 |
338 SkString onShortName() { | 338 SkString onShortName() { |
339 return SkString("dashing4"); | 339 return SkString("dashing4"); |
340 } | 340 } |
341 | 341 |
342 SkISize onISize() { return SkISize::Make(640, 950); } | 342 SkISize onISize() { return SkISize::Make(640, 950); } |
343 | 343 |
344 virtual void onDraw(SkCanvas* canvas) { | 344 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 }; | 408 }; |
409 | 409 |
410 ////////////////////////////////////////////////////////////////////////////// | 410 ////////////////////////////////////////////////////////////////////////////// |
411 | 411 |
412 class Dashing5GM : public skiagm::GM { | 412 class Dashing5GM : public skiagm::GM { |
413 public: | 413 public: |
414 Dashing5GM(bool doAA) : fDoAA(doAA) {} | 414 Dashing5GM(bool doAA) : fDoAA(doAA) {} |
415 | 415 |
416 protected: | 416 protected: |
417 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kAsBench_Flag | kSk
ipTiled_Flag; } | 417 uint32_t onGetFlags() const SK_OVERRIDE { return kAsBench_Flag | kSkipTiled_
Flag; } |
418 | 418 |
419 virtual SkString onShortName() SK_OVERRIDE { | 419 SkString onShortName() SK_OVERRIDE { |
420 if (fDoAA) { | 420 if (fDoAA) { |
421 return SkString("dashing5_aa"); | 421 return SkString("dashing5_aa"); |
422 } else { | 422 } else { |
423 return SkString("dashing5_bw"); | 423 return SkString("dashing5_bw"); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 200); } | 427 SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 200); } |
428 | 428 |
429 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 429 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
430 static const int kOn = 4; | 430 static const int kOn = 4; |
431 static const int kOff = 4; | 431 static const int kOff = 4; |
432 static const int kIntervalLength = kOn + kOff; | 432 static const int kIntervalLength = kOn + kOff; |
433 | 433 |
434 static const SkColor gColors[kIntervalLength] = { | 434 static const SkColor gColors[kIntervalLength] = { |
435 SK_ColorRED, | 435 SK_ColorRED, |
436 SK_ColorGREEN, | 436 SK_ColorGREEN, |
437 SK_ColorBLUE, | 437 SK_ColorBLUE, |
438 SK_ColorCYAN, | 438 SK_ColorCYAN, |
439 SK_ColorMAGENTA, | 439 SK_ColorMAGENTA, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 485 |
486 ////////////////////////////////////////////////////////////////////////////// | 486 ////////////////////////////////////////////////////////////////////////////// |
487 | 487 |
488 DEF_GM(return SkNEW(DashingGM);) | 488 DEF_GM(return SkNEW(DashingGM);) |
489 DEF_GM(return SkNEW(Dashing2GM);) | 489 DEF_GM(return SkNEW(Dashing2GM);) |
490 DEF_GM(return SkNEW(Dashing3GM);) | 490 DEF_GM(return SkNEW(Dashing3GM);) |
491 DEF_GM(return SkNEW(Dashing4GM);) | 491 DEF_GM(return SkNEW(Dashing4GM);) |
492 DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));) | 492 DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));) |
493 DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));) | 493 DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));) |
494 | 494 |
OLD | NEW |