OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "gm.h" | 7 #include "gm.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
11 | 11 |
| 12 // skbug.com/1316 shows that this cubic, when slightly clipped, creates big |
| 13 // (incorrect) changes to its control points. |
| 14 class ClippedCubicGM : public skiagm::GM { |
| 15 public: |
| 16 ClippedCubicGM() {} |
| 17 |
| 18 protected: |
| 19 SkString onShortName() { |
| 20 return SkString("cubicpath"); |
| 21 } |
| 22 |
| 23 SkISize onISize() { return SkISize::Make(1240, 390); } |
| 24 |
| 25 virtual void onDraw(SkCanvas* canvas) { |
| 26 SkPath path; |
| 27 path.moveTo(0, 0); |
| 28 path.cubicTo(140, 150, 40, 10, 170, 150); |
| 29 |
| 30 SkPaint paint; |
| 31 SkRect bounds = path.getBounds(); |
| 32 |
| 33 for (int dy = -1; dy <= 1; ++dy) { |
| 34 canvas->save(); |
| 35 for (int dx = -1; dx <= 1; ++dx) { |
| 36 canvas->save(); |
| 37 canvas->clipRect(bounds); |
| 38 canvas->translate(dx, dy); |
| 39 canvas->drawPath(path, paint); |
| 40 canvas->restore(); |
| 41 |
| 42 canvas->translate(bounds.width(), 0); |
| 43 } |
| 44 canvas->restore(); |
| 45 canvas->translate(0, bounds.height()); |
| 46 } |
| 47 } |
| 48 |
| 49 private: |
| 50 typedef skiagm::GM INHERITED; |
| 51 }; |
| 52 |
12 class CubicPathGM : public skiagm::GM { | 53 class CubicPathGM : public skiagm::GM { |
13 public: | 54 public: |
14 CubicPathGM() {} | 55 CubicPathGM() {} |
15 | 56 |
16 protected: | 57 protected: |
17 SkString onShortName() { | 58 SkString onShortName() { |
18 return SkString("cubicpath"); | 59 return SkString("cubicpath"); |
19 } | 60 } |
20 | 61 |
21 SkISize onISize() { return SkISize::Make(1240, 390); } | 62 SkISize onISize() { return SkISize::Make(1240, 390); } |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 334 } |
294 | 335 |
295 private: | 336 private: |
296 typedef skiagm::GM INHERITED; | 337 typedef skiagm::GM INHERITED; |
297 }; | 338 }; |
298 | 339 |
299 ////////////////////////////////////////////////////////////////////////////// | 340 ////////////////////////////////////////////////////////////////////////////// |
300 | 341 |
301 DEF_GM( return new CubicPathGM; ) | 342 DEF_GM( return new CubicPathGM; ) |
302 DEF_GM( return new CubicClosePathGM; ) | 343 DEF_GM( return new CubicClosePathGM; ) |
| 344 DEF_GM( return new ClippedCubicGM; ) |
OLD | NEW |