aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkOpAngle.h
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-08 11:47:37 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-08 11:47:37 +0000
commit07393cab57ce74a4aae89a31fae9aaa9780fc19d (patch)
tree2923009427914f3da107d4797e7e7fd2b9266f9a /src/pathops/SkOpAngle.h
parent390c6d7a9018e233a6519397ac6c739fb21a99ef (diff)
Add base types for path ops
Paths contain lines, quads, and cubics, which are collectively curves. To work with path intersections, intermediary curves are constructed. For now, those intermediates use doubles to guarantee sufficient precision. The DVector, DPoint, DLine, DQuad, and DCubic structs encapsulate these intermediate curves. The DRect and DTriangle structs are created to describe intersectable areas of interest. The Bounds struct inherits from SkRect to create a SkScalar-based rectangle that intersects shared edges. This also includes common math equalities and debugging that the remainder of path ops builds on, as well as a temporary top-level interface in include/pathops/SkPathOps.h. Review URL: https://codereview.chromium.org/12827020 git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pathops/SkOpAngle.h')
-rw-r--r--src/pathops/SkOpAngle.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/pathops/SkOpAngle.h b/src/pathops/SkOpAngle.h
new file mode 100644
index 0000000000..d599dea7c2
--- /dev/null
+++ b/src/pathops/SkOpAngle.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkOpAngle_DEFINED
+#define SkOpAngle_DEFINED
+
+#include "SkLineParameters.h"
+#include "SkOpSpan.h"
+#include "SkPath.h"
+#include "SkPathOpsCubic.h"
+#include "SkTDArray.h"
+
+// sorting angles
+// given angles of {dx dy ddx ddy dddx dddy} sort them
+class SkOpAngle {
+public:
+ bool operator<(const SkOpAngle& rh) const;
+ double dx() const {
+ return fTangent1.dx();
+ }
+
+ double dy() const {
+ return fTangent1.dy();
+ }
+
+ int end() const {
+ return fEnd;
+ }
+
+ bool isHorizontal() const {
+ return dy() == 0 && fVerb == SkPath::kLine_Verb;
+ }
+
+ bool lengthen();
+ bool reverseLengthen();
+ void set(const SkPoint* orig, SkPath::Verb verb, const SkOpSegment* segment,
+ int start, int end, const SkTDArray<SkOpSpan>& spans);
+
+ void setSpans();
+ SkOpSegment* segment() const {
+ return const_cast<SkOpSegment*>(fSegment);
+ }
+
+ int sign() const {
+ return SkSign32(fStart - fEnd);
+ }
+
+ const SkTDArray<SkOpSpan>* spans() const {
+ return fSpans;
+ }
+
+ int start() const {
+ return fStart;
+ }
+
+ bool unsortable() const {
+ return fUnsortable;
+ }
+
+#if DEBUG_ANGLE
+ const SkPoint* pts() const {
+ return fPts;
+ }
+
+ SkPath::Verb verb() const {
+ return fVerb;
+ }
+
+ void debugShow(const SkPoint& a) const {
+ SkDebugf(" d=(%1.9g,%1.9g) side=%1.9g\n", dx(), dy(), fSide);
+ }
+#endif
+
+private:
+ const SkPoint* fPts;
+ SkDCubic fCurvePart;
+ SkPath::Verb fVerb;
+ double fSide;
+ SkLineParameters fTangent1;
+ const SkTDArray<SkOpSpan>* fSpans;
+ const SkOpSegment* fSegment;
+ int fStart;
+ int fEnd;
+ bool fReversed;
+ mutable bool fUnsortable; // this alone is editable by the less than operator
+};
+
+#endif