| 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 SkOpEdgeBuilder_DEFINED |
| 8 |
#define SkOpEdgeBuilder_DEFINED |
| 9 |
|
| 10 |
#include "include/core/SkPoint.h" |
| 11 |
#include "include/core/SkScalar.h" |
| 12 |
#include "include/private/base/SkTDArray.h" |
| 13 |
#include "src/pathops/SkOpContour.h" |
| 14 |
#include "src/pathops/SkPathOpsTypes.h" |
| 15 |
#include "src/pathops/SkPathWriter.h" |
| 16 |
|
| 17 |
#include <cstdint> |
| 18 |
|
| 19 |
class SkPath; |
| 20 |
|
| 21 |
class SkOpEdgeBuilder { |
| 22 |
public: |
| 23 |
SkOpEdgeBuilder(const SkPath& path, SkOpContourHead* contours2, SkOpGlobalState* globalState) |
| 24 |
: fGlobalState(globalState) |
| 25 |
, fPath(&path) |
| 26 |
, fContourBuilder(contours2) |
| 27 |
, fContoursHead(contours2) |
| 28 |
, fAllowOpenContours(false) { |
| 29 |
init(); |
| 30 |
} |
| 31 |
|
| 32 |
void addOperand(const SkPath& path); |
| 33 |
|
| 34 |
void complete() { |
| 35 |
fContourBuilder.flush(); |
| 36 |
SkOpContour* contour = fContourBuilder.contour(); |
| 37 |
if (contour && contour->count()) { |
| 38 |
contour->complete(); |
| 39 |
fContourBuilder.setContour(nullptr); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
bool finish(); |
| 44 |
|
| 45 |
const SkOpContour* head() const { |
| 46 |
return fContoursHead; |
| 47 |
} |
| 48 |
|
| 49 |
void init(); |
| 50 |
bool unparseable() const { return fUnparseable; } |
| 51 |
SkPathOpsMask xorMask() const { return fXorMask[fOperand]; } |
| 52 |
|
| 53 |
private: |
| 54 |
void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); |
| 55 |
bool close(); |
| 56 |
int preFetch(); |
| 57 |
bool walk(); |
| 58 |
|
| 59 |
SkOpGlobalState* fGlobalState; |
| 60 |
const SkPath* fPath; |
| 61 |
SkTDArray<SkPoint> fPathPts; |
| 62 |
SkTDArray<SkScalar> fWeights; |
| 63 |
SkTDArray<uint8_t> fPathVerbs; |
| 64 |
SkOpContourBuilder fContourBuilder; |
| 65 |
SkOpContourHead* fContoursHead; |
| 66 |
SkPathOpsMask fXorMask[2]; |
| 67 |
int fSecondHalf; |
| 68 |
bool fOperand; |
| 69 |
bool fAllowOpenContours; |
| 70 |
bool fUnparseable; |
| 71 |
}; |
| 72 |
|
| 73 |
#endif |