Debian Codegraph @

src/pathops/SkPathWriter.h

raw
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 SkPathWriter_DEFINED
8 #define SkPathWriter_DEFINED
9
10 #include "include/core/SkPath.h"
11 #include "include/core/SkPathBuilder.h"
12 #include "include/core/SkPoint.h"
13 #include "include/core/SkScalar.h"
14 #include "include/private/base/SkTArray.h"
15 #include "include/private/base/SkTDArray.h"
16
17 class SkOpPtT;
18
19 // Construct the path one contour at a time.
20 // If the contour is closed, copy it to the final output.
21 // Otherwise, keep the partial contour for later assembly.
22
23 class SkPathWriter {
24 public:
25 SkPathWriter(SkPathFillType);
26 void assemble();
27 void conicTo(const SkPoint& pt1, const SkOpPtT* pt2, SkScalar weight);
28 void cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkOpPtT* pt3);
29 bool deferredLine(const SkOpPtT* pt);
30 void deferredMove(const SkOpPtT* pt);
31 void finishContour();
32 bool hasMove() const { return !fFirstPtT; }
33 void init();
34 bool isClosed() const;
35 SkPath nativePath() { return fBuilder.detach(); }
36 void quadTo(const SkPoint& pt1, const SkOpPtT* pt2);
37
38 private:
39 bool changedSlopes(const SkOpPtT* pt) const;
40 void close();
41 const SkTDArray<const SkOpPtT*>& endPtTs() const { return fEndPtTs; }
42 void lineTo();
43 bool matchedLast(const SkOpPtT*) const;
44 void moveTo();
45 const skia_private::TArray<SkPathBuilder>& partials() const { return fPartials; }
46 bool someAssemblyRequired();
47 SkPoint update(const SkOpPtT* pt);
48
49 SkPathBuilder fBuilder;
50 SkPathBuilder fCurrent; // contour under construction
51 skia_private::TArray<SkPathBuilder> fPartials; // contours with mismatched starts and ends
52 SkTDArray<const SkOpPtT*> fEndPtTs; // possible pt values for partial starts and ends
53 const SkOpPtT* fDefer[2]; // [0] deferred move, [1] deferred line
54 const SkOpPtT* fFirstPtT; // first in current contour
55 };
56
57 #endif /* defined(__PathOps__SkPathWriter__) */