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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsCubic.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     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 +
    1.11 +#ifndef SkPathOpsCubic_DEFINED
    1.12 +#define SkPathOpsCubic_DEFINED
    1.13 +
    1.14 +#include "SkPath.h"
    1.15 +#include "SkPathOpsPoint.h"
    1.16 +#include "SkTArray.h"
    1.17 +
    1.18 +struct SkDCubicPair {
    1.19 +    const SkDCubic& first() const { return (const SkDCubic&) pts[0]; }
    1.20 +    const SkDCubic& second() const { return (const SkDCubic&) pts[3]; }
    1.21 +    SkDPoint pts[7];
    1.22 +};
    1.23 +
    1.24 +struct SkDCubic {
    1.25 +    SkDPoint fPts[4];
    1.26 +
    1.27 +    void set(const SkPoint pts[4]) {
    1.28 +        fPts[0] = pts[0];
    1.29 +        fPts[1] = pts[1];
    1.30 +        fPts[2] = pts[2];
    1.31 +        fPts[3] = pts[3];
    1.32 +    }
    1.33 +
    1.34 +    static const int gPrecisionUnit;
    1.35 +
    1.36 +    const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
    1.37 +    SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
    1.38 +
    1.39 +    void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const;
    1.40 +    double calcPrecision() const;
    1.41 +    SkDCubicPair chopAt(double t) const;
    1.42 +    bool clockwise() const;
    1.43 +    static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D);
    1.44 +    bool controlsContainedByEnds() const;
    1.45 +    SkDVector dxdyAtT(double t) const;
    1.46 +    bool endsAreExtremaInXOrY() const;
    1.47 +    static int FindExtrema(double a, double b, double c, double d, double tValue[2]);
    1.48 +    int findInflections(double tValues[]) const;
    1.49 +
    1.50 +    static int FindInflections(const SkPoint a[4], double tValues[]) {
    1.51 +        SkDCubic cubic;
    1.52 +        cubic.set(a);
    1.53 +        return cubic.findInflections(tValues);
    1.54 +    }
    1.55 +
    1.56 +    int findMaxCurvature(double tValues[]) const;
    1.57 +    bool isLinear(int startIndex, int endIndex) const;
    1.58 +    bool monotonicInY() const;
    1.59 +    SkDPoint ptAtT(double t) const;
    1.60 +    static int RootsReal(double A, double B, double C, double D, double t[3]);
    1.61 +    static int RootsValidT(const double A, const double B, const double C, double D, double s[3]);
    1.62 +    bool serpentine() const;
    1.63 +    SkDCubic subDivide(double t1, double t2) const;
    1.64 +
    1.65 +    static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) {
    1.66 +        SkDCubic cubic;
    1.67 +        cubic.set(a);
    1.68 +        return cubic.subDivide(t1, t2);
    1.69 +    }
    1.70 +
    1.71 +    void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, SkDPoint p[2]) const;
    1.72 +
    1.73 +    static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoint& d, double t1,
    1.74 +                          double t2, SkDPoint p[2]) {
    1.75 +        SkDCubic cubic;
    1.76 +        cubic.set(pts);
    1.77 +        cubic.subDivide(a, d, t1, t2, p);
    1.78 +    }
    1.79 +
    1.80 +    SkDPoint top(double startT, double endT) const;
    1.81 +    void toQuadraticTs(double precision, SkTArray<double, true>* ts) const;
    1.82 +    SkDQuad toQuad() const;
    1.83 +
    1.84 +#ifdef SK_DEBUG
    1.85 +    void dump();
    1.86 +#endif
    1.87 +};
    1.88 +
    1.89 +#endif

mercurial