Changeset 72926 in webkit


Ignore:
Timestamp:
Nov 30, 2010 10:13:59 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

2010-11-30 Andreas Kling <kling@webkit.org>

Reviewed by Dirk Schulze.

GraphicsContext: Remove "current path" and have strokePath, fillPath and clipPath take a Path argument.
https://bugs.webkit.org/show_bug.cgi?id=48516

No new tests, this is refactoring only.

fillPath() -> fillPath(const Path&)
strokePath() -> strokePath(const Path&)
clipPath(WindRule) -> clipPath(const Path&, WindRule)

drawPath() was only used by CG, so made it PLATFORM(CG) specific.

The Qt, CG and Cairo implementations are best-effort.
For the rest, I've put beginPath/addPath and FIXMEs in the three affected methods.

  • WebCore.exp.in:
  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::fill): (WebCore::CanvasRenderingContext2D::stroke):
  • inspector/InspectorController.cpp: (WebCore::drawOutlinedQuad):
  • mathml/RenderMathMLRoot.cpp: (WebCore::RenderMathMLRoot::paint):
  • mathml/RenderMathMLSquareRoot.cpp: (WebCore::RenderMathMLSquareRoot::paint):
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/GraphicsContextPrivate.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::clipPath):
  • platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::drawEllipse): (WebCore::addConvexPolygonToPath): (WebCore::GraphicsContext::drawConvexPolygon): (WebCore::GraphicsContext::clipConvexPolygon): (WebCore::GraphicsContext::drawPath): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRoundedRect): (WebCore::GraphicsContext::clipPath):
  • platform/graphics/haiku/GraphicsContextHaiku.cpp: (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillPath):
  • platform/graphics/openvg/GraphicsContextOpenVG.cpp: (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::clipPath):
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContext::restorePlatformState): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::clipPath): (WebCore::GraphicsContext::strokeRect): (WebCore::GraphicsContext::translate): (WebCore::GraphicsContext::rotate): (WebCore::GraphicsContext::scale): (WebCore::GraphicsContext::concatCTM):
  • platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::GraphicsContext::clipPath): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath):
  • platform/graphics/wince/GraphicsContextWinCE.cpp: (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::clipPath):
  • platform/graphics/wx/GraphicsContextWx.cpp: (WebCore::GraphicsContext::clipPath): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath):
  • rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintBorder): (WebCore::RenderBoxModelObject::paintBoxShadow):
  • rendering/RenderEmbeddedObject.cpp: (WebCore::RenderEmbeddedObject::paintReplaced):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::drawBoxSideFromPath):
  • rendering/RenderSVGResource.h: (WebCore::RenderSVGResource::postApplyResource):
  • rendering/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::pathOnlyClipping):
  • rendering/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::postApplyResource):
  • rendering/RenderSVGResourceFilter.h:
  • rendering/RenderSVGResourceGradient.cpp: (WebCore::RenderSVGResourceGradient::applyResource):
  • rendering/RenderSVGResourceGradient.h:
  • rendering/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::postApplyResource):
  • rendering/RenderSVGResourcePattern.h:
  • rendering/RenderSVGResourceSolidColor.cpp: (WebCore::RenderSVGResourceSolidColor::postApplyResource):
  • rendering/RenderSVGResourceSolidColor.h:
  • rendering/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::finishRenderSVGContent):
  • rendering/svg/RenderSVGPath.cpp: (WebCore::RenderSVGPath::fillAndStrokePath):
  • rendering/svg/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::releasePaintingResource): (WebCore::SVGInlineTextBox::restoreGraphicsContextAfterTextPainting): (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
  • rendering/svg/SVGInlineTextBox.h:
  • svg/SVGFont.cpp: (WebCore::Font::drawTextUsingSVGFont):

2010-11-30 Andreas Kling <kling@webkit.org>

Reviewed by Dirk Schulze.

GraphicsContext: Remove "current path" and have strokePath, fillPath and clipPath take a Path argument
https://bugs.webkit.org/show_bug.cgi?id=48516

  • UIProcess/FindIndicator.cpp: (WebKit::FindIndicator::draw):
Location:
trunk
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r72924 r72926  
     12010-11-30  Andreas Kling  <kling@webkit.org>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        GraphicsContext: Remove "current path" and have strokePath, fillPath and clipPath take a Path argument.
     6        https://bugs.webkit.org/show_bug.cgi?id=48516
     7
     8        No new tests, this is refactoring only.
     9
     10        fillPath() -> fillPath(const Path&)
     11        strokePath() -> strokePath(const Path&)
     12        clipPath(WindRule) -> clipPath(const Path&, WindRule)
     13
     14        drawPath() was only used by CG, so made it PLATFORM(CG) specific.
     15
     16        The Qt, CG and Cairo implementations are best-effort.
     17        For the rest, I've put beginPath/addPath and FIXMEs in the three affected methods.
     18
     19        * WebCore.exp.in:
     20        * html/canvas/CanvasRenderingContext2D.cpp:
     21        (WebCore::CanvasRenderingContext2D::fill):
     22        (WebCore::CanvasRenderingContext2D::stroke):
     23        * inspector/InspectorController.cpp:
     24        (WebCore::drawOutlinedQuad):
     25        * mathml/RenderMathMLRoot.cpp:
     26        (WebCore::RenderMathMLRoot::paint):
     27        * mathml/RenderMathMLSquareRoot.cpp:
     28        (WebCore::RenderMathMLSquareRoot::paint):
     29        * platform/graphics/GraphicsContext.h:
     30        * platform/graphics/GraphicsContextPrivate.h:
     31        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     32        (WebCore::GraphicsContext::fillPath):
     33        (WebCore::GraphicsContext::strokePath):
     34        (WebCore::GraphicsContext::clipPath):
     35        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
     36        * platform/graphics/cg/GraphicsContextCG.cpp:
     37        (WebCore::GraphicsContext::drawEllipse):
     38        (WebCore::addConvexPolygonToPath):
     39        (WebCore::GraphicsContext::drawConvexPolygon):
     40        (WebCore::GraphicsContext::clipConvexPolygon):
     41        (WebCore::GraphicsContext::drawPath):
     42        (WebCore::GraphicsContext::fillPath):
     43        (WebCore::GraphicsContext::strokePath):
     44        (WebCore::GraphicsContext::fillRoundedRect):
     45        (WebCore::GraphicsContext::clipPath):
     46        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
     47        (WebCore::GraphicsContext::strokePath):
     48        (WebCore::GraphicsContext::fillPath):
     49        * platform/graphics/openvg/GraphicsContextOpenVG.cpp:
     50        (WebCore::GraphicsContext::fillPath):
     51        (WebCore::GraphicsContext::strokePath):
     52        (WebCore::GraphicsContext::clipPath):
     53        * platform/graphics/qt/GraphicsContextQt.cpp:
     54        (WebCore::GraphicsContext::restorePlatformState):
     55        (WebCore::GraphicsContext::fillPath):
     56        (WebCore::GraphicsContext::strokePath):
     57        (WebCore::GraphicsContext::clipPath):
     58        (WebCore::GraphicsContext::strokeRect):
     59        (WebCore::GraphicsContext::translate):
     60        (WebCore::GraphicsContext::rotate):
     61        (WebCore::GraphicsContext::scale):
     62        (WebCore::GraphicsContext::concatCTM):
     63        * platform/graphics/skia/GraphicsContextSkia.cpp:
     64        (WebCore::GraphicsContext::clipPath):
     65        (WebCore::GraphicsContext::fillPath):
     66        (WebCore::GraphicsContext::strokePath):
     67        * platform/graphics/wince/GraphicsContextWinCE.cpp:
     68        (WebCore::GraphicsContext::fillPath):
     69        (WebCore::GraphicsContext::strokePath):
     70        (WebCore::GraphicsContext::clipPath):
     71        * platform/graphics/wx/GraphicsContextWx.cpp:
     72        (WebCore::GraphicsContext::clipPath):
     73        (WebCore::GraphicsContext::fillPath):
     74        (WebCore::GraphicsContext::strokePath):
     75        * rendering/RenderBoxModelObject.cpp:
     76        (WebCore::RenderBoxModelObject::paintBorder):
     77        (WebCore::RenderBoxModelObject::paintBoxShadow):
     78        * rendering/RenderEmbeddedObject.cpp:
     79        (WebCore::RenderEmbeddedObject::paintReplaced):
     80        * rendering/RenderObject.cpp:
     81        (WebCore::RenderObject::drawBoxSideFromPath):
     82        * rendering/RenderSVGResource.h:
     83        (WebCore::RenderSVGResource::postApplyResource):
     84        * rendering/RenderSVGResourceClipper.cpp:
     85        (WebCore::RenderSVGResourceClipper::pathOnlyClipping):
     86        * rendering/RenderSVGResourceFilter.cpp:
     87        (WebCore::RenderSVGResourceFilter::postApplyResource):
     88        * rendering/RenderSVGResourceFilter.h:
     89        * rendering/RenderSVGResourceGradient.cpp:
     90        (WebCore::RenderSVGResourceGradient::applyResource):
     91        * rendering/RenderSVGResourceGradient.h:
     92        * rendering/RenderSVGResourcePattern.cpp:
     93        (WebCore::RenderSVGResourcePattern::postApplyResource):
     94        * rendering/RenderSVGResourcePattern.h:
     95        * rendering/RenderSVGResourceSolidColor.cpp:
     96        (WebCore::RenderSVGResourceSolidColor::postApplyResource):
     97        * rendering/RenderSVGResourceSolidColor.h:
     98        * rendering/SVGRenderSupport.cpp:
     99        (WebCore::SVGRenderSupport::finishRenderSVGContent):
     100        * rendering/svg/RenderSVGPath.cpp:
     101        (WebCore::RenderSVGPath::fillAndStrokePath):
     102        * rendering/svg/SVGInlineTextBox.cpp:
     103        (WebCore::SVGInlineTextBox::releasePaintingResource):
     104        (WebCore::SVGInlineTextBox::restoreGraphicsContextAfterTextPainting):
     105        (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
     106        * rendering/svg/SVGInlineTextBox.h:
     107        * svg/SVGFont.cpp:
     108        (WebCore::Font::drawTextUsingSVGFont):
     109
    11102010-11-30  Alexey Proskuryakov  <ap@apple.com>
    2111
  • trunk/WebCore/WebCore.exp.in

    r72887 r72926  
    359359__ZN7WebCore15GraphicsContext4saveEv
    360360__ZN7WebCore15GraphicsContext5scaleERKNS_9FloatSizeE
    361 __ZN7WebCore15GraphicsContext7addPathERKNS_4PathE
    362361__ZN7WebCore15GraphicsContext7restoreEv
    363 __ZN7WebCore15GraphicsContext8fillPathEv
     362__ZN7WebCore15GraphicsContext8fillPathERKNS_4PathE
    364363__ZN7WebCore15GraphicsContext8fillRectERKNS_9FloatRectE
    365364__ZN7WebCore15GraphicsContext8fillRectERKNS_9FloatRectERKNS_5ColorENS_10ColorSpaceE
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r71716 r72926  
    814814
    815815    if (!m_path.isEmpty()) {
    816         c->beginPath();
    817         c->addPath(m_path);
    818         c->fillPath();
     816        c->fillPath(m_path);
    819817        didDraw(m_path.boundingRect());
    820818    }
     
    834832
    835833    if (!m_path.isEmpty()) {
    836         c->beginPath();
    837         c->addPath(m_path);
    838 
    839834#if PLATFORM(QT)
    840835        // Fast approximation of the stroke's bounding rect.
     
    847842        FloatRect boundingRect = m_path.strokeBoundingRect(&strokeApplier);
    848843#endif
    849         c->strokePath();
     844        c->strokePath(m_path);
    850845        didDraw(boundingRect);
    851846    }
  • trunk/WebCore/inspector/InspectorController.cpp

    r72895 r72926  
    15381538    {
    15391539        context.save();
    1540         context.addPath(quadPath);
    15411540        context.clipOut(quadPath);
    15421541
    1543         context.addPath(quadPath);
    15441542        context.setStrokeThickness(outlineThickness);
    15451543        context.setStrokeColor(outlineColor, ColorSpaceDeviceRGB);
    1546         context.strokePath();
     1544        context.strokePath(quadPath);
    15471545
    15481546        context.restore();
     
    15501548
    15511549    // Now do the fill
    1552     context.addPath(quadPath);
    15531550    context.setFillColor(fillColor, ColorSpaceDeviceRGB);
    1554     context.fillPath();
     1551    context.fillPath(quadPath);
    15551552}
    15561553
  • trunk/WebCore/mathml/RenderMathMLRoot.cpp

    r70221 r72926  
    168168    root.addLineTo(leftEnd);
    169169   
    170     info.context->beginPath();
    171     info.context->addPath(root);
    172     info.context->strokePath();
     170    info.context->strokePath(root);
    173171   
    174172    info.context->save();
     
    182180    mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
    183181   
    184     info.context->beginPath();
    185     info.context->addPath(mask);
    186182    info.context->clip(mask);
    187183   
     
    194190    line.addLineTo(topLeft);
    195191
    196     info.context->beginPath();
    197     info.context->addPath(line);
    198     info.context->strokePath();
     192    info.context->strokePath(line);
    199193   
    200194    info.context->restore();
  • trunk/WebCore/mathml/RenderMathMLSquareRoot.cpp

    r70143 r72926  
    133133    // draw to end
    134134    root.addLineTo(leftEnd);
    135    
    136     info.context->beginPath();
    137     info.context->addPath(root);
    138     info.context->strokePath();
     135
     136    info.context->strokePath(root);
    139137   
    140138    info.context->save();
     
    148146    mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
    149147   
    150     info.context->beginPath();
    151     info.context->addPath(mask);
    152148    info.context->clip(mask);
    153149   
     
    160156    line.addLineTo(topLeft);
    161157   
    162     info.context->beginPath();
    163     info.context->addPath(line);
    164     info.context->strokePath();
     158    info.context->strokePath(line);
    165159   
    166160    info.context->restore();
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r72528 r72926  
    128128    class ImageBuffer;
    129129    class KURL;
    130     class Path;
    131130    class Pattern;
    132131    class SharedGraphicsContext3D;
     
    197196        void applyStrokePattern();
    198197        void applyFillPattern();
     198        void drawPath(const Path&);
    199199#endif
    200200
     
    211211        void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
    212212
    213         void drawPath();
    214         void fillPath();
    215         void strokePath();
     213        void fillPath(const Path&);
     214        void strokePath(const Path&);
    216215
    217216        // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
     
    254253        void clipOut(const IntRect&);
    255254        void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
    256         void clipPath(WindRule);
     255        void clipPath(const Path&, WindRule);
    257256        void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
    258257        void clipToImageBuffer(ImageBuffer*, const FloatRect&);
     
    303302        void setCompositeOperation(CompositeOperator);
    304303
     304#if PLATFORM(SKIA) || PLATFORM(WX) || PLATFORM(OPENVG) || OS(WINCE)
    305305        void beginPath();
    306306        void addPath(const Path&);
     307#endif
    307308
    308309        void clip(const Path&);
     
    394395#if PLATFORM(QT)
    395396        bool inTransparencyLayer() const;
    396         PlatformPath* currentPath();
    397397        void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
    398398        void takeOwnershipOfPlatformContext();
  • trunk/WebCore/platform/graphics/GraphicsContextPrivate.h

    r70143 r72926  
    3030#include "GraphicsContext.h"
    3131#include "Pattern.h"
    32 #include "TransformationMatrix.h"
    3332
    3433namespace WebCore {
     
    8079#if PLATFORM(CAIRO)
    8180        float globalAlpha;
    82 #elif PLATFORM(QT)
    83         TransformationMatrix pathTransform;
    8481#endif
    8582    };
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r72528 r72926  
    532532}
    533533
    534 void GraphicsContext::fillPath()
    535 {
    536     if (paintingDisabled())
    537         return;
    538 
    539     cairo_t* cr = m_data->cr;
    540 
    541     setPathOnCairoContext(cr, m_data->m_pendingPath.context());
     534void GraphicsContext::fillPath(const Path& path)
     535{
     536    if (paintingDisabled())
     537        return;
     538
     539    cairo_t* cr = m_data->cr;
     540    setPathOnCairoContext(cr, path.platformPath()->context());
    542541    fillCurrentCairoPath(this, m_common, cr);
    543542}
    544543
    545 void GraphicsContext::strokePath()
    546 {
    547     if (paintingDisabled())
    548         return;
    549 
    550     cairo_t* cr = m_data->cr;
    551     setPathOnCairoContext(cr, m_data->m_pendingPath.context());
     544void GraphicsContext::strokePath(const Path& path)
     545{
     546    if (paintingDisabled())
     547        return;
     548
     549    cairo_t* cr = m_data->cr;
     550    setPathOnCairoContext(cr, path.platformPath()->context());
    552551    strokeCurrentCairoPath(this, m_common, cr);
    553 }
    554 
    555 void GraphicsContext::drawPath()
    556 {
    557     if (paintingDisabled())
    558         return;
    559 
    560     cairo_t* cr = m_data->cr;
    561 
    562     setPathOnCairoContext(cr, m_data->m_pendingPath.context());
    563 
    564     cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    565     drawPathShadow(this, m_common, FillAndStroke);
    566 
    567     setPlatformFill(this, cr, m_common);
    568     setPlatformStroke(this, cr, m_common);
    569     cairo_new_path(cr);
    570552}
    571553
     
    608590}
    609591
    610 void GraphicsContext::clipPath(WindRule clipRule)
    611 {
    612     if (paintingDisabled())
    613         return;
    614 
    615     cairo_t* cr = m_data->cr;
     592void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     593{
     594    if (paintingDisabled())
     595        return;
     596
     597    cairo_t* cr = m_data->cr;
     598    setPathOnCairoContext(cr, path.platformPath()->context());
    616599    cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    617600    cairo_clip(cr);
     
    995978}
    996979
    997 void GraphicsContext::beginPath()
    998 {
    999     if (paintingDisabled())
    1000         return;
    1001 
    1002     cairo_new_path(m_data->m_pendingPath.context());
    1003 }
    1004 
    1005 void GraphicsContext::addPath(const Path& path)
    1006 {
    1007     if (paintingDisabled())
    1008         return;
    1009 
    1010     cairo_matrix_t currentMatrix;
    1011     cairo_get_matrix(m_data->cr, &currentMatrix);
    1012     cairo_set_matrix(m_data->m_pendingPath.context(), &currentMatrix);
    1013     appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path);
    1014 }
    1015 
    1016980void GraphicsContext::clip(const Path& path)
    1017981{
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h

    r69699 r72926  
    2828#include "GraphicsContext.h"
    2929
    30 #include "CairoPath.h"
    3130#include "ContextShadow.h"
    3231#include <cairo.h>
     
    9897    cairo_t* cr;
    9998    Vector<float> layers;
    100     CairoPath m_pendingPath;
    10199
    102100    ContextShadow shadow;
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r70996 r72926  
    300300void GraphicsContext::drawEllipse(const IntRect& rect)
    301301{
    302     // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse.
    303     // This code can only handle circles, not ellipses. But khtml only
    304     // uses it for circles.
    305     ASSERT(rect.width() == rect.height());
    306 
    307     if (paintingDisabled())
    308         return;
    309 
    310     CGContextRef context = platformContext();
    311     CGContextBeginPath(context);
    312     float r = (float)rect.width() / 2;
    313     CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0.0f, 2.0f * piFloat, 0);
    314     CGContextClosePath(context);
    315 
    316     drawPath();
     302    if (paintingDisabled())
     303        return;
     304
     305    Path path;
     306    path.addEllipse(rect);
     307    drawPath(path);
    317308}
    318309
     
    406397}
    407398
    408 static void addConvexPolygonToContext(CGContextRef context, size_t numPoints, const FloatPoint* points)
    409 {
    410     CGContextBeginPath(context);
    411     CGContextMoveToPoint(context, points[0].x(), points[0].y());
    412     for (size_t i = 1; i < numPoints; i++)
    413         CGContextAddLineToPoint(context, points[i].x(), points[i].y());
    414     CGContextClosePath(context);
    415 }
    416 
    417 void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased)
    418 {
    419     if (paintingDisabled())
    420         return;
    421 
    422     if (npoints <= 1)
     399static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
     400{
     401    ASSERT(numberOfPoints > 0);
     402
     403    path.moveTo(points[0]);
     404    for (size_t i = 1; i < numberOfPoints; ++i)
     405        path.addLineTo(points[i]);
     406    path.closeSubpath();
     407}
     408
     409void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
     410{
     411    if (paintingDisabled())
     412        return;
     413
     414    if (numberOfPoints <= 1)
    423415        return;
    424416
     
    428420        CGContextSetShouldAntialias(context, antialiased);
    429421
    430     addConvexPolygonToContext(context, npoints, points);
    431     drawPath();
     422    Path path;
     423    addConvexPolygonToPath(path, numberOfPoints, points);
     424    drawPath(path);
    432425
    433426    if (antialiased != shouldAntialias())
     
    435428}
    436429
    437 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias)
    438 {
    439     if (paintingDisabled())
    440         return;
    441 
    442     if (numPoints <= 1)
     430void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias)
     431{
     432    if (paintingDisabled())
     433        return;
     434
     435    if (numberOfPoints <= 1)
    443436        return;
    444437
     
    447440    if (antialias != shouldAntialias())
    448441        CGContextSetShouldAntialias(context, antialias);
    449    
    450     addConvexPolygonToContext(context, numPoints, points);
    451     clipPath(RULE_NONZERO);
     442
     443    Path path;
     444    addConvexPolygonToPath(path, numberOfPoints, points);
     445    clipPath(path, RULE_NONZERO);
    452446
    453447    if (antialias != shouldAntialias())
     
    512506}
    513507
    514 void GraphicsContext::drawPath()
     508void GraphicsContext::drawPath(const Path& path)
    515509{
    516510    if (paintingDisabled())
     
    522516    if (state.fillGradient || state.strokeGradient) {
    523517        // We don't have any optimized way to fill & stroke a path using gradients
    524         fillPath();
    525         strokePath();
    526         return;
    527     }
     518        // FIXME: Be smarter about this.
     519        fillPath(path);
     520        strokePath(path);
     521        return;
     522    }
     523
     524    CGContextBeginPath(context);
     525    CGContextAddPath(context, path.platformPath());
    528526
    529527    if (state.fillPattern)
     
    545543}
    546544
    547 void GraphicsContext::fillPath()
    548 {
    549     if (paintingDisabled())
    550         return;
    551 
    552     CGContextRef context = platformContext();
     545void GraphicsContext::fillPath(const Path& path)
     546{
     547    if (paintingDisabled())
     548        return;
     549
     550    CGContextRef context = platformContext();
     551
     552    CGContextBeginPath(context);
     553    CGContextAddPath(context, path.platformPath());
    553554
    554555    if (m_common->state.fillGradient) {
     
    569570}
    570571
    571 void GraphicsContext::strokePath()
    572 {
    573     if (paintingDisabled())
    574         return;
    575 
    576     CGContextRef context = platformContext();
     572void GraphicsContext::strokePath(const Path& path)
     573{
     574    if (paintingDisabled())
     575        return;
     576
     577    CGContextRef context = platformContext();
     578
     579    CGContextBeginPath(context);
     580    CGContextAddPath(context, path.platformPath());
    577581
    578582    if (m_common->state.strokeGradient) {
     
    644648    Path path;
    645649    path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
    646     addPath(path);
    647     fillPath();
     650    fillPath(path);
    648651
    649652    if (oldFillColor != color || oldColorSpace != colorSpace)
     
    670673}
    671674
    672 void GraphicsContext::clipPath(WindRule clipRule)
    673 {
    674     if (paintingDisabled())
    675         return;
    676 
    677     CGContextRef context = platformContext();
    678 
    679     if (!CGContextIsPathEmpty(context)) {
    680         if (clipRule == RULE_EVENODD)
    681             CGContextEOClip(context);
    682         else
    683             CGContextClip(context);
    684     }
     675void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     676{
     677    if (paintingDisabled())
     678        return;
     679
     680    if (path.isEmpty())
     681        return;
     682
     683    CGContextRef context = platformContext();
     684
     685    CGContextBeginPath(platformContext());
     686    CGContextAddPath(platformContext(), path.platformPath());
     687
     688    if (clipRule == RULE_EVENODD)
     689        CGContextEOClip(context);
     690    else
     691        CGContextClip(context);
    685692}
    686693
     
    862869        break;
    863870    }
    864 }
    865 
    866 void GraphicsContext::beginPath()
    867 {
    868     CGContextBeginPath(platformContext());
    869 }
    870 
    871 void GraphicsContext::addPath(const Path& path)
    872 {
    873     CGContextAddPath(platformContext(), path.platformPath());
    874871}
    875872
  • trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

    r72528 r72926  
    133133}
    134134
    135 void GraphicsContext::strokePath()
     135void GraphicsContext::strokePath(const Path&)
    136136{
    137137    notImplemented();
     
    192192}
    193193
    194 void GraphicsContext::fillPath()
    195 {
    196     notImplemented();
    197 }
    198 
    199 void GraphicsContext::beginPath()
    200 {
    201     notImplemented();
    202 }
    203 
    204 void GraphicsContext::addPath(const Path& path)
     194void GraphicsContext::fillPath(const Path&)
    205195{
    206196    notImplemented();
  • trunk/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp

    r70996 r72926  
    140140}
    141141
    142 void GraphicsContext::fillPath()
    143 {
    144     if (paintingDisabled())
    145         return;
     142void GraphicsContext::fillPath(const Path& path)
     143{
     144    if (paintingDisabled())
     145        return;
     146
     147    // FIXME: Be smarter about this.
     148    beginPath();
     149    addPath(path);
    146150
    147151    m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule);
    148152}
    149153
    150 void GraphicsContext::strokePath()
    151 {
    152     if (paintingDisabled())
    153         return;
     154void GraphicsContext::strokePath(const Path& path)
     155{
     156    if (paintingDisabled())
     157        return;
     158
     159    // FIXME: Be smarter about this.
     160    beginPath();
     161    addPath(path);
    154162
    155163    m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule);
    156 }
    157 
    158 void GraphicsContext::drawPath()
    159 {
    160     if (paintingDisabled())
    161         return;
    162 
    163     m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule);
    164164}
    165165
     
    222222}
    223223
    224 void GraphicsContext::clipPath(WindRule clipRule)
    225 {
    226     if (paintingDisabled())
    227         return;
     224void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     225{
     226    if (paintingDisabled())
     227        return;
     228
     229    // FIXME: Be smarter about this.
     230    beginPath();
     231    addPath(path);
    228232
    229233    m_data->clipPath(*(m_data->currentPath()), PainterOpenVG::IntersectClip, clipRule);
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r72907 r72926  
    5252#include "Path.h"
    5353#include "Pattern.h"
    54 #include "Pen.h"
    5554#include "TransparencyLayer.h"
    5655
     
    202201    InterpolationQuality imageInterpolationQuality;
    203202
    204     // Only used by SVG for now.
    205     QPainterPath currentPath;
    206 
    207203    ContextShadow shadow;
    208204    QStack<ContextShadow> shadowStack;
     
    211207    {
    212208        return shadow.m_type != ContextShadow::NoShadow;
    213     }
    214 
    215     inline void clearCurrentPath()
    216     {
    217         if (!currentPath.elementCount())
    218             return;
    219         currentPath = QPainterPath();
    220209    }
    221210
     
    319308
    320309    m_data->p()->restore();
    321 
    322     if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
    323         QTransform matrix = m_common->state.pathTransform;
    324         m_data->currentPath = m_data->currentPath * matrix;
    325     }
    326310
    327311    if (m_data->shadowStack.isEmpty())
     
    515499}
    516500
    517 void GraphicsContext::fillPath()
    518 {
    519     if (paintingDisabled())
    520         return;
    521 
    522     QPainter* p = m_data->p();
    523     QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
    524     path.setFillRule(toQtFillRule(fillRule()));
     501void GraphicsContext::fillPath(const Path& path)
     502{
     503    if (paintingDisabled())
     504        return;
     505
     506    QPainter* p = m_data->p();
     507    QPainterPath platformPath = path.platformPath();
     508    platformPath.setFillRule(toQtFillRule(fillRule()));
    525509
    526510    if (m_data->hasShadow()) {
     
    536520                QPointF translatedOffset(offset.x() / transform.m11(),
    537521                                         offset.y() / transform.m22());
    538                 path.translate(translatedOffset);
    539                 p->fillPath(path, QColor(shadow->m_color));
    540                 path.translate(-translatedOffset);
     522                platformPath.translate(translatedOffset);
     523                p->fillPath(platformPath, QColor(shadow->m_color));
     524                platformPath.translate(-translatedOffset);
    541525            } else {
    542526                p->translate(offset);
    543                 p->fillPath(path, QColor(shadow->m_color));
     527                p->fillPath(platformPath, QColor(shadow->m_color));
    544528                p->translate(-offset);
    545529            }
    546530        } else {
    547             QPainter* shadowPainter = shadow->beginShadowLayer(p, path.controlPointRect());
     531            QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect());
    548532            if (shadowPainter) {
    549533                shadowPainter->setCompositionMode(QPainter::CompositionMode_Source);
    550                 shadowPainter->fillPath(path, QColor(m_data->shadow.m_color));
     534                shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color));
    551535                shadow->endShadowLayer(p);
    552536            }
     
    556540    if (m_common->state.fillPattern) {
    557541        AffineTransform affine;
    558         p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
     542        p->fillPath(platformPath, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
    559543    } else if (m_common->state.fillGradient) {
    560544        QBrush brush(*m_common->state.fillGradient->platformGradient());
    561545        brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
    562         p->fillPath(path, brush);
     546        p->fillPath(platformPath, brush);
    563547    } else
    564         p->fillPath(path, p->brush());
    565 
    566     m_data->clearCurrentPath();
    567 }
    568 
    569 void GraphicsContext::strokePath()
     548        p->fillPath(platformPath, p->brush());
     549}
     550
     551void GraphicsContext::strokePath(const Path& path)
    570552{
    571553    if (paintingDisabled())
     
    574556    QPainter* p = m_data->p();
    575557    QPen pen(p->pen());
    576     QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
    577     path.setFillRule(toQtFillRule(fillRule()));
     558    QPainterPath platformPath = path.platformPath();
     559    platformPath.setFillRule(toQtFillRule(fillRule()));
    578560
    579561    if (m_data->hasShadow()) {
     
    592574                QPointF translatedOffset(offset.x() / transform.m11(),
    593575                                         offset.y() / transform.m22());
    594                 path.translate(translatedOffset);
    595                 p->strokePath(path, shadowPen);
    596                 path.translate(-translatedOffset);
     576                platformPath.translate(translatedOffset);
     577                p->strokePath(platformPath, shadowPen);
     578                platformPath.translate(-translatedOffset);
    597579            } else {
    598580                p->translate(offset);
    599                 p->strokePath(path, shadowPen);
     581                p->strokePath(platformPath, shadowPen);
    600582                p->translate(-offset);
    601583            }
    602584        } else {
    603             FloatRect boundingRect = path.controlPointRect();
     585            FloatRect boundingRect = platformPath.controlPointRect();
    604586            boundingRect.inflate(pen.miterLimit() + pen.widthF());
    605587            QPainter* shadowPainter = shadow->beginShadowLayer(p, boundingRect);
    606588            if (shadowPainter) {
    607589                shadowPainter->setOpacity(static_cast<qreal>(m_data->shadow.m_color.alpha()) / 255);
    608                 shadowPainter->strokePath(path, pen);
     590                shadowPainter->strokePath(platformPath, pen);
    609591                shadow->endShadowLayer(p);
    610592            }
     
    616598        pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
    617599        p->setPen(pen);
    618         p->strokePath(path, pen);
     600        p->strokePath(platformPath, pen);
    619601    } else if (m_common->state.strokeGradient) {
    620602        QBrush brush(*m_common->state.strokeGradient->platformGradient());
     
    622604        pen.setBrush(brush);
    623605        p->setPen(pen);
    624         p->strokePath(path, pen);
     606        p->strokePath(platformPath, pen);
    625607    } else
    626         p->strokePath(path, pen);
    627     m_data->clearCurrentPath();
     608        p->strokePath(platformPath, pen);
    628609}
    629610
     
    812793}
    813794
    814 void GraphicsContext::beginPath()
    815 {
    816     m_data->clearCurrentPath();
    817 }
    818 
    819 void GraphicsContext::addPath(const Path& path)
    820 {
    821     if (!m_data->currentPath.elementCount()) {
    822         m_data->currentPath = path.platformPath();
    823         return;
    824     }
    825     m_data->currentPath.addPath(path.platformPath());
    826 }
    827 
    828795bool GraphicsContext::inTransparencyLayer() const
    829796{
     
    831798}
    832799
    833 PlatformPath* GraphicsContext::currentPath()
    834 {
    835     return &m_data->currentPath;
    836 }
    837 
    838800ContextShadow* GraphicsContext::contextShadow()
    839801{
     
    849811}
    850812
    851 void GraphicsContext::clipPath(WindRule clipRule)
    852 {
    853     if (paintingDisabled())
    854         return;
    855 
    856     QPainter* p = m_data->p();
    857     QPainterPath newPath = m_data->currentPath;
    858     newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
    859     p->setClipPath(newPath, Qt::IntersectClip);
     813void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     814{
     815    if (paintingDisabled())
     816        return;
     817
     818    QPainter* p = m_data->p();
     819    QPainterPath platformPath = path.platformPath();
     820    platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
     821    p->setClipPath(platformPath, Qt::IntersectClip);
    860822}
    861823
     
    10861048        return;
    10871049
    1088     QPainterPath path;
     1050    Path path;
    10891051    path.addRect(rect);
    10901052    setStrokeThickness(width);
    1091     m_data->currentPath = path;
    1092 
    1093     strokePath();
     1053    strokePath(path);
    10941054}
    10951055
     
    12111171
    12121172    m_data->p()->translate(x, y);
    1213 
    1214     if (!m_data->currentPath.isEmpty()) {
    1215         QTransform matrix;
    1216         m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
    1217         m_common->state.pathTransform.translate(x, y);
    1218     }
    12191173}
    12201174
     
    12251179
    12261180    m_data->p()->rotate(180 / M_PI*radians);
    1227 
    1228     if (!m_data->currentPath.isEmpty()) {
    1229         QTransform matrix;
    1230         m_data->currentPath = m_data->currentPath * matrix.rotate(-180 / M_PI*radians);
    1231         m_common->state.pathTransform.rotate(radians);
    1232     }
    12331181}
    12341182
     
    12391187
    12401188    m_data->p()->scale(s.width(), s.height());
    1241 
    1242     if (!m_data->currentPath.isEmpty()) {
    1243         QTransform matrix;
    1244         m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
    1245         m_common->state.pathTransform.scaleNonUniform(s.width(), s.height());
    1246     }
    12471189}
    12481190
     
    13011243
    13021244    m_data->p()->setWorldTransform(transform, true);
    1303 
    1304     // Transformations to the context shouldn't transform the currentPath.
    1305     // We have to undo every change made to the context from the currentPath
    1306     // to avoid wrong drawings.
    1307     if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
    1308         QTransform matrix = transform.inverse();
    1309         m_data->currentPath = m_data->currentPath * matrix;
    1310         m_common->state.pathTransform.multiply(transform.toTransformationMatrix());
    1311     }
    13121245}
    13131246
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r72528 r72926  
    421421}
    422422
    423 void GraphicsContext::clipPath(WindRule clipRule)
    424 {
    425     if (paintingDisabled())
    426         return;
     423void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
     424{
     425    if (paintingDisabled())
     426        return;
     427
     428    // FIXME: Be smarter about this.
     429    beginPath();
     430    addPath(pathToClip);
    427431
    428432    SkPath path = platformContext()->currentPathInLocalCoordinates();
     
    724728}
    725729
    726 void GraphicsContext::fillPath()
    727 {
    728     if (paintingDisabled())
    729         return;
     730void GraphicsContext::fillPath(const Path& pathToFill)
     731{
     732    if (paintingDisabled())
     733        return;
     734
     735    // FIXME: Be smarter about this.
     736    beginPath();
     737    addPath(pathToFill);
    730738
    731739    SkPath path = platformContext()->currentPathInLocalCoordinates();
     
    11781186}
    11791187
    1180 void GraphicsContext::strokePath()
    1181 {
    1182     if (paintingDisabled())
    1183         return;
     1188void GraphicsContext::strokePath(const Path& pathToStroke)
     1189{
     1190    if (paintingDisabled())
     1191        return;
     1192
     1193    // FIXME: Be smarter about this.
     1194    beginPath();
     1195    addPath(pathToStroke);
    11841196
    11851197    SkPath path = platformContext()->currentPathInLocalCoordinates();
  • trunk/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp

    r72528 r72926  
    13261326}
    13271327
    1328 void GraphicsContext::fillPath()
    1329 {
     1328void GraphicsContext::fillPath(const Path& path)
     1329{
     1330    // FIXME: Be smarter about this.
     1331    beginPath();
     1332    addPath(path);
     1333
    13301334    Color c = m_common->state.fillGradient
    13311335        ? gradientAverageColor(m_common->state.fillGradient.get())
     
    13761380    if (!m_data->m_dc)
    13771381        return;
     1382
     1383    // FIXME: Be smarter about this.
     1384    beginPath();
     1385    addPath(path);
    13781386
    13791387    OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
     
    19011909}
    19021910
    1903 void GraphicsContext::clipPath(WindRule)
     1911void GraphicsContext::clipPath(const Path&, WindRule)
    19041912{
    19051913    notImplemented();
  • trunk/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r72528 r72926  
    338338}
    339339
    340 void GraphicsContext::clipPath(WindRule)
     340void GraphicsContext::clipPath(const Path&, WindRule)
    341341{
    342342    notImplemented();
     
    534534}
    535535
    536 void GraphicsContext::fillPath()
    537 {
    538 #if USE(WXGC)
     536void GraphicsContext::fillPath(const Path& path)
     537{
     538#if USE(WXGC)
     539    // FIXME: Be smarter about this.
     540    beginPath();
     541    addPath(path);
     542
    539543    wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
    540544    if (gc)
     
    543547}
    544548
    545 void GraphicsContext::strokePath()
    546 {
    547 #if USE(WXGC)
     549void GraphicsContext::strokePath(const Path& path)
     550{
     551#if USE(WXGC)
     552    // FIXME: Be smarter about this.
     553    beginPath();
     554    addPath(path);
     555
    548556    wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
    549557    if (gc)
    550558        gc->StrokePath(m_data->currentPath);
    551559#endif
    552 }
    553 
    554 void GraphicsContext::drawPath()
    555 {
    556     fillPath();
    557     strokePath();
    558560}
    559561
  • trunk/WebCore/rendering/RenderBoxModelObject.cpp

    r72282 r72926  
    10651065            graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
    10661066            roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
    1067             graphicsContext->addPath(roundedPath);
    10681067        }
    10691068    }
     
    18061805                path.addRect(holeRect);
    18071806
    1808             context->beginPath();
    1809             context->addPath(path);
    1810 
    18111807            context->setFillRule(RULE_EVENODD);
    18121808            context->setFillColor(fillColor, s->colorSpace());
    18131809            context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
    1814             context->fillPath();
     1810            context->fillPath(path);
    18151811
    18161812            context->restore();
  • trunk/WebCore/rendering/RenderEmbeddedObject.cpp

    r72839 r72926  
    167167    context->save();
    168168    context->clip(contentRect);
    169     context->beginPath();
    170     context->addPath(path); 
    171169    context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedRoundedRectOpacity : replacementTextRoundedRectOpacity);
    172170    context->setFillColor(m_missingPluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : Color::white, style()->colorSpace());
    173     context->fillPath();
     171    context->fillPath(path);
    174172
    175173    float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
  • trunk/WebCore/rendering/RenderObject.cpp

    r72777 r72926  
    957957        lineDash.append(whiteSpaceWidth);
    958958        graphicsContext->setLineDash(lineDash, patWidth);
    959         graphicsContext->addPath(borderPath);
    960         graphicsContext->strokePath();
     959        graphicsContext->strokePath(borderPath);
    961960        return;
    962961    }
  • trunk/WebCore/rendering/RenderSVGResource.h

    r69413 r72926  
    4949class FloatRect;
    5050class GraphicsContext;
     51class Path;
    5152class RenderObject;
    5253class RenderStyle;
     
    6263
    6364    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) = 0;
    64     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short) { }
     65    virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short, const Path*) { }
    6566    virtual FloatRect resourceBoundingBox(RenderObject*) = 0;
    6667
  • trunk/WebCore/rendering/RenderSVGResourceClipper.cpp

    r70143 r72926  
    152152    if (clipPath.isEmpty())
    153153        clipPath.addRect(FloatRect());
    154     context->beginPath();
    155     context->addPath(clipPath);
    156     context->clipPath(clipRule);
     154    context->clipPath(clipPath, clipRule);
    157155    return true;
    158156}
  • trunk/WebCore/rendering/RenderSVGResourceFilter.cpp

    r72474 r72926  
    255255}
    256256
    257 void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode)
     257void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode, const Path*)
    258258{
    259259    ASSERT(object);
  • trunk/WebCore/rendering/RenderSVGResourceFilter.h

    r72474 r72926  
    7171
    7272    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
    73     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
     73    virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
    7474
    7575    virtual FloatRect resourceBoundingBox(RenderObject*);
  • trunk/WebCore/rendering/RenderSVGResourceGradient.cpp

    r70143 r72926  
    231231}
    232232
    233 void RenderSVGResourceGradient::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode)
     233void RenderSVGResourceGradient::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
    234234{
    235235    ASSERT(context);
     
    259259        UNUSED_PARAM(object);
    260260#endif
    261     } else {
     261    } else if (path) {
    262262        if (resourceMode & ApplyToFillMode)
    263             context->fillPath();
     263            context->fillPath(*path);
    264264        else if (resourceMode & ApplyToStrokeMode)
    265             context->strokePath();
     265            context->strokePath(*path);
    266266    }
    267267
  • trunk/WebCore/rendering/RenderSVGResourceGradient.h

    r69413 r72926  
    5252
    5353    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
    54     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
     54    virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
    5555    virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
    5656
  • trunk/WebCore/rendering/RenderSVGResourcePattern.cpp

    r70143 r72926  
    183183}
    184184
    185 void RenderSVGResourcePattern::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode)
     185void RenderSVGResourcePattern::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
    186186{
    187187    ASSERT(context);
    188188    ASSERT(resourceMode != ApplyToDefaultMode);
    189189
    190     if (!(resourceMode & ApplyToTextMode)) {
     190    if (path && !(resourceMode & ApplyToTextMode)) {
    191191        if (resourceMode & ApplyToFillMode)
    192             context->fillPath();
     192            context->fillPath(*path);
    193193        else if (resourceMode & ApplyToStrokeMode)
    194             context->strokePath();
     194            context->strokePath(*path);
    195195    }
    196196
  • trunk/WebCore/rendering/RenderSVGResourcePattern.h

    r69413 r72926  
    5454
    5555    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
    56     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
     56    virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
    5757    virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
    5858
  • trunk/WebCore/rendering/RenderSVGResourceSolidColor.cpp

    r70143 r72926  
    7676}
    7777
    78 void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode)
     78void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
    7979{
    8080    ASSERT(context);
    8181    ASSERT(resourceMode != ApplyToDefaultMode);
    8282
    83     if (!(resourceMode & ApplyToTextMode)) {
     83    if (path && !(resourceMode & ApplyToTextMode)) {
    8484        if (resourceMode & ApplyToFillMode)
    85             context->fillPath();
     85            context->fillPath(*path);
    8686        else if (resourceMode & ApplyToStrokeMode)
    87             context->strokePath();
     87            context->strokePath(*path);
    8888    }
    89 
    90 #if PLATFORM(SKIA)
    91     // FIXME: Move this into the GraphicsContext
    92     // WebKit implicitly expects us to reset the path.
    93     // For example in fillAndStrokePath() of RenderSVGPath.cpp the path is
    94     // added back to the context after filling. This is because internally it
    95     // calls CGContextFillPath() which closes the path.
    96     context->beginPath();
    97     context->platformContext()->setFillShader(0);
    98     context->platformContext()->setStrokeShader(0);
    99 #endif
    10089}
    10190
  • trunk/WebCore/rendering/RenderSVGResourceSolidColor.h

    r65310 r72926  
    3838
    3939    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
    40     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
     40    virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
    4141    virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
    4242
  • trunk/WebCore/rendering/SVGRenderSupport.cpp

    r69279 r72926  
    149149    if (resources) {
    150150        if (RenderSVGResourceFilter* filter = resources->filter()) {
    151             filter->postApplyResource(object, paintInfo.context, ApplyToDefaultMode);
     151            filter->postApplyResource(object, paintInfo.context, ApplyToDefaultMode, /* path */0);
    152152            paintInfo.context = savedContext;
    153153        }
  • trunk/WebCore/rendering/svg/RenderSVGPath.cpp

    r69517 r72926  
    149149void RenderSVGPath::fillAndStrokePath(GraphicsContext* context)
    150150{
    151     context->beginPath();
    152151    RenderStyle* style = this->style();
    153152
    154153    Color fallbackColor;
    155154    if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(this, style, fallbackColor)) {
    156         context->addPath(m_path);
    157155        if (fillPaintingResource->applyResource(this, style, context, ApplyToFillMode))
    158             fillPaintingResource->postApplyResource(this, context, ApplyToFillMode);
     156            fillPaintingResource->postApplyResource(this, context, ApplyToFillMode, &m_path);
    159157        else if (fallbackColor.isValid()) {
    160158            RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
    161159            fallbackResource->setColor(fallbackColor);
    162160            if (fallbackResource->applyResource(this, style, context, ApplyToFillMode))
    163                 fallbackResource->postApplyResource(this, context, ApplyToFillMode);
     161                fallbackResource->postApplyResource(this, context, ApplyToFillMode, &m_path);
    164162        }
    165163    }
     
    170168        return;
    171169
     170    Path path;
     171
     172    bool nonScalingStroke = style->svgStyle()->vectorEffect() == VE_NON_SCALING_STROKE;
    172173    bool restoreContext = false;
    173     if (style->svgStyle()->vectorEffect() == VE_NON_SCALING_STROKE) {
     174    if (nonScalingStroke) {
    174175        SVGStyledTransformableElement* element = static_cast<SVGStyledTransformableElement*>(node());
    175176        AffineTransform nonScalingStrokeTransform = element->getScreenCTM(SVGLocatable::DisallowStyleUpdate);
     
    177178            return;
    178179
    179         Path transformedPath = m_path;
    180         transformedPath.transform(nonScalingStrokeTransform);
     180        path = m_path;
     181        path.transform(nonScalingStrokeTransform);
    181182
    182183        context->save();
    183184        context->concatCTM(nonScalingStrokeTransform.inverse());
    184         context->addPath(transformedPath);
    185185        restoreContext = true;
    186     } else
    187         context->addPath(m_path);
     186    }
    188187
    189188    if (strokePaintingResource->applyResource(this, style, context, ApplyToStrokeMode))
    190         strokePaintingResource->postApplyResource(this, context, ApplyToStrokeMode);
     189        strokePaintingResource->postApplyResource(this, context, ApplyToStrokeMode, nonScalingStroke ? &path : &m_path);
    191190    else if (fallbackColor.isValid()) {
    192191        RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
    193192        fallbackResource->setColor(fallbackColor);
    194193        if (fallbackResource->applyResource(this, style, context, ApplyToStrokeMode))
    195             fallbackResource->postApplyResource(this, context, ApplyToStrokeMode);
     194            fallbackResource->postApplyResource(this, context, ApplyToStrokeMode, nonScalingStroke ? &path : &m_path);
    196195    }
    197196
  • trunk/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r72235 r72926  
    319319}
    320320
    321 void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context)
     321void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context, const Path* path)
    322322{
    323323    ASSERT(m_paintingResource);
     
    326326    ASSERT(parentRenderer);
    327327
    328     m_paintingResource->postApplyResource(parentRenderer, context, m_paintingResourceMode);
     328    m_paintingResource->postApplyResource(parentRenderer, context, m_paintingResourceMode, path);
    329329    m_paintingResource = 0;
    330330}
     
    345345void SVGInlineTextBox::restoreGraphicsContextAfterTextPainting(GraphicsContext*& context, TextRun& textRun)
    346346{
    347     releasePaintingResource(context);
     347    releasePaintingResource(context, /* path */0);
    348348
    349349#if ENABLE(SVG_FONTS)
     
    501501
    502502    context->save();
    503     context->beginPath();
    504     context->addPath(path);
    505503
    506504    if (acquirePaintingResource(context, decorationRenderer, decorationStyle))
    507         releasePaintingResource(context);
     505        releasePaintingResource(context, &path);
    508506
    509507    context->restore();
  • trunk/WebCore/rendering/svg/SVGInlineTextBox.h

    r68976 r72926  
    6969
    7070    bool acquirePaintingResource(GraphicsContext*&, RenderObject*, RenderStyle*);
    71     void releasePaintingResource(GraphicsContext*&);
     71    void releasePaintingResource(GraphicsContext*&, const Path*);
    7272
    7373    bool prepareGraphicsContextForTextPainting(GraphicsContext*&, TextRun&, RenderStyle*);
  • trunk/WebCore/svg/SVGFont.cpp

    r65468 r72926  
    535535                    glyphPath.transform(glyphPathTransform);
    536536
    537                     context->beginPath();
    538                     context->addPath(glyphPath);
    539 
    540537                    RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0;
    541538                    if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode))
    542                         activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode);
     539                        activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode, &glyphPath);
    543540
    544541                    context->restore();
  • trunk/WebKit2/ChangeLog

    r72923 r72926  
     12010-11-30  Andreas Kling  <kling@webkit.org>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        GraphicsContext: Remove "current path" and have strokePath, fillPath and clipPath take a Path argument
     6        https://bugs.webkit.org/show_bug.cgi?id=48516
     7
     8        * UIProcess/FindIndicator.cpp:
     9        (WebKit::FindIndicator::draw):
     10
    1112010-11-30  Steve Falkenburg  <sfalken@apple.com>
    212
  • trunk/WebKit2/UIProcess/FindIndicator.cpp

    r71640 r72926  
    150150        FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
    151151        graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
    152         graphicsContext.addPath(pathWithRoundedRect(outerPathRect, cornerRadius));
    153152        graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
    154         graphicsContext.fillPath();
     153        graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
    155154        graphicsContext.restore();
    156155
Note: See TracChangeset for help on using the changeset viewer.