Changeset 18306 in webkit


Ignore:
Timestamp:
Dec 19, 2006 12:54:00 AM (17 years ago)
Author:
hyatt
Message:

Convert stroke thickness to a float. This allows the thickness argument to strokeArc to be eliminated.


Reviewed by olliej

  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::setStrokeThickness): (WebCore::GraphicsContext::strokeThickness): (WebCore::GraphicsContext::setPlatformStrokeThickness):
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::drawEllipse): (WebCore::GraphicsContext::strokeArc):
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContext::strokeArc): (WebCore::GraphicsContext::setPlatformStrokeThickness):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::drawBorderArc):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r18305 r18306  
     12006-12-19  David Hyatt  <hyatt@apple.com>
     2
     3        Convert stroke thickness to a float.  This allows the thickness argument to strokeArc to be eliminated.
     4       
     5        Reviewed by olliej
     6
     7        * platform/graphics/GraphicsContext.cpp:
     8        (WebCore::GraphicsContext::setStrokeThickness):
     9        (WebCore::GraphicsContext::strokeThickness):
     10        (WebCore::GraphicsContext::setPlatformStrokeThickness):
     11        * platform/graphics/GraphicsContext.h:
     12        * platform/graphics/cg/GraphicsContextCG.cpp:
     13        (WebCore::GraphicsContext::drawEllipse):
     14        (WebCore::GraphicsContext::strokeArc):
     15        * platform/graphics/qt/GraphicsContextQt.cpp:
     16        (WebCore::GraphicsContext::strokeArc):
     17        (WebCore::GraphicsContext::setPlatformStrokeThickness):
     18        * rendering/RenderObject.cpp:
     19        (WebCore::RenderObject::drawBorderArc):
     20
    1212006-12-19  David Hyatt  <hyatt@apple.com>
    222
  • trunk/WebCore/platform/graphics/GraphicsContext.cpp

    r18294 r18306  
    4646    Font font;
    4747    StrokeStyle strokeStyle;
    48     unsigned strokeThickness;
     48    float strokeThickness;
    4949    Color strokeColor;
    5050    Color fillColor;
     
    118118}
    119119
    120 void GraphicsContext::setStrokeThickness(unsigned thickness)
     120void GraphicsContext::setStrokeThickness(float thickness)
    121121{
    122122    m_common->state.strokeThickness = thickness;
     
    136136}
    137137
    138 unsigned GraphicsContext::strokeThickness() const
     138float GraphicsContext::strokeThickness() const
    139139{
    140140    return m_common->state.strokeThickness;
     
    352352}
    353353
    354 void GraphicsContext::setPlatformStrokeThickness(unsigned)
     354void GraphicsContext::setPlatformStrokeThickness(float)
    355355{
    356356}
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r18305 r18306  
    8888        void setFont(const Font&);
    8989       
    90         unsigned strokeThickness() const;
    91         void setStrokeThickness(unsigned);
     90        float strokeThickness() const;
     91        void setStrokeThickness(float);
    9292        StrokeStyle strokeStyle() const;
    9393        void setStrokeStyle(const StrokeStyle& style);
     
    107107        void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
    108108
    109         // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.  It ignores
    110         // the stroke thickness, relying instead on a passed-in argument (because of float vs. int issues).
    111         // FIXME: Reconcile this method with stroke thickness by converting stroke thickness to a float.
    112         void strokeArc(const IntRect&, float thickness, int startAngle, int angleSpan);
     109        // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
     110        void strokeArc(const IntRect&, int startAngle, int angleSpan);
    113111       
    114112        void fillRect(const IntRect&, const Color&);
     
    207205        void setPlatformStrokeColor(const Color&);
    208206        void setPlatformStrokeStyle(const StrokeStyle&);
    209         void setPlatformStrokeThickness(unsigned);
     207        void setPlatformStrokeThickness(float);
    210208        void setPlatformFillColor(const Color&);
    211209        void setPlatformFont(const Font& font);
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r18305 r18306  
    267267        if (strokeStyle() != NoStroke) {
    268268            // stroke and fill
    269             unsigned penWidth = max(strokeThickness(), 1U);
    270             CGContextSetLineWidth(context, penWidth);
     269            unsigned strokeWidth = max(strokeThickness(), 1.0f);
     270            CGContextSetLineWidth(context, strokeWidth);
    271271            CGContextDrawPath(context, kCGPathFillStroke);
    272272        } else
    273273            CGContextFillPath(context);
    274274    } else if (strokeStyle() != NoStroke) {
    275         unsigned penWidth = max(strokeThickness(), 1U);
    276         CGContextSetLineWidth(context, penWidth);
     275        unsigned strokeWidth = max(strokeThickness(), 1.0f);
     276        CGContextSetLineWidth(context, strokeWidth);
    277277        CGContextStrokePath(context);
    278278    }
     
    280280
    281281
    282 void GraphicsContext::strokeArc(const IntRect& rect, float thickness, int startAngle, int angleSpan)
     282void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
    283283{
    284     if (paintingDisabled() || strokeStyle() == NoStroke || thickness <= 0.0f || !strokeColor().alpha())
     284    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
    285285        return;
    286286   
     
    312312   
    313313   
    314     float width = max(thickness,  1.0f);
     314    float width = max(strokeThickness(),  1.0f);
    315315    int patWidth = 0;
    316316   
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r18305 r18306  
    440440}
    441441
    442 void GraphicsContext::strokeArc(const IntRect& rect, float thickness, int startAngle, int angleSpan)
    443 {
    444     if (paintingDisabled() || strokeStyle() == NoStroke || thickness <= 0.0f || !strokeColor().alpha())
    445         return;
    446 
    447     const QPen oldPen = m_data->p().pen();
    448     QPen nPen = oldPen;
    449     nPen.setWidthF(thickness);
    450     m_data->p().setPen(nPen);
     442void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
     443{
     444    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
     445        return;
     446
    451447    m_data->p().drawArc(rect, startAngle, angleSpan);
    452     m_data->p().setPen(oldPen);
    453448}
    454449
     
    856851}
    857852
    858 void GraphicsContext::setPlatformStrokeThickness(unsigned thickness)
     853void GraphicsContext::setPlatformStrokeThickness(float thickness)
    859854{
    860855    QPen newPen(m_data->p().pen());
    861     newPen.setWidth(thickness);
     856    newPen.setWidthF(thickness);
    862857    m_data->p().setPen(newPen);
    863858}
  • trunk/WebCore/rendering/RenderObject.cpp

    r18305 r18306  
    878878            graphicsContext->setStrokeColor(c);
    879879            graphicsContext->setStrokeStyle(style == DOTTED ? DottedStroke : DashedStroke);
    880             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     880            graphicsContext->setStrokeThickness(thickness);
     881            graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
    881882            break;
    882883        case DOUBLE: {
     
    897898
    898899            graphicsContext->setStrokeStyle(SolidStroke);
    899             graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), third, angleStart, angleSpan);
    900             graphicsContext->strokeArc(IntRect(innerX, innerY, innerWidth, innerHeight), (innerThird > 2) ? innerThird - 1 : innerThird,
    901                                      angleStart, angleSpan);
     900            graphicsContext->setStrokeColor(c);
     901            graphicsContext->setStrokeThickness(third);
     902            graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), angleStart, angleSpan);
     903            graphicsContext->setStrokeThickness(innerThird > 2 ? innerThird - 1 : innerThird);
     904            graphicsContext->strokeArc(IntRect(innerX, innerY, innerWidth, innerHeight), angleStart, angleSpan);
    902905            break;
    903906        }
     
    915918            graphicsContext->setStrokeStyle(SolidStroke);
    916919            graphicsContext->setStrokeColor(c);
    917             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     920            graphicsContext->setStrokeThickness(thickness);
     921            graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
    918922
    919923            float halfThickness = (thickness + 1.0f) / 4.0f;
    920924            int shiftForInner = static_cast<int>(halfThickness * 1.5f);
    921925            graphicsContext->setStrokeColor(c2);
     926            graphicsContext->setStrokeThickness(halfThickness > 2 ? halfThickness - 1 : halfThickness);
    922927            graphicsContext->strokeArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2,
    923                                      (radius.height() - shiftForInner) * 2), (halfThickness > 2) ? halfThickness - 1 : halfThickness,
    924                                      angleStart, angleSpan);
     928                                       (radius.height() - shiftForInner) * 2), angleStart, angleSpan);
    925929            break;
    926930        }
     
    934938            graphicsContext->setStrokeStyle(SolidStroke);
    935939            graphicsContext->setStrokeColor(c);
    936             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan);
     940            graphicsContext->setStrokeThickness(thickness);
     941            graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
    937942            break;
    938943    }
Note: See TracChangeset for help on using the changeset viewer.