Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3090)

Unified Diff: WebCore/platform/graphics/skia/PlatformContextSkia.cpp

Issue 437067: Merge WebKit 51319: Chromium Linux: Limit the stroke width and mitre limit.... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/249/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698