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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pathops/SkOpAngle.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     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 SkOpAngle_DEFINED
    1.11 +#define SkOpAngle_DEFINED
    1.12 +
    1.13 +#include "SkLineParameters.h"
    1.14 +#include "SkPath.h"
    1.15 +#include "SkPathOpsCubic.h"
    1.16 +
    1.17 +class SkOpSegment;
    1.18 +struct SkOpSpan;
    1.19 +
    1.20 +// sorting angles
    1.21 +// given angles of {dx dy ddx ddy dddx dddy} sort them
    1.22 +class SkOpAngle {
    1.23 +public:
    1.24 +    enum { kStackBasedCount = 8 }; // FIXME: determine what this should be
    1.25 +    enum IncludeType {
    1.26 +        kUnaryWinding,
    1.27 +        kUnaryXor,
    1.28 +        kBinarySingle,
    1.29 +        kBinaryOpp,
    1.30 +    };
    1.31 +
    1.32 +    bool operator<(const SkOpAngle& rh) const;
    1.33 +
    1.34 +    bool calcSlop(double x, double y, double rx, double ry, bool* result) const;
    1.35 +
    1.36 +    double dx() const {
    1.37 +        return fTangentPart.dx();
    1.38 +    }
    1.39 +
    1.40 +    double dy() const {
    1.41 +        return fTangentPart.dy();
    1.42 +    }
    1.43 +
    1.44 +    int end() const {
    1.45 +        return fEnd;
    1.46 +    }
    1.47 +
    1.48 +    bool isHorizontal() const;
    1.49 +
    1.50 +    SkOpSpan* lastMarked() const {
    1.51 +        return fLastMarked;
    1.52 +    }
    1.53 +
    1.54 +    void set(const SkOpSegment* segment, int start, int end);
    1.55 +
    1.56 +    void setLastMarked(SkOpSpan* marked) {
    1.57 +        fLastMarked = marked;
    1.58 +    }
    1.59 +
    1.60 +    SkOpSegment* segment() const {
    1.61 +        return const_cast<SkOpSegment*>(fSegment);
    1.62 +    }
    1.63 +
    1.64 +    int sign() const {
    1.65 +        return SkSign32(fStart - fEnd);
    1.66 +    }
    1.67 +
    1.68 +    int start() const {
    1.69 +        return fStart;
    1.70 +    }
    1.71 +
    1.72 +    bool unorderable() const {
    1.73 +        return fUnorderable;
    1.74 +    }
    1.75 +
    1.76 +    bool unsortable() const {
    1.77 +        return fUnsortable;
    1.78 +    }
    1.79 +
    1.80 +#ifdef SK_DEBUG
    1.81 +    void dump() const;
    1.82 +#endif
    1.83 +
    1.84 +#if DEBUG_ANGLE
    1.85 +    void setID(int id) {
    1.86 +        fID = id;
    1.87 +    }
    1.88 +#endif
    1.89 +
    1.90 +private:
    1.91 +    bool lengthen(const SkOpAngle& );
    1.92 +    void setSpans();
    1.93 +
    1.94 +    SkDCubic fCurvePart; // the curve from start to end
    1.95 +    SkDCubic fCurveHalf; // the curve from start to 1 or 0
    1.96 +    double fSide;
    1.97 +    double fSide2;
    1.98 +    SkLineParameters fTangentPart;
    1.99 +    SkLineParameters fTangentHalf;
   1.100 +    const SkOpSegment* fSegment;
   1.101 +    SkOpSpan* fLastMarked;
   1.102 +    int fStart;
   1.103 +    int fEnd;
   1.104 +    bool fComputed; // tangent is computed, may contain some error
   1.105 +    // if subdividing a quad or cubic causes the tangent to go from the maximum angle to the
   1.106 +    // minimum, mark it unorderable. It still can be sorted, which is good enough for find-top
   1.107 +    // but can't be ordered, and therefore can't be used to compute winding
   1.108 +    bool fUnorderable;
   1.109 +    mutable bool fUnsortable;  // this alone is editable by the less than operator
   1.110 +#if DEBUG_ANGLE
   1.111 +    int fID;
   1.112 +#endif
   1.113 +};
   1.114 +
   1.115 +#endif

mercurial