Changeset 51319 in webkit


Ignore:
Timestamp:
Nov 23, 2009 2:10:55 PM (14 years ago)
Author:
agl@chromium.org
Message:

2009-11-23 Adam Langley <agl@google.com>

Reviewed by Dmitry Titov.

Chromium Linux: Limit the stroke width and mitre limit.

Limit the stroke width and mitre limit that we'll pass into Skia to
avoid overflowing Skia's uint16_t glyph widths.

http://code.google.com/p/chromium/issues/detail?id=28250
https://bugs.webkit.org/show_bug.cgi?id=31747

  • platform/graphics/skia/PlatformContextSkia.cpp: (scalarBound): (PlatformContextSkia::setupPaintForStroking):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51317 r51319  
     12009-11-23  Adam Langley  <agl@google.com>
     2
     3        Reviewed by Dmitry Titov.
     4
     5        Chromium Linux: Limit the stroke width and mitre limit.
     6
     7        Limit the stroke width and mitre limit that we'll pass into Skia to
     8        avoid overflowing Skia's uint16_t glyph widths.
     9
     10        http://code.google.com/p/chromium/issues/detail?id=28250
     11        https://bugs.webkit.org/show_bug.cgi?id=31747
     12
     13        * platform/graphics/skia/PlatformContextSkia.cpp:
     14        (scalarBound):
     15        (PlatformContextSkia::setupPaintForStroking):
     16
    1172009-11-23  Alexey Proskuryakov  <ap@apple.com>
    218
  • trunk/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r50253 r51319  
    344344}
    345345
     346static SkScalar scalarBound(SkScalar v, SkScalar min, SkScalar max)
     347{
     348    if (v < min)
     349        return min;
     350    if (v > max)
     351        return max;
     352    return v;
     353}
     354
    346355float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, int length) const
    347356{
     
    352361    paint->setShader(m_state->m_strokeShader);
    353362    paint->setStyle(SkPaint::kStroke_Style);
    354     paint->setStrokeWidth(SkFloatToScalar(width));
     363    // The limits here (512 and 256) were made up but are hopefully large
     364    // enough to be reasonable. They are, empirically, small enough not to
     365    // cause overflows in Skia.
     366    paint->setStrokeWidth(scalarBound(SkFloatToScalar(width), 0, 512));
    355367    paint->setStrokeCap(m_state->m_lineCap);
    356368    paint->setStrokeJoin(m_state->m_lineJoin);
    357     paint->setStrokeMiter(SkFloatToScalar(m_state->m_miterLimit));
     369    paint->setStrokeMiter(scalarBound(SkFloatToScalar(m_state->m_miterLimit), 0, 256));
    358370
    359371    if (m_state->m_dash)
Note: See TracChangeset for help on using the changeset viewer.