bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPath& src, SkScalar resScale) const { SkASSERT(style); SkASSERT(dst); SkStrokeRec strokeRec = fStrokeRec; strokeRec.setResScale(resScale); const SkPath* pathForStrokeRec = &src; if (apply_path_effect(dst, &strokeRec, fPathEffect, src)) { pathForStrokeRec = dst; } else if (fPathEffect) { return false; } if (strokeRec.needToApply()) { if (!strokeRec.applyToPath(dst, *pathForStrokeRec)) { return false; } *style = SkStrokeRec::kFill_InitStyle; } else if (!fPathEffect) { // Nothing to do for path effect or stroke, fail. return false; } else { SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() || SkStrokeRec::kHairline_Style == strokeRec.getStyle()); *style = strokeRec.getStyle() == SkStrokeRec::kFill_Style ? SkStrokeRec::kFill_InitStyle : SkStrokeRec::kHairline_InitStyle; } return true; }
bool GrStyle::applyPathEffectToPath(SkPath *dst, SkStrokeRec *remainingStroke, const SkPath &src, SkScalar resScale) const { SkASSERT(dst); SkStrokeRec strokeRec = fStrokeRec; strokeRec.setResScale(resScale); if (!apply_path_effect(dst, &strokeRec, fPathEffect, src)) { return false; } *remainingStroke = strokeRec; return true; }