gfx/skia/trunk/src/pathops/SkOpEdgeBuilder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pathops/SkOpEdgeBuilder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/*
     1.5 + * Copyright 2012 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +#ifndef SkOpEdgeBuilder_DEFINED
    1.11 +#define SkOpEdgeBuilder_DEFINED
    1.12 +
    1.13 +#include "SkOpContour.h"
    1.14 +#include "SkPathWriter.h"
    1.15 +#include "SkTArray.h"
    1.16 +
    1.17 +class SkOpEdgeBuilder {
    1.18 +public:
    1.19 +    SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours)
    1.20 +        : fPath(path.nativePath())
    1.21 +        , fContours(contours)
    1.22 +        , fAllowOpenContours(true) {
    1.23 +        init();
    1.24 +    }
    1.25 +
    1.26 +    SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours)
    1.27 +        : fPath(&path)
    1.28 +        , fContours(contours)
    1.29 +        , fAllowOpenContours(false) {
    1.30 +        init();
    1.31 +    }
    1.32 +
    1.33 +    void complete() {
    1.34 +        if (fCurrentContour && fCurrentContour->segments().count()) {
    1.35 +            fCurrentContour->complete();
    1.36 +            fCurrentContour = NULL;
    1.37 +        }
    1.38 +    }
    1.39 +
    1.40 +    SkPathOpsMask xorMask() const {
    1.41 +        return fXorMask[fOperand];
    1.42 +    }
    1.43 +
    1.44 +    void addOperand(const SkPath& path);
    1.45 +    bool finish();
    1.46 +    void init();
    1.47 +
    1.48 +private:
    1.49 +    void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart);
    1.50 +    bool close();
    1.51 +    int preFetch();
    1.52 +    bool walk();
    1.53 +
    1.54 +    const SkPath* fPath;
    1.55 +    SkTArray<SkPoint, true> fPathPts;
    1.56 +    SkTArray<uint8_t, true> fPathVerbs;
    1.57 +    SkOpContour* fCurrentContour;
    1.58 +    SkTArray<SkOpContour>& fContours;
    1.59 +    SkPathOpsMask fXorMask[2];
    1.60 +    int fSecondHalf;
    1.61 +    bool fOperand;
    1.62 +    bool fAllowOpenContours;
    1.63 +    bool fUnparseable;
    1.64 +};
    1.65 +
    1.66 +#endif

mercurial