OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkTArray.h" | 10 #include "SkTArray.h" |
11 | 11 |
12 namespace skiagm { | 12 namespace skiagm { |
13 | 13 |
14 // this GM tests hairlines which fill nearly the entire render target | 14 // this GM tests hairlines which fill nearly the entire render target |
15 class StLouisArchGM : public GM { | 15 class StLouisArchGM : public GM { |
16 protected: | 16 protected: |
17 SkString onShortName() SK_OVERRIDE { | 17 SkString onShortName() override { |
18 return SkString("stlouisarch"); | 18 return SkString("stlouisarch"); |
19 } | 19 } |
20 | 20 |
21 SkISize onISize() SK_OVERRIDE { return SkISize::Make((int)kWidth, (int)kHeig
ht); } | 21 SkISize onISize() override { return SkISize::Make((int)kWidth, (int)kHeight)
; } |
22 | 22 |
23 void onOnceBeforeDraw() SK_OVERRIDE { | 23 void onOnceBeforeDraw() override { |
24 { | 24 { |
25 SkPath* bigQuad = &fPaths.push_back(); | 25 SkPath* bigQuad = &fPaths.push_back(); |
26 bigQuad->moveTo(0, 0); | 26 bigQuad->moveTo(0, 0); |
27 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0); | 27 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0); |
28 } | 28 } |
29 | 29 |
30 { | 30 { |
31 SkPath* degenBigQuad = &fPaths.push_back(); | 31 SkPath* degenBigQuad = &fPaths.push_back(); |
32 SkScalar yPos = kHeight / 2 + 10; | 32 SkScalar yPos = kHeight / 2 + 10; |
33 degenBigQuad->moveTo(0, yPos); | 33 degenBigQuad->moveTo(0, yPos); |
(...skipping 25 matching lines...) Expand all Loading... |
59 } | 59 } |
60 | 60 |
61 { | 61 { |
62 SkPath* degenBigConic = &fPaths.push_back(); | 62 SkPath* degenBigConic = &fPaths.push_back(); |
63 SkScalar yPos = kHeight / 2 - 10; | 63 SkScalar yPos = kHeight / 2 - 10; |
64 degenBigConic->moveTo(0, yPos); | 64 degenBigConic->moveTo(0, yPos); |
65 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5); | 65 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 69 void onDraw(SkCanvas* canvas) override { |
70 canvas->save(); | 70 canvas->save(); |
71 canvas->scale(1, -1); | 71 canvas->scale(1, -1); |
72 canvas->translate(0, -kHeight); | 72 canvas->translate(0, -kHeight); |
73 for (int p = 0; p < fPaths.count(); ++p) { | 73 for (int p = 0; p < fPaths.count(); ++p) { |
74 SkPaint paint; | 74 SkPaint paint; |
75 paint.setARGB(0xff, 0, 0, 0); | 75 paint.setARGB(0xff, 0, 0, 0); |
76 paint.setAntiAlias(true); | 76 paint.setAntiAlias(true); |
77 paint.setStyle(SkPaint::kStroke_Style); | 77 paint.setStyle(SkPaint::kStroke_Style); |
78 paint.setStrokeWidth(0); | 78 paint.setStrokeWidth(0); |
79 canvas->drawPath(fPaths[p], paint); | 79 canvas->drawPath(fPaths[p], paint); |
80 } | 80 } |
81 canvas->restore(); | 81 canvas->restore(); |
82 } | 82 } |
83 | 83 |
84 const SkScalar kWidth = 256; | 84 const SkScalar kWidth = 256; |
85 const SkScalar kHeight = 256; | 85 const SkScalar kHeight = 256; |
86 | 86 |
87 private: | 87 private: |
88 SkTArray<SkPath> fPaths; | 88 SkTArray<SkPath> fPaths; |
89 typedef GM INHERITED; | 89 typedef GM INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 ////////////////////////////////////////////////////////////////////////////// | 92 ////////////////////////////////////////////////////////////////////////////// |
93 | 93 |
94 static GM* MyFactory(void*) { return new StLouisArchGM; } | 94 static GM* MyFactory(void*) { return new StLouisArchGM; } |
95 static GMRegistry reg(MyFactory); | 95 static GMRegistry reg(MyFactory); |
96 | 96 |
97 } | 97 } |
OLD | NEW |