SkPath::Direction serves two masters:
- input param to addFoo (e.g. addRect), where only CW or CCW are valid)
- output param from computing functions, that sometimes return kUnknown
This CL's intent is to split these into distinct enums/features:
- Direction (public) loses kUnknown, and is only used for input
- FirstDirection (private) is used for computing the first direction we see when analyzing a contour
BUG=skia:
Review URL: https://codereview.chromium.org/1176953002
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 5d08aa5..45a4ca3 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -22,6 +22,7 @@
#include "GrPipelineBuilder.h"
#include "GrStrokeInfo.h"
#include "SkGeometry.h"
+#include "SkPathPriv.h"
#include "SkString.h"
#include "SkTraceEvent.h"
#include "gl/GrGLProcessor.h"
@@ -116,7 +117,7 @@
static void compute_vectors(SegmentArray* segments,
SkPoint* fanPt,
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
int* vCount,
int* iCount) {
center_of_mass(*segments, fanPt);
@@ -124,7 +125,7 @@
// Make the normals point towards the outside
SkPoint::Side normSide;
- if (dir == SkPath::kCCW_Direction) {
+ if (dir == SkPathPriv::kCCW_FirstDirection) {
normSide = SkPoint::kRight_Side;
} else {
normSide = SkPoint::kLeft_Side;
@@ -212,8 +213,9 @@
}
}
-static inline bool get_direction(const SkPath& path, const SkMatrix& m, SkPath::Direction* dir) {
- if (!path.cheapComputeDirection(dir)) {
+static inline bool get_direction(const SkPath& path, const SkMatrix& m,
+ SkPathPriv::FirstDirection* dir) {
+ if (!SkPathPriv::CheapComputeFirstDirection(path, dir)) {
return false;
}
// check whether m reverses the orientation
@@ -221,7 +223,7 @@
SkScalar det2x2 = SkScalarMul(m.get(SkMatrix::kMScaleX), m.get(SkMatrix::kMScaleY)) -
SkScalarMul(m.get(SkMatrix::kMSkewX), m.get(SkMatrix::kMSkewY));
if (det2x2 < 0) {
- *dir = SkPath::OppositeDirection(*dir);
+ *dir = SkPathPriv::OppositeFirstDirection(*dir);
}
return true;
}
@@ -248,7 +250,7 @@
}
static inline void add_cubic_segments(const SkPoint pts[4],
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
SegmentArray* segments) {
SkSTArray<15, SkPoint, true> quads;
GrPathUtils::convertCubicToQuads(pts, SK_Scalar1, true, dir, &quads);
@@ -273,7 +275,7 @@
// line paths. We detect paths that are very close to a line (zero area) and
// draw nothing.
DegenerateTestData degenerateData;
- SkPath::Direction dir;
+ SkPathPriv::FirstDirection dir;
// get_direction can fail for some degenerate paths.
if (!get_direction(path, m, &dir)) {
return false;
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index b7cb237..da60a6c 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -345,7 +345,7 @@
if (SkIRect::Intersects(devClipBounds, ibounds)) {
PREALLOC_PTARRAY(32) q;
// we don't need a direction if we aren't constraining the subdivision
- static const SkPath::Direction kDummyDir = SkPath::kCCW_Direction;
+ const SkPathPriv::FirstDirection kDummyDir = SkPathPriv::kCCW_FirstDirection;
// We convert cubics to quadratics (for now).
// In perspective have to do conversion in src space.
if (persp) {
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 3e2c3bf..21d1155 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -365,16 +365,16 @@
const SkVector& ab,
const SkVector& dc,
const SkPoint& d,
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
const SkPoint p) {
SkVector ap = p - a;
SkScalar apXab = ap.cross(ab);
- if (SkPath::kCW_Direction == dir) {
+ if (SkPathPriv::kCW_FirstDirection == dir) {
if (apXab > 0) {
return false;
}
} else {
- SkASSERT(SkPath::kCCW_Direction == dir);
+ SkASSERT(SkPathPriv::kCCW_FirstDirection == dir);
if (apXab < 0) {
return false;
}
@@ -382,12 +382,12 @@
SkVector dp = p - d;
SkScalar dpXdc = dp.cross(dc);
- if (SkPath::kCW_Direction == dir) {
+ if (SkPathPriv::kCW_FirstDirection == dir) {
if (dpXdc < 0) {
return false;
}
} else {
- SkASSERT(SkPath::kCCW_Direction == dir);
+ SkASSERT(SkPathPriv::kCCW_FirstDirection == dir);
if (dpXdc > 0) {
return false;
}
@@ -398,7 +398,7 @@
void convert_noninflect_cubic_to_quads(const SkPoint p[4],
SkScalar toleranceSqd,
bool constrainWithinTangents,
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
SkTArray<SkPoint, true>* quads,
int sublevel = 0) {
@@ -546,7 +546,7 @@
void GrPathUtils::convertCubicToQuads(const SkPoint p[4],
SkScalar tolScale,
bool constrainWithinTangents,
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
SkTArray<SkPoint, true>* quads) {
SkPoint chopped[10];
int count = SkChopCubicAtInflections(p, chopped);
diff --git a/src/gpu/GrPathUtils.h b/src/gpu/GrPathUtils.h
index 250b0a2..8e52e33 100644
--- a/src/gpu/GrPathUtils.h
+++ b/src/gpu/GrPathUtils.h
@@ -9,7 +9,7 @@
#define GrPathUtils_DEFINED
#include "SkRect.h"
-#include "SkPath.h"
+#include "SkPathPriv.h"
#include "SkTArray.h"
class SkMatrix;
@@ -121,7 +121,7 @@
void convertCubicToQuads(const SkPoint p[4],
SkScalar tolScale,
bool constrainWithinTangents,
- SkPath::Direction dir,
+ SkPathPriv::FirstDirection dir,
SkTArray<SkPoint, true>* quads);
// Chops the cubic bezier passed in by src, at the double point (intersection point)
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 0cef3fa..0048279 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -7,7 +7,7 @@
#include "GrConvexPolyEffect.h"
#include "GrInvariantOutput.h"
-#include "SkPath.h"
+#include "SkPathPriv.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/builders/GrGLProgramBuilder.h"
@@ -279,8 +279,8 @@
SkPoint pts[kMaxEdges];
SkScalar edges[3 * kMaxEdges];
- SkPath::Direction dir;
- SkAssertResult(path.cheapComputeDirection(&dir));
+ SkPathPriv::FirstDirection dir;
+ SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir));
SkVector t;
if (NULL == offset) {
@@ -295,7 +295,7 @@
if (pts[lastPt] != pts[i]) {
SkVector v = pts[i] - pts[lastPt];
v.normalize();
- if (SkPath::kCCW_Direction == dir) {
+ if (SkPathPriv::kCCW_FirstDirection == dir) {
edges[3 * n] = v.fY;
edges[3 * n + 1] = -v.fX;
} else {