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

Unified Diff: src/gpu/GrAAConvexTessellator.h

Issue 1180903006: added stroking support to GrAALinearizingConvexPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows build issue Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAAConvexTessellator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
@@ -19,6 +20,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;
// The AAConvexTessellator holds the global pool of points and the triangulation
@@ -27,14 +31,15 @@ class GrAAConvexTessellator;
// 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; }
bool tessellate(const SkMatrix& m, const SkPath& path);
@@ -46,7 +51,7 @@ public:
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 @@ private:
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 @@ 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, 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,8 +191,12 @@ private:
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]);
void cubicTo(const SkMatrix& m, SkPoint pts[4]);
@@ -200,23 +210,24 @@ private:
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);
- void validate() const;
+ 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);
-#ifdef SK_DEBUG
- SkScalar computeRealDepth(const SkPoint& p) const;
- void checkAllDepths() const;
-#endif
+ void validate() const;
- // 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 @@ private:
#endif
CandidateVerts fCandidateVerts;
- SkScalar fTargetDepth;
+ // < 0 means filling rather than stroking
+ SkScalar fStrokeWidth;
- SkTDArray<SkPoint> fPointBuffer;
+ SkPaint::Join fJoin;
- // 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;)
+ SkScalar fMiterLimit;
- SkDEBUGCODE(SkScalar fMinCross;)
-
- SkDEBUGCODE(SkScalar fMaxCross;)
+ SkTDArray<SkPoint> fPointBuffer;
};
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAAConvexTessellator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698