aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkStrokeRec.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/SkStrokeRec.cpp b/src/core/SkStrokeRec.cpp
index 1b4007cd83..41a3c30e41 100644
--- a/src/core/SkStrokeRec.cpp
+++ b/src/core/SkStrokeRec.cpp
@@ -136,29 +136,36 @@ void SkStrokeRec::applyToPaint(SkPaint* paint) const {
}
static inline SkScalar get_inflation_bounds(SkPaint::Join join,
- SkScalar strokeWidth,
- SkScalar miterLimit) {
+ SkScalar miterLimit,
+ SkPaint::Cap cap,
+ SkScalar strokeWidth) {
if (strokeWidth < 0) { // fill
return 0;
} else if (0 == strokeWidth) {
+ // FIXME: We need a "matrixScale" parameter here in order to properly handle hairlines.
+ // Their with is determined in device space, unlike other strokes.
+ // http://skbug.com/8157
return SK_Scalar1;
}
- // since we're stroked, outset the rect by the radius (and join type)
- SkScalar radius = SkScalarHalf(strokeWidth);
+
+ // since we're stroked, outset the rect by the radius (and join type, caps)
+ SkScalar multiplier = SK_Scalar1;
if (SkPaint::kMiter_Join == join) {
- if (miterLimit > SK_Scalar1) {
- radius *= miterLimit;
- }
+ multiplier = SkTMax(multiplier, miterLimit);
+ }
+ if (SkPaint::kSquare_Cap == cap) {
+ multiplier = SkTMax(multiplier, SK_ScalarSqrt2);
}
- return radius;
+ return strokeWidth/2 * multiplier;
}
SkScalar SkStrokeRec::getInflationRadius() const {
- return get_inflation_bounds((SkPaint::Join)fJoin, fWidth, fMiterLimit);
+ return get_inflation_bounds((SkPaint::Join)fJoin, fMiterLimit, (SkPaint::Cap)fCap, fWidth);
}
SkScalar SkStrokeRec::GetInflationRadius(const SkPaint& paint, SkPaint::Style style) {
SkScalar width = SkPaint::kFill_Style == style ? -SK_Scalar1 : paint.getStrokeWidth();
- return get_inflation_bounds(paint.getStrokeJoin(), width, paint.getStrokeMiter());
+ return get_inflation_bounds(paint.getStrokeJoin(), paint.getStrokeMiter(), paint.getStrokeCap(),
+ width);
}