Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
SkPathBuilder Class Reference

#include <SkPathBuilder.h>

Public Types

enum  ArcSize { kSmall_ArcSize , kLarge_ArcSize }
 

Public Member Functions

 SkPathBuilder ()
 
 SkPathBuilder (SkPathFillType)
 
 SkPathBuilder (const SkPath &)
 
 SkPathBuilder (const SkPathBuilder &)=default
 
 ~SkPathBuilder ()
 
SkPathBuilderoperator= (const SkPath &)
 
SkPathBuilderoperator= (const SkPathBuilder &)=default
 
SkPathFillType fillType () const
 
SkRect computeBounds () const
 
SkPath snapshot () const
 
SkPath detach ()
 
SkPathBuildersetFillType (SkPathFillType ft)
 
SkPathBuildersetIsVolatile (bool isVolatile)
 
SkPathBuilderreset ()
 
SkPathBuildermoveTo (SkPoint pt)
 
SkPathBuildermoveTo (SkScalar x, SkScalar y)
 
SkPathBuilderlineTo (SkPoint pt)
 
SkPathBuilderlineTo (SkScalar x, SkScalar y)
 
SkPathBuilderquadTo (SkPoint pt1, SkPoint pt2)
 
SkPathBuilderquadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 
SkPathBuilderquadTo (const SkPoint pts[2])
 
SkPathBuilderconicTo (SkPoint pt1, SkPoint pt2, SkScalar w)
 
SkPathBuilderconicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 
SkPathBuilderconicTo (const SkPoint pts[2], SkScalar w)
 
SkPathBuildercubicTo (SkPoint pt1, SkPoint pt2, SkPoint pt3)
 
SkPathBuildercubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 
SkPathBuildercubicTo (const SkPoint pts[3])
 
SkPathBuilderclose ()
 
SkPathBuilderpolylineTo (const SkPoint pts[], int count)
 
SkPathBuilderpolylineTo (const std::initializer_list< SkPoint > &list)
 
SkPathBuilderrLineTo (SkPoint pt)
 
SkPathBuilderrLineTo (SkScalar x, SkScalar y)
 
SkPathBuilderrQuadTo (SkPoint pt1, SkPoint pt2)
 
SkPathBuilderrQuadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 
SkPathBuilderrConicTo (SkPoint p1, SkPoint p2, SkScalar w)
 
SkPathBuilderrConicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 
SkPathBuilderrCubicTo (SkPoint pt1, SkPoint pt2, SkPoint pt3)
 
SkPathBuilderrCubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 
SkPathBuilderarcTo (const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
 
SkPathBuilderarcTo (SkPoint p1, SkPoint p2, SkScalar radius)
 
SkPathBuilderarcTo (SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkPoint xy)
 
SkPathBuilderaddArc (const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg)
 
SkPathBuilderaddRect (const SkRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddOval (const SkRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddRRect (const SkRRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddRect (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddOval (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddRRect (const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddCircle (SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddPolygon (const SkPoint pts[], int count, bool isClosed)
 
SkPathBuilderaddPolygon (const std::initializer_list< SkPoint > &list, bool isClosed)
 
SkPathBuilderaddPath (const SkPath &)
 
void incReserve (int extraPtCount, int extraVerbCount)
 
void incReserve (int extraPtCount)
 
SkPathBuilderoffset (SkScalar dx, SkScalar dy)
 
SkPathBuildertoggleInverseFillType ()
 

Friends

class SkPathPriv
 

Detailed Description

Definition at line 25 of file SkPathBuilder.h.

Member Enumeration Documentation

◆ ArcSize

Enumerator
kSmall_ArcSize 

smaller of arc pair

kLarge_ArcSize 

larger of arc pair

Definition at line 141 of file SkPathBuilder.h.

141 {
142 kSmall_ArcSize, //!< smaller of arc pair
143 kLarge_ArcSize, //!< larger of arc pair
144 };
@ kSmall_ArcSize
smaller of arc pair
@ kLarge_ArcSize
larger of arc pair

Constructor & Destructor Documentation

◆ SkPathBuilder() [1/4]

SkPathBuilder::SkPathBuilder ( )

Definition at line 27 of file SkPathBuilder.cpp.

27 {
28 this->reset();
29}
SkPathBuilder & reset()

◆ SkPathBuilder() [2/4]

SkPathBuilder::SkPathBuilder ( SkPathFillType  ft)

Definition at line 31 of file SkPathBuilder.cpp.

31 {
32 this->reset();
33 fFillType = ft;
34}

◆ SkPathBuilder() [3/4]

SkPathBuilder::SkPathBuilder ( const SkPath src)

Definition at line 36 of file SkPathBuilder.cpp.

36 {
37 *this = src;
38}

◆ SkPathBuilder() [4/4]

SkPathBuilder::SkPathBuilder ( const SkPathBuilder )
default

◆ ~SkPathBuilder()

SkPathBuilder::~SkPathBuilder ( )

Definition at line 40 of file SkPathBuilder.cpp.

40 {
41}

Member Function Documentation

◆ addArc()

SkPathBuilder & SkPathBuilder::addArc ( const SkRect oval,
SkScalar  startAngleDeg,
SkScalar  sweepAngleDeg 
)

Appends arc to the builder, as the start of new contour. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.

If sweepAngle <= -360, or sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle values are treated modulo 360, and arc may or may not draw depending on numeric rounding.

Parameters
ovalbounds of ellipse containing arc
startAngleDegstarting angle of arc in degrees
sweepAngleDegsweep, in degrees. Positive is clockwise; treated modulo 360
Returns
reference to this builder

Definition at line 394 of file SkPathBuilder.cpp.

394 {
395 if (oval.isEmpty() || 0 == sweepAngle) {
396 return *this;
397 }
398
399 const SkScalar kFullCircleAngle = SkIntToScalar(360);
400
401 if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) {
402 // We can treat the arc as an oval if it begins at one of our legal starting positions.
403 // See SkPath::addOval() docs.
404 SkScalar startOver90 = startAngle / 90.f;
405 SkScalar startOver90I = SkScalarRoundToScalar(startOver90);
406 SkScalar error = startOver90 - startOver90I;
407 if (SkScalarNearlyEqual(error, 0)) {
408 // Index 1 is at startAngle == 0.
409 SkScalar startIndex = std::fmod(startOver90I + 1.f, 4.f);
410 startIndex = startIndex < 0 ? startIndex + 4.f : startIndex;
411 return this->addOval(oval, sweepAngle > 0 ? SkPathDirection::kCW : SkPathDirection::kCCW,
412 (unsigned) startIndex);
413 }
414 }
415 return this->arcTo(oval, startAngle, sweepAngle, true);
416}
SkPathDirection
Definition SkPathTypes.h:34
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define SkScalarRoundToScalar(x)
Definition SkScalar.h:32
SkPathBuilder & arcTo(const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
SkPathBuilder & addOval(const SkRect &, SkPathDirection, unsigned startIndex)
float SkScalar
Definition extension.cpp:12
const uint8_t uint32_t uint32_t GError ** error
SkRect oval
Definition SkRecords.h:249
SkScalar startAngle
Definition SkRecords.h:250
bool isEmpty() const
Definition SkRect.h:693

◆ addCircle()

SkPathBuilder & SkPathBuilder::addCircle ( SkScalar  center_x,
SkScalar  center_y,
SkScalar  radius,
SkPathDirection  dir = SkPathDirection::kCW 
)

Definition at line 759 of file SkPathBuilder.cpp.

759 {
760 if (r >= 0) {
761 this->addOval(SkRect::MakeLTRB(x - r, y - r, x + r, y + r), dir);
762 }
763 return *this;
764}
double y
double x
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

◆ addOval() [1/2]

SkPathBuilder & SkPathBuilder::addOval ( const SkRect oval,
SkPathDirection  dir,
unsigned  startIndex 
)

Definition at line 682 of file SkPathBuilder.cpp.

682 {
683 const IsA prevIsA = fIsA;
684
685 const int kPts = 9; // moveTo + 4 conics(2 pts each)
686 const int kVerbs = 6; // moveTo + 4 conics + close
687 this->incReserve(kPts, kVerbs);
688
689 OvalPointIterator ovalIter(oval, dir, index);
690 RectPointIterator rectIter(oval, dir, index + (dir == SkPathDirection::kCW ? 0 : 1));
691
692 // The corner iterator pts are tracking "behind" the oval/radii pts.
693
694 this->moveTo(ovalIter.current());
695 for (unsigned i = 0; i < 4; ++i) {
696 this->conicTo(rectIter.next(), ovalIter.next(), SK_ScalarRoot2Over2);
697 }
698 this->close();
699
700 if (prevIsA == kIsA_JustMoves) {
701 fIsA = kIsA_Oval;
702 fIsACCW = (dir == SkPathDirection::kCCW);
703 fIsAStart = index % 4;
704 }
705 return *this;
706}
#define SK_ScalarRoot2Over2
Definition SkScalar.h:23
SkPathBuilder & conicTo(SkPoint pt1, SkPoint pt2, SkScalar w)
SkPathBuilder & close()
void incReserve(int extraPtCount, int extraVerbCount)
SkPathBuilder & moveTo(SkPoint pt)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition switches.h:145

◆ addOval() [2/2]

SkPathBuilder & SkPathBuilder::addOval ( const SkRect rect,
SkPathDirection  dir = SkPathDirection::kCW 
)
inline

Definition at line 197 of file SkPathBuilder.h.

197 {
198 // legacy start index: 1
199 return this->addOval(rect, dir, 1);
200 }

◆ addPath()

SkPathBuilder & SkPathBuilder::addPath ( const SkPath src)

Definition at line 800 of file SkPathBuilder.cpp.

800 {
801 SkPath::RawIter iter(src);
802 SkPoint pts[4];
803 SkPath::Verb verb;
804
805 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
806 switch (verb) {
807 case SkPath::kMove_Verb: this->moveTo (pts[0]); break;
808 case SkPath::kLine_Verb: this->lineTo (pts[1]); break;
809 case SkPath::kQuad_Verb: this->quadTo (pts[1], pts[2]); break;
810 case SkPath::kCubic_Verb: this->cubicTo(pts[1], pts[2], pts[3]); break;
811 case SkPath::kConic_Verb: this->conicTo(pts[1], pts[2], iter.conicWeight()); break;
812 case SkPath::kClose_Verb: this->close(); break;
814 }
815 }
816
817 return *this;
818}
#define SkUNREACHABLE
Definition SkAssert.h:135
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3)
SkPathBuilder & quadTo(SkPoint pt1, SkPoint pt2)
@ kClose_Verb
Definition SkPath.h:1463
@ kMove_Verb
Definition SkPath.h:1458
@ kConic_Verb
Definition SkPath.h:1461
@ kDone_Verb
Definition SkPath.h:1464
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459

◆ addPolygon() [1/2]

SkPathBuilder & SkPathBuilder::addPolygon ( const SkPoint  pts[],
int  count,
bool  isClosed 
)

Definition at line 766 of file SkPathBuilder.cpp.

766 {
767 if (count <= 0) {
768 return *this;
769 }
770
771 this->moveTo(pts[0]);
772 this->polylineTo(&pts[1], count - 1);
773 if (isClosed) {
774 this->close();
775 }
776 return *this;
777}
int count
SkPathBuilder & polylineTo(const SkPoint pts[], int count)

◆ addPolygon() [2/2]

SkPathBuilder & SkPathBuilder::addPolygon ( const std::initializer_list< SkPoint > &  list,
bool  isClosed 
)
inline

Definition at line 210 of file SkPathBuilder.h.

210 {
211 return this->addPolygon(list.begin(), SkToInt(list.size()), isClosed);
212 }
constexpr int SkToInt(S x)
Definition SkTo.h:29
SkPathBuilder & addPolygon(const SkPoint pts[], int count, bool isClosed)

◆ addRect() [1/2]

SkPathBuilder & SkPathBuilder::addRect ( const SkRect rect,
SkPathDirection  dir,
unsigned  startIndex 
)

Definition at line 668 of file SkPathBuilder.cpp.

668 {
669 const int kPts = 4; // moveTo + 3 lines
670 const int kVerbs = 5; // moveTo + 3 lines + close
671 this->incReserve(kPts, kVerbs);
672
673 RectPointIterator iter(rect, dir, index);
674
675 this->moveTo(iter.current());
676 this->lineTo(iter.next());
677 this->lineTo(iter.next());
678 this->lineTo(iter.next());
679 return this->close();
680}

◆ addRect() [2/2]

SkPathBuilder & SkPathBuilder::addRect ( const SkRect rect,
SkPathDirection  dir = SkPathDirection::kCW 
)
inline

Definition at line 194 of file SkPathBuilder.h.

194 {
195 return this->addRect(rect, dir, 0);
196 }
SkPathBuilder & addRect(const SkRect &, SkPathDirection, unsigned startIndex)

◆ addRRect() [1/2]

SkPathBuilder & SkPathBuilder::addRRect ( const SkRRect rrect,
SkPathDirection  dir,
unsigned  startIndex 
)

Definition at line 708 of file SkPathBuilder.cpp.

708 {
709 const IsA prevIsA = fIsA;
710 const SkRect& bounds = rrect.getBounds();
711
712 if (rrect.isRect() || rrect.isEmpty()) {
713 // degenerate(rect) => radii points are collapsing
714 this->addRect(bounds, dir, (index + 1) / 2);
715 } else if (rrect.isOval()) {
716 // degenerate(oval) => line points are collapsing
717 this->addOval(bounds, dir, index / 2);
718 } else {
719 // we start with a conic on odd indices when moving CW vs. even indices when moving CCW
720 const bool startsWithConic = ((index & 1) == (dir == SkPathDirection::kCW));
721 const SkScalar weight = SK_ScalarRoot2Over2;
722
723 const int kVerbs = startsWithConic
724 ? 9 // moveTo + 4x conicTo + 3x lineTo + close
725 : 10; // moveTo + 4x lineTo + 4x conicTo + close
726 this->incReserve(kVerbs);
727
728 RRectPointIterator rrectIter(rrect, dir, index);
729 // Corner iterator indices follow the collapsed radii model,
730 // adjusted such that the start pt is "behind" the radii start pt.
731 const unsigned rectStartIndex = index / 2 + (dir == SkPathDirection::kCW ? 0 : 1);
732 RectPointIterator rectIter(bounds, dir, rectStartIndex);
733
734 this->moveTo(rrectIter.current());
735 if (startsWithConic) {
736 for (unsigned i = 0; i < 3; ++i) {
737 this->conicTo(rectIter.next(), rrectIter.next(), weight);
738 this->lineTo(rrectIter.next());
739 }
740 this->conicTo(rectIter.next(), rrectIter.next(), weight);
741 // final lineTo handled by close().
742 } else {
743 for (unsigned i = 0; i < 4; ++i) {
744 this->lineTo(rrectIter.next());
745 this->conicTo(rectIter.next(), rrectIter.next(), weight);
746 }
747 }
748 this->close();
749 }
750
751 if (prevIsA == kIsA_JustMoves) {
752 fIsA = kIsA_RRect;
753 fIsACCW = (dir == SkPathDirection::kCCW);
754 fIsAStart = index % 8;
755 }
756 return *this;
757}
bool isOval() const
Definition SkRRect.h:85
bool isRect() const
Definition SkRRect.h:84
bool isEmpty() const
Definition SkRRect.h:83
const SkRect & getBounds() const
Definition SkRRect.h:279
Optional< SkRect > bounds
Definition SkRecords.h:189
SkRRect rrect
Definition SkRecords.h:232

◆ addRRect() [2/2]

SkPathBuilder & SkPathBuilder::addRRect ( const SkRRect rrect,
SkPathDirection  dir = SkPathDirection::kCW 
)
inline

Definition at line 201 of file SkPathBuilder.h.

201 {
202 // legacy start indices: 6 (CW) and 7 (CCW)
203 return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
204 }
SkPathBuilder & addRRect(const SkRRect &, SkPathDirection, unsigned startIndex)

◆ arcTo() [1/3]

SkPathBuilder & SkPathBuilder::arcTo ( const SkRect oval,
SkScalar  startAngleDeg,
SkScalar  sweepAngleDeg,
bool  forceMoveTo 
)

Appends arc to the builder. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.

arcTo() adds line connecting the builder's last point to initial arc point if forceMoveTo is false and the builder is not empty. Otherwise, added contour begins with first point of arc. Angles greater than -360 and less than 360 are treated modulo 360.

Parameters
ovalbounds of ellipse containing arc
startAngleDegstarting angle of arc in degrees
sweepAngleDegsweep, in degrees. Positive is clockwise; treated modulo 360
forceMoveTotrue to start a new contour with arc
Returns
reference to the builder

Definition at line 331 of file SkPathBuilder.cpp.

332 {
333 if (oval.width() < 0 || oval.height() < 0) {
334 return *this;
335 }
336
337 if (fVerbs.empty()) {
338 forceMoveTo = true;
339 }
340
341 SkPoint lonePt;
342 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) {
343 return forceMoveTo ? this->moveTo(lonePt) : this->lineTo(lonePt);
344 }
345
346 SkVector startV, stopV;
348 angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir);
349
350 SkPoint singlePt;
351
352 // Adds a move-to to 'pt' if forceMoveTo is true. Otherwise a lineTo unless we're sufficiently
353 // close to 'pt' currently. This prevents spurious lineTos when adding a series of contiguous
354 // arcs from the same oval.
355 auto addPt = [forceMoveTo, this](const SkPoint& pt) {
356 if (forceMoveTo) {
357 this->moveTo(pt);
358 } else if (!nearly_equal(fPts.back(), pt)) {
359 this->lineTo(pt);
360 }
361 };
362
363 // At this point, we know that the arc is not a lone point, but startV == stopV
364 // indicates that the sweepAngle is too small such that angles_to_unit_vectors
365 // cannot handle it.
366 if (startV == stopV) {
367 SkScalar endAngle = SkDegreesToRadians(startAngle + sweepAngle);
368 SkScalar radiusX = oval.width() / 2;
369 SkScalar radiusY = oval.height() / 2;
370 // We do not use SkScalar[Sin|Cos]SnapToZero here. When sin(startAngle) is 0 and sweepAngle
371 // is very small and radius is huge, the expected behavior here is to draw a line. But
372 // calling SkScalarSinSnapToZero will make sin(endAngle) be 0 which will then draw a dot.
373 singlePt.set(oval.centerX() + radiusX * SkScalarCos(endAngle),
374 oval.centerY() + radiusY * SkScalarSin(endAngle));
375 addPt(singlePt);
376 return *this;
377 }
378
380 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt);
381 if (count) {
382 this->incReserve(count * 2 + 1);
383 const SkPoint& pt = conics[0].fPts[0];
384 addPt(pt);
385 for (int i = 0; i < count; ++i) {
386 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW);
387 }
388 } else {
389 addPt(singlePt);
390 }
391 return *this;
392}
SkRotationDirection
Definition SkGeometry.h:321
static int build_arc_conics(const SkRect &oval, const SkVector &start, const SkVector &stop, SkRotationDirection dir, SkConic conics[SkConic::kMaxConicsForArc], SkPoint *singlePt)
Definition SkPath.cpp:968
static bool arc_is_lone_point(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, SkPoint *pt)
Definition SkPath.cpp:907
static void angles_to_unit_vectors(SkScalar startAngle, SkScalar sweepAngle, SkVector *startV, SkVector *stopV, SkRotationDirection *dir)
Definition SkPath.cpp:930
#define SkDegreesToRadians(degrees)
Definition SkScalar.h:77
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SkScalarCos(radians)
Definition SkScalar.h:46
bool empty() const
Definition SkTArray.h:194
static bool nearly_equal(SkColor4f x, SkColor4f y)
Definition p3.cpp:35
SkPoint fPts[3]
Definition SkGeometry.h:336
@ kMaxConicsForArc
Definition SkGeometry.h:411
void set(float x, float y)
constexpr float centerX() const
Definition SkRect.h:776
constexpr float height() const
Definition SkRect.h:769
constexpr float centerY() const
Definition SkRect.h:785
constexpr float width() const
Definition SkRect.h:762

◆ arcTo() [2/3]

SkPathBuilder & SkPathBuilder::arcTo ( SkPoint  p1,
SkPoint  p2,
SkScalar  radius 
)

Appends arc to SkPath, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last SkPath point to p1, and tangent from p1 to p2. Arc is part of circle sized to radius, positioned so it touches both tangent lines.

If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath. The length of vector from p1 to p2 does not affect arc.

Arc sweep is always less than 180 degrees. If radius is zero, or if tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.

arcTo() appends at most one line and one conic. arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.

Parameters
p1SkPoint common to pair of tangents
p2end of second tangent
radiusdistance from arc to circle center
Returns
reference to SkPath

Definition at line 418 of file SkPathBuilder.cpp.

418 {
419 this->ensureMove();
420
421 if (radius == 0) {
422 return this->lineTo(p1);
423 }
424
425 // need to know our prev pt so we can construct tangent vectors
426 SkPoint start = fPts.back();
427
428 // need double precision for these calcs.
429 skvx::double2 befored = normalize(skvx::double2{p1.fX - start.fX, p1.fY - start.fY});
430 skvx::double2 afterd = normalize(skvx::double2{p2.fX - p1.fX, p2.fY - p1.fY});
431 double cosh = dot(befored, afterd);
432 double sinh = cross(befored, afterd);
433
434 // If the previous point equals the first point, befored will be denormalized.
435 // If the two points equal, afterd will be denormalized.
436 // If the second point equals the first point, sinh will be zero.
437 // In all these cases, we cannot construct an arc, so we construct a line to the first point.
438 if (!isfinite(befored) || !isfinite(afterd) || SkScalarNearlyZero(SkDoubleToScalar(sinh))) {
439 return this->lineTo(p1);
440 }
441
442 // safe to convert back to floats now
443 SkScalar dist = SkScalarAbs(SkDoubleToScalar(radius * (1 - cosh) / sinh));
444 SkScalar xx = p1.fX - dist * befored[0];
445 SkScalar yy = p1.fY - dist * befored[1];
446
447 SkVector after = SkVector::Make(afterd[0], afterd[1]);
448 after.setLength(dist);
449 this->lineTo(xx, yy);
450 SkScalar weight = SkScalarSqrt(SkDoubleToScalar(SK_ScalarHalf + cosh * 0.5));
451 return this->conicTo(p1, p1 + after, weight);
452}
static void normalize(int n, double *gauss)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:101
#define SK_ScalarHalf
Definition SkScalar.h:19
#define SkDoubleToScalar(x)
Definition SkScalar.h:64
#define SkScalarSqrt(x)
Definition SkScalar.h:42
#define SkScalarAbs(x)
Definition SkScalar.h:39
int64_t cross(Point d0, Point d1)
Definition Myers.cpp:55
SINT bool isfinite(const Vec< N, T > &v)
Definition SkVx.h:1003
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
Definition SkVx.h:964
bool setLength(float length)
Definition SkPoint.cpp:30
float fX
x-axis value
static constexpr SkPoint Make(float x, float y)
float fY
y-axis value

◆ arcTo() [3/3]

SkPathBuilder & SkPathBuilder::arcTo ( SkPoint  r,
SkScalar  xAxisRotate,
SkPathBuilder::ArcSize  arcLarge,
SkPathDirection  sweep,
SkPoint  xy 
)

Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves from last SkPath SkPoint to (xy.fX, xy.fY), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger.

Arc sweep is always less than 360 degrees. arcTo() appends line to xy if either radii are zero, or if last SkPath SkPoint equals (xy.fX, xy.fY). arcTo() scales radii r to fit last SkPath SkPoint and xy if both are greater than zero but too small to describe an arc.

arcTo() appends up to four conic curves. arcTo() implements the functionality of SVG arc, although SVG sweep-flag value is opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while kCW_Direction cast to int is zero.

Parameters
rradii on axes before x-axis rotation
xAxisRotatex-axis rotation in degrees; positive values are clockwise
largeArcchooses smaller or larger arc
sweepchooses clockwise or counterclockwise arc
xyend of arc
Returns
reference to SkPath

Definition at line 460 of file SkPathBuilder.cpp.

461 {
462 this->ensureMove();
463
464 SkPoint srcPts[2] = { fPts.back(), endPt };
465
466 // If rx = 0 or ry = 0 then this arc is treated as a straight line segment (a "lineto")
467 // joining the endpoints.
468 // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
469 if (!rad.fX || !rad.fY) {
470 return this->lineTo(endPt);
471 }
472 // If the current point and target point for the arc are identical, it should be treated as a
473 // zero length path. This ensures continuity in animations.
474 if (srcPts[0] == srcPts[1]) {
475 return this->lineTo(endPt);
476 }
477 SkScalar rx = SkScalarAbs(rad.fX);
478 SkScalar ry = SkScalarAbs(rad.fY);
479 SkVector midPointDistance = srcPts[0] - srcPts[1];
480 midPointDistance *= 0.5f;
481
482 SkMatrix pointTransform;
483 pointTransform.setRotate(-angle);
484
485 SkPoint transformedMidPoint;
486 pointTransform.mapPoints(&transformedMidPoint, &midPointDistance, 1);
487 SkScalar squareRx = rx * rx;
488 SkScalar squareRy = ry * ry;
489 SkScalar squareX = transformedMidPoint.fX * transformedMidPoint.fX;
490 SkScalar squareY = transformedMidPoint.fY * transformedMidPoint.fY;
491
492 // Check if the radii are big enough to draw the arc, scale radii if not.
493 // http://www.w3.org/TR/SVG/implnote.html#ArcCorrectionOutOfRangeRadii
494 SkScalar radiiScale = squareX / squareRx + squareY / squareRy;
495 if (radiiScale > 1) {
496 radiiScale = SkScalarSqrt(radiiScale);
497 rx *= radiiScale;
498 ry *= radiiScale;
499 }
500
501 pointTransform.setScale(1 / rx, 1 / ry);
502 pointTransform.preRotate(-angle);
503
504 SkPoint unitPts[2];
505 pointTransform.mapPoints(unitPts, srcPts, (int) std::size(unitPts));
506 SkVector delta = unitPts[1] - unitPts[0];
507
508 SkScalar d = delta.fX * delta.fX + delta.fY * delta.fY;
509 SkScalar scaleFactorSquared = std::max(1 / d - 0.25f, 0.f);
510
511 SkScalar scaleFactor = SkScalarSqrt(scaleFactorSquared);
512 if ((arcSweep == SkPathDirection::kCCW) != SkToBool(arcLarge)) { // flipped from the original implementation
513 scaleFactor = -scaleFactor;
514 }
515 delta.scale(scaleFactor);
516 SkPoint centerPoint = unitPts[0] + unitPts[1];
517 centerPoint *= 0.5f;
518 centerPoint.offset(-delta.fY, delta.fX);
519 unitPts[0] -= centerPoint;
520 unitPts[1] -= centerPoint;
521 SkScalar theta1 = SkScalarATan2(unitPts[0].fY, unitPts[0].fX);
522 SkScalar theta2 = SkScalarATan2(unitPts[1].fY, unitPts[1].fX);
523 SkScalar thetaArc = theta2 - theta1;
524 if (thetaArc < 0 && (arcSweep == SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
525 thetaArc += SK_ScalarPI * 2;
526 } else if (thetaArc > 0 && (arcSweep != SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
527 thetaArc -= SK_ScalarPI * 2;
528 }
529
530 // Very tiny angles cause our subsequent math to go wonky (skbug.com/9272)
531 // so we do a quick check here. The precise tolerance amount is just made up.
532 // PI/million happens to fix the bug in 9272, but a larger value is probably
533 // ok too.
534 if (SkScalarAbs(thetaArc) < (SK_ScalarPI / (1000 * 1000))) {
535 return this->lineTo(endPt);
536 }
537
538 pointTransform.setRotate(angle);
539 pointTransform.preScale(rx, ry);
540
541 // the arc may be slightly bigger than 1/4 circle, so allow up to 1/3rd
542 int segments = SkScalarCeilToInt(SkScalarAbs(thetaArc / (2 * SK_ScalarPI / 3)));
543 SkScalar thetaWidth = thetaArc / segments;
544 SkScalar t = SkScalarTan(0.5f * thetaWidth);
545 if (!SkIsFinite(t)) {
546 return *this;
547 }
548 SkScalar startTheta = theta1;
550 auto scalar_is_integer = [](SkScalar scalar) -> bool {
551 return scalar == SkScalarFloorToScalar(scalar);
552 };
553 bool expectIntegers = SkScalarNearlyZero(SK_ScalarPI/2 - SkScalarAbs(thetaWidth)) &&
554 scalar_is_integer(rx) && scalar_is_integer(ry) &&
555 scalar_is_integer(endPt.fX) && scalar_is_integer(endPt.fY);
556
557 for (int i = 0; i < segments; ++i) {
558 SkScalar endTheta = startTheta + thetaWidth,
559 sinEndTheta = SkScalarSinSnapToZero(endTheta),
560 cosEndTheta = SkScalarCosSnapToZero(endTheta);
561
562 unitPts[1].set(cosEndTheta, sinEndTheta);
563 unitPts[1] += centerPoint;
564 unitPts[0] = unitPts[1];
565 unitPts[0].offset(t * sinEndTheta, -t * cosEndTheta);
566 SkPoint mapped[2];
567 pointTransform.mapPoints(mapped, unitPts, (int) std::size(unitPts));
568 /*
569 Computing the arc width introduces rounding errors that cause arcs to start
570 outside their marks. A round rect may lose convexity as a result. If the input
571 values are on integers, place the conic on integers as well.
572 */
573 if (expectIntegers) {
574 for (SkPoint& point : mapped) {
575 point.fX = SkScalarRoundToScalar(point.fX);
576 point.fY = SkScalarRoundToScalar(point.fY);
577 }
578 }
579 this->conicTo(mapped[0], mapped[1], w);
580 startTheta = endTheta;
581 }
582
583 // The final point should match the input point (by definition); replace it to
584 // ensure that rounding errors in the above math don't cause any problems.
585 fPts.back() = endPt;
586 return *this;
587}
static bool SkIsFinite(T x, Pack... values)
#define SkScalarFloorToScalar(x)
Definition SkScalar.h:30
static float SkScalarSinSnapToZero(SkScalar radians)
Definition SkScalar.h:115
#define SkScalarTan(radians)
Definition SkScalar.h:47
#define SkScalarATan2(y, x)
Definition SkScalar.h:50
#define SkScalarCeilToInt(x)
Definition SkScalar.h:36
static float SkScalarCosSnapToZero(SkScalar radians)
Definition SkScalar.h:120
#define SK_ScalarPI
Definition SkScalar.h:21
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition SkMatrix.cpp:770
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:296
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:452
SkMatrix & preRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:462
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:315
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
SkScalar w
void offset(float dx, float dy)

◆ close()

SkPathBuilder & SkPathBuilder::close ( )

Definition at line 155 of file SkPathBuilder.cpp.

155 {
156 if (!fVerbs.empty()) {
157 this->ensureMove();
158
159 fVerbs.push_back((uint8_t)SkPathVerb::kClose);
160
161 // fLastMovePoint stays where it is -- the previous moveTo
162 fNeedsMoveVerb = true;
163 }
164 return *this;
165}
@ kClose
SkPath::RawIter returns 0 points.

◆ computeBounds()

SkRect SkPathBuilder::computeBounds ( ) const

Definition at line 81 of file SkPathBuilder.cpp.

81 {
83 bounds.setBounds(fPts.begin(), fPts.size());
84 return bounds;
85}
int size() const
Definition SkTArray.h:416

◆ conicTo() [1/3]

SkPathBuilder & SkPathBuilder::conicTo ( const SkPoint  pts[2],
SkScalar  w 
)
inline

Definition at line 63 of file SkPathBuilder.h.

63 {
64 return this->conicTo(pts[0], pts[1], w);
65 }

◆ conicTo() [2/3]

SkPathBuilder & SkPathBuilder::conicTo ( SkPoint  pt1,
SkPoint  pt2,
SkScalar  w 
)

Definition at line 129 of file SkPathBuilder.cpp.

129 {
130 this->ensureMove();
131
132 SkPoint* p = fPts.push_back_n(2);
133 p[0] = pt1;
134 p[1] = pt2;
135 fVerbs.push_back((uint8_t)SkPathVerb::kConic);
136 fConicWeights.push_back(w);
137
138 fSegmentMask |= kConic_SkPathSegmentMask;
139 return *this;
140}
@ kConic_SkPathSegmentMask
Definition SkPathTypes.h:44
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
T * push_back_n(int n)
Definition SkTArray.h:262

◆ conicTo() [3/3]

SkPathBuilder & SkPathBuilder::conicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  w 
)
inline

Definition at line 60 of file SkPathBuilder.h.

60 {
61 return this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
62 }

◆ cubicTo() [1/3]

SkPathBuilder & SkPathBuilder::cubicTo ( const SkPoint  pts[3])
inline

Definition at line 71 of file SkPathBuilder.h.

71 {
72 return this->cubicTo(pts[0], pts[1], pts[2]);
73 }

◆ cubicTo() [2/3]

SkPathBuilder & SkPathBuilder::cubicTo ( SkPoint  pt1,
SkPoint  pt2,
SkPoint  pt3 
)

Definition at line 142 of file SkPathBuilder.cpp.

142 {
143 this->ensureMove();
144
145 SkPoint* p = fPts.push_back_n(3);
146 p[0] = pt1;
147 p[1] = pt2;
148 p[2] = pt3;
149 fVerbs.push_back((uint8_t)SkPathVerb::kCubic);
150
151 fSegmentMask |= kCubic_SkPathSegmentMask;
152 return *this;
153}
@ kCubic_SkPathSegmentMask
Definition SkPathTypes.h:45
@ kCubic
SkPath::RawIter returns 4 points.

◆ cubicTo() [3/3]

SkPathBuilder & SkPathBuilder::cubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)
inline

Definition at line 68 of file SkPathBuilder.h.

68 {
69 return this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Make(x3, y3));
70 }

◆ detach()

SkPath SkPathBuilder::detach ( )

Definition at line 239 of file SkPathBuilder.cpp.

239 {
240 auto path = this->make(sk_sp<SkPathRef>(new SkPathRef(std::move(fPts),
241 std::move(fVerbs),
242 std::move(fConicWeights),
243 fSegmentMask)));
244 this->reset();
245 return path;
246}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ fillType()

SkPathFillType SkPathBuilder::fillType ( ) const
inline

Definition at line 36 of file SkPathBuilder.h.

36{ return fFillType; }

◆ incReserve() [1/2]

void SkPathBuilder::incReserve ( int  extraPtCount)
inline

Definition at line 219 of file SkPathBuilder.h.

219 {
220 this->incReserve(extraPtCount, extraPtCount);
221 }

◆ incReserve() [2/2]

void SkPathBuilder::incReserve ( int  extraPtCount,
int  extraVerbCount 
)

Definition at line 76 of file SkPathBuilder.cpp.

76 {
77 fPts.reserve_exact(Sk32_sat_add(fPts.size(), extraPtCount));
78 fVerbs.reserve_exact(Sk32_sat_add(fVerbs.size(), extraVbCount));
79}
static constexpr int32_t Sk32_sat_add(int32_t a, int32_t b)
Definition SkSafe32.h:20
void reserve_exact(int n)
Definition SkTArray.h:176

◆ lineTo() [1/2]

SkPathBuilder & SkPathBuilder::lineTo ( SkPoint  pt)

Definition at line 107 of file SkPathBuilder.cpp.

107 {
108 this->ensureMove();
109
110 fPts.push_back(pt);
111 fVerbs.push_back((uint8_t)SkPathVerb::kLine);
112
113 fSegmentMask |= kLine_SkPathSegmentMask;
114 return *this;
115}
@ kLine_SkPathSegmentMask
Definition SkPathTypes.h:42
@ kLine
SkPath::RawIter returns 2 points.

◆ lineTo() [2/2]

SkPathBuilder & SkPathBuilder::lineTo ( SkScalar  x,
SkScalar  y 
)
inline

Definition at line 51 of file SkPathBuilder.h.

51{ return this->lineTo(SkPoint::Make(x, y)); }

◆ moveTo() [1/2]

SkPathBuilder & SkPathBuilder::moveTo ( SkPoint  pt)

Definition at line 95 of file SkPathBuilder.cpp.

95 {
96 // only needed while SkPath is mutable
97 fLastMoveIndex = SkToInt(fPts.size());
98
99 fPts.push_back(pt);
100 fVerbs.push_back((uint8_t)SkPathVerb::kMove);
101
102 fLastMovePoint = pt;
103 fNeedsMoveVerb = false;
104 return *this;
105}
@ kMove
SkPath::RawIter returns 1 point.

◆ moveTo() [2/2]

SkPathBuilder & SkPathBuilder::moveTo ( SkScalar  x,
SkScalar  y 
)
inline

Definition at line 48 of file SkPathBuilder.h.

48{ return this->moveTo(SkPoint::Make(x, y)); }

◆ offset()

SkPathBuilder & SkPathBuilder::offset ( SkScalar  dx,
SkScalar  dy 
)

Definition at line 793 of file SkPathBuilder.cpp.

793 {
794 for (auto& p : fPts) {
795 p += {dx, dy};
796 }
797 return *this;
798}
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208

◆ operator=() [1/2]

SkPathBuilder & SkPathBuilder::operator= ( const SkPath src)

Definition at line 60 of file SkPathBuilder.cpp.

60 {
61 this->reset().setFillType(src.getFillType());
62
63 for (auto [verb, pts, w] : SkPathPriv::Iterate(src)) {
64 switch (verb) {
65 case SkPathVerb::kMove: this->moveTo(pts[0]); break;
66 case SkPathVerb::kLine: this->lineTo(pts[1]); break;
67 case SkPathVerb::kQuad: this->quadTo(pts[1], pts[2]); break;
68 case SkPathVerb::kConic: this->conicTo(pts[1], pts[2], w[0]); break;
69 case SkPathVerb::kCubic: this->cubicTo(pts[1], pts[2], pts[3]); break;
70 case SkPathVerb::kClose: this->close(); break;
71 }
72 }
73 return *this;
74}
@ kQuad
SkPath::RawIter returns 3 points.
SkPathBuilder & setFillType(SkPathFillType ft)
SkPathFillType getFillType() const
Definition SkPath.h:230

◆ operator=() [2/2]

SkPathBuilder & SkPathBuilder::operator= ( const SkPathBuilder )
default

◆ polylineTo() [1/2]

SkPathBuilder & SkPathBuilder::polylineTo ( const SkPoint  pts[],
int  count 
)

Definition at line 779 of file SkPathBuilder.cpp.

779 {
780 if (count > 0) {
781 this->ensureMove();
782
783 this->incReserve(count, count);
784 memcpy(fPts.push_back_n(count), pts, count * sizeof(SkPoint));
785 memset(fVerbs.push_back_n(count), (uint8_t)SkPathVerb::kLine, count);
786 fSegmentMask |= kLine_SkPathSegmentMask;
787 }
788 return *this;
789}

◆ polylineTo() [2/2]

SkPathBuilder & SkPathBuilder::polylineTo ( const std::initializer_list< SkPoint > &  list)
inline

Definition at line 79 of file SkPathBuilder.h.

79 {
80 return this->polylineTo(list.begin(), SkToInt(list.size()));
81 }

◆ quadTo() [1/3]

SkPathBuilder & SkPathBuilder::quadTo ( const SkPoint  pts[2])
inline

Definition at line 57 of file SkPathBuilder.h.

57{ return this->quadTo(pts[0], pts[1]); }

◆ quadTo() [2/3]

SkPathBuilder & SkPathBuilder::quadTo ( SkPoint  pt1,
SkPoint  pt2 
)

Definition at line 117 of file SkPathBuilder.cpp.

117 {
118 this->ensureMove();
119
120 SkPoint* p = fPts.push_back_n(2);
121 p[0] = pt1;
122 p[1] = pt2;
123 fVerbs.push_back((uint8_t)SkPathVerb::kQuad);
124
125 fSegmentMask |= kQuad_SkPathSegmentMask;
126 return *this;
127}
@ kQuad_SkPathSegmentMask
Definition SkPathTypes.h:43

◆ quadTo() [3/3]

SkPathBuilder & SkPathBuilder::quadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)
inline

