/src/skia/src/pathops/SkIntersectionHelper.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2012 Google Inc. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | #ifndef SkIntersectionHelper_DEFINED |
8 | | #define SkIntersectionHelper_DEFINED |
9 | | |
10 | | #include "include/core/SkPath.h" |
11 | | #include "src/pathops/SkOpContour.h" |
12 | | #include "src/pathops/SkOpSegment.h" |
13 | | |
14 | | #ifdef SK_DEBUG |
15 | | #include "src/pathops/SkPathOpsPoint.h" |
16 | | #endif |
17 | | |
18 | | class SkIntersectionHelper { |
19 | | public: |
20 | | enum SegmentType { |
21 | | kHorizontalLine_Segment = -1, |
22 | | kVerticalLine_Segment = 0, |
23 | | kLine_Segment = SkPath::kLine_Verb, |
24 | | kQuad_Segment = SkPath::kQuad_Verb, |
25 | | kConic_Segment = SkPath::kConic_Verb, |
26 | | kCubic_Segment = SkPath::kCubic_Verb, |
27 | | }; |
28 | | |
29 | 6.77G | bool advance() { |
30 | 6.77G | fSegment = fSegment->next(); |
31 | 6.77G | return fSegment != nullptr; |
32 | 6.77G | } |
33 | | |
34 | 6.67M | SkScalar bottom() const { |
35 | 6.67M | return bounds().fBottom; |
36 | 6.67M | } |
37 | | |
38 | 13.1G | const SkPathOpsBounds& bounds() const { |
39 | 13.1G | return fSegment->bounds(); |
40 | 13.1G | } |
41 | | |
42 | 0 | SkOpContour* contour() const { |
43 | 0 | return fSegment->contour(); |
44 | 0 | } |
45 | | |
46 | 250M | void init(SkOpContour* contour) { |
47 | 250M | fSegment = contour->first(); |
48 | 250M | } |
49 | | |
50 | 6.34M | SkScalar left() const { |
51 | 6.34M | return bounds().fLeft; |
52 | 6.34M | } |
53 | | |
54 | 218M | const SkPoint* pts() const { |
55 | 218M | return fSegment->pts(); |
56 | 218M | } |
57 | | |
58 | 6.34M | SkScalar right() const { |
59 | 6.34M | return bounds().fRight; |
60 | 6.34M | } |
61 | | |
62 | 313M | SkOpSegment* segment() const { |
63 | 313M | return fSegment; |
64 | 313M | } |
65 | | |
66 | 218M | SegmentType segmentType() const { |
67 | 218M | SegmentType type = (SegmentType) fSegment->verb(); |
68 | 218M | if (type != kLine_Segment) { |
69 | 98.8M | return type; |
70 | 98.8M | } |
71 | 119M | if (fSegment->isHorizontal()) { |
72 | 7.53M | return kHorizontalLine_Segment; |
73 | 7.53M | } |
74 | 112M | if (fSegment->isVertical()) { |
75 | 8.01M | return kVerticalLine_Segment; |
76 | 8.01M | } |
77 | 104M | return kLine_Segment; |
78 | 112M | } |
79 | | |
80 | 17.4M | bool startAfter(const SkIntersectionHelper& after) { |
81 | 17.4M | fSegment = after.fSegment->next(); |
82 | 17.4M | return fSegment != nullptr; |
83 | 17.4M | } |
84 | | |
85 | 6.67M | SkScalar top() const { |
86 | 6.67M | return bounds().fTop; |
87 | 6.67M | } |
88 | | |
89 | 19.7M | SkScalar weight() const { |
90 | 19.7M | return fSegment->weight(); |
91 | 19.7M | } |
92 | | |
93 | 13.0M | SkScalar x() const { |
94 | 13.0M | return bounds().fLeft; |
95 | 13.0M | } |
96 | | |
97 | 6.34M | bool xFlipped() const { |
98 | 6.34M | return x() != pts()[0].fX; |
99 | 6.34M | } |
100 | | |
101 | 13.0M | SkScalar y() const { |
102 | 13.0M | return bounds().fTop; |
103 | 13.0M | } |
104 | | |
105 | 6.67M | bool yFlipped() const { |
106 | 6.67M | return y() != pts()[0].fY; |
107 | 6.67M | } |
108 | | |
109 | | private: |
110 | | SkOpSegment* fSegment; |
111 | | }; |
112 | | |
113 | | #endif |