Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: src/gpu/batches/GrAAConvexTessellator.h

Issue 2301353004: Make AALinearizingConvexPathRenderer able to handle stroke and fill (Closed)
Patch Set: Fix bug Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/batches/GrAAConvexTessellator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkPaint.h" 12 #include "SkPaint.h"
13 #include "SkPoint.h" 13 #include "SkPoint.h"
14 #include "SkScalar.h" 14 #include "SkScalar.h"
15 #include "SkStrokeRec.h"
15 #include "SkTDArray.h" 16 #include "SkTDArray.h"
16 17
17 class SkCanvas; 18 class SkCanvas;
18 class SkMatrix; 19 class SkMatrix;
19 class SkPath; 20 class SkPath;
20 21
21 //#define GR_AA_CONVEX_TESSELLATOR_VIZ 1 22 //#define GR_AA_CONVEX_TESSELLATOR_VIZ 1
22 23
23 // device space distance which we inset / outset points in order to create the s oft antialiased edge 24 // device space distance which we inset / outset points in order to create the s oft antialiased edge
24 static const SkScalar kAntialiasingRadius = 0.5f; 25 static const SkScalar kAntialiasingRadius = 0.5f;
25 26
26 class GrAAConvexTessellator; 27 class GrAAConvexTessellator;
27 28
28 // The AAConvexTessellator holds the global pool of points and the triangulation 29 // The AAConvexTessellator holds the global pool of points and the triangulation
29 // that connects them. It also drives the tessellation process. 30 // that connects them. It also drives the tessellation process.
30 // The outward facing normals of the original polygon are stored (in 'fNorms') t o service 31 // The outward facing normals of the original polygon are stored (in 'fNorms') t o service
31 // computeDepthFromEdge requests. 32 // computeDepthFromEdge requests.
32 class GrAAConvexTessellator { 33 class GrAAConvexTessellator {
33 public: 34 public:
34 GrAAConvexTessellator(SkScalar strokeWidth = -1.0f, 35 GrAAConvexTessellator(SkStrokeRec::Style style = SkStrokeRec::kFill_Style,
36 SkScalar strokeWidth = -1.0f,
35 SkPaint::Join join = SkPaint::Join::kBevel_Join, 37 SkPaint::Join join = SkPaint::Join::kBevel_Join,
36 SkScalar miterLimit = 0.0f) 38 SkScalar miterLimit = 0.0f)
37 : fSide(SkPoint::kOn_Side) 39 : fSide(SkPoint::kOn_Side)
38 , fStrokeWidth(strokeWidth) 40 , fStrokeWidth(strokeWidth)
41 , fStyle(style)
39 , fJoin(join) 42 , fJoin(join)
40 , fMiterLimit(miterLimit) { 43 , fMiterLimit(miterLimit) {
41 } 44 }
42 45
43 SkPoint::Side side() const { return fSide; } 46 SkPoint::Side side() const { return fSide; }
44 47
45 bool tessellate(const SkMatrix& m, const SkPath& path); 48 bool tessellate(const SkMatrix& m, const SkPath& path);
46 49
47 // The next five should only be called after tessellate to extract the resul t 50 // The next five should only be called after tessellate to extract the resul t
48 int numPts() const { return fPts.count(); } 51 int numPts() const { return fPts.count(); }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void rewind() { fPts.rewind(); } 132 void rewind() { fPts.rewind(); }
130 133
131 int numPts() const { return fPts.count(); } 134 int numPts() const { return fPts.count(); }
132 135
133 void addIdx(int index, int origEdgeId) { 136 void addIdx(int index, int origEdgeId) {
134 struct PointData* pt = fPts.push(); 137 struct PointData* pt = fPts.push();
135 pt->fIndex = index; 138 pt->fIndex = index;
136 pt->fOrigEdgeId = origEdgeId; 139 pt->fOrigEdgeId = origEdgeId;
137 } 140 }
138 141
142 // Upgrade this ring so that it can behave like an originating ring
143 void makeOriginalRing() {
144 for (int i = 0; i < fPts.count(); ++i) {
145 fPts[i].fOrigEdgeId = fPts[i].fIndex;
146 }
147 }
148
139 // init should be called after all the indices have been added (via addI dx) 149 // init should be called after all the indices have been added (via addI dx)
140 void init(const GrAAConvexTessellator& tess); 150 void init(const GrAAConvexTessellator& tess);
141 void init(const SkTDArray<SkVector>& norms, const SkTDArray<SkVector>& b isectors); 151 void init(const SkTDArray<SkVector>& norms, const SkTDArray<SkVector>& b isectors);
142 152
143 const SkPoint& norm(int index) const { return fPts[index].fNorm; } 153 const SkPoint& norm(int index) const { return fPts[index].fNorm; }
144 const SkPoint& bisector(int index) const { return fPts[index].fBisector; } 154 const SkPoint& bisector(int index) const { return fPts[index].fBisector; }
145 int index(int index) const { return fPts[index].fIndex; } 155 int index(int index) const { return fPts[index].fIndex; }
146 int origEdgeID(int index) const { return fPts[index].fOrigEdgeId; } 156 int origEdgeID(int index) const { return fPts[index].fOrigEdgeId; }
147 void setOrigEdgeId(int index, int id) { fPts[index].fOrigEdgeId = id; } 157 void setOrigEdgeId(int index, int id) { fPts[index].fOrigEdgeId = id; }
148 158
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 270
261 Ring fInitialRing; 271 Ring fInitialRing;
262 #if GR_AA_CONVEX_TESSELLATOR_VIZ 272 #if GR_AA_CONVEX_TESSELLATOR_VIZ
263 // When visualizing save all the rings 273 // When visualizing save all the rings
264 SkTDArray<Ring*> fRings; 274 SkTDArray<Ring*> fRings;
265 #else 275 #else
266 Ring fRings[2]; 276 Ring fRings[2];
267 #endif 277 #endif
268 CandidateVerts fCandidateVerts; 278 CandidateVerts fCandidateVerts;
269 279
270 // < 0 means filling rather than stroking 280 // the stroke width is only used for stroke or stroke-and-fill styles
271 SkScalar fStrokeWidth; 281 SkScalar fStrokeWidth;
282 SkStrokeRec::Style fStyle;
272 283
273 SkPaint::Join fJoin; 284 SkPaint::Join fJoin;
274 285
275 SkScalar fMiterLimit; 286 SkScalar fMiterLimit;
276 287
277 SkTDArray<SkPoint> fPointBuffer; 288 SkTDArray<SkPoint> fPointBuffer;
278 }; 289 };
279 290
280 291
281 #endif 292 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/batches/GrAAConvexTessellator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698