/* Note: does NOT use convexity in the raw, so it need not be resolved, *ifconvertingfrombuilderorpath.
*/ staticbool Contains(const SkPathRaw&, SkPoint);
// skbug.com/40041027: Not a perfect solution for W plane clipping, but 1/16384 is a // reasonable limit (roughly 5e-5) inlinestatic constexpr SkScalar kW0PlaneDistance = 1.f / (1 << 14);
static SkPathFirstDirection AsFirstDirection(SkPathDirection dir) { // since we agree numerically for the values in Direction, we can just cast. return (SkPathFirstDirection)dir;
}
// Asserts the path contour was built from RRect, so it does not return // an optional. This exists so path's can have a flag that they are really // a RRect, without having to actually store the 4 radii... since those can // be deduced from the contour itself. // static SkRRect DeduceRRectFromContour(const SkRect& bounds,
SkSpan<const SkPoint>, SkSpan<const SkPathVerb>);
// returns Empty() if there are no points static SkRect ComputeTightBounds(SkSpan<const SkPoint> points,
SkSpan<const SkPathVerb> verbs,
SkSpan<constfloat> conicWeights);
/** Returns the oval info if this path was created as an oval or circle, else returns {}.
*/ static std::optional<SkPathOvalInfo> IsOval(const SkPath& path) { return path.getOvalInfo();
}
/** Returns the rrect info if this path was created as one, else returns {}.
*/ static std::optional<SkPathRRectInfo> IsRRect(const SkPath& path) { return path.getRRectInfo();
}
/** *Sometimesinthedrawingpipeline,wehavetoperformmathonpathcoordinates,evenafter *thepathisindevice-coordinates.Tessellationandclippingaretwoexamples.Usuallythis *isprettymodest,butitcaninvolvesubtracting/addingcoordinates,ormultiplyingby *smallconstants(e.g.2,3,4).Totrytopreflightissueswheretheseoptionationscouldturn *finitepathvaluesintoinfinities(orNaNs),weallowtheupperdrawingcodetoreject *thepathifitsbounds(indevicecoordinates)istooclosetomaxfloat.
*/ staticbool TooBigForMath(const SkRect& bounds) { // This value is just a guess. smaller is safer, but we don't want to reject largish paths // that we don't have to.
constexpr SkScalar scale_down_to_allow_for_small_multiplies = 0.25f;
constexpr SkScalar max = SK_ScalarMax * scale_down_to_allow_for_small_multiplies;
// use ! expression so we return true if bounds contains NaN return !(bounds.fLeft >= -max && bounds.fTop >= -max &&
bounds.fRight <= max && bounds.fBottom <= max);
}
/** Returns true if SkPath is equivalent to nested SkRect pair when filled. Iffalse,rectanddirsareunchanged. Iftrue,rectanddirsarewrittentoifnotnullptr: settingrect[0]toouterSkRect,andrect[1]toinnerSkRect; settingdirs[0]toSkPathDirectionofouterSkRect,anddirs[1]toSkPathDirectionof innerSkRect.
// Returns Empty if there are no points // Returns {} if the bounds are not finite static std::optional<SkRect> TrimmedBounds(SkSpan<const SkPoint> pts,
SkSpan<const SkPathVerb> vbs) { // Does a trailing kMove verb contribute to the bounds? // - only if it is the only verb in the path // - otherwise we ignore it when computing bounds if (vbs.size() > 1 && vbs.back() == SkPathVerb::kMove) {
SkASSERT(pts.size() > 0); // While trailing moves do not contribute to the bounds, we still reject them. if (!pts.back().isFinite()) { return {};
}
pts = pts.subspan(0, pts.size() - 1);
} return SkRect::Bounds(pts);
}
};
// Lightweight variant of SkPath::Iter that only returns segments (e.g. lines/conics). // Does not return kMove or kClose. // Always "auto-closes" each contour. // Roughly the same as SkPath::Iter(path, true), but does not return moves or closes // class SkPathEdgeIter { const SkPathVerb* fVerbs; const SkPathVerb* fVerbsStop; const SkPoint* fPts; const SkPoint* fMoveToPtr; const SkScalar* fConicWeights;
SkPoint fScratch[2]; // for auto-close lines bool fNeedsCloseLine; bool fNextIsNewContour;
SkDEBUGCODE(bool fIsConic;)
// todo: return as optional? fPts become span? struct Result { const SkPoint* fPts; // points for the segment, or null if done
Edge fEdge; bool fIsNewContour;
// Returns true when it holds an Edge, false when the path is done. explicitoperatorbool() { return fPts != nullptr; }
};
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.