36 int32_t* index,
int count) {
37 for (
int i = 0; i <
count; ++i) {
39 if (phase > gap || (phase == gap && gap)) {
55 SkScalar* initialDashLength, int32_t* initialDashIndex,
58 for (
int i = 0; i <
count; i++) {
61 *intervalLength = len;
79 }
else if (phase >= len) {
82 *adjustedPhase = phase;
87 initialDashIndex,
count);
90 SkASSERT(*initialDashIndex >= 0 && *initialDashIndex <
count);
101 rect->outset(radius, radius);
119 if (dxy.
fX && dxy.
fY) {
126 bool swapped = maxXY < minXY;
133 SkScalar leftTop = (&bounds.fLeft)[xyOffset];
134 SkScalar rightBottom = (&bounds.fRight)[xyOffset];
135 if (maxXY < leftTop || minXY > rightBottom) {
143 if (minXY < leftTop) {
144 minXY = leftTop -
SkScalarMod(leftTop - minXY, intervalLength);
149 if (maxXY > rightBottom) {
150 maxXY = rightBottom +
SkScalarMod(maxXY - rightBottom, intervalLength);
161 (&pts[0].
fX)[xyOffset] = minXY;
162 (&pts[1].
fX)[xyOffset] = maxXY;
164 if (minXY == maxXY) {
177 if (srcPath.
isLine(pts) && pts[0] == pts[1]) {
192 if (srcPath.
isLine(pts)) {
193 if (
clip_line(pts, bounds, intervalLength, 0)) {
202 if (srcPath.
isRect(
nullptr)) {
215 if (
clip_line(pts, bounds, intervalLength, std::fmod(accum, intervalLength))) {
219 if (!dstPath->
getLastPt(&last) || last != pts[0]) {
238 int intervalCount,
SkScalar intervalLength) {
250 fTangent = fPts[1] - fPts[0];
255 fPathLength = pathLength;
267 SkScalar ptCount = pathLength * intervalCount / (float)intervalLength;
283 if (d1 > fPathLength) {
293 pts[0].
set(x0 + fNormal.
fX, y0 + fNormal.
fY);
294 pts[1].
set(x1 + fNormal.
fX, y1 + fNormal.
fY);
295 pts[2].
set(x1 - fNormal.
fX, y1 - fNormal.
fY);
296 pts[3].
set(x0 - fNormal.
fX, y0 - fNormal.
fY);
298 path->addPoly(pts, std::size(pts),
false);
311 int32_t
count,
SkScalar initialDashLength, int32_t initialDashIndex,
323 const SkScalar* intervals = aIntervals;
328 const SkPath* srcPtr = &src;
329 if (
cull_path(src, *rec, cullRect, intervalLength, &cullPathStorage)) {
332 if (src.isRect(
nullptr) && src.isLastContourClosed() &&
is_even(initialDashIndex)) {
334#if defined(SK_LEGACY_RECT_DASHING_BUG)
340 while (endPhase > intervals[index]) {
341 endPhase -= intervals[index++];
343 if (index ==
count) {
353 if (
is_even(index) == (endPhase > 0)) {
354 SkPoint midPoint = src.getPoint(0);
356 int last = src.countPoints() - 1;
357 while (midPoint == src.getPoint(last)) {
363 while (midPoint == src.getPoint(
next)) {
367 SkVector v = midPoint - src.getPoint(last);
371 cullPathStorage.
moveTo(midPoint - v);
372 cullPathStorage.
lineTo(midPoint);
373 v = midPoint - src.getPoint(
next);
376 cullPathStorage.
lineTo(midPoint - v);
379 srcPtr = &cullPathStorage;
383 bool specialLine = (StrokeRecApplication::kAllow == strokeRecApplication) &&
384 lineRec.
init(*srcPtr, dst, rec,
count >> 1, intervalLength);
389 bool skipFirstSegment = meas.
isClosed();
390 bool addedSegment =
false;
392 int index = initialDashIndex;
402 dashCount +=
length * (
count >> 1) / intervalLength;
411 double dlen = initialDashLength;
413 while (distance <
length) {
415 addedSegment =
false;
416 if (
is_even(index) && !skipFirstSegment) {
433 skipFirstSegment =
false;
438 if (index ==
count) {
443 dlen = intervals[index];
448 initialDashLength >= 0) {
449 meas.
getSegment(0, initialDashLength, dst, !addedSegment);
468 int32_t initialDashIndex = 0;
471 &initialDashLength, &initialDashIndex, &intervalLength);
473 initialDashIndex, intervalLength,
info.fPhase);
481 for (
int i = 0; i <
count; i++) {
482 if (intervals[i] < 0) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static float next(float f)
static constexpr bool SkIsAlign2(T x)
#define SkAssertResult(cond)
static void adjust_zero_length_line(SkPoint pts[2])
static int is_even(int x)
static bool cull_path(const SkPath &srcPath, const SkStrokeRec &rec, const SkRect *cullRect, SkScalar intervalLength, SkPath *dstPath)
static bool clip_line(SkPoint pts[2], const SkRect &bounds, SkScalar intervalLength, SkScalar priorPhase)
static void outset_for_stroke(SkRect *rect, const SkStrokeRec &rec)
static SkScalar find_first_interval(const SkScalar intervals[], SkScalar phase, int32_t *index, int count)
static bool SkIsFinite(T x, Pack... values)
static constexpr float sk_ieee_float_divide(float numer, float denom)
void swap(sk_sp< T > &a, sk_sp< T > &b)
#define SkScalarMod(x, y)
#define SkDoubleToScalar(x)
#define SkScalarCeilToInt(x)
#define SK_ScalarNearlyZero
static constexpr bool SkToBool(const T &x)
@ kButt_Cap
no stroke extension
@ kMiter_Join
extends to miter limit
bool getSegment(SkScalar startD, SkScalar stopD, SkPath *dst, bool startWithMoveTo)
static void SetConvexity(const SkPath &path, SkPathConvexity c)
Verb next(SkPoint pts[4])
SkPath & moveTo(SkScalar x, SkScalar y)
bool isLine(SkPoint line[2]) const
bool getLastPt(SkPoint *lastPt) const
SkPath & lineTo(SkScalar x, SkScalar y)
bool isRect(SkRect *rect, bool *isClosed=nullptr, SkPathDirection *direction=nullptr) const
static void RotateCCW(const SkPoint &src, SkPoint *dst)
bool isHairlineStyle() const
SkScalar getWidth() const
SkPaint::Join getJoin() const
SkPaint::Cap getCap() const
SkScalar getResScale() const
SkScalar getMiter() const
bool init(const SkPath &src, SkPath *dst, SkStrokeRec *rec, int intervalCount, SkScalar intervalLength)
void addSegment(SkScalar d0, SkScalar d1, SkPath *path) const
const SkScalar kMaxDashCount
bool FilterDashPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *, const SkPathEffect::DashInfo &info)
bool InternalFilter(SkPath *dst, const SkPath &src, SkStrokeRec *rec, const SkRect *cullRect, const SkScalar aIntervals[], int32_t count, SkScalar initialDashLength, int32_t initialDashIndex, SkScalar intervalLength, SkScalar startPhase, StrokeRecApplication=StrokeRecApplication::kAllow)
void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count, SkScalar *initialDashLength, int32_t *initialDashIndex, SkScalar *intervalLength, SkScalar *adjustedPhase=nullptr)
bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count)
void set(float x, float y)
static float Distance(const SkPoint &a, const SkPoint &b)
void scale(float scale, SkPoint *dst) const