Definition at line 54 of file SkPathBuilder.h.

54 {
55 return this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
56 }

◆ rConicTo() [1/2]

SkPathBuilder & SkPathBuilder::rConicTo ( SkPoint  p1,
SkPoint  p2,
SkScalar  w 
)

Definition at line 180 of file SkPathBuilder.cpp.

180 {
181 this->ensureMove();
182 SkPoint base = fPts.back();
183 return this->conicTo(base + p1, base + p2, w);
184}

◆ rConicTo() [2/2]

SkPathBuilder & SkPathBuilder::rConicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  w 
)
inline

Definition at line 92 of file SkPathBuilder.h.

92 {
93 return this->rConicTo({x1, y1}, {x2, y2}, w);
94 }
SkPathBuilder & rConicTo(SkPoint p1, SkPoint p2, SkScalar w)

◆ rCubicTo() [1/2]

SkPathBuilder & SkPathBuilder::rCubicTo ( SkPoint  pt1,
SkPoint  pt2,
SkPoint  pt3 
)

Definition at line 186 of file SkPathBuilder.cpp.

186 {
187 this->ensureMove();
188 SkPoint base = fPts.back();
189 return this->cubicTo(base + p1, base + p2, base + p3);
190}

◆ rCubicTo() [2/2]

SkPathBuilder & SkPathBuilder::rCubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)
inline

