OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPathEffect_DEFINED | 10 #ifndef SkPathEffect_DEFINED |
(...skipping 13 matching lines...) Expand all Loading... |
24 SkPathEffect is the base class for objects in the SkPaint that affect | 24 SkPathEffect is the base class for objects in the SkPaint that affect |
25 the geometry of a drawing primitive before it is transformed by the | 25 the geometry of a drawing primitive before it is transformed by the |
26 canvas' matrix and drawn. | 26 canvas' matrix and drawn. |
27 | 27 |
28 Dashing is implemented as a subclass of SkPathEffect. | 28 Dashing is implemented as a subclass of SkPathEffect. |
29 */ | 29 */ |
30 class SK_API SkPathEffect : public SkFlattenable { | 30 class SK_API SkPathEffect : public SkFlattenable { |
31 public: | 31 public: |
32 SK_DECLARE_INST_COUNT(SkPathEffect) | 32 SK_DECLARE_INST_COUNT(SkPathEffect) |
33 | 33 |
34 SkPathEffect() {} | |
35 | |
36 /** | 34 /** |
37 * Given a src path (input) and a stroke-rec (input and output), apply | 35 * Given a src path (input) and a stroke-rec (input and output), apply |
38 * this effect to the src path, returning the new path in dst, and return | 36 * this effect to the src path, returning the new path in dst, and return |
39 * true. If this effect cannot be applied, return false and ignore dst | 37 * true. If this effect cannot be applied, return false and ignore dst |
40 * and stroke-rec. | 38 * and stroke-rec. |
41 * | 39 * |
42 * The stroke-rec specifies the initial request for stroking (if any). | 40 * The stroke-rec specifies the initial request for stroking (if any). |
43 * The effect can treat this as input only, or it can choose to change | 41 * The effect can treat this as input only, or it can choose to change |
44 * the rec as well. For example, the effect can decide to change the | 42 * the rec as well. For example, the effect can decide to change the |
45 * stroke's width or join, or the effect can change the rec from stroke | 43 * stroke's width or join, or the effect can change the rec from stroke |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 * Does applying this path effect to 'src' yield a set of points? If so, | 100 * Does applying this path effect to 'src' yield a set of points? If so, |
103 * optionally return the points in 'results'. | 101 * optionally return the points in 'results'. |
104 */ | 102 */ |
105 virtual bool asPoints(PointData* results, const SkPath& src, | 103 virtual bool asPoints(PointData* results, const SkPath& src, |
106 const SkStrokeRec&, const SkMatrix&, | 104 const SkStrokeRec&, const SkMatrix&, |
107 const SkRect* cullR) const; | 105 const SkRect* cullR) const; |
108 | 106 |
109 SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect) | 107 SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect) |
110 | 108 |
111 protected: | 109 protected: |
| 110 SkPathEffect() {} |
112 SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} | 111 SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} |
113 | 112 |
114 private: | 113 private: |
115 // illegal | 114 // illegal |
116 SkPathEffect(const SkPathEffect&); | 115 SkPathEffect(const SkPathEffect&); |
117 SkPathEffect& operator=(const SkPathEffect&); | 116 SkPathEffect& operator=(const SkPathEffect&); |
118 | 117 |
119 typedef SkFlattenable INHERITED; | 118 typedef SkFlattenable INHERITED; |
120 }; | 119 }; |
121 | 120 |
122 /** \class SkPairPathEffect | 121 /** \class SkPairPathEffect |
123 | 122 |
124 Common baseclass for Compose and Sum. This subclass manages two pathEffects, | 123 Common baseclass for Compose and Sum. This subclass manages two pathEffects, |
125 including flattening them. It does nothing in filterPath, and is only useful | 124 including flattening them. It does nothing in filterPath, and is only useful |
126 for managing the lifetimes of its two arguments. | 125 for managing the lifetimes of its two arguments. |
127 */ | 126 */ |
128 class SkPairPathEffect : public SkPathEffect { | 127 class SkPairPathEffect : public SkPathEffect { |
129 public: | 128 public: |
130 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); | |
131 virtual ~SkPairPathEffect(); | 129 virtual ~SkPairPathEffect(); |
132 | 130 |
133 protected: | 131 protected: |
| 132 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); |
134 SkPairPathEffect(SkReadBuffer&); | 133 SkPairPathEffect(SkReadBuffer&); |
135 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 134 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
136 | 135 |
137 // these are visible to our subclasses | 136 // these are visible to our subclasses |
138 SkPathEffect* fPE0, *fPE1; | 137 SkPathEffect* fPE0, *fPE1; |
139 | 138 |
140 private: | 139 private: |
141 typedef SkPathEffect INHERITED; | 140 typedef SkPathEffect INHERITED; |
142 }; | 141 }; |
143 | 142 |
144 /** \class SkComposePathEffect | 143 /** \class SkComposePathEffect |
145 | 144 |
146 This subclass of SkPathEffect composes its two arguments, to create | 145 This subclass of SkPathEffect composes its two arguments, to create |
147 a compound pathEffect. | 146 a compound pathEffect. |
148 */ | 147 */ |
149 class SkComposePathEffect : public SkPairPathEffect { | 148 class SkComposePathEffect : public SkPairPathEffect { |
150 public: | 149 public: |
151 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct | 150 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct |
152 and the the outer pathEffect (e.g. outer(inner(path))) | 151 and the the outer pathEffect (e.g. outer(inner(path))) |
153 The reference counts for outer and inner are both incremented in the con
structor, | 152 The reference counts for outer and inner are both incremented in the con
structor, |
154 and decremented in the destructor. | 153 and decremented in the destructor. |
155 */ | 154 */ |
156 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) | 155 static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner)
{ |
157 : INHERITED(outer, inner) {} | 156 return SkNEW_ARGS(SkComposePathEffect, (outer, inner)); |
| 157 } |
158 | 158 |
159 virtual bool filterPath(SkPath* dst, const SkPath& src, | 159 virtual bool filterPath(SkPath* dst, const SkPath& src, |
160 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 160 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
161 | 161 |
162 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) | 162 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) |
163 | 163 |
164 protected: | 164 protected: |
165 SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} | 165 SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} |
166 | 166 |
| 167 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 168 public: |
| 169 #endif |
| 170 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) |
| 171 : INHERITED(outer, inner) {} |
| 172 |
167 private: | 173 private: |
168 // illegal | 174 // illegal |
169 SkComposePathEffect(const SkComposePathEffect&); | 175 SkComposePathEffect(const SkComposePathEffect&); |
170 SkComposePathEffect& operator=(const SkComposePathEffect&); | 176 SkComposePathEffect& operator=(const SkComposePathEffect&); |
171 | 177 |
172 typedef SkPairPathEffect INHERITED; | 178 typedef SkPairPathEffect INHERITED; |
173 }; | 179 }; |
174 | 180 |
175 /** \class SkSumPathEffect | 181 /** \class SkSumPathEffect |
176 | 182 |
177 This subclass of SkPathEffect applies two pathEffects, one after the other. | 183 This subclass of SkPathEffect applies two pathEffects, one after the other. |
178 Its filterPath() returns true if either of the effects succeeded. | 184 Its filterPath() returns true if either of the effects succeeded. |
179 */ | 185 */ |
180 class SkSumPathEffect : public SkPairPathEffect { | 186 class SkSumPathEffect : public SkPairPathEffect { |
181 public: | 187 public: |
182 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. | 188 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. |
183 (e.g. first(path) + second(path)) | 189 (e.g. first(path) + second(path)) |
184 The reference counts for first and second are both incremented in the co
nstructor, | 190 The reference counts for first and second are both incremented in the co
nstructor, |
185 and decremented in the destructor. | 191 and decremented in the destructor. |
186 */ | 192 */ |
187 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) | 193 static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
188 : INHERITED(first, second) {} | 194 return SkNEW_ARGS(SkSumPathEffect, (first, second)); |
| 195 } |
189 | 196 |
190 virtual bool filterPath(SkPath* dst, const SkPath& src, | 197 virtual bool filterPath(SkPath* dst, const SkPath& src, |
191 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 198 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
192 | 199 |
193 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) | 200 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) |
194 | 201 |
195 protected: | 202 protected: |
196 SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} | 203 SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {} |
197 | 204 |
| 205 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 206 public: |
| 207 #endif |
| 208 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) |
| 209 : INHERITED(first, second) {} |
| 210 |
198 private: | 211 private: |
199 // illegal | 212 // illegal |
200 SkSumPathEffect(const SkSumPathEffect&); | 213 SkSumPathEffect(const SkSumPathEffect&); |
201 SkSumPathEffect& operator=(const SkSumPathEffect&); | 214 SkSumPathEffect& operator=(const SkSumPathEffect&); |
202 | 215 |
203 typedef SkPairPathEffect INHERITED; | 216 typedef SkPairPathEffect INHERITED; |
204 }; | 217 }; |
205 | 218 |
206 #endif | 219 #endif |
OLD | NEW |