| Index: WebCore/platform/graphics/skia/PlatformContextSkia.cpp
|
| ===================================================================
|
| --- WebCore/platform/graphics/skia/PlatformContextSkia.cpp (revision 33098)
|
| +++ WebCore/platform/graphics/skia/PlatformContextSkia.cpp (working copy)
|
| @@ -343,6 +343,15 @@
|
| paint->setShader(m_state->m_fillShader);
|
| }
|
|
|
| +static SkScalar scalarBound(SkScalar v, SkScalar min, SkScalar max)
|
| +{
|
| + if (v < min)
|
| + return min;
|
| + if (v > max)
|
| + return max;
|
| + return v;
|
| +}
|
| +
|
| float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, int length) const
|
| {
|
| setupPaintCommon(paint);
|
| @@ -351,10 +360,13 @@
|
| paint->setColor(m_state->applyAlpha(m_state->m_strokeColor));
|
| paint->setShader(m_state->m_strokeShader);
|
| paint->setStyle(SkPaint::kStroke_Style);
|
| - paint->setStrokeWidth(SkFloatToScalar(width));
|
| + // The limits here (512 and 256) were made up but are hopefully large
|
| + // enough to be reasonable. They are, empirically, small enough not to
|
| + // cause overflows in Skia.
|
| + paint->setStrokeWidth(scalarBound(SkFloatToScalar(width), 0, 512));
|
| paint->setStrokeCap(m_state->m_lineCap);
|
| paint->setStrokeJoin(m_state->m_lineJoin);
|
| - paint->setStrokeMiter(SkFloatToScalar(m_state->m_miterLimit));
|
| + paint->setStrokeMiter(scalarBound(SkFloatToScalar(m_state->m_miterLimit), 0, 256));
|
|
|
| if (m_state->m_dash)
|
| paint->setPathEffect(m_state->m_dash);
|
|
|