Definition at line 96 of file SkPathBuilder.h.

96 {
97 return this->rCubicTo({x1, y1}, {x2, y2}, {x3, y3});
98 }
SkPathBuilder & rCubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3)

◆ reset()

SkPathBuilder & SkPathBuilder::reset ( )

Definition at line 43 of file SkPathBuilder.cpp.

43 {
44 fPts.clear();
45 fVerbs.clear();
46 fConicWeights.clear();
47 fFillType = SkPathFillType::kWinding;
48 fIsVolatile = false;
49
50 // these are internal state
51
52 fSegmentMask = 0;
53 fLastMovePoint = {0, 0};
54 fLastMoveIndex = -1; // illegal
55 fNeedsMoveVerb = true;
56
57 return *this;
58}

◆ rLineTo() [1/2]

SkPathBuilder & SkPathBuilder::rLineTo ( SkPoint  pt)

Definition at line 169 of file SkPathBuilder.cpp.

169 {
170 this->ensureMove();
171 return this->lineTo(fPts.back() + p1);
172}

◆ rLineTo() [2/2]

SkPathBuilder & SkPathBuilder::rLineTo ( SkScalar  x,
SkScalar  y 
)
inline

Definition at line 86 of file SkPathBuilder.h.

86{ return this->rLineTo({x, y}); }
SkPathBuilder & rLineTo(SkPoint pt)

