SkPath.h revision 30c174b9ce6b9777ee50ae0d0565a01b2a060f01
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
1365a87cc13d6babcf12844cca244ca7cc5258cadcbsalomon@google.com#include "SkInstCnt.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMatrix.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTDArray.h"
161dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com#include "SkRefCnt.h"
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1856c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
19f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC              fGenerationID++
20f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr)     ptr->fGenerationID++
21f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#else
22f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC
23f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr)
24f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
25f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
26739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.comclass SkReader32;
27739456585a0cc52b335cd1c0a9fc6b01782a7f89reed@google.comclass SkWriter32;
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoPathBoundsUpdate;
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkString;
301dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.comclass SkPathRef;
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
32ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com#ifndef SK_DEBUG_PATH_REF
337823d9a07fb08f21994031254f5b0342a721f460bsalomon@google.com    #define SK_DEBUG_PATH_REF 0
34ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com#endif
35ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPath
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    The SkPath class encapsulates compound (multiple contour) geometric paths
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    consisting of straight line segments, quadratic curves, and cubic curves.
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
417ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPath {
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
4365a87cc13d6babcf12844cca244ca7cc5258cadcbsalomon@google.com    SK_DECLARE_INST_COUNT_ROOT(SkPath);
4465a87cc13d6babcf12844cca244ca7cc5258cadcbsalomon@google.com
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath();
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath(const SkPath&);
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ~SkPath();
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath& operator=(const SkPath&);
50b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
515e728450247c677343e072f37150967b36892573bsalomon@google.com    friend  SK_API bool operator==(const SkPath&, const SkPath&);
523abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator!=(const SkPath& a, const SkPath& b) {
533abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com        return !(a == b);
543abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    }
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum FillType {
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by a non-zero sum of signed
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            edge crossings
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kWinding_FillType,
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by an odd number of edge
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            crossings
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kEvenOdd_FillType,
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as Winding, but draws outside of the path, rather than inside
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseWinding_FillType,
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as EvenOdd, but draws outside of the path, rather than inside
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com         */
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseEvenOdd_FillType
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the path's fill type. This is used to define how "inside" is
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the path's fill type
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    FillType getFillType() const { return (FillType)fFillType; }
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the path's fill type. This is used to define how "inside" is
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
82b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ft The new fill type for this path
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
85f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setFillType(FillType ft) {
86f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType = SkToU8(ft);
87f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
88f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the filltype is one of the Inverse variants */
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isInverseFillType() const { return (fFillType & 2) != 0; }
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
93b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
94b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Toggle between inverse and normal filltypes. This reverse the return
95b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  value of isInverseFillType()
96b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
97f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void toggleInverseFillType() {
98f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType ^= 2;
99f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
100f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com     }
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
10204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    enum Convexity {
10304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kUnknown_Convexity,
10404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConvex_Convexity,
10504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConcave_Convexity
10604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    };
10704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
10804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
10930c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  Return the path's convexity, as stored in the path. If it is currently unknown,
11030c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  then this function will attempt to compute the convexity (and cache the result).
111b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
112b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexity() const {
11330c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        if (kUnknown_Convexity != fConvexity) {
11430c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com            return static_cast<Convexity>(fConvexity);
11530c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        } else {
11630c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com            return this->internalGetConvexity();
117b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        }
118b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    }
119b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com
120b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
121b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Return the currently cached value for convexity, even if that is set to
122b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown_Convexity. Note: getConvexity() will automatically call
123b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  ComputeConvexity and cache its return value if the current setting is
124b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown.
12504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
126b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; }
12704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
12804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
12904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Store a convexity setting in the path. There is no automatic check to
13030c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  see if this value actually agrees with the return value that would be
13130c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  computed by getConvexity().
132b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *
133b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Note: even if this is set to a "known" value, if the path is later
134b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  changed (e.g. lineTo(), addRect(), etc.) then the cached value will be
135b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  reset to kUnknown_Convexity.
13604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
13704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    void setConvexity(Convexity);
13804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
13904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
14004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use getConvexity()
14104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Returns true if the path is flagged as being convex. This is not a
14204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  confirmed by any analysis, it is just the value set earlier.
14304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
14404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    bool isConvex() const {
14504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        return kConvex_Convexity == this->getConvexity();
14604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    }
14704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
14804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
14904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use setConvexity()
15004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Set the isConvex flag to true or false. Convex paths may draw faster if
15104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  this flag is set, though setting this to true on a path that is in fact
15204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  not convex can give undefined results when drawn. Paths default to
15304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  isConvex == false
1546b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
155f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setIsConvex(bool isConvex) {
15604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
157f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
1586b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
1596aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    /** Returns true if the path is an oval.
1606aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *
1616aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     * @param rect      returns the bounding rect of this oval. It's a circle
1626aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *                  if the height and width are the same.
1636aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *
1646aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     * @return true if this path is an oval.
1656aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              Tracking whether a path is an oval is considered an
1666aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              optimization for performance and so some paths that are in
1676aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              fact ovals can report false.
1686aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     */
1696aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    bool isOval(SkRect* rect) const;
1706aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Clear any lines and curves from the path, making it empty. This frees up
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        internal storage associated with those segments.
1736b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reset();
176fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Similar to reset(), in that all lines and curves are removed from the
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path. However, any internal storage for those lines/curves is retained,
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        making reuse of the path potentially faster.
1806b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rewind();
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path is empty (contains no lines or curves)
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path is empty (contains no lines or curves)
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isEmpty() const;
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1900bb18bb264b26afca45452910437c09445e23a3creed@google.com    /**
1910bb18bb264b26afca45452910437c09445e23a3creed@google.com     *  Returns true if all of the points in this path are finite, meaning there
1920bb18bb264b26afca45452910437c09445e23a3creed@google.com     *  are no infinities and no NaNs.
1930bb18bb264b26afca45452910437c09445e23a3creed@google.com     */
1940bb18bb264b26afca45452910437c09445e23a3creed@google.com    bool isFinite() const {
1950bb18bb264b26afca45452910437c09445e23a3creed@google.com        if (fBoundsIsDirty) {
1960bb18bb264b26afca45452910437c09445e23a3creed@google.com            this->computeBounds();
1970bb18bb264b26afca45452910437c09445e23a3creed@google.com        }
198fc91dc70042dcb6d2868e8822fbab15aa4402375robertphillips@google.com        return SkToBool(fIsFinite);
1990bb18bb264b26afca45452910437c09445e23a3creed@google.com    }
2000bb18bb264b26afca45452910437c09445e23a3creed@google.com
2014da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a line for zero length
2024da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2034da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the line is of zero length; otherwise false.
2044da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2054da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) {
20694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2);
2074da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2084da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2094da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a quad for zero length
2104da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2114da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the quad is of zero length; otherwise false.
2124da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2134da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
2144da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                 const SkPoint& p3) {
21594fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2) &&
21694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p2.equalsWithinTolerance(p3);
2174da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2184da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2194da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a cubic curve for zero length
2204da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2214da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the cubic is of zero length; otherwise false.
2224da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2234da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
2244da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                  const SkPoint& p3, const SkPoint& p4) {
22594fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2) &&
22694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p2.equalsWithinTolerance(p3) &&
22794fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p3.equalsWithinTolerance(p4);
2284da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2294da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2307e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com    /**
2317e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  Returns true if the path specifies a single line (i.e. it contains just
2327e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  a moveTo and a lineTo). If so, and line[] is not null, it sets the 2
2337e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  points in line[] to the end-points of the line. If the path is not a
2347e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  line, returns false and ignores line[].
2357e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     */
2367e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com    bool isLine(SkPoint line[2]) const;
2377e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path specifies a rectangle. If so, and if rect is
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        not null, set rect to the bounds of the path. If the path does not
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        specify a rectangle, return false and ignore rect.
241fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect If not null, returns the bounds of the path if it specifies
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    a rectangle
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path specifies a rectangle
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isRect(SkRect* rect) const;
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
248d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the number of points in the path
249d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
2501dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com    int countPoints() const;
251d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
252d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the point at the specified index. If the index is out of range
253d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         (i.e. is not 0 <= index < countPoints()) then the returned coordinates
254d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         will be (0,0)
255d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
256d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    SkPoint getPoint(int index) const;
257d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns the number of points in the path. Up to max points are copied.
259fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param points If not null, receives up to max points
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param max The maximum number of points to copy into points
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the actual number of points in the path
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getPoints(SkPoint points[], int max) const;
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
266df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    /** Return the number of verbs in the path
267df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com     */
2681dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com    int countVerbs() const;
269df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com
270df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    /** Returns the number of verbs in the path. Up to max verbs are copied. The
271df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        verbs are copied as one byte per verb.
272fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
273df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @param verbs If not null, receives up to max verbs
274df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @param max The maximum number of verbs to copy into verbs
275df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @return the actual number of verbs in the path
276df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    */
277df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    int getVerbs(uint8_t verbs[], int max) const;
278df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com
2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //! Swap contents of this and other. Guaranteed not to throw
2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void swap(SkPath& other);
2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
282d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    /** Returns the bounds of the path's points. If the path contains 0 or 1
283d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
284d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        Note: this bounds may be larger than the actual shape, since curves
285d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        do not extend as far as their control points.
286d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    */
287d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    const SkRect& getBounds() const {
288d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        if (fBoundsIsDirty) {
289d252db03d9650013b545ef9781fe993c07f8f314reed@android.com            this->computeBounds();
290d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        }
291d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        return fBounds;
292d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Calling this will, if the internal cache of the bounds is out of date,
295d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        update it so that subsequent calls to getBounds will be instanteous.
2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        This also means that any copies or simple transformations of the path
2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        will inherit the cached bounds.
298d252db03d9650013b545ef9781fe993c07f8f314reed@android.com     */
299d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void updateBoundsCache() const {
300d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        // for now, just calling getBounds() is sufficient
301d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        this->getBounds();
302d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //  Construction methods
3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Hint to the path to prepare for adding more points. This can allow the
3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path to more efficiently grow its storage.
308fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param extraPtCount The number of extra points the path should
3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            preallocate for.
3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void incReserve(unsigned extraPtCount);
3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point (x,y).
315fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the start of a new contour
3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the start of a new contour
3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(SkScalar x, SkScalar y);
3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point
322fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The start of a new contour
3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(const SkPoint& p) {
3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->moveTo(p.fX, p.fY);
3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour relative to the last point on the
3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        previous contour. If there is no previous contour, this is treated the
3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        same as moveTo().
332fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the end of the
3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the end of the
3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rMoveTo(SkScalar dx, SkScalar dy);
3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point (x,y). If no
3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the end of a line
3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the end of a line
3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(SkScalar x, SkScalar y);
3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point. If no moveTo()
3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        call has been made for this contour, the first point is automatically
3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        set to (0,0).
3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The end of a line
3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(const SkPoint& p) {
3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->lineTo(p.fX, p.fY);
3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as lineTo, but the coordinates are considered relative to the last
3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
362fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the previous point
3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the previous point
3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rLineTo(SkScalar dx, SkScalar dy);
3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for
3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this contour, the first point is automatically set to (0,0).
373fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the control point on a quadratic curve
3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the control point on a quadratic curve
3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the end point on a quadratic curve
3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the end point on a quadratic curve
3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        p1, and ending at p2. If no moveTo() call has been made for this
3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
384fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The control point on a quadratic curve
3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The end point on a quadratic curve
3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(const SkPoint& p1, const SkPoint& p2) {
3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as quadTo, but the coordinates are considered relative to the last
3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points
4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been
4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        made for this contour, the first point is automatically set to (0,0).
410fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the 1st control point on a cubic curve
4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the 1st control point on a cubic curve
4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the 2nd control point on a cubic curve
4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the 2nd control point on a cubic curve
4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x3   The x-coordinate of the end point on a cubic curve
4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y3   The y-coordinate of the end point on a cubic curve
4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 SkScalar x3, SkScalar y3);
4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points p1
4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and p2, and ending at p3. If no moveTo() call has been made for this
4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
424fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The 1st control point on a cubic curve
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The 2nd control point on a cubic curve
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p3   The end point on a cubic curve
4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as cubicTo, but the coordinates are considered relative to the
4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        current point on this contour. If there is no previous point, then a
4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(0,0) is inserted automatically.
436fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx3   The amount to add to the x-coordinate of the last point on
4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy3   The amount to add to the y-coordinate of the last point on
4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     SkScalar x3, SkScalar y3);
4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append the specified arc to the path as a new contour. If the start of
4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the path is different from the path's current last point, then an
4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatic lineTo() is added to connect the current contour to the start
4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        of the arc. However, if the path is empty, then we call moveTo() with
4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the first point of the arc. The sweep angle is treated mod 360.
458fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval defining the shape and size of the arc
4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise. This is
4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          treated mod 360.
4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param forceMoveTo If true, always begin a new contour with the arc
4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                  bool forceMoveTo);
4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com               SkScalar radius);
4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Close the current contour. If the current point is not equal to the
4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point of the contour, a line segment is automatically added.
4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void close();
4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Direction {
48730c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        /** Direction either has not been or could not be computed */
48830c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kUnknown_Direction,
4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** clockwise direction for adding closed contours */
4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCW_Direction,
4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** counter-clockwise direction for adding closed contours */
49230c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kCCW_Direction,
4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
49530c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com    static Direction OppositeDirection(Direction dir) {
49630c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        static const Direction kOppositeDir[] = {kUnknown_Direction, kCCW_Direction, kCW_Direction};
49730c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        return kOppositeDir[dir];
49830c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com    }
49930c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com
50069a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    /**
50169a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  Tries to quickly compute the direction of the first non-degenerate
50269a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  contour. If it can be computed, return true and set dir to that
50369a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  direction. If it cannot be (quickly) determined, return false and ignore
50430c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  the dir parameter. If the direction was determined, it is cached to make
50530c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com     *  subsequent calls return quickly.
50669a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     */
50769a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    bool cheapComputeDirection(Direction* dir) const;
50869a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com
50969a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    /**
51069a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  Returns true if the path's direction can be computed via
51169a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  cheapComputDirection() and if that computed direction matches the
51269a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  specified direction.
51369a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     */
51469a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    bool cheapIsDirection(Direction dir) const {
51530c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        SkASSERT(kCW_Direction == dir || kCCW_Direction == dir);
51669a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com        Direction computedDir;
51769a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com        return this->cheapComputeDirection(&computedDir) && computedDir == dir;
51869a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    }
51969a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com
5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The rectangle to add as a closed contour to the path
5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the rectangle's contour
5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param left     The left side of a rectangle to add as a closed contour
5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param top      The top of a rectangle to add as a closed contour to the
5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param right    The right side of a rectangle to add as a closed contour
5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param bottom   The bottom of a rectangle to add as a closed contour to
5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        the path
5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the rectangle's contour
5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 Direction dir = kCW_Direction);
5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed oval contour to the path
5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval to add as a closed contour to the path
5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the oval's contour
5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addOval(const SkRect& oval, Direction dir = kCW_Direction);
5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed circle contour to the path
5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x        The x-coordinate of the center of a circle to add as a
5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y        The y-coordinate of the center of a circle to add as a
5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius of a circle to add as a closed contour to the
5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the circle's contour
5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addCircle(SkScalar x, SkScalar y, SkScalar radius,
5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                   Direction dir = kCW_Direction);
5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add the specified arc to the path as a new contour.
562fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
5638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounds of oval used to define the size of the arc
5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise
5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path
5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rx   The x-radius of the rounded corners on the round-rectangle
5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ry   The y-radius of the rounded corners on the round-rectangle
5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                         Direction dir = kCW_Direction);
5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path. Each corner receives
5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        two radius values [X, Y]. The corners are ordered top-left, top-right,
5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bottom-right, bottom-left.
5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radii Array of 8 scalars, 4 [X,Y] pairs for each corner
5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRoundRect(const SkRect& rect, const SkScalar radii[],
5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      Direction dir = kCW_Direction);
5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
588744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com    /**
589744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *  Add a new contour made of just lines. This is just a fast version of
590744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *  the following:
591744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      this->moveTo(pts[0]);
592744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      for (int i = 1; i < count; ++i) {
593744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *          this->lineTo(pts[i]);
594744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      }
595744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      if (close) {
596744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *          this->close();
597744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      }
598744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     */
599744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com    void addPoly(const SkPoint pts[], int count, bool close);
600744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com
6018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, offset by (dx,dy)
6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in X as it is added
6048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in Y as it is added
6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
60663d73749fbe36491403ea521005fd298dc70a94creed@google.com    void addPath(const SkPath& src, SkScalar dx, SkScalar dy);
6078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path
6098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src) {
6118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkMatrix m;
6128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        m.reset();
6138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->addPath(src, m);
6148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, transformed by matrix
6178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src, const SkMatrix& matrix);
6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
62163d73749fbe36491403ea521005fd298dc70a94creed@google.com    /**
62263d73749fbe36491403ea521005fd298dc70a94creed@google.com     *  Same as addPath(), but reverses the src input
62363d73749fbe36491403ea521005fd298dc70a94creed@google.com     */
62463d73749fbe36491403ea521005fd298dc70a94creed@google.com    void reverseAddPath(const SkPath& src);
62563d73749fbe36491403ea521005fd298dc70a94creed@google.com
6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
627fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
628fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dx   The amount in the X direction to offset the entire path
629fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dy   The amount in the Y direction to offset the entire path
6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst  The translated path is written here
6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
635fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
636fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dx   The amount in the X direction to offset the entire path
637fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dy   The amount in the Y direction to offset the entire path
6388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy) {
6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->offset(dx, dy, this);
6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix, and write the answer into
6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        dst.
645fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix   The matrix to apply to the path
6478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst      The transformed path is written here
6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix, SkPath* dst) const;
6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix
6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix The matrix to apply to the path
6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix) {
6568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->transform(matrix, this);
6578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the last point on the path. If no points have been added, (0,0)
660294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        is returned. If there are no points, this returns false, otherwise it
661294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        returns true.
662fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param lastPt   The last point on the path is returned here
6648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
665294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com    bool getLastPt(SkPoint* lastPt) const;
6668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added,
6688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(x,y) is automatically called.
669fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The new x-coordinate for the last point
6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The new y-coordinate for the last point
6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(SkScalar x, SkScalar y);
6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added, moveTo(p)
6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is automatically called.
6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The new location for the last point
6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(const SkPoint& p) {
6818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->setLastPt(p.fX, p.fY);
6828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
68410296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    enum SegmentMask {
68510296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kLine_SegmentMask   = 1 << 0,
68610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kQuad_SegmentMask   = 1 << 1,
68710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kCubic_SegmentMask  = 1 << 2
68810296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    };
68910296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
69010296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    /**
69110296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns a mask, where each bit corresponding to a SegmentMask is
69210296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  set if the path contains 1 or more segments of that type.
69310296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns 0 for an empty path (no segments).
69410296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     */
69510296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint32_t getSegmentMasks() const { return fSegmentMask; }
69610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
6978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Verb {
6988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMove_Verb,     //!< iter.next returns 1 point
6998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLine_Verb,     //!< iter.next returns 2 points
7008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kQuad_Verb,     //!< iter.next returns 3 points
7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCubic_Verb,    //!< iter.next returns 4 points
702b3b8dfa31326c51dab8b5ed569e19ee715582d1bbsalomon@google.com        kClose_Verb,    //!< iter.next returns 1 point (contour's moveTo pt)
7038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDone_Verb      //!< iter.next returns 0 points
7048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
7058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Iterate through all of the segments (lines, quadratics, cubics) of
7078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        each contours in a path.
70872785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org
70972785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        The iterator cleans up the segments along the way, removing degenerate
71072785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        segments and adding close verbs where necessary. When the forceClose
71172785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        argument is provided, each contour (as defined by a new starting
71272785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        move command) will be completed with a close verb regardless of the
71372785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        contour's contents.
7148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7157ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org    class SK_API Iter {
7168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    public:
71772785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter();
71872785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter(const SkPath&, bool forceClose);
7198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void setPath(const SkPath&, bool forceClose);
7218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Return the next verb in this iteration of the path. When all
7238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            segments have been visited, return kDone_Verb.
724b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @param  pts The points representing the current verb and/or segment
7264a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            @param doConsumeDegerates If true, first scan for segments that are
7274a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com                   deemed degenerate (too short) and skip those.
7288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return The verb for the current segment
7298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7304a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        Verb next(SkPoint pts[4], bool doConsumeDegerates = true) {
7314a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            if (doConsumeDegerates) {
7324a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com                this->consumeDegenerateSegments();
7334a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            }
7344a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            return this->doNext(pts);
7354a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        }
7368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** If next() returns kLine_Verb, then this query returns true if the
7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            line was the result of a close() command (i.e. the end point is the
7398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            initial moveto for this contour). If next() returned a different
7408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            verb, this returns an undefined value.
741b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return If the last call to next() returned kLine_Verb, return true
7438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    if it was the result of an explicit close command.
7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isCloseLine() const { return SkToBool(fCloseLine); }
746b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Returns true if the current contour is closed (has a kClose_Verb)
7488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return true if the current contour is closed (has a kClose_Verb)
7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isClosedContour() const;
7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    private:
7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkPoint*  fPts;
7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbs;
7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbStop;
7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fMoveTo;
7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fLastPt;
7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fForceClose;
7598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fNeedClose;
7608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fCloseLine;
761b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org        SkBool8         fSegmentState;
7628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7639e25dbf589539dd44244bc2581590bd7591e17a2reed@google.com        inline const SkPoint& cons_moveTo();
7648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb autoClose(SkPoint pts[2]);
7654da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        void consumeDegenerateSegments();
7664a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        Verb doNext(SkPoint pts[4]);
7678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
7688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7696630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    /** Iterate through the verbs in the path, providing the associated points.
7706630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    */
7716630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    class SK_API RawIter {
7726630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    public:
7736630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter();
7746630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter(const SkPath&);
7756630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7766630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        void setPath(const SkPath&);
7776630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7786630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        /** Return the next verb in this iteration of the path. When all
7796630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            segments have been visited, return kDone_Verb.
780fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
7816630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @param  pts The points representing the current verb and/or segment
782f6d3c5aa5f93e4c3cc7a7aebf014e960cf837783bsalomon@google.com                        This must not be NULL.
7836630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @return The verb for the current segment
7846630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        */
7856630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        Verb next(SkPoint pts[4]);
7866630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7876630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    private:
7886630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const SkPoint*  fPts;
7896630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbs;
7906630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbStop;
7916630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fMoveTo;
7926630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fLastPt;
7936630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    };
7946630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
795bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org    /**
796bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     *  Returns true if the point { x, y } is contained by the path, taking into
797bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     *  account the FillType.
798bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     */
799bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org    bool contains(SkScalar x, SkScalar y) const;
800bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org
8018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void dump(bool forceClose, const char title[] = NULL) const;
802e522ca5d5f249bd51a00cb68bb051f811d0a9e85reed@android.com    void dump() const;
8038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
80494e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    /**
80594e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  Write the region to the buffer, and return the number of bytes written.
80694e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  If buffer is NULL, it still returns the number of bytes.
80794e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     */
80894e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    uint32_t writeToMemory(void* buffer) const;
80994e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    /**
81094e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  Initialized the region from the buffer, returning the number
81194e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  of bytes actually read.
81294e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     */
81394e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    uint32_t readFromMemory(const void* buffer);
8148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
81556c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
816f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t getGenerationID() const;
817e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    const SkPath* getSourcePath() const;
818e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    void setSourcePath(const SkPath* path);
819f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
820f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
8218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDEBUGCODE(void validate() const;)
8228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
82401ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com    enum SerializationOffsets {
82530c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kDirection_SerializationShift = 26, // requires 2 bits
82630c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kIsFinite_SerializationShift = 25,  // requires 1 bit
82730c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kIsOval_SerializationShift = 24,    // requires 1 bit
82830c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kConvexity_SerializationShift = 16, // requires 2 bits
82930c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kFillType_SerializationShift = 8,   // requires 2 bits
83030c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com        kSegmentMask_SerializationShift = 0 // requires 3 bits
83101ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com    };
83201ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com
833ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com#if SK_DEBUG_PATH_REF
834ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.compublic:
835ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    /** Debugging wrapper for SkAutoTUnref<SkPathRef> used to track owners (SkPaths)
836ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        of SkPathRefs */
837ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    class PathRefDebugRef {
838ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    public:
839ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        PathRefDebugRef(SkPath* owner);
840ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        PathRefDebugRef(SkPathRef* pr, SkPath* owner);
841ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        ~PathRefDebugRef();
8427cc7f494796afc681355b15e88c57ef2709a9220skia.committer@gmail.com        void reset(SkPathRef* ref);
843ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        void swap(PathRefDebugRef* other);
844ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        SkPathRef* get() const;
845ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        SkAutoTUnref<SkPathRef>::BlockRefType *operator->() const;
846ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        operator SkPathRef*();
847ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    private:
848ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        SkAutoTUnref<SkPathRef>   fPathRef;
849ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com        SkPath*                   fOwner;
850ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    };
851ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com
852ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.comprivate:
853ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    PathRefDebugRef     fPathRef;
854ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com#else
855ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com    SkAutoTUnref<SkPathRef> fPathRef;
856ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com#endif
857ae09f2dc3fb1e8a8db99b214c8a71d0b9613a856bsalomon@google.com
858d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    mutable SkRect      fBounds;
859d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    int                 fLastMoveToIndex;
8608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t             fFillType;
86110296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint8_t             fSegmentMask;
86210296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    mutable uint8_t     fBoundsIsDirty;
863b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    mutable uint8_t     fConvexity;
86430c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com    mutable uint8_t     fDirection;
8650bb18bb264b26afca45452910437c09445e23a3creed@google.com    mutable SkBool8     fIsFinite;    // only meaningful if bounds are valid
8666aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    mutable SkBool8     fIsOval;
86756c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
868f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t            fGenerationID;
869e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    const SkPath*       fSourcePath;
870f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
8718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
872d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    // called, if dirty, by getBounds()
873d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void computeBounds() const;
874d252db03d9650013b545ef9781fe993c07f8f314reed@android.com
8758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class Iter;
8768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkPathStroker;
8788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append the first contour of path, ignoring path's initial point. If no
8798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
8808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
8818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void pathTo(const SkPath& path);
8838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append, in reverse order, the first contour of path, ignoring path's
8858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        last point. If no moveTo() call has been made for this contour, the
8868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point is automatically set to (0,0).
8878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reversePathTo(const SkPath&);
8898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
890d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // called before we add points for lineTo, quadTo, cubicTo, checking to see
891d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // if we need to inject a leading moveTo first
892d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //
893d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //  SkPath path; path.lineTo(...);   <--- need a leading moveTo(0, 0)
894d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
895d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //
896d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    inline void injectMoveToIfNeeded();
897d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com
8986aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    inline bool hasOnlyMoveTos() const;
8996aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com
90030c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com    Convexity internalGetConvexity() const;
90130c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com
9028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkAutoPathBoundsUpdate;
9036aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    friend class SkAutoDisableOvalCheck;
90430c174b9ce6b9777ee50ae0d0565a01b2a060f01bsalomon@google.com    friend class SkAutoDisableDirectionCheck;
90530e6d2c2054c15f1cb6c0637bee6756261291751bsalomon@google.com    friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
9068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
9078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
909