OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef GrStrokeInfo_DEFINED | 8 #ifndef GrStrokeInfo_DEFINED |
9 #define GrStrokeInfo_DEFINED | 9 #define GrStrokeInfo_DEFINED |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 } else { | 31 } else { |
32 fDashType = SkPathEffect::kNone_DashType; | 32 fDashType = SkPathEffect::kNone_DashType; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 GrStrokeInfo(const SkPaint& paint, SkPaint::Style styleOverride) : | 36 GrStrokeInfo(const SkPaint& paint, SkPaint::Style styleOverride) : |
37 fStroke(paint, styleOverride), fDashType(SkPathEffect::kNone_DashType) { | 37 fStroke(paint, styleOverride), fDashType(SkPathEffect::kNone_DashType) { |
38 this->init(paint); | 38 this->init(paint); |
39 } | 39 } |
40 | 40 |
41 | |
42 explicit GrStrokeInfo(const SkPaint& paint) : | 41 explicit GrStrokeInfo(const SkPaint& paint) : |
43 fStroke(paint), fDashType(SkPathEffect::kNone_DashType) { | 42 fStroke(paint), fDashType(SkPathEffect::kNone_DashType) { |
44 this->init(paint); | 43 this->init(paint); |
45 } | 44 } |
46 | 45 |
47 GrStrokeInfo& operator=(const GrStrokeInfo& other) { | 46 GrStrokeInfo& operator=(const GrStrokeInfo& other) { |
48 fStroke = other.fStroke; | 47 fStroke = other.fStroke; |
49 fDashInfo = other.fDashInfo; | 48 fDashInfo = other.fDashInfo; |
50 fDashType = other.fDashType; | 49 fDashType = other.fDashType; |
51 fIntervals.reset(other.dashCount()); | 50 fIntervals.reset(other.dashCount()); |
(...skipping 19 matching lines...) Expand all Loading... |
71 if (SkPathEffect::kDash_DashType == fDashType) { | 70 if (SkPathEffect::kDash_DashType == fDashType) { |
72 fIntervals.reset(fDashInfo.fCount); | 71 fIntervals.reset(fDashInfo.fCount); |
73 fDashInfo.fIntervals = fIntervals.get(); | 72 fDashInfo.fIntervals = fIntervals.get(); |
74 pe->asADash(&fDashInfo); | 73 pe->asADash(&fDashInfo); |
75 return true; | 74 return true; |
76 } | 75 } |
77 } | 76 } |
78 return false; | 77 return false; |
79 } | 78 } |
80 | 79 |
| 80 /* |
| 81 * Like the above, but sets with an explicit SkPathEffect::DashInfo |
| 82 */ |
| 83 bool setDashInfo(const SkPathEffect::DashInfo& info) { |
| 84 if (!fStroke.isFillStyle()) { |
| 85 SkASSERT(!fStroke.isFillStyle()); |
| 86 fDashInfo.fCount = info.fCount; |
| 87 fDashInfo.fPhase = info.fPhase; |
| 88 fIntervals.reset(info.fCount); |
| 89 for (int i = 0; i < info.fCount; i++) { |
| 90 fIntervals[i] = info.fIntervals[i]; |
| 91 } |
| 92 fDashInfo.fIntervals = fIntervals.get(); |
| 93 return true; |
| 94 } |
| 95 return false; |
| 96 } |
| 97 |
81 bool isDashed() const { | 98 bool isDashed() const { |
82 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT
ype); | 99 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT
ype); |
83 } | 100 } |
84 | 101 |
85 bool isFillStyle() const { return fStroke.isFillStyle(); } | 102 bool isFillStyle() const { return fStroke.isFillStyle(); } |
86 | 103 |
87 int32_t dashCount() const { | 104 int32_t dashCount() const { |
88 return fDashInfo.fCount; | 105 return fDashInfo.fCount; |
89 } | 106 } |
90 | 107 |
(...skipping 18 matching lines...) Expand all Loading... |
109 this->setDashInfo(pe); | 126 this->setDashInfo(pe); |
110 } | 127 } |
111 | 128 |
112 SkStrokeRec fStroke; | 129 SkStrokeRec fStroke; |
113 SkPathEffect::DashType fDashType; | 130 SkPathEffect::DashType fDashType; |
114 SkPathEffect::DashInfo fDashInfo; | 131 SkPathEffect::DashInfo fDashInfo; |
115 SkAutoSTArray<2, SkScalar> fIntervals; | 132 SkAutoSTArray<2, SkScalar> fIntervals; |
116 }; | 133 }; |
117 | 134 |
118 #endif | 135 #endif |
OLD | NEW |