/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count);
fCount = count; for (int i = 0; i < count; i++) {
fIntervals[i] = intervals[i];
}
// set the internal data members
SkDashPath::CalcDashParameters(phase, fIntervals, fCount,
&fInitialDashLength, &fInitialDashIndex, &fIntervalLength, &fPhase);
}
// Attempt to trim the line to minimally cover the cull rect (currently // only works for horizontal and vertical lines). // Return true if processing should continue; false otherwise. staticbool cull_line(SkPoint* pts, const SkStrokeRec& rec, const SkMatrix& ctm, const SkRect* cullRect, const SkScalar intervalLength) { if (nullptr == cullRect) {
SkASSERT(false); // Shouldn't ever occur in practice returnfalse;
}
// Now we actually perform the chop, removing the excess to the left and // right of the bounds (keeping our new line "in phase" with the dash, // hence the (mod intervalLength).
// Now we actually perform the chop, removing the excess to the top and // bottom of the bounds (keeping our new line "in phase" with the dash, // hence the (mod intervalLength).
SkASSERT(maxY > minY); if (dy < 0) { using std::swap;
swap(minY, maxY);
}
pts[0].fY = minY;
pts[1].fY = maxY;
}
returntrue;
}
// Currently asPoints is more restrictive then it needs to be. In the future // we need to: // allow kRound_Cap capping (could allow rotations in the matrix with this) // allow paths to be returned bool SkDashImpl::onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec& rec, const SkMatrix& matrix, const SkRect* cullRect) const { // width < 0 -> fill && width == 0 -> hairline so requiring width > 0 rules both out if (0 >= rec.getWidth()) { returnfalse;
}
// TODO: this next test could be eased up. We could allow any number of // intervals as long as all the ons match and all the offs match. // Additionally, they do not necessarily need to be integers. // We cannot allow arbitrary intervals since we want the returned points // to be uniformly sized. if (fCount != 2 ||
!SkScalarNearlyEqual(fIntervals[0], fIntervals[1]) ||
!SkScalarIsInt(fIntervals[0]) ||
!SkScalarIsInt(fIntervals[1])) { returnfalse;
}
SkPoint pts[2];
if (!src.isLine(pts)) { returnfalse;
}
// TODO: this test could be eased up to allow circles if (SkPaint::kButt_Cap != rec.getCap()) { returnfalse;
}
// TODO: this test could be eased up for circles. Rotations could be allowed. if (!matrix.rectStaysRect()) { returnfalse;
}
// See if the line can be limited to something plausible. if (!cull_line(pts, rec, matrix, cullRect, fIntervalLength)) { returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.