| 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
| 13 #include "SkTArray.h" | 13 #include "SkTArray.h" |
| 14 | 14 |
| 15 namespace skiagm { | 15 namespace skiagm { |
| 16 | 16 |
| 17 // This GM tests a grab-bag of convex and concave polygons. They are triangles, | 17 // This GM tests a grab-bag of convex and concave polygons. They are triangles, |
| 18 // trapezoid, diamond, polygons with lots of edges, several concave polygons... | 18 // trapezoid, diamond, polygons with lots of edges, several concave polygons... |
| 19 // But rectangles are excluded. | 19 // But rectangles are excluded. |
| 20 class PolygonsGM: public GM { | 20 class PolygonsGM: public GM { |
| 21 public: | 21 public: |
| 22 PolygonsGM() {} | 22 PolygonsGM() {} |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 virtual SkString onShortName() SK_OVERRIDE { | 25 virtual SkString onShortName() SK_OVERRIDE { |
| 26 return SkString("polygons"); | 26 return SkString("polygons"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual SkISize onISize() SK_OVERRIDE { | 29 virtual SkISize onISize() SK_OVERRIDE { |
| 30 size_t width = kNumPolygons * kCellSize + 40; | 30 int width = kNumPolygons * kCellSize + 40; |
| 31 size_t height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCell
Size + 40; | 31 int height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCellSiz
e + 40; |
| 32 return SkISize::Make(width, height); | 32 return SkISize::Make(width, height); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Construct all polygons | 35 // Construct all polygons |
| 36 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 36 virtual void onOnceBeforeDraw() SK_OVERRIDE { |
| 37 SkPoint p0[] = {{0, 0}, {60, 0}, {90, 40}}; // triangle | 37 SkPoint p0[] = {{0, 0}, {60, 0}, {90, 40}}; // triangle |
| 38 SkPoint p1[] = {{0, 0}, {0, 40}, {60, 40}, {40, 0}}; // trapezoid | 38 SkPoint p1[] = {{0, 0}, {0, 40}, {60, 40}, {40, 0}}; // trapezoid |
| 39 SkPoint p2[] = {{0, 0}, {40, 40}, {80, 40}, {40, 0}}; // diamond | 39 SkPoint p2[] = {{0, 0}, {40, 40}, {80, 40}, {40, 0}}; // diamond |
| 40 SkPoint p3[] = {{10, 0}, {50, 0}, {60, 10}, {60, 30}, {50, 40}, | 40 SkPoint p3[] = {{10, 0}, {50, 0}, {60, 10}, {60, 30}, {50, 40}, |
| 41 {10, 40}, {0, 30}, {0, 10}}; // octagon | 41 {10, 40}, {0, 30}, {0, 10}}; // octagon |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 SkTArray<SkPath> fPolygons; | 160 SkTArray<SkPath> fPolygons; |
| 161 typedef GM INHERITED; | 161 typedef GM INHERITED; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 ////////////////////////////////////////////////////////////////////////////// | 164 ////////////////////////////////////////////////////////////////////////////// |
| 165 | 165 |
| 166 DEF_GM(return new PolygonsGM;) | 166 DEF_GM(return new PolygonsGM;) |
| 167 | 167 |
| 168 } | 168 } |
| OLD | NEW |