◆ rQuadTo() [1/2]

SkPathBuilder & SkPathBuilder::rQuadTo ( SkPoint  pt1,
SkPoint  pt2 
)

Definition at line 174 of file SkPathBuilder.cpp.

174 {
175 this->ensureMove();
176 SkPoint base = fPts.back();
177 return this->quadTo(base + p1, base + p2);
178}

◆ rQuadTo() [2/2]

SkPathBuilder & SkPathBuilder::rQuadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)
inline

Definition at line 88 of file SkPathBuilder.h.

88 {
89 return this->rQuadTo({x1, y1}, {x2, y2});
90 }
SkPathBuilder & rQuadTo(SkPoint pt1, SkPoint pt2)

◆ setFillType()

SkPathBuilder & SkPathBuilder::setFillType ( SkPathFillType  ft)
inline

Definition at line 42 of file SkPathBuilder.h.

42{ fFillType = ft; return *this; }

◆ setIsVolatile()

SkPathBuilder & SkPathBuilder::setIsVolatile ( bool  isVolatile)
inline

Definition at line 43 of file SkPathBuilder.h.

43{ fIsVolatile = isVolatile; return *this; }

◆ snapshot()

SkPath SkPathBuilder::snapshot ( ) const

Definition at line 232 of file SkPathBuilder.cpp.

232 {
233 return this->make(sk_sp<SkPathRef>(new SkPathRef(fPts,
234 fVerbs,
235 fConicWeights,
236 fSegmentMask)));
237}

◆ toggleInverseFillType()

SkPathBuilder & SkPathBuilder::toggleInverseFillType ( )
inline

Definition at line 225 of file SkPathBuilder.h.

225 {
226 fFillType = (SkPathFillType)((unsigned)fFillType ^ 2);
227 return *this;
228 }
SkPathFillType
Definition SkPathTypes.h:11

Friends And Related Symbol Documentation

◆ SkPathPriv

friend class SkPathPriv
friend

Definition at line 267 of file SkPathBuilder.h.


The documentation for this class was generated from the following files: