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 #ifndef GrAAConvexTessellator_DEFINED | 8 #ifndef GrAAConvexTessellator_DEFINED |
9 #define GrAAConvexTessellator_DEFINED | 9 #define GrAAConvexTessellator_DEFINED |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 struct PointData { | 159 struct PointData { |
160 SkPoint fNorm; | 160 SkPoint fNorm; |
161 SkPoint fBisector; | 161 SkPoint fBisector; |
162 int fIndex; | 162 int fIndex; |
163 int fOrigEdgeId; | 163 int fOrigEdgeId; |
164 }; | 164 }; |
165 | 165 |
166 SkTDArray<PointData> fPts; | 166 SkTDArray<PointData> fPts; |
167 }; | 167 }; |
168 | 168 |
| 169 // Represents whether a given point is within a curve. A point is inside a c
urve only if it is |
| 170 // an interior point within a quad, cubic, or conic, or if it is the endpoin
t of a quad, cubic, |
| 171 // or conic with another curve meeting it at (more or less) the same angle. |
| 172 enum CurveState { |
| 173 // point is a sharp vertex |
| 174 kSharp_CurveState, |
| 175 // endpoint of a curve with the other side's curvature not yet determine
d |
| 176 kIndeterminate_CurveState, |
| 177 // point is in the interior of a curve |
| 178 kCurve_CurveState |
| 179 }; |
| 180 |
169 bool movable(int index) const { return fMovable[index]; } | 181 bool movable(int index) const { return fMovable[index]; } |
170 | 182 |
171 // Movable points are those that can be slid along their bisector. | 183 // Movable points are those that can be slid along their bisector. |
172 // Basically, a point is immovable if it is part of the original | 184 // Basically, a point is immovable if it is part of the original |
173 // polygon or it results from the fusing of two bisectors. | 185 // polygon or it results from the fusing of two bisectors. |
174 int addPt(const SkPoint& pt, SkScalar depth, SkScalar coverage, bool movable
, bool isCurve); | 186 int addPt(const SkPoint& pt, SkScalar depth, SkScalar coverage, bool movable
, CurveState curve); |
175 void popLastPt(); | 187 void popLastPt(); |
176 void popFirstPtShuffle(); | 188 void popFirstPtShuffle(); |
177 | 189 |
178 void updatePt(int index, const SkPoint& pt, SkScalar depth, SkScalar coverag
e); | 190 void updatePt(int index, const SkPoint& pt, SkScalar depth, SkScalar coverag
e); |
179 | 191 |
180 void addTri(int i0, int i1, int i2); | 192 void addTri(int i0, int i1, int i2); |
181 | 193 |
182 void reservePts(int count) { | 194 void reservePts(int count) { |
183 fPts.setReserve(count); | 195 fPts.setReserve(count); |
184 fCoverages.setReserve(count); | 196 fCoverages.setReserve(count); |
185 fMovable.setReserve(count); | 197 fMovable.setReserve(count); |
186 } | 198 } |
187 | 199 |
188 SkScalar computeDepthFromEdge(int edgeIdx, const SkPoint& p) const; | 200 SkScalar computeDepthFromEdge(int edgeIdx, const SkPoint& p) const; |
189 | 201 |
190 bool computePtAlongBisector(int startIdx, const SkPoint& bisector, | 202 bool computePtAlongBisector(int startIdx, const SkPoint& bisector, |
191 int edgeIdx, SkScalar desiredDepth, | 203 int edgeIdx, SkScalar desiredDepth, |
192 SkPoint* result) const; | 204 SkPoint* result) const; |
193 | 205 |
194 void lineTo(SkPoint p, bool isCurve); | 206 void lineTo(SkPoint p, CurveState curve); |
195 | 207 |
196 void lineTo(const SkMatrix& m, SkPoint p, bool isCurve); | 208 void lineTo(const SkMatrix& m, SkPoint p, CurveState curve); |
197 | 209 |
198 void quadTo(SkPoint pts[3]); | 210 void quadTo(SkPoint pts[3]); |
199 | 211 |
200 void quadTo(const SkMatrix& m, SkPoint pts[3]); | 212 void quadTo(const SkMatrix& m, SkPoint pts[3]); |
201 | 213 |
202 void cubicTo(const SkMatrix& m, SkPoint pts[4]); | 214 void cubicTo(const SkMatrix& m, SkPoint pts[4]); |
203 | 215 |
204 void conicTo(const SkMatrix& m, SkPoint pts[3], SkScalar w); | 216 void conicTo(const SkMatrix& m, SkPoint pts[3], SkScalar w); |
205 | 217 |
206 void terminate(const Ring& lastRing); | 218 void terminate(const Ring& lastRing); |
(...skipping 12 matching lines...) Expand all Loading... |
219 bool createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar in
itialCoverage, | 231 bool createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar in
itialCoverage, |
220 SkScalar targetDepth, SkScalar targetCoverage, Ring**
finalRing); | 232 SkScalar targetDepth, SkScalar targetCoverage, Ring**
finalRing); |
221 | 233 |
222 bool createInsetRing(const Ring& lastRing, Ring* nextRing, | 234 bool createInsetRing(const Ring& lastRing, Ring* nextRing, |
223 SkScalar initialDepth, SkScalar initialCoverage, SkScal
ar targetDepth, | 235 SkScalar initialDepth, SkScalar initialCoverage, SkScal
ar targetDepth, |
224 SkScalar targetCoverage, bool forceNew); | 236 SkScalar targetCoverage, bool forceNew); |
225 | 237 |
226 void validate() const; | 238 void validate() const; |
227 | 239 |
228 // fPts, fCoverages & fMovable should always have the same # of elements | 240 // fPts, fCoverages & fMovable should always have the same # of elements |
229 SkTDArray<SkPoint> fPts; | 241 SkTDArray<SkPoint> fPts; |
230 SkTDArray<SkScalar> fCoverages; | 242 SkTDArray<SkScalar> fCoverages; |
231 // movable points are those that can be slid further along their bisector | 243 // movable points are those that can be slid further along their bisector |
232 SkTDArray<bool> fMovable; | 244 SkTDArray<bool> fMovable; |
233 | 245 |
234 // The outward facing normals for the original polygon | 246 // The outward facing normals for the original polygon |
235 SkTDArray<SkVector> fNorms; | 247 SkTDArray<SkVector> fNorms; |
236 // The inward facing bisector at each point in the original polygon. Only | 248 // The inward facing bisector at each point in the original polygon. Only |
237 // needed for exterior ring creation and then handed off to the initial ring
. | 249 // needed for exterior ring creation and then handed off to the initial ring
. |
238 SkTDArray<SkVector> fBisectors; | 250 SkTDArray<SkVector> fBisectors; |
239 | 251 |
240 // Tracks whether a given point is interior to a curve. Such points are | 252 // Tracks whether a given point is interior to a curve. Such points are |
241 // assumed to have shallow curvature. | 253 // assumed to have shallow curvature. |
242 SkTDArray<bool> fIsCurve; | 254 SkTDArray<CurveState> fCurveState; |
243 | 255 |
244 SkPoint::Side fSide; // winding of the original polygon | 256 SkPoint::Side fSide; // winding of the original polygon |
245 | 257 |
246 // The triangulation of the points | 258 // The triangulation of the points |
247 SkTDArray<int> fIndices; | 259 SkTDArray<int> fIndices; |
248 | 260 |
249 Ring fInitialRing; | 261 Ring fInitialRing; |
250 #if GR_AA_CONVEX_TESSELLATOR_VIZ | 262 #if GR_AA_CONVEX_TESSELLATOR_VIZ |
251 // When visualizing save all the rings | 263 // When visualizing save all the rings |
252 SkTDArray<Ring*> fRings; | 264 SkTDArray<Ring*> fRings; |
253 #else | 265 #else |
254 Ring fRings[2]; | 266 Ring fRings[2]; |
255 #endif | 267 #endif |
256 CandidateVerts fCandidateVerts; | 268 CandidateVerts fCandidateVerts; |
257 | 269 |
258 // < 0 means filling rather than stroking | 270 // < 0 means filling rather than stroking |
259 SkScalar fStrokeWidth; | 271 SkScalar fStrokeWidth; |
260 | 272 |
261 SkPaint::Join fJoin; | 273 SkPaint::Join fJoin; |
262 | 274 |
263 SkScalar fMiterLimit; | 275 SkScalar fMiterLimit; |
264 | 276 |
265 SkTDArray<SkPoint> fPointBuffer; | 277 SkTDArray<SkPoint> fPointBuffer; |
266 }; | 278 }; |
267 | 279 |
268 | 280 |
269 #endif | 281 #endif |
OLD | NEW |