SkPath.h revision 63d73749fbe36491403ea521005fd298dc70a94c
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPath_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPath_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMatrix.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTDArray.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1656c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
17f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC              fGenerationID++
18f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr)     ptr->fGenerationID++
19f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#else
20f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC
21f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr)
22f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
23f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
24739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.comclass SkReader32;
25739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.comclass SkWriter32;
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoPathBoundsUpdate;
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkString;
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPath
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    The SkPath class encapsulates compound (multiple contour) geometric paths
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    consisting of straight line segments, quadratic curves, and cubic curves.
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
347ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPath {
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath();
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath(const SkPath&);
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ~SkPath();
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath& operator=(const SkPath&);
41b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
423abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator==(const SkPath&, const SkPath&);
433abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator!=(const SkPath& a, const SkPath& b) {
443abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com        return !(a == b);
453abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    }
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum FillType {
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by a non-zero sum of signed
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            edge crossings
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kWinding_FillType,
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by an odd number of edge
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            crossings
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kEvenOdd_FillType,
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as Winding, but draws outside of the path, rather than inside
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseWinding_FillType,
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as EvenOdd, but draws outside of the path, rather than inside
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com         */
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseEvenOdd_FillType
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the path's fill type. This is used to define how "inside" is
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the path's fill type
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    FillType getFillType() const { return (FillType)fFillType; }
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the path's fill type. This is used to define how "inside" is
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
73b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ft The new fill type for this path
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
76f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setFillType(FillType ft) {
77f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType = SkToU8(ft);
78f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
79f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the filltype is one of the Inverse variants */
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isInverseFillType() const { return (fFillType & 2) != 0; }
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
84b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
85b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Toggle between inverse and normal filltypes. This reverse the return
86b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  value of isInverseFillType()
87b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
88f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void toggleInverseFillType() {
89f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType ^= 2;
90f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
91f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com     }
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    enum Convexity {
9404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kUnknown_Convexity,
9504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConvex_Convexity,
9604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConcave_Convexity
9704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    };
9804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
9904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
100b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Return the path's convexity, as stored in the path. If it is currently
101b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  unknown, and the computeIfUnknown bool is true, then this will first
102b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  call ComputeConvexity() and then return that (cached) value.
103b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
104b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexity() const {
105b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        if (kUnknown_Convexity == fConvexity) {
106b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com            fConvexity = (uint8_t)ComputeConvexity(*this);
107b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        }
108b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        return (Convexity)fConvexity;
109b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    }
110b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com
111b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
112b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Return the currently cached value for convexity, even if that is set to
113b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown_Convexity. Note: getConvexity() will automatically call
114b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  ComputeConvexity and cache its return value if the current setting is
115b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown.
11604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
117b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; }
11804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
11904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
12004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Store a convexity setting in the path. There is no automatic check to
12104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  see if this value actually agress with the return value from
12204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  ComputeConvexity().
123b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *
124b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Note: even if this is set to a "known" value, if the path is later
125b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  changed (e.g. lineTo(), addRect(), etc.) then the cached value will be
126b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  reset to kUnknown_Convexity.
12704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
12804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    void setConvexity(Convexity);
12904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
13004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
13104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Compute the convexity of the specified path. This does not look at the
13204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  value stored in the path, but computes it directly from the path's data.
13304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *
134b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  This never returns kUnknown_Convexity.
135b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *
13604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  If there is more than one contour, this returns kConcave_Convexity.
137b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  If the contour is degenerate (e.g. there are fewer than 3 non-degenerate
138b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  segments), then this returns kConvex_Convexity.
13904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  The contour is treated as if it were closed, even if there is no kClose
14004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  verb.
1416b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
14204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    static Convexity ComputeConvexity(const SkPath&);
1436b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
14404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
14504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use getConvexity()
14604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Returns true if the path is flagged as being convex. This is not a
14704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  confirmed by any analysis, it is just the value set earlier.
14804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
14904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    bool isConvex() const {
15004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        return kConvex_Convexity == this->getConvexity();
15104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    }
15204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
15304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
15404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use setConvexity()
15504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Set the isConvex flag to true or false. Convex paths may draw faster if
15604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  this flag is set, though setting this to true on a path that is in fact
15704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  not convex can give undefined results when drawn. Paths default to
15804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  isConvex == false
1596b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
160f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setIsConvex(bool isConvex) {
16104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
162f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
1636b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Clear any lines and curves from the path, making it empty. This frees up
1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        internal storage associated with those segments.
1666b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reset();
1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Similar to reset(), in that all lines and curves are removed from the
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path. However, any internal storage for those lines/curves is retained,
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        making reuse of the path potentially faster.
1736b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rewind();
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path is empty (contains no lines or curves)
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path is empty (contains no lines or curves)
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isEmpty() const;
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1834da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a line for zero length
1844da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
1854da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the line is of zero length; otherwise false.
1864da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
1874da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) {
1884da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        return p1.equalsWithinTolerance(p2, SK_ScalarNearlyZero);
1894da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
1904da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
1914da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a quad for zero length
1924da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
1934da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the quad is of zero length; otherwise false.
1944da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
1954da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
1964da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                 const SkPoint& p3) {
1974da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        return p1.equalsWithinTolerance(p2, SK_ScalarNearlyZero) &&
1984da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org               p2.equalsWithinTolerance(p3, SK_ScalarNearlyZero);
1994da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2004da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2014da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a cubic curve for zero length
2024da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2034da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the cubic is of zero length; otherwise false.
2044da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2054da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
2064da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                  const SkPoint& p3, const SkPoint& p4) {
2074da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        return p1.equalsWithinTolerance(p2, SK_ScalarNearlyZero) &&
2084da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org               p2.equalsWithinTolerance(p3, SK_ScalarNearlyZero) &&
2094da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org               p3.equalsWithinTolerance(p4, SK_ScalarNearlyZero);
2104da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2114da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path specifies a rectangle. If so, and if rect is
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        not null, set rect to the bounds of the path. If the path does not
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        specify a rectangle, return false and ignore rect.
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect If not null, returns the bounds of the path if it specifies
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    a rectangle
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path specifies a rectangle
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isRect(SkRect* rect) const;
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
222d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the number of points in the path
223d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
224d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    int countPoints() const {
225d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com        return this->getPoints(NULL, 0);
226d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    }
227d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
228d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the point at the specified index. If the index is out of range
229d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         (i.e. is not 0 <= index < countPoints()) then the returned coordinates
230d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         will be (0,0)
231d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
232d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    SkPoint getPoint(int index) const;
233d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns the number of points in the path. Up to max points are copied.
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param points If not null, receives up to max points
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param max The maximum number of points to copy into points
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the actual number of points in the path
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getPoints(SkPoint points[], int max) const;
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //! Swap contents of this and other. Guaranteed not to throw
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void swap(SkPath& other);
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
245d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    /** Returns the bounds of the path's points. If the path contains 0 or 1
246d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
247d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        Note: this bounds may be larger than the actual shape, since curves
248d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        do not extend as far as their control points.
249d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    */
250d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    const SkRect& getBounds() const {
251d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        if (fBoundsIsDirty) {
252d252db03d9650013b545ef9781fe993c07f8f314reed@android.com            this->computeBounds();
253d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        }
254d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        return fBounds;
255d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Calling this will, if the internal cache of the bounds is out of date,
258d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        update it so that subsequent calls to getBounds will be instanteous.
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        This also means that any copies or simple transformations of the path
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        will inherit the cached bounds.
261d252db03d9650013b545ef9781fe993c07f8f314reed@android.com     */
262d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void updateBoundsCache() const {
263d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        // for now, just calling getBounds() is sufficient
264d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        this->getBounds();
265d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //  Construction methods
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Hint to the path to prepare for adding more points. This can allow the
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path to more efficiently grow its storage.
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param extraPtCount The number of extra points the path should
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            preallocate for.
2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void incReserve(unsigned extraPtCount);
2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point (x,y).
2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the start of a new contour
2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the start of a new contour
2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(SkScalar x, SkScalar y);
2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point
2858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The start of a new contour
2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(const SkPoint& p) {
2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->moveTo(p.fX, p.fY);
2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour relative to the last point on the
2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        previous contour. If there is no previous contour, this is treated the
2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        same as moveTo().
2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the end of the
2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the end of the
2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rMoveTo(SkScalar dx, SkScalar dy);
3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point (x,y). If no
3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the end of a line
3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the end of a line
3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(SkScalar x, SkScalar y);
3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point. If no moveTo()
3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        call has been made for this contour, the first point is automatically
3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        set to (0,0).
3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The end of a line
3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(const SkPoint& p) {
3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->lineTo(p.fX, p.fY);
3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as lineTo, but the coordinates are considered relative to the last
3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the previous point
3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the previous point
3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rLineTo(SkScalar dx, SkScalar dy);
3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for
3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this contour, the first point is automatically set to (0,0).
3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the control point on a quadratic curve
3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the control point on a quadratic curve
3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the end point on a quadratic curve
3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the end point on a quadratic curve
3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        p1, and ending at p2. If no moveTo() call has been made for this
3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The control point on a quadratic curve
3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The end point on a quadratic curve
3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(const SkPoint& p1, const SkPoint& p2) {
3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as quadTo, but the coordinates are considered relative to the last
3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points
3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been
3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        made for this contour, the first point is automatically set to (0,0).
3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the 1st control point on a cubic curve
3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the 1st control point on a cubic curve
3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the 2nd control point on a cubic curve
3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the 2nd control point on a cubic curve
3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x3   The x-coordinate of the end point on a cubic curve
3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y3   The y-coordinate of the end point on a cubic curve
3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 SkScalar x3, SkScalar y3);
3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points p1
3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and p2, and ending at p3. If no moveTo() call has been made for this
3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The 1st control point on a cubic curve
3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The 2nd control point on a cubic curve
3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p3   The end point on a cubic curve
3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as cubicTo, but the coordinates are considered relative to the
3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        current point on this contour. If there is no previous point, then a
3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(0,0) is inserted automatically.
3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx3   The amount to add to the x-coordinate of the last point on
4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy3   The amount to add to the y-coordinate of the last point on
4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     SkScalar x3, SkScalar y3);
4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append the specified arc to the path as a new contour. If the start of
4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the path is different from the path's current last point, then an
4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatic lineTo() is added to connect the current contour to the start
4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        of the arc. However, if the path is empty, then we call moveTo() with
4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the first point of the arc. The sweep angle is treated mod 360.
4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval defining the shape and size of the arc
4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise. This is
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          treated mod 360.
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param forceMoveTo If true, always begin a new contour with the arc
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                  bool forceMoveTo);
4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com               SkScalar radius);
4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Close the current contour. If the current point is not equal to the
4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point of the contour, a line segment is automatically added.
4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void close();
4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Direction {
4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** clockwise direction for adding closed contours */
4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCW_Direction,
4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** counter-clockwise direction for adding closed contours */
4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCCW_Direction
4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The rectangle to add as a closed contour to the path
4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the rectangle's contour
4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param left     The left side of a rectangle to add as a closed contour
4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param top      The top of a rectangle to add as a closed contour to the
4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param right    The right side of a rectangle to add as a closed contour
4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param bottom   The bottom of a rectangle to add as a closed contour to
4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        the path
4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the rectangle's contour
4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 Direction dir = kCW_Direction);
4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed oval contour to the path
4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval to add as a closed contour to the path
4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the oval's contour
4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addOval(const SkRect& oval, Direction dir = kCW_Direction);
4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed circle contour to the path
4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x        The x-coordinate of the center of a circle to add as a
4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y        The y-coordinate of the center of a circle to add as a
4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius of a circle to add as a closed contour to the
4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the circle's contour
4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addCircle(SkScalar x, SkScalar y, SkScalar radius,
4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                   Direction dir = kCW_Direction);
4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add the specified arc to the path as a new contour.
4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounds of oval used to define the size of the arc
5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise
5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path
5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rx   The x-radius of the rounded corners on the round-rectangle
5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ry   The y-radius of the rounded corners on the round-rectangle
5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                         Direction dir = kCW_Direction);
5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path. Each corner receives
5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        two radius values [X, Y]. The corners are ordered top-left, top-right,
5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bottom-right, bottom-left.
5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radii Array of 8 scalars, 4 [X,Y] pairs for each corner
5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRoundRect(const SkRect& rect, const SkScalar radii[],
5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      Direction dir = kCW_Direction);
5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, offset by (dx,dy)
5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in X as it is added
5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in Y as it is added
5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
52963d73749fbe36491403ea521005fd298dc70a94creed@google.com    void addPath(const SkPath& src, SkScalar dx, SkScalar dy);
5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path
5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src) {
5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkMatrix m;
5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        m.reset();
5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->addPath(src, m);
5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, transformed by matrix
5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src, const SkMatrix& matrix);
5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
54463d73749fbe36491403ea521005fd298dc70a94creed@google.com    /**
54563d73749fbe36491403ea521005fd298dc70a94creed@google.com     *  Same as addPath(), but reverses the src input
54663d73749fbe36491403ea521005fd298dc70a94creed@google.com     */
54763d73749fbe36491403ea521005fd298dc70a94creed@google.com    void reverseAddPath(const SkPath& src);
54863d73749fbe36491403ea521005fd298dc70a94creed@google.com
5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount in the X direction to offset the entire path
5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount in the Y direction to offset the entire path
5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst  The translated path is written here
5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount in the X direction to offset the entire path
5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount in the Y direction to offset the entire path
5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy) {
5638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->offset(dx, dy, this);
5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix, and write the answer into
5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        dst.
5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix   The matrix to apply to the path
5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst      The transformed path is written here
5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix, SkPath* dst) const;
5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix
5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix The matrix to apply to the path
5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix) {
5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->transform(matrix, this);
5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the last point on the path. If no points have been added, (0,0)
583294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        is returned. If there are no points, this returns false, otherwise it
584294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        returns true.
5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param lastPt   The last point on the path is returned here
5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
588294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com    bool getLastPt(SkPoint* lastPt) const;
5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added,
5918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(x,y) is automatically called.
5928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The new x-coordinate for the last point
5948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The new y-coordinate for the last point
5958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(SkScalar x, SkScalar y);
5978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added, moveTo(p)
5998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is automatically called.
6008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The new location for the last point
6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(const SkPoint& p) {
6048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->setLastPt(p.fX, p.fY);
6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
60710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    enum SegmentMask {
60810296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kLine_SegmentMask   = 1 << 0,
60910296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kQuad_SegmentMask   = 1 << 1,
61010296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kCubic_SegmentMask  = 1 << 2
61110296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    };
61210296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
61310296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    /**
61410296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns a mask, where each bit corresponding to a SegmentMask is
61510296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  set if the path contains 1 or more segments of that type.
61610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns 0 for an empty path (no segments).
61710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     */
61810296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint32_t getSegmentMasks() const { return fSegmentMask; }
61910296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Verb {
6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMove_Verb,     //!< iter.next returns 1 point
6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLine_Verb,     //!< iter.next returns 2 points
6238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kQuad_Verb,     //!< iter.next returns 3 points
6248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCubic_Verb,    //!< iter.next returns 4 points
625b3b8dfa31326c51dab8b5ed569e19ee715582d1bbsalomon@google.com        kClose_Verb,    //!< iter.next returns 1 point (contour's moveTo pt)
6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDone_Verb      //!< iter.next returns 0 points
6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Iterate through all of the segments (lines, quadratics, cubics) of
6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        each contours in a path.
63172785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org
63272785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        The iterator cleans up the segments along the way, removing degenerate
63372785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        segments and adding close verbs where necessary. When the forceClose
63472785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        argument is provided, each contour (as defined by a new starting
63572785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        move command) will be completed with a close verb regardless of the
63672785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        contour's contents.
6378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6387ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org    class SK_API Iter {
6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    public:
64072785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter();
64172785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter(const SkPath&, bool forceClose);
6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void setPath(const SkPath&, bool forceClose);
6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Return the next verb in this iteration of the path. When all
6468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            segments have been visited, return kDone_Verb.
647b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @param  pts The points representing the current verb and/or segment
6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return The verb for the current segment
6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb next(SkPoint pts[4]);
6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** If next() returns kLine_Verb, then this query returns true if the
6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            line was the result of a close() command (i.e. the end point is the
6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            initial moveto for this contour). If next() returned a different
6568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            verb, this returns an undefined value.
657b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
6588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return If the last call to next() returned kLine_Verb, return true
6598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    if it was the result of an explicit close command.
6608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
6618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isCloseLine() const { return SkToBool(fCloseLine); }
662b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
6638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Returns true if the current contour is closed (has a kClose_Verb)
6648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return true if the current contour is closed (has a kClose_Verb)
6658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
6668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isClosedContour() const;
6678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    private:
6698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkPoint*  fPts;
6708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbs;
6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbStop;
6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fMoveTo;
6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fLastPt;
6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fForceClose;
6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fNeedClose;
6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fCloseLine;
677b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org        SkBool8         fSegmentState;
6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool cons_moveTo(SkPoint pts[1]);
6808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb autoClose(SkPoint pts[2]);
6814da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        void consumeDegenerateSegments();
6828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6846630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    /** Iterate through the verbs in the path, providing the associated points.
6856630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    */
6866630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    class SK_API RawIter {
6876630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    public:
6886630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter();
6896630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter(const SkPath&);
6906630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
6916630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        void setPath(const SkPath&);
6926630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
6936630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        /** Return the next verb in this iteration of the path. When all
6946630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            segments have been visited, return kDone_Verb.
6956630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
6966630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @param  pts The points representing the current verb and/or segment
6976630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @return The verb for the current segment
6986630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        */
6996630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        Verb next(SkPoint pts[4]);
7006630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7016630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    private:
7026630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const SkPoint*  fPts;
7036630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbs;
7046630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbStop;
7056630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fMoveTo;
7066630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fLastPt;
7076630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    };
7086630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void dump(bool forceClose, const char title[] = NULL) const;
710e522ca5d5f249bd51a00cb68bb051f811d0a9e85reed@android.com    void dump() const;
7118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
712739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.com    void flatten(SkWriter32&) const;
713739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.com    void unflatten(SkReader32&);
7148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
71556c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
716f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t getGenerationID() const;
717f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
718f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
7198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDEBUGCODE(void validate() const;)
7208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
7228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTDArray<SkPoint>  fPts;
7238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTDArray<uint8_t>  fVerbs;
724d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    mutable SkRect      fBounds;
7258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t             fFillType;
72610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint8_t             fSegmentMask;
72710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    mutable uint8_t     fBoundsIsDirty;
728b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    mutable uint8_t     fConvexity;
72956c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
730f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t            fGenerationID;
731f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
7328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
733d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    // called, if dirty, by getBounds()
734d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void computeBounds() const;
735d252db03d9650013b545ef9781fe993c07f8f314reed@android.com
7368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class Iter;
7378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cons_moveto();
7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkPathStroker;
7408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append the first contour of path, ignoring path's initial point. If no
7418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
7428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
7438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void pathTo(const SkPath& path);
7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append, in reverse order, the first contour of path, ignoring path's
7478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        last point. If no moveTo() call has been made for this contour, the
7488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point is automatically set to (0,0).
7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reversePathTo(const SkPath&);
7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend const SkPoint* sk_get_path_points(const SkPath&, int index);
7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkAutoPathBoundsUpdate;
7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
757