Index: src/gpu/GrAAConvexTessellator.h |
diff --git a/src/gpu/GrAAConvexTessellator.h b/src/gpu/GrAAConvexTessellator.h |
index 93e8d4ba61716507b1d6b1febde241bcd1ae3709..f3d84dc8ad8b7de222f7ecfd2f08c5873ff0e111 100644 |
--- a/src/gpu/GrAAConvexTessellator.h |
+++ b/src/gpu/GrAAConvexTessellator.h |
@@ -9,6 +9,7 @@ |
#define GrAAConvexTessellator_DEFINED |
#include "SkColor.h" |
+#include "SkPaint.h" |
#include "SkPoint.h" |
#include "SkScalar.h" |
#include "SkTDArray.h" |
@@ -18,6 +19,9 @@ |
class SkPath; |
//#define GR_AA_CONVEX_TESSELLATOR_VIZ 1 |
+ |
+// device space distance which we inset / outset points in order to create the soft antialiased edge |
+static const SkScalar kAntialiasingRadius = 0.5f; |
class GrAAConvexTessellator; |
@@ -27,13 +31,14 @@ |
// computeDepthFromEdge requests. |
class GrAAConvexTessellator { |
public: |
- GrAAConvexTessellator(SkScalar targetDepth = 0.5f) |
+ GrAAConvexTessellator(SkScalar strokeWidth = -1.0f, |
+ SkPaint::Join join = SkPaint::Join::kBevel_Join, |
+ SkScalar miterLimit = 0.0f) |
: fSide(SkPoint::kOn_Side) |
- , fTargetDepth(targetDepth) { |
+ , fStrokeWidth(strokeWidth) |
+ , fJoin(join) |
+ , fMiterLimit(miterLimit) { |
} |
- |
- void setTargetDepth(SkScalar targetDepth) { fTargetDepth = targetDepth; } |
- SkScalar targetDepth() const { return fTargetDepth; } |
SkPoint::Side side() const { return fSide; } |
@@ -46,7 +51,7 @@ |
const SkPoint& lastPoint() const { return fPts.top(); } |
const SkPoint& point(int index) const { return fPts[index]; } |
int index(int index) const { return fIndices[index]; } |
- SkScalar depth(int index) const {return fDepths[index]; } |
+ SkScalar coverage(int index) const { return fCoverages[index]; } |
#if GR_AA_CONVEX_TESSELLATOR_VIZ |
void draw(SkCanvas* canvas) const; |
@@ -139,6 +144,7 @@ |
const SkPoint& bisector(int index) const { return fPts[index].fBisector; } |
int index(int index) const { return fPts[index].fIndex; } |
int origEdgeID(int index) const { return fPts[index].fOrigEdgeId; } |
+ void setOrigEdgeId(int index, int id) { fPts[index].fOrigEdgeId = id; } |
#if GR_AA_CONVEX_TESSELLATOR_VIZ |
void draw(SkCanvas* canvas, const GrAAConvexTessellator& tess) const; |
@@ -165,17 +171,17 @@ |
// 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, bool isCurve); |
+ int addPt(const SkPoint& pt, SkScalar depth, SkScalar coverage, bool movable, bool isCurve); |
void popLastPt(); |
void popFirstPtShuffle(); |
- void updatePt(int index, const SkPoint& pt, SkScalar depth); |
+ void updatePt(int index, const SkPoint& pt, SkScalar depth, SkScalar coverage); |
void addTri(int i0, int i1, int i2); |
void reservePts(int count) { |
fPts.setReserve(count); |
- fDepths.setReserve(count); |
+ fCoverages.setReserve(count); |
fMovable.setReserve(count); |
} |
@@ -185,7 +191,11 @@ |
int edgeIdx, SkScalar desiredDepth, |
SkPoint* result) const; |
+ void lineTo(SkPoint p, bool isCurve); |
+ |
void lineTo(const SkMatrix& m, SkPoint p, bool isCurve); |
+ |
+ void quadTo(SkPoint pts[3]); |
void quadTo(const SkMatrix& m, SkPoint pts[3]); |
@@ -200,23 +210,24 @@ |
void computeBisectors(); |
void fanRing(const Ring& ring); |
- void createOuterRing(); |
Ring* getNextRing(Ring* lastRing); |
- bool createInsetRing(const Ring& lastRing, Ring* nextRing); |
+ void createOuterRing(const Ring& previousRing, SkScalar outset, SkScalar coverage, |
+ Ring* nextRing); |
+ |
+ bool createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar initialCoverage, |
+ SkScalar targetDepth, SkScalar targetCoverage, Ring** finalRing); |
+ |
+ bool createInsetRing(const Ring& lastRing, Ring* nextRing, |
+ SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth, |
+ SkScalar targetCoverage, bool forceNew); |
void validate() const; |
- |
-#ifdef SK_DEBUG |
- SkScalar computeRealDepth(const SkPoint& p) const; |
- void checkAllDepths() const; |
-#endif |
- |
- // fPts, fWeights & fMovable should always have the same # of elements |
+ // fPts, fCoverages & fMovable should always have the same # of elements |
SkTDArray<SkPoint> fPts; |
- SkTDArray<SkScalar> fDepths; |
+ SkTDArray<SkScalar> fCoverages; |
// movable points are those that can be slid further along their bisector |
SkTDArray<bool> fMovable; |
@@ -244,18 +255,14 @@ |
#endif |
CandidateVerts fCandidateVerts; |
- SkScalar fTargetDepth; |
+ // < 0 means filling rather than stroking |
+ SkScalar fStrokeWidth; |
+ |
+ SkPaint::Join fJoin; |
+ |
+ SkScalar fMiterLimit; |
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. |
- SkDEBUGCODE(bool fShouldCheckDepths;) |
- |
- SkDEBUGCODE(SkScalar fMinCross;) |
- |
- SkDEBUGCODE(SkScalar fMaxCross;) |
}; |