Index: src/gpu/GrAAFlatteningConvexTessellator.h |
diff --git a/src/gpu/GrAAConvexTessellator.h b/src/gpu/GrAAFlatteningConvexTessellator.h |
similarity index 84% |
copy from src/gpu/GrAAConvexTessellator.h |
copy to src/gpu/GrAAFlatteningConvexTessellator.h |
index 707995fadd4b80e3e85cdbf73be61fdfb29a220c..756452a1a25cfc066ac8a84d7e4f0b48e49c4323 100644 |
--- a/src/gpu/GrAAConvexTessellator.h |
+++ b/src/gpu/GrAAFlatteningConvexTessellator.h |
@@ -5,8 +5,8 @@ |
* found in the LICENSE file. |
*/ |
-#ifndef GrAAConvexTessellator_DEFINED |
-#define GrAAConvexTessellator_DEFINED |
+#ifndef GrAAFlatteningConvexTessellator_DEFINED |
+#define GrAAFlatteningConvexTessellator_DEFINED |
#include "SkColor.h" |
#include "SkPoint.h" |
@@ -17,17 +17,17 @@ class SkCanvas; |
class SkMatrix; |
class SkPath; |
-//#define GR_AA_CONVEX_TESSELLATOR_VIZ 1 |
+//#define GR_AA_FLATTENING_CONVEX_TESSELLATOR_VIZ 1 |
-class GrAAConvexTessellator; |
+class GrAAFlatteningConvexTessellator; |
robertphillips
2015/05/27 18:10:54
Does this class really diverge enough that we need
|
// The AAConvexTessellator holds the global pool of points and the triangulation |
// that connects them. It also drives the tessellation process. |
// The outward facing normals of the original polygon are stored (in 'fNorms') to service |
// computeDepthFromEdge requests. |
-class GrAAConvexTessellator { |
+class GrAAFlatteningConvexTessellator { |
public: |
- GrAAConvexTessellator(SkScalar targetDepth = 0.5f) |
+ GrAAFlatteningConvexTessellator(SkScalar targetDepth = 0.5f) |
: fSide(SkPoint::kOn_Side) |
, fTargetDepth(targetDepth) { |
} |
@@ -48,7 +48,7 @@ public: |
int index(int index) const { return fIndices[index]; } |
SkScalar depth(int index) const {return fDepths[index]; } |
-#if GR_AA_CONVEX_TESSELLATOR_VIZ |
+#if GR_AA_FLATTENING_CONVEX_TESSELLATOR_VIZ |
void draw(SkCanvas* canvas) const; |
#endif |
@@ -132,7 +132,7 @@ private: |
} |
// init should be called after all the indices have been added (via addIdx) |
- void init(const GrAAConvexTessellator& tess); |
+ void init(const GrAAFlatteningConvexTessellator& tess); |
void init(const SkTDArray<SkVector>& norms, const SkTDArray<SkVector>& bisectors); |
const SkPoint& norm(int index) const { return fPts[index].fNorm; } |
@@ -140,15 +140,15 @@ private: |
int index(int index) const { return fPts[index].fIndex; } |
int origEdgeID(int index) const { return fPts[index].fOrigEdgeId; } |
- #if GR_AA_CONVEX_TESSELLATOR_VIZ |
- void draw(SkCanvas* canvas, const GrAAConvexTessellator& tess) const; |
+ #if GR_AA_FLATTENING_CONVEX_TESSELLATOR_VIZ |
+ void draw(SkCanvas* canvas, const GrAAFlatteningConvexTessellator& tess) const; |
#endif |
private: |
- void computeNormals(const GrAAConvexTessellator& result); |
- void computeBisectors(const GrAAConvexTessellator& tess); |
+ void computeNormals(const GrAAFlatteningConvexTessellator& result); |
+ void computeBisectors(const GrAAFlatteningConvexTessellator& tess); |
- SkDEBUGCODE(bool isConvex(const GrAAConvexTessellator& tess) const;) |
+ SkDEBUGCODE(bool isConvex(const GrAAFlatteningConvexTessellator& tess) const;) |
struct PointData { |
SkPoint fNorm; |
@@ -165,7 +165,7 @@ private: |
// Movable points are those that can be slid along their bisector. |
// Basically, a point is immovable if it is part of the original |
// polygon or it results from the fusing of two bisectors. |
- int addPt(const SkPoint& pt, SkScalar depth, bool movable); |
+ int addPt(const SkPoint& pt, SkScalar depth, bool movable, bool isCurve); |
void popLastPt(); |
void popFirstPtShuffle(); |
@@ -185,6 +185,14 @@ private: |
int edgeIdx, SkScalar desiredDepth, |
SkPoint* result) const; |
+ void lineTo(const SkMatrix& m, SkPoint p, bool isCurve); |
+ |
+ void quadTo(const SkMatrix& m, SkPoint* pts); |
bsalomon
2015/05/27 17:11:07
just as documentation, it'd be nice to have pts[2]
ethannicholas
2015/05/27 19:22:30
Done.
|
+ |
+ void cubicTo(const SkMatrix& m, SkPoint* pts); |
+ |
+ void conicTo(const SkMatrix& m, SkPoint* pts, SkScalar w); |
+ |
void terminate(const Ring& lastRing); |
// return false on failure/degenerate path |
@@ -217,13 +225,18 @@ private: |
// The inward facing bisector at each point in the original polygon. Only |
// needed for exterior ring creation and then handed off to the initial ring. |
SkTDArray<SkVector> fBisectors; |
+ |
+ // Tracks whether a given point is interior to a curve. Such points are |
+ // assumed to have shallow curvature. |
+ SkTDArray<bool> fIsCurve; |
+ |
SkPoint::Side fSide; // winding of the original polygon |
// The triangulation of the points |
SkTDArray<int> fIndices; |
Ring fInitialRing; |
-#if GR_AA_CONVEX_TESSELLATOR_VIZ |
+#if GR_AA_FLATTENING_CONVEX_TESSELLATOR_VIZ |
// When visualizing save all the rings |
SkTDArray<Ring*> fRings; |
#else |
@@ -233,6 +246,8 @@ private: |
SkScalar fTargetDepth; |
+ SkTDArray<SkPoint> fPointBuffer; |
+ |
// If some goes wrong with the inset computation the tessellator will |
// truncate the creation of the inset polygon. In this case the depth |
// check will complain. |