SkPath.h revision f5dbe2f00f853c6a1719924bdd0c33335a53423a
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 23f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#ifdef ANDROID 24f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC fGenerationID++ 25f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr) ptr->fGenerationID++ 26f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#else 27f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_INC 28f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#define GEN_ID_PTR_INC(ptr) 29f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif 30f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkFlattenableReadBuffer; 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkFlattenableWriteBuffer; 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoPathBoundsUpdate; 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkString; 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPath 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The SkPath class encapsulates compound (multiple contour) geometric paths 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com consisting of straight line segments, quadratic curves, and cubic curves. 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 417ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPath { 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPath(); 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPath(const SkPath&); 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~SkPath(); 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPath& operator=(const SkPath&); 483abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com 493abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com friend bool operator==(const SkPath&, const SkPath&); 503abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com friend bool operator!=(const SkPath& a, const SkPath& b) { 513abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com return !(a == b); 523abec1d7c38e9bd786fc6057f9608f3eeec98c86reed@android.com } 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum FillType { 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Specifies that "inside" is computed by a non-zero sum of signed 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com edge crossings 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kWinding_FillType, 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Specifies that "inside" is computed by an odd number of edge 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com crossings 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kEvenOdd_FillType, 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Same as Winding, but draws outside of the path, rather than inside 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kInverseWinding_FillType, 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Same as EvenOdd, but draws outside of the path, rather than inside 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kInverseEvenOdd_FillType 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the path's fill type. This is used to define how "inside" is 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com computed. The default value is kWinding_FillType. 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the path's fill type 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com FillType getFillType() const { return (FillType)fFillType; } 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the path's fill type. This is used to define how "inside" is 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com computed. The default value is kWinding_FillType. 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ft The new fill type for this path 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 83f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com void setFillType(FillType ft) { 84f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com fFillType = SkToU8(ft); 85f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com GEN_ID_INC; 86f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com } 878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the filltype is one of the Inverse variants */ 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isInverseFillType() const { return (fFillType & 2) != 0; } 908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Toggle between inverse and normal filltypes. This reverse the return 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com value of isInverseFillType() 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 94f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com void toggleInverseFillType() { 95f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com fFillType ^= 2; 96f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com GEN_ID_INC; 97f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com } 988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 996b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com /** Returns true if the path is flagged as being convex. This is not a 1006b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com confirmed by any analysis, it is just the value set earlier. 1016b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com */ 10281aaa9d8c097f6c5116a85ba6abbd8b3bdab4019deanm@chromium.org bool isConvex() const { return fIsConvex != 0; } 1036b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com 1046b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com /** Set the isConvex flag to true or false. Convex paths may draw faster if 1056b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com this flag is set, though setting this to true on a path that is in fact 1066b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com not convex can give undefined results when drawn. Paths default to 1076b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com isConvex == false 1086b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com */ 109f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com void setIsConvex(bool isConvex) { 110f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com fIsConvex = (isConvex != 0); 111f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com GEN_ID_INC; 112f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com } 1136b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Clear any lines and curves from the path, making it empty. This frees up 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com internal storage associated with those segments. 1166b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com This does NOT change the fill-type setting nor isConvex 1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void reset(); 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Similar to reset(), in that all lines and curves are removed from the 1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path. However, any internal storage for those lines/curves is retained, 1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com making reuse of the path potentially faster. 1236b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com This does NOT change the fill-type setting nor isConvex 1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void rewind(); 1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the path is empty (contains no lines or curves) 1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the path is empty (contains no lines or curves) 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isEmpty() const; 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the path specifies a rectangle. If so, and if rect is 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com not null, set rect to the bounds of the path. If the path does not 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specify a rectangle, return false and ignore rect. 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect If not null, returns the bounds of the path if it specifies 1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com a rectangle 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the path specifies a rectangle 1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isRect(SkRect* rect) const; 1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 143d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com /** Return the number of points in the path 144d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com */ 145d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com int countPoints() const { 146d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com return this->getPoints(NULL, 0); 147d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com } 148d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com 149d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com /** Return the point at the specified index. If the index is out of range 150d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com (i.e. is not 0 <= index < countPoints()) then the returned coordinates 151d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com will be (0,0) 152d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com */ 153d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com SkPoint getPoint(int index) const; 154d3aa4ff7a564953dff9a15ff03fd42eebf64569freed@android.com 1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the number of points in the path. Up to max points are copied. 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param points If not null, receives up to max points 1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param max The maximum number of points to copy into points 1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the actual number of points in the path 1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int getPoints(SkPoint points[], int max) const; 1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com //! Swap contents of this and other. Guaranteed not to throw 1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void swap(SkPath& other); 1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 166d252db03d9650013b545ef9781fe993c07f8f314reed@android.com /** Returns the bounds of the path's points. If the path contains 0 or 1 167d252db03d9650013b545ef9781fe993c07f8f314reed@android.com points, the bounds is set to (0,0,0,0), and isEmpty() will return true. 168d252db03d9650013b545ef9781fe993c07f8f314reed@android.com Note: this bounds may be larger than the actual shape, since curves 169d252db03d9650013b545ef9781fe993c07f8f314reed@android.com do not extend as far as their control points. 170d252db03d9650013b545ef9781fe993c07f8f314reed@android.com */ 171d252db03d9650013b545ef9781fe993c07f8f314reed@android.com const SkRect& getBounds() const { 172d252db03d9650013b545ef9781fe993c07f8f314reed@android.com if (fBoundsIsDirty) { 173d252db03d9650013b545ef9781fe993c07f8f314reed@android.com this->computeBounds(); 174d252db03d9650013b545ef9781fe993c07f8f314reed@android.com } 175d252db03d9650013b545ef9781fe993c07f8f314reed@android.com return fBounds; 176d252db03d9650013b545ef9781fe993c07f8f314reed@android.com } 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Calling this will, if the internal cache of the bounds is out of date, 179d252db03d9650013b545ef9781fe993c07f8f314reed@android.com update it so that subsequent calls to getBounds will be instanteous. 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This also means that any copies or simple transformations of the path 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will inherit the cached bounds. 182d252db03d9650013b545ef9781fe993c07f8f314reed@android.com */ 183d252db03d9650013b545ef9781fe993c07f8f314reed@android.com void updateBoundsCache() const { 184d252db03d9650013b545ef9781fe993c07f8f314reed@android.com // for now, just calling getBounds() is sufficient 185d252db03d9650013b545ef9781fe993c07f8f314reed@android.com this->getBounds(); 186d252db03d9650013b545ef9781fe993c07f8f314reed@android.com } 1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // Construction methods 1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Hint to the path to prepare for adding more points. This can allow the 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path to more efficiently grow its storage. 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param extraPtCount The number of extra points the path should 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com preallocate for. 1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void incReserve(unsigned extraPtCount); 1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the beginning of the next contour to the point (x,y). 1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-coordinate of the start of a new contour 2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-coordinate of the start of a new contour 2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void moveTo(SkScalar x, SkScalar y); 2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the beginning of the next contour to the point 2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p The start of a new contour 2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void moveTo(const SkPoint& p) { 2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->moveTo(p.fX, p.fY); 2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the beginning of the next contour relative to the last point on the 2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com previous contour. If there is no previous contour, this is treated the 2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com same as moveTo(). 2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount to add to the x-coordinate of the end of the 2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com previous contour, to specify the start of a new contour 2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The amount to add to the y-coordinate of the end of the 2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com previous contour, to specify the start of a new contour 2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void rMoveTo(SkScalar dx, SkScalar dy); 2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a line from the last point to the specified point (x,y). If no 2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com moveTo() call has been made for this contour, the first point is 2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com automatically set to (0,0). 2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-coordinate of the end of a line 2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-coordinate of the end of a line 2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void lineTo(SkScalar x, SkScalar y); 2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a line from the last point to the specified point. If no moveTo() 2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com call has been made for this contour, the first point is automatically 2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com set to (0,0). 2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p The end of a line 2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void lineTo(const SkPoint& p) { 2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->lineTo(p.fX, p.fY); 2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Same as lineTo, but the coordinates are considered relative to the last 2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com point on this contour. If there is no previous point, then a moveTo(0,0) 2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is inserted automatically. 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount to add to the x-coordinate of the previous point 2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com on this contour, to specify a line 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The amount to add to the y-coordinate of the previous point 2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com on this contour, to specify a line 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void rLineTo(SkScalar dx, SkScalar dy); 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a quadratic bezier from the last point, approaching control point 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for 2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, the first point is automatically set to (0,0). 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x1 The x-coordinate of the control point on a quadratic curve 2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y1 The y-coordinate of the control point on a quadratic curve 2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x2 The x-coordinate of the end point on a quadratic curve 2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y2 The y-coordinate of the end point on a quadratic curve 2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2); 2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a quadratic bezier from the last point, approaching control point 2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com p1, and ending at p2. If no moveTo() call has been made for this 2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contour, the first point is automatically set to (0,0). 2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p1 The control point on a quadratic curve 2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p2 The end point on a quadratic curve 2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void quadTo(const SkPoint& p1, const SkPoint& p2) { 2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY); 2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Same as quadTo, but the coordinates are considered relative to the last 2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com point on this contour. If there is no previous point, then a moveTo(0,0) 2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is inserted automatically. 2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx1 The amount to add to the x-coordinate of the last point on 2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the control point of a quadratic curve 2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy1 The amount to add to the y-coordinate of the last point on 2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the control point of a quadratic curve 2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx2 The amount to add to the x-coordinate of the last point on 2858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the end point of a quadratic curve 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy2 The amount to add to the y-coordinate of the last point on 2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the end point of a quadratic curve 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2); 2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a cubic bezier from the last point, approaching control points 2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been 2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com made for this contour, the first point is automatically set to (0,0). 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x1 The x-coordinate of the 1st control point on a cubic curve 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y1 The y-coordinate of the 1st control point on a cubic curve 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x2 The x-coordinate of the 2nd control point on a cubic curve 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y2 The y-coordinate of the 2nd control point on a cubic curve 2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x3 The x-coordinate of the end point on a cubic curve 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y3 The y-coordinate of the end point on a cubic curve 3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar x3, SkScalar y3); 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a cubic bezier from the last point, approaching control points p1 3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com and p2, and ending at p3. If no moveTo() call has been made for this 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contour, the first point is automatically set to (0,0). 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p1 The 1st control point on a cubic curve 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p2 The 2nd control point on a cubic curve 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p3 The end point on a cubic curve 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) { 3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY); 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Same as cubicTo, but the coordinates are considered relative to the 3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current point on this contour. If there is no previous point, then a 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com moveTo(0,0) is inserted automatically. 3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx1 The amount to add to the x-coordinate of the last point on 3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the 1st control point of a cubic curve 3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy1 The amount to add to the y-coordinate of the last point on 3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the 1st control point of a cubic curve 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx2 The amount to add to the x-coordinate of the last point on 3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the 2nd control point of a cubic curve 3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy2 The amount to add to the y-coordinate of the last point on 3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the 2nd control point of a cubic curve 3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx3 The amount to add to the x-coordinate of the last point on 3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the end point of a cubic curve 3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy3 The amount to add to the y-coordinate of the last point on 3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this contour, to specify the end point of a cubic curve 3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar x3, SkScalar y3); 3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Append the specified arc to the path as a new contour. If the start of 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the path is different from the path's current last point, then an 3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com automatic lineTo() is added to connect the current contour to the start 3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of the arc. However, if the path is empty, then we call moveTo() with 3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the first point of the arc. The sweep angle is treated mod 360. 3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The bounding oval defining the shape and size of the arc 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param startAngle Starting angle (in degrees) where the arc begins 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sweepAngle Sweep angle (in degrees) measured clockwise. This is 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com treated mod 360. 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param forceMoveTo If true, always begin a new contour with the arc 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, 3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool forceMoveTo); 3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Append a line and arc to the current path. This is the same as the 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com PostScript call "arct". 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar radius); 3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Append a line and arc to the current path. This is the same as the 3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com PostScript call "arct". 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) { 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius); 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Close the current contour. If the current point is not equal to the 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com first point of the contour, a line segment is automatically added. 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void close(); 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Direction { 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** clockwise direction for adding closed contours */ 3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kCW_Direction, 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** counter-clockwise direction for adding closed contours */ 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kCCW_Direction 3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed rectangle contour to the path 3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rectangle to add as a closed contour to the path 3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the rectangle's contour 3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addRect(const SkRect& rect, Direction dir = kCW_Direction); 3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed rectangle contour to the path 3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The left side of a rectangle to add as a closed contour 3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com to the path 3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The top of a rectangle to add as a closed contour to the 3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path 3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param right The right side of a rectangle to add as a closed contour 3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com to the path 3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bottom The bottom of a rectangle to add as a closed contour to 3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the path 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the rectangle's contour 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Direction dir = kCW_Direction); 3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed oval contour to the path 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The bounding oval to add as a closed contour to the path 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the oval's contour 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addOval(const SkRect& oval, Direction dir = kCW_Direction); 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed circle contour to the path 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-coordinate of the center of a circle to add as a 4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com closed contour to the path 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-coordinate of the center of a circle to add as a 4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com closed contour to the path 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param radius The radius of a circle to add as a closed contour to the 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the circle's contour 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addCircle(SkScalar x, SkScalar y, SkScalar radius, 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Direction dir = kCW_Direction); 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add the specified arc to the path as a new contour. 4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The bounds of oval used to define the size of the arc 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param startAngle Starting angle (in degrees) where the arc begins 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sweepAngle Sweep angle (in degrees) measured clockwise 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle); 4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed round-rectangle contour to the path 4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The bounds of a round-rectangle to add as a closed contour 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rx The x-radius of the rounded corners on the round-rectangle 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ry The y-radius of the rounded corners on the round-rectangle 4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the round-rectangle's contour 4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, 4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Direction dir = kCW_Direction); 4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a closed round-rectangle contour to the path. Each corner receives 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com two radius values [X, Y]. The corners are ordered top-left, top-right, 4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bottom-right, bottom-left. 4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The bounds of a round-rectangle to add as a closed contour 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param radii Array of 8 scalars, 4 [X,Y] pairs for each corner 4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dir The direction to wind the round-rectangle's contour 4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addRoundRect(const SkRect& rect, const SkScalar radii[], 4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Direction dir = kCW_Direction); 4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a copy of src to the path, offset by (dx,dy) 4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param src The path to add as a new contour 4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount to translate the path in X as it is added 4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount to translate the path in Y as it is added 4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addPath(const SkPath& src, SkScalar dx, SkScalar dy); 4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a copy of src to the path 4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addPath(const SkPath& src) { 4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMatrix m; 4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com m.reset(); 4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->addPath(src, m); 4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Add a copy of src to the path, transformed by matrix 4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param src The path to add as a new contour 4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void addPath(const SkPath& src, const SkMatrix& matrix); 4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Offset the path by (dx,dy), returning true on success 4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount in the X direction to offset the entire path 4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The amount in the Y direction to offset the entire path 4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dst The translated path is written here 4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void offset(SkScalar dx, SkScalar dy, SkPath* dst) const; 4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Offset the path by (dx,dy), returning true on success 4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The amount in the X direction to offset the entire path 4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The amount in the Y direction to offset the entire path 4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void offset(SkScalar dx, SkScalar dy) { 4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->offset(dx, dy, this); 4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Transform the points in this path by matrix, and write the answer into 4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com dst. 4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix to apply to the path 4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dst The transformed path is written here 4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void transform(const SkMatrix& matrix, SkPath* dst) const; 4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Transform the points in this path by matrix 4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix to apply to the path 4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void transform(const SkMatrix& matrix) { 4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->transform(matrix, this); 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the last point on the path. If no points have been added, (0,0) 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is returned. 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param lastPt The last point on the path is returned here 5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void getLastPt(SkPoint* lastPt) const; 5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the last point on the path. If no points have been added, 5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com moveTo(x,y) is automatically called. 5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The new x-coordinate for the last point 5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The new y-coordinate for the last point 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setLastPt(SkScalar x, SkScalar y); 5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the last point on the path. If no points have been added, moveTo(p) 5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is automatically called. 5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param p The new location for the last point 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setLastPt(const SkPoint& p) { 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->setLastPt(p.fX, p.fY); 5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Verb { 5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMove_Verb, //!< iter.next returns 1 point 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kLine_Verb, //!< iter.next returns 2 points 5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kQuad_Verb, //!< iter.next returns 3 points 5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kCubic_Verb, //!< iter.next returns 4 points 5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kClose_Verb, //!< iter.next returns 1 point (the last point) 5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kDone_Verb //!< iter.next returns 0 points 5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Iterate through all of the segments (lines, quadratics, cubics) of 5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com each contours in a path. 5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5347ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org class SK_API Iter { 5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public: 5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Iter(); 5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Iter(const SkPath&, bool forceClose); 5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setPath(const SkPath&, bool forceClose); 5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the next verb in this iteration of the path. When all 5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com segments have been visited, return kDone_Verb. 5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param pts The points representing the current verb and/or segment 5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The verb for the current segment 5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Verb next(SkPoint pts[4]); 5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** If next() returns kLine_Verb, then this query returns true if the 5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com line was the result of a close() command (i.e. the end point is the 5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com initial moveto for this contour). If next() returned a different 5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com verb, this returns an undefined value. 5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return If the last call to next() returned kLine_Verb, return true 5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if it was the result of an explicit close command. 5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isCloseLine() const { return SkToBool(fCloseLine); } 5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the current contour is closed (has a kClose_Verb) 5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the current contour is closed (has a kClose_Verb) 5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isClosedContour() const; 5638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private: 5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint* fPts; 5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint8_t* fVerbs; 5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint8_t* fVerbStop; 5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPoint fMoveTo; 5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPoint fLastPt; 5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBool8 fForceClose; 5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBool8 fNeedClose; 5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBool8 fNeedMoveTo; 5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBool8 fCloseLine; 5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool cons_moveTo(SkPoint pts[1]); 5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Verb autoClose(SkPoint pts[2]); 5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void dump(bool forceClose, const char title[] = NULL) const; 580e522ca5d5f249bd51a00cb68bb051f811d0a9e85reed@android.com void dump() const; 5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void flatten(SkFlattenableWriteBuffer&) const; 5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void unflatten(SkFlattenableReadBuffer&); 5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Subdivide the path so that no segment is longer that dist. 5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If bendLines is true, then turn all line segments into curves. 5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If dst == null, then the original path itself is modified (not const!) 5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void subdivide(SkScalar dist, bool bendLines, SkPath* dst = NULL) const; 5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 591f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#ifdef ANDROID 592f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com uint32_t getGenerationID() const; 593f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif 594f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com 5958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDEBUGCODE(void validate() const;) 5968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 5988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkTDArray<SkPoint> fPts; 5998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkTDArray<uint8_t> fVerbs; 600d252db03d9650013b545ef9781fe993c07f8f314reed@android.com mutable SkRect fBounds; 601d252db03d9650013b545ef9781fe993c07f8f314reed@android.com mutable uint8_t fBoundsIsDirty; 6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint8_t fFillType; 6036b82d1adc6a4726e36674e468ff1157e0b75373freed@android.com uint8_t fIsConvex; 604f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#ifdef ANDROID 605f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com uint32_t fGenerationID; 606f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif 6078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 608d252db03d9650013b545ef9781fe993c07f8f314reed@android.com // called, if dirty, by getBounds() 609d252db03d9650013b545ef9781fe993c07f8f314reed@android.com void computeBounds() const; 610d252db03d9650013b545ef9781fe993c07f8f314reed@android.com 6118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class Iter; 6128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void cons_moveto(); 6138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkPathStroker; 6158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /* Append the first contour of path, ignoring path's initial point. If no 6168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com moveTo() call has been made for this contour, the first point is 6178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com automatically set to (0,0). 6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void pathTo(const SkPath& path); 6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /* Append, in reverse order, the first contour of path, ignoring path's 6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com last point. If no moveTo() call has been made for this contour, the 6238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com first point is automatically set to (0,0). 6248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void reversePathTo(const SkPath&); 6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend const SkPoint* sk_get_path_points(const SkPath&, int index); 6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkAutoPathBoundsUpdate; 6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 633