Index: src/core/SkStrokeRec.cpp |
diff --git a/src/core/SkStrokeRec.cpp b/src/core/SkStrokeRec.cpp |
index 6aed573418c3b4fc34629344aa7389085faa1fb2..52eba1314444b0092f6addb1e3187df384725496 100644 |
--- a/src/core/SkStrokeRec.cpp |
+++ b/src/core/SkStrokeRec.cpp |
@@ -134,3 +134,33 @@ void SkStrokeRec::applyToPaint(SkPaint* paint) const { |
paint->setStrokeCap((SkPaint::Cap)fCap); |
paint->setStrokeJoin((SkPaint::Join)fJoin); |
} |
+ |
+static inline SkScalar get_inflation_bounds(SkPaint::Join join, |
+ SkScalar strokeWidth, |
+ SkScalar miterLimit) { |
+ if (strokeWidth < 0) { // fill |
+ return 0; |
+ } else if (0 == strokeWidth) { |
+ return SK_Scalar1; |
+ } |
+ // since we're stroked, outset the rect by the radius (and join type) |
+ SkScalar radius = SkScalarHalf(strokeWidth); |
+ if (SkPaint::kMiter_Join == join) { |
+ if (miterLimit > SK_Scalar1) { |
+ radius = SkScalarMul(miterLimit, radius); |
+ } |
+ } |
+ return radius; |
+} |
+ |
+SkScalar SkStrokeRec::getInflationRadius() const { |
+ return get_inflation_bounds((SkPaint::Join)fJoin, fWidth, fMiterLimit); |
+} |
+ |
+SkScalar SkStrokeRec::GetInflationBounds(const SkPaint& paint) { |
+ SkScalar width = SkPaint::kFill_Style == paint.getStyle() |
+ ? -SK_Scalar1 |
+ : paint.getStrokeWidth(); |
+ return get_inflation_bounds(paint.getStrokeJoin(), width, paint.getStrokeMiter()); |
+ |
+} |