Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: gm/polygons.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/poly2poly.cpp ('k') | gm/quadpaths.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25
26 SkString onShortName() SK_OVERRIDE { 26 SkString onShortName() override {
27 return SkString("polygons"); 27 return SkString("polygons");
28 } 28 }
29 29
30 SkISize onISize() SK_OVERRIDE { 30 SkISize onISize() override {
31 int width = kNumPolygons * kCellSize + 40; 31 int width = kNumPolygons * kCellSize + 40;
32 int height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCellSiz e + 40; 32 int height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCellSiz e + 40;
33 return SkISize::Make(width, height); 33 return SkISize::Make(width, height);
34 } 34 }
35 35
36 // Construct all polygons 36 // Construct all polygons
37 void onOnceBeforeDraw() SK_OVERRIDE { 37 void onOnceBeforeDraw() override {
38 SkPoint p0[] = {{0, 0}, {60, 0}, {90, 40}}; // triangle 38 SkPoint p0[] = {{0, 0}, {60, 0}, {90, 40}}; // triangle
39 SkPoint p1[] = {{0, 0}, {0, 40}, {60, 40}, {40, 0}}; // trapezoid 39 SkPoint p1[] = {{0, 0}, {0, 40}, {60, 40}, {40, 0}}; // trapezoid
40 SkPoint p2[] = {{0, 0}, {40, 40}, {80, 40}, {40, 0}}; // diamond 40 SkPoint p2[] = {{0, 0}, {40, 40}, {80, 40}, {40, 0}}; // diamond
41 SkPoint p3[] = {{10, 0}, {50, 0}, {60, 10}, {60, 30}, {50, 40}, 41 SkPoint p3[] = {{10, 0}, {50, 0}, {60, 10}, {60, 30}, {50, 40},
42 {10, 40}, {0, 30}, {0, 10}}; // octagon 42 {10, 40}, {0, 30}, {0, 10}}; // octagon
43 SkPoint p4[32]; // circle-like polygons with 32-edges. 43 SkPoint p4[32]; // circle-like polygons with 32-edges.
44 SkPoint p5[] = {{0, 0}, {20, 20}, {0, 40}, {60, 20}}; // concave polygo n with 4 edges 44 SkPoint p5[] = {{0, 0}, {20, 20}, {0, 40}, {60, 20}}; // concave polygo n with 4 edges
45 SkPoint p6[] = {{0, 40}, {0, 30}, {15, 30}, {15, 20}, {30, 20}, 45 SkPoint p6[] = {{0, 40}, {0, 30}, {15, 30}, {15, 20}, {30, 20},
46 {30, 10}, {45, 10}, {45, 0}, {60, 0}, {60, 40}}; // sta irs-like polygon 46 {30, 10}, {45, 10}, {45, 0}, {60, 0}, {60, 40}}; // sta irs-like polygon
47 SkPoint p7[] = {{0, 20}, {20, 20}, {30, 0}, {40, 20}, {60, 20}, 47 SkPoint p7[] = {{0, 20}, {20, 20}, {30, 0}, {40, 20}, {60, 20},
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 static void SetColorAndAlpha(SkPaint* paint, SkRandom* rand) { 88 static void SetColorAndAlpha(SkPaint* paint, SkRandom* rand) {
89 SkColor color = rand->nextU(); 89 SkColor color = rand->nextU();
90 color |= 0xff000000; 90 color |= 0xff000000;
91 paint->setColor(color); 91 paint->setColor(color);
92 if (40 == paint->getStrokeWidth()) { 92 if (40 == paint->getStrokeWidth()) {
93 paint->setAlpha(0xA0); 93 paint->setAlpha(0xA0);
94 } 94 }
95 } 95 }
96 96
97 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 97 void onDraw(SkCanvas* canvas) override {
98 // Stroke widths are: 98 // Stroke widths are:
99 // 0(may use hairline rendering), 10(common case for stroke-style) 99 // 0(may use hairline rendering), 10(common case for stroke-style)
100 // 40(>= geometry width/height, make the contour filled in fact) 100 // 40(>= geometry width/height, make the contour filled in fact)
101 static const int kStrokeWidths[] = {0, 10, 40}; 101 static const int kStrokeWidths[] = {0, 10, 40};
102 SkASSERT(kNumStrokeWidths == SK_ARRAY_COUNT(kStrokeWidths)); 102 SkASSERT(kNumStrokeWidths == SK_ARRAY_COUNT(kStrokeWidths));
103 103
104 static const SkPaint::Join kJoins[] = { 104 static const SkPaint::Join kJoins[] = {
105 SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join 105 SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join
106 }; 106 };
107 SkASSERT(kNumJoins == SK_ARRAY_COUNT(kJoins)); 107 SkASSERT(kNumJoins == SK_ARRAY_COUNT(kJoins));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 SkTArray<SkPath> fPolygons; 161 SkTArray<SkPath> fPolygons;
162 typedef GM INHERITED; 162 typedef GM INHERITED;
163 }; 163 };
164 164
165 ////////////////////////////////////////////////////////////////////////////// 165 //////////////////////////////////////////////////////////////////////////////
166 166
167 DEF_GM(return new PolygonsGM;) 167 DEF_GM(return new PolygonsGM;)
168 168
169 } 169 }
OLDNEW
« no previous file with comments | « gm/poly2poly.cpp ('k') | gm/quadpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698