SkPath.h revision 1dfe88e00aeddf20690fd2469fd17e43f670ee3a
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
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPath
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    The SkPath class encapsulates compound (multiple contour) geometric paths
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    consisting of straight line segments, quadratic curves, and cubic curves.
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
377ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPath {
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
3965a87cc13d6babcf12844cca244ca7cc5258cadcbsalomon@google.com    SK_DECLARE_INST_COUNT_ROOT(SkPath);
4065a87cc13d6babcf12844cca244ca7cc5258cadcbsalomon@google.com
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath();
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath(const SkPath&);
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ~SkPath();
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath& operator=(const SkPath&);
46b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
475e728450247c677343e072f37150967b36892573bsalomon@google.com    friend  SK_API bool operator==(const SkPath&, const SkPath&);
483abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator!=(const SkPath& a, const SkPath& b) {
493abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com        return !(a == b);
503abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    }
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum FillType {
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by a non-zero sum of signed
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            edge crossings
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kWinding_FillType,
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by an odd number of edge
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            crossings
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kEvenOdd_FillType,
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as Winding, but draws outside of the path, rather than inside
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseWinding_FillType,
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as EvenOdd, but draws outside of the path, rather than inside
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com         */
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseEvenOdd_FillType
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the path's fill type. This is used to define how "inside" is
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the path's fill type
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    FillType getFillType() const { return (FillType)fFillType; }
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the path's fill type. This is used to define how "inside" is
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
78b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ft The new fill type for this path
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
81f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setFillType(FillType ft) {
82f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType = SkToU8(ft);
83f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
84f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the filltype is one of the Inverse variants */
878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isInverseFillType() const { return (fFillType & 2) != 0; }
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
89b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
90b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Toggle between inverse and normal filltypes. This reverse the return
91b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  value of isInverseFillType()
92b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
93f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void toggleInverseFillType() {
94f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        fFillType ^= 2;
95f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com        GEN_ID_INC;
96f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com     }
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    enum Convexity {
9904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kUnknown_Convexity,
10004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConvex_Convexity,
10104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        kConcave_Convexity
10204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    };
10304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
10404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
105b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Return the path's convexity, as stored in the path. If it is currently
106b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  unknown, and the computeIfUnknown bool is true, then this will first
107b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  call ComputeConvexity() and then return that (cached) value.
108b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     */
109b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexity() const {
110b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        if (kUnknown_Convexity == fConvexity) {
111b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com            fConvexity = (uint8_t)ComputeConvexity(*this);
112b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        }
113b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com        return (Convexity)fConvexity;
114b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    }
115b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com
116b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    /**
117b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Return the currently cached value for convexity, even if that is set to
118b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown_Convexity. Note: getConvexity() will automatically call
119b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  ComputeConvexity and cache its return value if the current setting is
120b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  kUnknown.
12104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
122b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; }
12304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
12404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
12504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Store a convexity setting in the path. There is no automatic check to
12604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  see if this value actually agress with the return value from
12704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  ComputeConvexity().
128b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *
129b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  Note: even if this is set to a "known" value, if the path is later
130b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  changed (e.g. lineTo(), addRect(), etc.) then the cached value will be
131b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  reset to kUnknown_Convexity.
13204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
13304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    void setConvexity(Convexity);
13404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
13504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
13604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Compute the convexity of the specified path. This does not look at the
13704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  value stored in the path, but computes it directly from the path's data.
13804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *
139b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  This never returns kUnknown_Convexity.
140b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *
14104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  If there is more than one contour, this returns kConcave_Convexity.
142b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  If the contour is degenerate (e.g. there are fewer than 3 non-degenerate
143b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com     *  segments), then this returns kConvex_Convexity.
14404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  The contour is treated as if it were closed, even if there is no kClose
14504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  verb.
1466b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
14704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    static Convexity ComputeConvexity(const SkPath&);
1486b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
14904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
15004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use getConvexity()
15104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Returns true if the path is flagged as being convex. This is not a
15204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  confirmed by any analysis, it is just the value set earlier.
15304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     */
15404863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    bool isConvex() const {
15504863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        return kConvex_Convexity == this->getConvexity();
15604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    }
15704863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com
15804863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com    /**
15904863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  DEPRECATED: use setConvexity()
16004863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  Set the isConvex flag to true or false. Convex paths may draw faster if
16104863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  this flag is set, though setting this to true on a path that is in fact
16204863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  not convex can give undefined results when drawn. Paths default to
16304863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com     *  isConvex == false
1646b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
165f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setIsConvex(bool isConvex) {
16604863fa14a44ddf85acbc6268690ebc3f0d1d6dbreed@google.com        this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
167f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    }
1686b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
1696aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    /** Returns true if the path is an oval.
1706aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *
1716aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     * @param rect      returns the bounding rect of this oval. It's a circle
1726aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *                  if the height and width are the same.
1736aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *
1746aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     * @return true if this path is an oval.
1756aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              Tracking whether a path is an oval is considered an
1766aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              optimization for performance and so some paths that are in
1776aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     *              fact ovals can report false.
1786aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com     */
1796aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    bool isOval(SkRect* rect) const;
1806aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Clear any lines and curves from the path, making it empty. This frees up
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        internal storage associated with those segments.
1836b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reset();
186fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Similar to reset(), in that all lines and curves are removed from the
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path. However, any internal storage for those lines/curves is retained,
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        making reuse of the path potentially faster.
1906b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rewind();
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path is empty (contains no lines or curves)
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path is empty (contains no lines or curves)
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isEmpty() const;
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2000bb18bb264b26afca45452910437c09445e23a3creed@google.com    /**
2010bb18bb264b26afca45452910437c09445e23a3creed@google.com     *  Returns true if all of the points in this path are finite, meaning there
2020bb18bb264b26afca45452910437c09445e23a3creed@google.com     *  are no infinities and no NaNs.
2030bb18bb264b26afca45452910437c09445e23a3creed@google.com     */
2040bb18bb264b26afca45452910437c09445e23a3creed@google.com    bool isFinite() const {
2050bb18bb264b26afca45452910437c09445e23a3creed@google.com        if (fBoundsIsDirty) {
2060bb18bb264b26afca45452910437c09445e23a3creed@google.com            this->computeBounds();
2070bb18bb264b26afca45452910437c09445e23a3creed@google.com        }
208fc91dc70042dcb6d2868e8822fbab15aa4402375robertphillips@google.com        return SkToBool(fIsFinite);
2090bb18bb264b26afca45452910437c09445e23a3creed@google.com    }
2100bb18bb264b26afca45452910437c09445e23a3creed@google.com
2114da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a line for zero length
2124da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2134da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the line is of zero length; otherwise false.
2144da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2154da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2) {
21694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2);
2174da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2184da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2194da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a quad for zero length
2204da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2214da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the quad is of zero length; otherwise false.
2224da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2234da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
2244da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                 const SkPoint& p3) {
22594fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2) &&
22694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p2.equalsWithinTolerance(p3);
2274da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2284da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2294da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    /** Test a cubic curve for zero length
2304da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2314da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        @return true if the cubic is of zero length; otherwise false.
2324da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    */
2334da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
2344da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org                                  const SkPoint& p3, const SkPoint& p4) {
23594fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com        return p1.equalsWithinTolerance(p2) &&
23694fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p2.equalsWithinTolerance(p3) &&
23794fa43c6255906660c2ff001fb462b6492cbdc07epoger@google.com               p3.equalsWithinTolerance(p4);
2384da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org    }
2394da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org
2407e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com    /**
2417e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  Returns true if the path specifies a single line (i.e. it contains just
2427e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  a moveTo and a lineTo). If so, and line[] is not null, it sets the 2
2437e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  points in line[] to the end-points of the line. If the path is not a
2447e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     *  line, returns false and ignores line[].
2457e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com     */
2467e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com    bool isLine(SkPoint line[2]) const;
2477e6c4d16010550ee148f1c79cf088c0320fed5c1reed@google.com
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path specifies a rectangle. If so, and if rect is
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        not null, set rect to the bounds of the path. If the path does not
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        specify a rectangle, return false and ignore rect.
251fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect If not null, returns the bounds of the path if it specifies
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    a rectangle
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path specifies a rectangle
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isRect(SkRect* rect) const;
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
258d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the number of points in the path
259d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
2601dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com    int countPoints() const;
261d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
262d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the point at the specified index. If the index is out of range
263d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         (i.e. is not 0 <= index < countPoints()) then the returned coordinates
264d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         will be (0,0)
265d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
266d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    SkPoint getPoint(int index) const;
267d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns the number of points in the path. Up to max points are copied.
269fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param points If not null, receives up to max points
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param max The maximum number of points to copy into points
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the actual number of points in the path
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getPoints(SkPoint points[], int max) const;
2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
276df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    /** Return the number of verbs in the path
277df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com     */
2781dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com    int countVerbs() const;
279df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com
280df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    /** Returns the number of verbs in the path. Up to max verbs are copied. The
281df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        verbs are copied as one byte per verb.
282fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
283df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @param verbs If not null, receives up to max verbs
284df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @param max The maximum number of verbs to copy into verbs
285df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com        @return the actual number of verbs in the path
286df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    */
287df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com    int getVerbs(uint8_t verbs[], int max) const;
288df9d656c352928f995abce0a62c4ec3255232a45bsalomon@google.com
2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //! Swap contents of this and other. Guaranteed not to throw
2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void swap(SkPath& other);
2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
292d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    /** Returns the bounds of the path's points. If the path contains 0 or 1
293d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
294d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        Note: this bounds may be larger than the actual shape, since curves
295d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        do not extend as far as their control points.
296d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    */
297d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    const SkRect& getBounds() const {
298d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        if (fBoundsIsDirty) {
299d252db03d9650013b545ef9781fe993c07f8f314reed@android.com            this->computeBounds();
300d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        }
301d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        return fBounds;
302d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Calling this will, if the internal cache of the bounds is out of date,
305d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        update it so that subsequent calls to getBounds will be instanteous.
3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        This also means that any copies or simple transformations of the path
3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        will inherit the cached bounds.
308d252db03d9650013b545ef9781fe993c07f8f314reed@android.com     */
309d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void updateBoundsCache() const {
310d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        // for now, just calling getBounds() is sufficient
311d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        this->getBounds();
312d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //  Construction methods
3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Hint to the path to prepare for adding more points. This can allow the
3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path to more efficiently grow its storage.
318fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param extraPtCount The number of extra points the path should
3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            preallocate for.
3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void incReserve(unsigned extraPtCount);
3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point (x,y).
325fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the start of a new contour
3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the start of a new contour
3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(SkScalar x, SkScalar y);
3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point
332fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The start of a new contour
3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(const SkPoint& p) {
3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->moveTo(p.fX, p.fY);
3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour relative to the last point on the
3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        previous contour. If there is no previous contour, this is treated the
3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        same as moveTo().
342fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the end of the
3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the end of the
3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rMoveTo(SkScalar dx, SkScalar dy);
3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point (x,y). If no
3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the end of a line
3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the end of a line
3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(SkScalar x, SkScalar y);
3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point. If no moveTo()
3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        call has been made for this contour, the first point is automatically
3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        set to (0,0).
3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The end of a line
3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(const SkPoint& p) {
3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->lineTo(p.fX, p.fY);
3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as lineTo, but the coordinates are considered relative to the last
3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
372fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the previous point
3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the previous point
3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rLineTo(SkScalar dx, SkScalar dy);
3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for
3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this contour, the first point is automatically set to (0,0).
383fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the control point on a quadratic curve
3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the control point on a quadratic curve
3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the end point on a quadratic curve
3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the end point on a quadratic curve
3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        p1, and ending at p2. If no moveTo() call has been made for this
3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
394fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The control point on a quadratic curve
3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The end point on a quadratic curve
3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(const SkPoint& p1, const SkPoint& p2) {
3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as quadTo, but the coordinates are considered relative to the last
4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points
4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been
4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        made for this contour, the first point is automatically set to (0,0).
420fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the 1st control point on a cubic curve
4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the 1st control point on a cubic curve
4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the 2nd control point on a cubic curve
4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the 2nd control point on a cubic curve
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x3   The x-coordinate of the end point on a cubic curve
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y3   The y-coordinate of the end point on a cubic curve
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 SkScalar x3, SkScalar y3);
4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points p1
4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and p2, and ending at p3. If no moveTo() call has been made for this
4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
434fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The 1st control point on a cubic curve
4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The 2nd control point on a cubic curve
4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p3   The end point on a cubic curve
4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as cubicTo, but the coordinates are considered relative to the
4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        current point on this contour. If there is no previous point, then a
4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(0,0) is inserted automatically.
446fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx3   The amount to add to the x-coordinate of the last point on
4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy3   The amount to add to the y-coordinate of the last point on
4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     SkScalar x3, SkScalar y3);
4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append the specified arc to the path as a new contour. If the start of
4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the path is different from the path's current last point, then an
4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatic lineTo() is added to connect the current contour to the start
4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        of the arc. However, if the path is empty, then we call moveTo() with
4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the first point of the arc. The sweep angle is treated mod 360.
468fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval defining the shape and size of the arc
4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise. This is
4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          treated mod 360.
4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param forceMoveTo If true, always begin a new contour with the arc
4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                  bool forceMoveTo);
4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com               SkScalar radius);
4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Close the current contour. If the current point is not equal to the
4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point of the contour, a line segment is automatically added.
4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void close();
4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Direction {
4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** clockwise direction for adding closed contours */
4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCW_Direction,
4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** counter-clockwise direction for adding closed contours */
5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCCW_Direction
5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
50369a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    /**
50469a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  Tries to quickly compute the direction of the first non-degenerate
50569a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  contour. If it can be computed, return true and set dir to that
50669a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  direction. If it cannot be (quickly) determined, return false and ignore
50769a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  the dir parameter.
50869a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     */
50969a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    bool cheapComputeDirection(Direction* dir) const;
51069a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com
51169a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    /**
51269a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  Returns true if the path's direction can be computed via
51369a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  cheapComputDirection() and if that computed direction matches the
51469a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     *  specified direction.
51569a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com     */
51669a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    bool cheapIsDirection(Direction dir) const {
51769a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com        Direction computedDir;
51869a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com        return this->cheapComputeDirection(&computedDir) && computedDir == dir;
51969a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com    }
52069a9943b67cc52c24beac853c6f8865dcb197b85reed@google.com
5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The rectangle to add as a closed contour to the path
5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the rectangle's contour
5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param left     The left side of a rectangle to add as a closed contour
5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param top      The top of a rectangle to add as a closed contour to the
5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param right    The right side of a rectangle to add as a closed contour
5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param bottom   The bottom of a rectangle to add as a closed contour to
5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        the path
5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the rectangle's contour
5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 Direction dir = kCW_Direction);
5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed oval contour to the path
5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval to add as a closed contour to the path
5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the oval's contour
5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addOval(const SkRect& oval, Direction dir = kCW_Direction);
5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed circle contour to the path
5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x        The x-coordinate of the center of a circle to add as a
5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y        The y-coordinate of the center of a circle to add as a
5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius of a circle to add as a closed contour to the
5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the circle's contour
5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addCircle(SkScalar x, SkScalar y, SkScalar radius,
5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                   Direction dir = kCW_Direction);
5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add the specified arc to the path as a new contour.
563fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounds of oval used to define the size of the arc
5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise
5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path
5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rx   The x-radius of the rounded corners on the round-rectangle
5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ry   The y-radius of the rounded corners on the round-rectangle
5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                         Direction dir = kCW_Direction);
5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path. Each corner receives
5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        two radius values [X, Y]. The corners are ordered top-left, top-right,
5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bottom-right, bottom-left.
5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radii Array of 8 scalars, 4 [X,Y] pairs for each corner
5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRoundRect(const SkRect& rect, const SkScalar radii[],
5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      Direction dir = kCW_Direction);
5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
589744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com    /**
590744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *  Add a new contour made of just lines. This is just a fast version of
591744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *  the following:
592744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      this->moveTo(pts[0]);
593744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      for (int i = 1; i < count; ++i) {
594744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *          this->lineTo(pts[i]);
595744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      }
596744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      if (close) {
597744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *          this->close();
598744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     *      }
599744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com     */
600744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com    void addPoly(const SkPoint pts[], int count, bool close);
601744fabad474e3e111e7cbd8609cf7e209df17f32reed@google.com
6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, offset by (dx,dy)
6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
6048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in X as it is added
6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in Y as it is added
6068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
60763d73749fbe36491403ea521005fd298dc70a94creed@google.com    void addPath(const SkPath& src, SkScalar dx, SkScalar dy);
6088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path
6108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src) {
6128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkMatrix m;
6138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        m.reset();
6148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->addPath(src, m);
6158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, transformed by matrix
6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src, const SkMatrix& matrix);
6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
62263d73749fbe36491403ea521005fd298dc70a94creed@google.com    /**
62363d73749fbe36491403ea521005fd298dc70a94creed@google.com     *  Same as addPath(), but reverses the src input
62463d73749fbe36491403ea521005fd298dc70a94creed@google.com     */
62563d73749fbe36491403ea521005fd298dc70a94creed@google.com    void reverseAddPath(const SkPath& src);
62663d73749fbe36491403ea521005fd298dc70a94creed@google.com
6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
628fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
629fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dx   The amount in the X direction to offset the entire path
630fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dy   The amount in the Y direction to offset the entire path
6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst  The translated path is written here
6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
636fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
637fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dx   The amount in the X direction to offset the entire path
638fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        @param dy   The amount in the Y direction to offset the entire path
6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy) {
6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->offset(dx, dy, this);
6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix, and write the answer into
6458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        dst.
646fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix   The matrix to apply to the path
6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst      The transformed path is written here
6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix, SkPath* dst) const;
6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix
6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix The matrix to apply to the path
6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix) {
6578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->transform(matrix, this);
6588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the last point on the path. If no points have been added, (0,0)
661294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        is returned. If there are no points, this returns false, otherwise it
662294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com        returns true.
663fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param lastPt   The last point on the path is returned here
6658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
666294dd7b3d7b55ba38881cd4cabb6636abda23eb9reed@google.com    bool getLastPt(SkPoint* lastPt) const;
6678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added,
6698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(x,y) is automatically called.
670fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The new x-coordinate for the last point
6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The new y-coordinate for the last point
6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(SkScalar x, SkScalar y);
6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added, moveTo(p)
6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is automatically called.
6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The new location for the last point
6808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(const SkPoint& p) {
6828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->setLastPt(p.fX, p.fY);
6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
6848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
68510296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    enum SegmentMask {
68610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kLine_SegmentMask   = 1 << 0,
68710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kQuad_SegmentMask   = 1 << 1,
68810296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com        kCubic_SegmentMask  = 1 << 2
68910296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    };
69010296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
69110296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    /**
69210296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns a mask, where each bit corresponding to a SegmentMask is
69310296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  set if the path contains 1 or more segments of that type.
69410296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     *  Returns 0 for an empty path (no segments).
69510296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com     */
69610296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint32_t getSegmentMasks() const { return fSegmentMask; }
69710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com
6988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Verb {
6998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMove_Verb,     //!< iter.next returns 1 point
7008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLine_Verb,     //!< iter.next returns 2 points
7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kQuad_Verb,     //!< iter.next returns 3 points
7028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCubic_Verb,    //!< iter.next returns 4 points
703b3b8dfa31326c51dab8b5ed569e19ee715582d1bbsalomon@google.com        kClose_Verb,    //!< iter.next returns 1 point (contour's moveTo pt)
7048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDone_Verb      //!< iter.next returns 0 points
7058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
7068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Iterate through all of the segments (lines, quadratics, cubics) of
7088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        each contours in a path.
70972785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org
71072785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        The iterator cleans up the segments along the way, removing degenerate
71172785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        segments and adding close verbs where necessary. When the forceClose
71272785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        argument is provided, each contour (as defined by a new starting
71372785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        move command) will be completed with a close verb regardless of the
71472785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        contour's contents.
7158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7167ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org    class SK_API Iter {
7178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    public:
71872785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter();
71972785c4c8928a8b0fc5bbdb48929f9356554daceschenney@chromium.org        Iter(const SkPath&, bool forceClose);
7208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void setPath(const SkPath&, bool forceClose);
7228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Return the next verb in this iteration of the path. When all
7248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            segments have been visited, return kDone_Verb.
725b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @param  pts The points representing the current verb and/or segment
7274a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            @param doConsumeDegerates If true, first scan for segments that are
7284a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com                   deemed degenerate (too short) and skip those.
7298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return The verb for the current segment
7308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7314a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        Verb next(SkPoint pts[4], bool doConsumeDegerates = true) {
7324a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            if (doConsumeDegerates) {
7334a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com                this->consumeDegenerateSegments();
7344a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            }
7354a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com            return this->doNext(pts);
7364a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        }
7378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** If next() returns kLine_Verb, then this query returns true if the
7398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            line was the result of a close() command (i.e. the end point is the
7408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            initial moveto for this contour). If next() returned a different
7418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            verb, this returns an undefined value.
742b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return If the last call to next() returned kLine_Verb, return true
7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    if it was the result of an explicit close command.
7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isCloseLine() const { return SkToBool(fCloseLine); }
747b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org
7488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Returns true if the current contour is closed (has a kClose_Verb)
7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return true if the current contour is closed (has a kClose_Verb)
7508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isClosedContour() const;
7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    private:
7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkPoint*  fPts;
7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbs;
7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbStop;
7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fMoveTo;
7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fLastPt;
7598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fForceClose;
7608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fNeedClose;
7618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fCloseLine;
762b0af6dad94f3c51ea0d5d6426a9509354338c6b2schenney@chromium.org        SkBool8         fSegmentState;
7638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7649e25dbf589539dd44244bc2581590bd7591e17a2reed@google.com        inline const SkPoint& cons_moveTo();
7658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb autoClose(SkPoint pts[2]);
7664da06ab3351f2a96f9216d96106db33a77b19644schenney@chromium.org        void consumeDegenerateSegments();
7674a3b714d73e585a3985d614600c6b79d5c8b1f1ereed@google.com        Verb doNext(SkPoint pts[4]);
7688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
7698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7706630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    /** Iterate through the verbs in the path, providing the associated points.
7716630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    */
7726630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    class SK_API RawIter {
7736630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    public:
7746630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter();
7756630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        RawIter(const SkPath&);
7766630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7776630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        void setPath(const SkPath&);
7786630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7796630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        /** Return the next verb in this iteration of the path. When all
7806630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            segments have been visited, return kDone_Verb.
781fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
7826630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @param  pts The points representing the current verb and/or segment
783f6d3c5aa5f93e4c3cc7a7aebf014e960cf837783bsalomon@google.com                        This must not be NULL.
7846630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org            @return The verb for the current segment
7856630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        */
7866630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        Verb next(SkPoint pts[4]);
7876630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
7886630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    private:
7896630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const SkPoint*  fPts;
7906630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbs;
7916630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        const uint8_t*  fVerbStop;
7926630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fMoveTo;
7936630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org        SkPoint         fLastPt;
7946630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org    };
7956630d8d8ea7a897a18e3d950bab9fa40f065804aschenney@chromium.org
796bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org    /**
797bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     *  Returns true if the point { x, y } is contained by the path, taking into
798bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     *  account the FillType.
799bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org     */
800bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org    bool contains(SkScalar x, SkScalar y) const;
801bad1b2ff1d34ff86693b776f89d7b46995746127mike@reedtribe.org
8028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void dump(bool forceClose, const char title[] = NULL) const;
803e522ca5d5f249bd51a00cb68bb051f811d0a9e85reed@android.com    void dump() const;
8048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
80594e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    /**
80694e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  Write the region to the buffer, and return the number of bytes written.
80794e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  If buffer is NULL, it still returns the number of bytes.
80894e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     */
80994e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    uint32_t writeToMemory(void* buffer) const;
81094e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    /**
81194e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  Initialized the region from the buffer, returning the number
81294e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     *  of bytes actually read.
81394e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com     */
81494e75ee46a569cbcdf61fb7f04ee3a69d3ca0896djsollen@google.com    uint32_t readFromMemory(const void* buffer);
8158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
81656c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
817f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t getGenerationID() const;
818e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    const SkPath* getSourcePath() const;
819e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    void setSourcePath(const SkPath* path);
820f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
821f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
8228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDEBUGCODE(void validate() const;)
8238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
82501ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com    enum SerializationOffsets {
82601ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com        kIsFinite_SerializationShift = 25,
82701ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com        kIsOval_SerializationShift = 24,
828607d08b7db477ae11dbafff0bbebaa91f5c9fd7absalomon@google.com        kConvexity_SerializationShift = 16,
829607d08b7db477ae11dbafff0bbebaa91f5c9fd7absalomon@google.com        kFillType_SerializationShift = 8,
83001ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com        kSegmentMask_SerializationShift = 0
83101ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com    };
83201ec2eb42e9c64f8d06afd51f80c055710147141robertphillips@google.com
8331dfe88e00aeddf20690fd2469fd17e43f670ee3absalomon@google.com    SkAutoTUnref<SkPathRef>   fPathRef;
834d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    mutable SkRect      fBounds;
835d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    int                 fLastMoveToIndex;
8368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t             fFillType;
83710296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    uint8_t             fSegmentMask;
83810296ccb6a63c65b2e60733a929bf15d8bf94309reed@google.com    mutable uint8_t     fBoundsIsDirty;
839b54455e440e66e0b1c30954d226226f49aac26d6reed@google.com    mutable uint8_t     fConvexity;
8400bb18bb264b26afca45452910437c09445e23a3creed@google.com    mutable SkBool8     fIsFinite;    // only meaningful if bounds are valid
8416aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    mutable SkBool8     fIsOval;
84256c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
843f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t            fGenerationID;
844e63793a2c8d2871bf7d95195be7b93ff669688d7djsollen@google.com    const SkPath*       fSourcePath;
845f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
8468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
847d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    // called, if dirty, by getBounds()
848d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void computeBounds() const;
849d252db03d9650013b545ef9781fe993c07f8f314reed@android.com
8508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class Iter;
8518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkPathStroker;
8538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append the first contour of path, ignoring path's initial point. If no
8548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
8558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
8568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void pathTo(const SkPath& path);
8588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append, in reverse order, the first contour of path, ignoring path's
8608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        last point. If no moveTo() call has been made for this contour, the
8618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point is automatically set to (0,0).
8628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reversePathTo(const SkPath&);
8648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
865d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // called before we add points for lineTo, quadTo, cubicTo, checking to see
866d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // if we need to inject a leading moveTo first
867d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //
868d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //  SkPath path; path.lineTo(...);   <--- need a leading moveTo(0, 0)
869d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
870d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    //
871d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com    inline void injectMoveToIfNeeded();
872d335d1d784167f8b9a4bf8a35e04d8e82d0a9507reed@google.com
8736aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    inline bool hasOnlyMoveTos() const;
8746aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com
8758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkAutoPathBoundsUpdate;
8766aa2965ca814dd3329b65398b5c5af980e54b101bsalomon@google.com    friend class SkAutoDisableOvalCheck;
87730e6d2c2054c15f1cb6c0637bee6756261291751bsalomon@google.com    friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
8788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
8798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
881