SkPath.h revision d3aa4ff7a564953dff9a15ff03fd42eebf64569f
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Copyright (C) 2006 The Android Open Source Project
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Licensed under the Apache License, Version 2.0 (the "License");
58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * you may not use this file except in compliance with the License.
68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * You may obtain a copy of the License at
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *      http://www.apache.org/licenses/LICENSE-2.0
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Unless required by applicable law or agreed to in writing, software
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * distributed under the License is distributed on an "AS IS" BASIS,
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * See the License for the specific language governing permissions and
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * limitations under the License.
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPath_DEFINED
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPath_DEFINED
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMatrix.h"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTDArray.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkFlattenableReadBuffer;
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkFlattenableWriteBuffer;
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoPathBoundsUpdate;
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkString;
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPath
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    The SkPath class encapsulates compound (multiple contour) geometric paths
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    consisting of straight line segments, quadratic curves, and cubic curves.
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath {
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath();
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath(const SkPath&);
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ~SkPath();
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath& operator=(const SkPath&);
403abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com
413abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator==(const SkPath&, const SkPath&);
423abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    friend bool operator!=(const SkPath& a, const SkPath& b) {
433abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com        return !(a == b);
443abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com    }
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum FillType {
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by a non-zero sum of signed
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            edge crossings
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kWinding_FillType,
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Specifies that "inside" is computed by an odd number of edge
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            crossings
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kEvenOdd_FillType,
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as Winding, but draws outside of the path, rather than inside
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseWinding_FillType,
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Same as EvenOdd, but draws outside of the path, rather than inside
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com         */
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInverseEvenOdd_FillType
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the path's fill type. This is used to define how "inside" is
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the path's fill type
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    FillType getFillType() const { return (FillType)fFillType; }
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the path's fill type. This is used to define how "inside" is
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        computed. The default value is kWinding_FillType.
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ft The new fill type for this path
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setFillType(FillType ft) { fFillType = SkToU8(ft); }
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the filltype is one of the Inverse variants */
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isInverseFillType() const { return (fFillType & 2) != 0; }
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Toggle between inverse and normal filltypes. This reverse the return
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        value of isInverseFillType()
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void toggleInverseFillType() { fFillType ^= 2; }
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
856b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com    /** Returns true if the path is flagged as being convex. This is not a
866b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        confirmed by any analysis, it is just the value set earlier.
876b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
8881aaa9d8c097f6c5116a85ba6abbd8b3bdab4019deanm@chromium.org    bool isConvex() const { return fIsConvex != 0; }
896b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
906b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com    /** Set the isConvex flag to true or false. Convex paths may draw faster if
916b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        this flag is set, though setting this to true on a path that is in fact
926b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        not convex can give undefined results when drawn. Paths default to
936b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        isConvex == false
946b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com     */
956b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com    void setIsConvex(bool isConvex) { fIsConvex = (isConvex != 0); }
966b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Clear any lines and curves from the path, making it empty. This frees up
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        internal storage associated with those segments.
996b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reset();
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Similar to reset(), in that all lines and curves are removed from the
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path. However, any internal storage for those lines/curves is retained,
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        making reuse of the path potentially faster.
1066b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com        This does NOT change the fill-type setting nor isConvex
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rewind();
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path is empty (contains no lines or curves)
1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path is empty (contains no lines or curves)
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isEmpty() const;
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns true if the path specifies a rectangle. If so, and if rect is
1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        not null, set rect to the bounds of the path. If the path does not
1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        specify a rectangle, return false and ignore rect.
1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect If not null, returns the bounds of the path if it specifies
1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    a rectangle
1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the path specifies a rectangle
1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool isRect(SkRect* rect) const;
1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
126d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the number of points in the path
127d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
128d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    int countPoints() const {
129d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com        return this->getPoints(NULL, 0);
130d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    }
131d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
132d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    /** Return the point at the specified index. If the index is out of range
133d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         (i.e. is not 0 <= index < countPoints()) then the returned coordinates
134d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com         will be (0,0)
135d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com     */
136d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com    SkPoint getPoint(int index) const;
137d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com
1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Returns the number of points in the path. Up to max points are copied.
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param points If not null, receives up to max points
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param max The maximum number of points to copy into points
1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the actual number of points in the path
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getPoints(SkPoint points[], int max) const;
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //! Swap contents of this and other. Guaranteed not to throw
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void swap(SkPath& other);
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
149d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    /** Returns the bounds of the path's points. If the path contains 0 or 1
150d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
151d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        Note: this bounds may be larger than the actual shape, since curves
152d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        do not extend as far as their control points.
153d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    */
154d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    const SkRect& getBounds() const {
155d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        if (fBoundsIsDirty) {
156d252db03d9650013b545ef9781fe993c07f8f314reed@android.com            this->computeBounds();
157d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        }
158d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        return fBounds;
159d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Calling this will, if the internal cache of the bounds is out of date,
162d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        update it so that subsequent calls to getBounds will be instanteous.
1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        This also means that any copies or simple transformations of the path
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        will inherit the cached bounds.
165d252db03d9650013b545ef9781fe993c07f8f314reed@android.com     */
166d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void updateBoundsCache() const {
167d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        // for now, just calling getBounds() is sufficient
168d252db03d9650013b545ef9781fe993c07f8f314reed@android.com        this->getBounds();
169d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    }
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //  Construction methods
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Hint to the path to prepare for adding more points. This can allow the
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        path to more efficiently grow its storage.
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param extraPtCount The number of extra points the path should
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            preallocate for.
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void incReserve(unsigned extraPtCount);
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point (x,y).
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the start of a new contour
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the start of a new contour
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(SkScalar x, SkScalar y);
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour to the point
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The start of a new contour
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void moveTo(const SkPoint& p) {
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->moveTo(p.fX, p.fY);
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the beginning of the next contour relative to the last point on the
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        previous contour. If there is no previous contour, this is treated the
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        same as moveTo().
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the end of the
2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the end of the
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    previous contour, to specify the start of a new contour
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rMoveTo(SkScalar dx, SkScalar dy);
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point (x,y). If no
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The x-coordinate of the end of a line
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The y-coordinate of the end of a line
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(SkScalar x, SkScalar y);
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a line from the last point to the specified point. If no moveTo()
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        call has been made for this contour, the first point is automatically
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        set to (0,0).
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The end of a line
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void lineTo(const SkPoint& p) {
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->lineTo(p.fX, p.fY);
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as lineTo, but the coordinates are considered relative to the last
2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to add to the x-coordinate of the previous point
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount to add to the y-coordinate of the previous point
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    on this contour, to specify a line
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rLineTo(SkScalar dx, SkScalar dy);
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this contour, the first point is automatically set to (0,0).
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the control point on a quadratic curve
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the control point on a quadratic curve
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the end point on a quadratic curve
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the end point on a quadratic curve
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a quadratic bezier from the last point, approaching control point
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        p1, and ending at p2. If no moveTo() call has been made for this
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The control point on a quadratic curve
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The end point on a quadratic curve
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void quadTo(const SkPoint& p1, const SkPoint& p2) {
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as quadTo, but the coordinates are considered relative to the last
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        point on this contour. If there is no previous point, then a moveTo(0,0)
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is inserted automatically.
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the control point of a quadratic curve
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a quadratic curve
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points
2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been
2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        made for this contour, the first point is automatically set to (0,0).
2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x1   The x-coordinate of the 1st control point on a cubic curve
2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y1   The y-coordinate of the 1st control point on a cubic curve
2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x2   The x-coordinate of the 2nd control point on a cubic curve
2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y2   The y-coordinate of the 2nd control point on a cubic curve
2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x3   The x-coordinate of the end point on a cubic curve
2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y3   The y-coordinate of the end point on a cubic curve
2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 SkScalar x3, SkScalar y3);
2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a cubic bezier from the last point, approaching control points p1
2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and p2, and ending at p3. If no moveTo() call has been made for this
2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour, the first point is automatically set to (0,0).
2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p1   The 1st control point on a cubic curve
2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p2   The 2nd control point on a cubic curve
2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p3   The end point on a cubic curve
2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Same as cubicTo, but the coordinates are considered relative to the
3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        current point on this contour. If there is no previous point, then a
3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(0,0) is inserted automatically.
3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx1   The amount to add to the x-coordinate of the last point on
3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy1   The amount to add to the y-coordinate of the last point on
3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 1st control point of a cubic curve
3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx2   The amount to add to the x-coordinate of the last point on
3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy2   The amount to add to the y-coordinate of the last point on
3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                this contour, to specify the 2nd control point of a cubic curve
3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx3   The amount to add to the x-coordinate of the last point on
3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy3   The amount to add to the y-coordinate of the last point on
3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     this contour, to specify the end point of a cubic curve
3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     SkScalar x3, SkScalar y3);
3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append the specified arc to the path as a new contour. If the start of
3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the path is different from the path's current last point, then an
3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatic lineTo() is added to connect the current contour to the start
3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        of the arc. However, if the path is empty, then we call moveTo() with
3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the first point of the arc. The sweep angle is treated mod 360.
3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval defining the shape and size of the arc
3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise. This is
3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          treated mod 360.
3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param forceMoveTo If true, always begin a new contour with the arc
3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                  bool forceMoveTo);
3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com               SkScalar radius);
3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Append a line and arc to the current path. This is the same as the
3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        PostScript call "arct".
3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Close the current contour. If the current point is not equal to the
3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point of the contour, a line segment is automatically added.
3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void close();
3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Direction {
3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** clockwise direction for adding closed contours */
3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCW_Direction,
3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** counter-clockwise direction for adding closed contours */
3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCCW_Direction
3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The rectangle to add as a closed contour to the path
3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the rectangle's contour
3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed rectangle contour to the path
3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param left     The left side of a rectangle to add as a closed contour
3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param top      The top of a rectangle to add as a closed contour to the
3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param right    The right side of a rectangle to add as a closed contour
3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        to the path
3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param bottom   The bottom of a rectangle to add as a closed contour to
3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        the path
3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the rectangle's contour
3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                 Direction dir = kCW_Direction);
3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed oval contour to the path
3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounding oval to add as a closed contour to the path
3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the oval's contour
3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addOval(const SkRect& oval, Direction dir = kCW_Direction);
3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed circle contour to the path
3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x        The x-coordinate of the center of a circle to add as a
3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y        The y-coordinate of the center of a circle to add as a
3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        closed contour to the path
3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius of a circle to add as a closed contour to the
3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        path
3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir      The direction to wind the circle's contour
3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addCircle(SkScalar x, SkScalar y, SkScalar radius,
3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                   Direction dir = kCW_Direction);
4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add the specified arc to the path as a new contour.
4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param oval The bounds of oval used to define the size of the arc
4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param startAngle Starting angle (in degrees) where the arc begins
4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param sweepAngle Sweep angle (in degrees) measured clockwise
4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path
4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rx   The x-radius of the rounded corners on the round-rectangle
4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ry   The y-radius of the rounded corners on the round-rectangle
4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                         Direction dir = kCW_Direction);
4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a closed round-rectangle contour to the path. Each corner receives
4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        two radius values [X, Y]. The corners are ordered top-left, top-right,
4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bottom-right, bottom-left.
4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rect The bounds of a round-rectangle to add as a closed contour
4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radii Array of 8 scalars, 4 [X,Y] pairs for each corner
4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dir  The direction to wind the round-rectangle's contour
4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addRoundRect(const SkRect& rect, const SkScalar radii[],
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      Direction dir = kCW_Direction);
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, offset by (dx,dy)
4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in X as it is added
4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount to translate the path in Y as it is added
4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    addPath(const SkPath& src, SkScalar dx, SkScalar dy);
4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path
4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src) {
4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkMatrix m;
4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        m.reset();
4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->addPath(src, m);
4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Add a copy of src to the path, transformed by matrix
4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param src  The path to add as a new contour
4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void addPath(const SkPath& src, const SkMatrix& matrix);
4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount in the X direction to offset the entire path
4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount in the Y direction to offset the entire path
4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst  The translated path is written here
4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Offset the path by (dx,dy), returning true on success
4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dx   The amount in the X direction to offset the entire path
4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dy   The amount in the Y direction to offset the entire path
4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void offset(SkScalar dx, SkScalar dy) {
4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->offset(dx, dy, this);
4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix, and write the answer into
4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        dst.
4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix   The matrix to apply to the path
4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dst      The transformed path is written here
4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix, SkPath* dst) const;
4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Transform the points in this path by matrix
4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param matrix The matrix to apply to the path
4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void transform(const SkMatrix& matrix) {
4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->transform(matrix, this);
4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the last point on the path. If no points have been added, (0,0)
4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is returned.
4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param lastPt   The last point on the path is returned here
4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void getLastPt(SkPoint* lastPt) const;
4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added,
4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo(x,y) is automatically called.
4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param x    The new x-coordinate for the last point
4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param y    The new y-coordinate for the last point
4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(SkScalar x, SkScalar y);
4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the last point on the path. If no points have been added, moveTo(p)
4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is automatically called.
4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param p    The new location for the last point
5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLastPt(const SkPoint& p) {
5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        this->setLastPt(p.fX, p.fY);
5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Verb {
5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMove_Verb,     //!< iter.next returns 1 point
5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLine_Verb,     //!< iter.next returns 2 points
5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kQuad_Verb,     //!< iter.next returns 3 points
5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCubic_Verb,    //!< iter.next returns 4 points
5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kClose_Verb,    //!< iter.next returns 1 point (the last point)
5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDone_Verb      //!< iter.next returns 0 points
5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Iterate through all of the segments (lines, quadratics, cubics) of
5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        each contours in a path.
5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    class Iter {
5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    public:
5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                Iter();
5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                Iter(const SkPath&, bool forceClose);
5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        void setPath(const SkPath&, bool forceClose);
5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Return the next verb in this iteration of the path. When all
5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            segments have been visited, return kDone_Verb.
5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @param  pts The points representing the current verb and/or segment
5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return The verb for the current segment
5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb next(SkPoint pts[4]);
5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** If next() returns kLine_Verb, then this query returns true if the
5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            line was the result of a close() command (i.e. the end point is the
5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            initial moveto for this contour). If next() returned a different
5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            verb, this returns an undefined value.
5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return If the last call to next() returned kLine_Verb, return true
5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    if it was the result of an explicit close command.
5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isCloseLine() const { return SkToBool(fCloseLine); }
5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** Returns true if the current contour is closed (has a kClose_Verb)
5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            @return true if the current contour is closed (has a kClose_Verb)
5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isClosedContour() const;
5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    private:
5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const SkPoint*  fPts;
5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbs;
5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        const uint8_t*  fVerbStop;
5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fMoveTo;
5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkPoint         fLastPt;
5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fForceClose;
5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fNeedClose;
5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fNeedMoveTo;
5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkBool8         fCloseLine;
5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool cons_moveTo(SkPoint pts[1]);
5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Verb autoClose(SkPoint pts[2]);
5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void dump(bool forceClose, const char title[] = NULL) const;
563e522ca5d5f249bd51a00cb68bb051f811d0a9e85reed@android.com    void dump() const;
5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void flatten(SkFlattenableWriteBuffer&) const;
5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void unflatten(SkFlattenableReadBuffer&);
5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Subdivide the path so that no segment is longer that dist.
5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If bendLines is true, then turn all line segments into curves.
5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If dst == null, then the original path itself is modified (not const!)
5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void subdivide(SkScalar dist, bool bendLines, SkPath* dst = NULL) const;
5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDEBUGCODE(void validate() const;)
5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTDArray<SkPoint>  fPts;
5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTDArray<uint8_t>  fVerbs;
579d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    mutable SkRect      fBounds;
580d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    mutable uint8_t     fBoundsIsDirty;
5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t             fFillType;
5826b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com    uint8_t             fIsConvex;
5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
584d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    // called, if dirty, by getBounds()
585d252db03d9650013b545ef9781fe993c07f8f314reed@android.com    void computeBounds() const;
586d252db03d9650013b545ef9781fe993c07f8f314reed@android.com
5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class Iter;
5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void cons_moveto();
5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkPathStroker;
5918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append the first contour of path, ignoring path's initial point. If no
5928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        moveTo() call has been made for this contour, the first point is
5938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        automatically set to (0,0).
5948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void pathTo(const SkPath& path);
5968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /*  Append, in reverse order, the first contour of path, ignoring path's
5988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        last point. If no moveTo() call has been made for this contour, the
5998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        first point is automatically set to (0,0).
6008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reversePathTo(const SkPath&);
6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend const SkPoint* sk_get_path_points(const SkPath&, int index);
6048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkAutoPathBoundsUpdate;
6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
6068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
6088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
609