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 | 9 |
10 #include "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkRRect.h" | 13 #include "SkRRect.h" |
14 | 14 |
15 namespace skiagm { | 15 namespace skiagm { |
16 | 16 |
17 class ContourStartGM : public GM { | 17 class ContourStartGM : public GM { |
18 public: | 18 public: |
19 ContourStartGM() { | 19 ContourStartGM() { |
20 const SkScalar kMaxDashLen = 100; | 20 const SkScalar kMaxDashLen = 100; |
21 const SkScalar kDashGrowth = 1.2f; | 21 const SkScalar kDashGrowth = 1.2f; |
22 | 22 |
23 SkSTArray<100, SkScalar> intervals; | 23 SkSTArray<100, SkScalar> intervals; |
24 for (SkScalar len = 1; len < kMaxDashLen; len *= kDashGrowth) { | 24 for (SkScalar len = 1; len < kMaxDashLen; len *= kDashGrowth) { |
25 intervals.push_back(len); | 25 intervals.push_back(len); |
26 intervals.push_back(len); | 26 intervals.push_back(len); |
27 } | 27 } |
28 | 28 |
29 SkAutoTUnref<SkPathEffect> effect( | |
30 SkDashPathEffect::Create(intervals.begin(), intervals.count(), 0)); | |
31 | |
32 fDashPaint.setAntiAlias(true); | 29 fDashPaint.setAntiAlias(true); |
33 fDashPaint.setStyle(SkPaint::kStroke_Style); | 30 fDashPaint.setStyle(SkPaint::kStroke_Style); |
34 fDashPaint.setStrokeWidth(6); | 31 fDashPaint.setStrokeWidth(6); |
35 fDashPaint.setColor(0xff008000); | 32 fDashPaint.setColor(0xff008000); |
36 fDashPaint.setPathEffect(effect); | 33 fDashPaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(), inter
vals.count(), 0)); |
37 | 34 |
38 fPointsPaint.setColor(0xff800000); | 35 fPointsPaint.setColor(0xff800000); |
39 fPointsPaint.setStrokeWidth(3); | 36 fPointsPaint.setStrokeWidth(3); |
40 | 37 |
41 fRect = SkRect::MakeLTRB(10, 10, 100, 70); | 38 fRect = SkRect::MakeLTRB(10, 10, 100, 70); |
42 } | 39 } |
43 | 40 |
44 protected: | 41 protected: |
45 SkString onShortName() override { | 42 SkString onShortName() override { |
46 return SkString("contour_start"); | 43 return SkString("contour_start"); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 121 } |
125 } | 122 } |
126 | 123 |
127 typedef GM INHERITED; | 124 typedef GM INHERITED; |
128 }; | 125 }; |
129 | 126 |
130 DEF_GM( return new ContourStartGM(); ) | 127 DEF_GM( return new ContourStartGM(); ) |
131 | 128 |
132 } // namespace skiagm | 129 } // namespace skiagm |
133 | 130 |
OLD | NEW |