bool SkEdgeClipper::clipCubic(const SkPoint srcPts[4], const SkRect& clip) { fCurrPoint = fPoints; fCurrVerb = fVerbs; SkRect bounds; bounds.set(srcPts, 4); if (!quick_reject(bounds, clip)) { SkPoint monoY[10]; int countY = SkChopCubicAtYExtrema(srcPts, monoY); for (int y = 0; y <= countY; y++) { // sk_assert_monotonic_y(&monoY[y * 3], 4); SkPoint monoX[10]; int countX = SkChopCubicAtXExtrema(&monoY[y * 3], monoX); for (int x = 0; x <= countX; x++) { // sk_assert_monotonic_y(&monoX[x * 3], 4); // sk_assert_monotonic_x(&monoX[x * 3], 4); this->clipMonoCubic(&monoX[x * 3], clip); SkASSERT(fCurrVerb - fVerbs < kMaxVerbs); SkASSERT(fCurrPoint - fPoints <= kMaxPoints); } } } *fCurrVerb = SkPath::kDone_Verb; fCurrPoint = fPoints; fCurrVerb = fVerbs; return SkPath::kDone_Verb != fVerbs[0]; }
int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4]) { int num_crossings = 0; SkPoint monotonic_cubics[10]; int num_monotonic_cubics = SkChopCubicAtYExtrema(cubic, monotonic_cubics); if (SkXRayCrossesMonotonicCubic(pt, &monotonic_cubics[0])) ++num_crossings; if (num_monotonic_cubics > 0) if (SkXRayCrossesMonotonicCubic(pt, &monotonic_cubics[3])) ++num_crossings; if (num_monotonic_cubics > 1) if (SkXRayCrossesMonotonicCubic(pt, &monotonic_cubics[6])) ++num_crossings; return num_crossings; }