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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72926
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+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 Alexey Proskuryakov <ap@apple.com>
Reviewed by Darin Adler and Geoff Garen.
__ZN7WebCore15GraphicsContext4clipERKNS_9FloatRectE
__ZN7WebCore15GraphicsContext4saveEv
__ZN7WebCore15GraphicsContext5scaleERKNS_9FloatSizeE
-__ZN7WebCore15GraphicsContext7addPathERKNS_4PathE
__ZN7WebCore15GraphicsContext7restoreEv
-__ZN7WebCore15GraphicsContext8fillPathEv
+__ZN7WebCore15GraphicsContext8fillPathERKNS_4PathE
__ZN7WebCore15GraphicsContext8fillRectERKNS_9FloatRectE
__ZN7WebCore15GraphicsContext8fillRectERKNS_9FloatRectERKNS_5ColorENS_10ColorSpaceE
__ZN7WebCore15GraphicsContext9setShadowERKNS_9FloatSizeEfRKNS_5ColorENS_10ColorSpaceE
return;
if (!m_path.isEmpty()) {
- c->beginPath();
- c->addPath(m_path);
- c->fillPath();
+ c->fillPath(m_path);
didDraw(m_path.boundingRect());
}
return;
if (!m_path.isEmpty()) {
- c->beginPath();
- c->addPath(m_path);
-
#if PLATFORM(QT)
// Fast approximation of the stroke's bounding rect.
// This yields a slightly oversized rect but is very fast
CanvasStrokeStyleApplier strokeApplier(this);
FloatRect boundingRect = m_path.strokeBoundingRect(&strokeApplier);
#endif
- c->strokePath();
+ c->strokePath(m_path);
didDraw(boundingRect);
}
// of outline (because inflating a quad is hard)
{
context.save();
- context.addPath(quadPath);
context.clipOut(quadPath);
- context.addPath(quadPath);
context.setStrokeThickness(outlineThickness);
context.setStrokeColor(outlineColor, ColorSpaceDeviceRGB);
- context.strokePath();
+ context.strokePath(quadPath);
context.restore();
}
// Now do the fill
- context.addPath(quadPath);
context.setFillColor(fillColor, ColorSpaceDeviceRGB);
- context.fillPath();
+ context.fillPath(quadPath);
}
static void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad& quad, const FloatQuad& clipQuad, const Color& fillColor)
// draw to end
root.addLineTo(leftEnd);
- info.context->beginPath();
- info.context->addPath(root);
- info.context->strokePath();
+ info.context->strokePath(root);
info.context->save();
mask.addLineTo(topLeft);
mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
- info.context->beginPath();
- info.context->addPath(mask);
info.context->clip(mask);
// Draw the thick part of the root.
line.moveTo(bottomLeft);
line.addLineTo(topLeft);
- info.context->beginPath();
- info.context->addPath(line);
- info.context->strokePath();
+ info.context->strokePath(line);
info.context->restore();
root.addLineTo(topLeft);
// draw to end
root.addLineTo(leftEnd);
-
- info.context->beginPath();
- info.context->addPath(root);
- info.context->strokePath();
+
+ info.context->strokePath(root);
info.context->save();
mask.addLineTo(topLeft);
mask.addLineTo(FloatPoint(2 * topLeft.x() - leftEnd.x(), 2 * topLeft.y() - leftEnd.y()));
- info.context->beginPath();
- info.context->addPath(mask);
info.context->clip(mask);
// Draw the thick part of the root.
line.moveTo(bottomLeft);
line.addLineTo(topLeft);
- info.context->beginPath();
- info.context->addPath(line);
- info.context->strokePath();
+ info.context->strokePath(line);
info.context->restore();
class GraphicsContextPrivate;
class ImageBuffer;
class KURL;
- class Path;
class Pattern;
class SharedGraphicsContext3D;
class TextRun;
#if PLATFORM(CG)
void applyStrokePattern();
void applyFillPattern();
+ void drawPath(const Path&);
#endif
void save();
void drawEllipse(const IntRect&);
void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
- void drawPath();
- void fillPath();
- void strokePath();
+ void fillPath(const Path&);
+ void strokePath(const Path&);
// Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
void strokeArc(const IntRect&, int startAngle, int angleSpan);
void addInnerRoundedRectClip(const IntRect&, int thickness);
void clipOut(const IntRect&);
void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
- void clipPath(WindRule);
+ void clipPath(const Path&, WindRule);
void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
void clipToImageBuffer(ImageBuffer*, const FloatRect&);
void setCompositeOperation(CompositeOperator);
+#if PLATFORM(SKIA) || PLATFORM(WX) || PLATFORM(OPENVG) || OS(WINCE)
void beginPath();
void addPath(const Path&);
+#endif
void clip(const Path&);
#if PLATFORM(QT)
bool inTransparencyLayer() const;
- PlatformPath* currentPath();
void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
void takeOwnershipOfPlatformContext();
static QPainter::CompositionMode toQtCompositionMode(CompositeOperator op);
#include "Gradient.h"
#include "GraphicsContext.h"
#include "Pattern.h"
-#include "TransformationMatrix.h"
namespace WebCore {
bool shadowsIgnoreTransforms;
#if PLATFORM(CAIRO)
float globalAlpha;
-#elif PLATFORM(QT)
- TransformationMatrix pathTransform;
#endif
};
cairo_set_fill_rule(cr, savedFillRule);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
if (paintingDisabled())
return;
cairo_t* cr = m_data->cr;
-
- setPathOnCairoContext(cr, m_data->m_pendingPath.context());
+ setPathOnCairoContext(cr, path.platformPath()->context());
fillCurrentCairoPath(this, m_common, cr);
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
if (paintingDisabled())
return;
cairo_t* cr = m_data->cr;
- setPathOnCairoContext(cr, m_data->m_pendingPath.context());
+ setPathOnCairoContext(cr, path.platformPath()->context());
strokeCurrentCairoPath(this, m_common, cr);
}
-void GraphicsContext::drawPath()
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
-
- setPathOnCairoContext(cr, m_data->m_pendingPath.context());
-
- cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- drawPathShadow(this, m_common, FillAndStroke);
-
- setPlatformFill(this, cr, m_common);
- setPlatformStroke(this, cr, m_common);
- cairo_new_path(cr);
-}
-
void GraphicsContext::fillRect(const FloatRect& rect)
{
if (paintingDisabled())
m_data->clip(rect);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
if (paintingDisabled())
return;
cairo_t* cr = m_data->cr;
+ setPathOnCairoContext(cr, path.platformPath()->context());
cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
cairo_clip(cr);
}
cairo_set_operator(m_data->cr, toCairoOperator(op));
}
-void GraphicsContext::beginPath()
-{
- if (paintingDisabled())
- return;
-
- cairo_new_path(m_data->m_pendingPath.context());
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- cairo_matrix_t currentMatrix;
- cairo_get_matrix(m_data->cr, ¤tMatrix);
- cairo_set_matrix(m_data->m_pendingPath.context(), ¤tMatrix);
- appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path);
-}
-
void GraphicsContext::clip(const Path& path)
{
if (paintingDisabled())
#include "GraphicsContext.h"
-#include "CairoPath.h"
#include "ContextShadow.h"
#include <cairo.h>
#include <math.h>
cairo_t* cr;
Vector<float> layers;
- CairoPath m_pendingPath;
ContextShadow shadow;
Vector<ContextShadow> shadowStack;
// This method is only used to draw the little circles used in lists.
void GraphicsContext::drawEllipse(const IntRect& rect)
{
- // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse.
- // This code can only handle circles, not ellipses. But khtml only
- // uses it for circles.
- ASSERT(rect.width() == rect.height());
-
if (paintingDisabled())
return;
- CGContextRef context = platformContext();
- CGContextBeginPath(context);
- float r = (float)rect.width() / 2;
- CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0.0f, 2.0f * piFloat, 0);
- CGContextClosePath(context);
-
- drawPath();
+ Path path;
+ path.addEllipse(rect);
+ drawPath(path);
}
CGContextRestoreGState(context);
}
-static void addConvexPolygonToContext(CGContextRef context, size_t numPoints, const FloatPoint* points)
+static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
{
- CGContextBeginPath(context);
- CGContextMoveToPoint(context, points[0].x(), points[0].y());
- for (size_t i = 1; i < numPoints; i++)
- CGContextAddLineToPoint(context, points[i].x(), points[i].y());
- CGContextClosePath(context);
+ ASSERT(numberOfPoints > 0);
+
+ path.moveTo(points[0]);
+ for (size_t i = 1; i < numberOfPoints; ++i)
+ path.addLineTo(points[i]);
+ path.closeSubpath();
}
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased)
+void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
{
if (paintingDisabled())
return;
- if (npoints <= 1)
+ if (numberOfPoints <= 1)
return;
CGContextRef context = platformContext();
if (antialiased != shouldAntialias())
CGContextSetShouldAntialias(context, antialiased);
- addConvexPolygonToContext(context, npoints, points);
- drawPath();
+ Path path;
+ addConvexPolygonToPath(path, numberOfPoints, points);
+ drawPath(path);
if (antialiased != shouldAntialias())
CGContextSetShouldAntialias(context, shouldAntialias());
}
-void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias)
+void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias)
{
if (paintingDisabled())
return;
- if (numPoints <= 1)
+ if (numberOfPoints <= 1)
return;
CGContextRef context = platformContext();
if (antialias != shouldAntialias())
CGContextSetShouldAntialias(context, antialias);
-
- addConvexPolygonToContext(context, numPoints, points);
- clipPath(RULE_NONZERO);
+
+ Path path;
+ addConvexPolygonToPath(path, numberOfPoints, points);
+ clipPath(path, RULE_NONZERO);
if (antialias != shouldAntialias())
CGContextSetShouldAntialias(context, shouldAntialias());
return shouldFill || shouldStroke;
}
-void GraphicsContext::drawPath()
+void GraphicsContext::drawPath(const Path& path)
{
if (paintingDisabled())
return;
if (state.fillGradient || state.strokeGradient) {
// We don't have any optimized way to fill & stroke a path using gradients
- fillPath();
- strokePath();
+ // FIXME: Be smarter about this.
+ fillPath(path);
+ strokePath(path);
return;
}
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path.platformPath());
+
if (state.fillPattern)
applyFillPattern();
if (state.strokePattern)
CGContextFillPath(context);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
if (paintingDisabled())
return;
CGContextRef context = platformContext();
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path.platformPath());
+
if (m_common->state.fillGradient) {
CGContextSaveGState(context);
if (fillRule() == RULE_EVENODD)
fillPathWithFillRule(context, fillRule());
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
if (paintingDisabled())
return;
CGContextRef context = platformContext();
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path.platformPath());
+
if (m_common->state.strokeGradient) {
CGContextSaveGState(context);
CGContextReplacePathWithStrokedPath(context);
Path path;
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
- addPath(path);
- fillPath();
+ fillPath(path);
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, oldFillColor, oldColorSpace);
CGContextEOClip(platformContext());
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
if (paintingDisabled())
return;
+ if (path.isEmpty())
+ return;
+
CGContextRef context = platformContext();
- if (!CGContextIsPathEmpty(context)) {
- if (clipRule == RULE_EVENODD)
- CGContextEOClip(context);
- else
- CGContextClip(context);
- }
+ CGContextBeginPath(platformContext());
+ CGContextAddPath(platformContext(), path.platformPath());
+
+ if (clipRule == RULE_EVENODD)
+ CGContextEOClip(context);
+ else
+ CGContextClip(context);
}
void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
}
}
-void GraphicsContext::beginPath()
-{
- CGContextBeginPath(platformContext());
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- CGContextAddPath(platformContext(), path.platformPath());
-}
-
void GraphicsContext::clip(const Path& path)
{
if (paintingDisabled())
m_data->m_view->StrokeArc(rect, startAngle, angleSpan, getHaikuStrokeStyle());
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path&)
{
notImplemented();
}
// FillRect and FillArc calls are needed.
}
-void GraphicsContext::fillPath()
-{
- notImplemented();
-}
-
-void GraphicsContext::beginPath()
-{
- notImplemented();
-}
-
-void GraphicsContext::addPath(const Path& path)
+void GraphicsContext::fillPath(const Path&)
{
notImplemented();
}
UNUSED_PARAM(shouldAntialias); // FIXME
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule);
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
if (paintingDisabled())
return;
- m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule);
-}
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
-void GraphicsContext::drawPath()
-{
- if (paintingDisabled())
- return;
-
- m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule);
+ m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule);
}
void GraphicsContext::fillRect(const FloatRect& rect)
m_data->intersectClipRect(rect);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
m_data->clipPath(*(m_data->currentPath()), PainterOpenVG::IntersectClip, clipRule);
}
#include "NotImplemented.h"
#include "Path.h"
#include "Pattern.h"
-#include "Pen.h"
#include "TransparencyLayer.h"
#include <QBrush>
InterpolationQuality imageInterpolationQuality;
- // Only used by SVG for now.
- QPainterPath currentPath;
-
ContextShadow shadow;
QStack<ContextShadow> shadowStack;
return shadow.m_type != ContextShadow::NoShadow;
}
- inline void clearCurrentPath()
- {
- if (!currentPath.elementCount())
- return;
- currentPath = QPainterPath();
- }
-
QRectF clipBoundingRect() const
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
m_data->p()->restore();
- if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
- QTransform matrix = m_common->state.pathTransform;
- m_data->currentPath = m_data->currentPath * matrix;
- }
-
if (m_data->shadowStack.isEmpty())
m_data->shadow = ContextShadow();
else
p->setRenderHint(QPainter::Antialiasing, painterWasAntialiased);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
- QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
- path.setFillRule(toQtFillRule(fillRule()));
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(toQtFillRule(fillRule()));
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
// so that the relative offset to its shape is kept.
QPointF translatedOffset(offset.x() / transform.m11(),
offset.y() / transform.m22());
- path.translate(translatedOffset);
- p->fillPath(path, QColor(shadow->m_color));
- path.translate(-translatedOffset);
+ platformPath.translate(translatedOffset);
+ p->fillPath(platformPath, QColor(shadow->m_color));
+ platformPath.translate(-translatedOffset);
} else {
p->translate(offset);
- p->fillPath(path, QColor(shadow->m_color));
+ p->fillPath(platformPath, QColor(shadow->m_color));
p->translate(-offset);
}
} else {
- QPainter* shadowPainter = shadow->beginShadowLayer(p, path.controlPointRect());
+ QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect());
if (shadowPainter) {
shadowPainter->setCompositionMode(QPainter::CompositionMode_Source);
- shadowPainter->fillPath(path, QColor(m_data->shadow.m_color));
+ shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color));
shadow->endShadowLayer(p);
}
}
}
if (m_common->state.fillPattern) {
AffineTransform affine;
- p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
+ p->fillPath(platformPath, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
} else if (m_common->state.fillGradient) {
QBrush brush(*m_common->state.fillGradient->platformGradient());
brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
- p->fillPath(path, brush);
+ p->fillPath(platformPath, brush);
} else
- p->fillPath(path, p->brush());
-
- m_data->clearCurrentPath();
+ p->fillPath(platformPath, p->brush());
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
QPen pen(p->pen());
- QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath
- path.setFillRule(toQtFillRule(fillRule()));
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(toQtFillRule(fillRule()));
if (m_data->hasShadow()) {
ContextShadow* shadow = contextShadow();
// so that the relative offset to its shape is kept.
QPointF translatedOffset(offset.x() / transform.m11(),
offset.y() / transform.m22());
- path.translate(translatedOffset);
- p->strokePath(path, shadowPen);
- path.translate(-translatedOffset);
+ platformPath.translate(translatedOffset);
+ p->strokePath(platformPath, shadowPen);
+ platformPath.translate(-translatedOffset);
} else {
p->translate(offset);
- p->strokePath(path, shadowPen);
+ p->strokePath(platformPath, shadowPen);
p->translate(-offset);
}
} else {
- FloatRect boundingRect = path.controlPointRect();
+ FloatRect boundingRect = platformPath.controlPointRect();
boundingRect.inflate(pen.miterLimit() + pen.widthF());
QPainter* shadowPainter = shadow->beginShadowLayer(p, boundingRect);
if (shadowPainter) {
shadowPainter->setOpacity(static_cast<qreal>(m_data->shadow.m_color.alpha()) / 255);
- shadowPainter->strokePath(path, pen);
+ shadowPainter->strokePath(platformPath, pen);
shadow->endShadowLayer(p);
}
}
AffineTransform affine;
pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
p->setPen(pen);
- p->strokePath(path, pen);
+ p->strokePath(platformPath, pen);
} else if (m_common->state.strokeGradient) {
QBrush brush(*m_common->state.strokeGradient->platformGradient());
brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform());
pen.setBrush(brush);
p->setPen(pen);
- p->strokePath(path, pen);
+ p->strokePath(platformPath, pen);
} else
- p->strokePath(path, pen);
- m_data->clearCurrentPath();
+ p->strokePath(platformPath, pen);
}
static inline void drawRepeatPattern(QPainter* p, QPixmap* image, const FloatRect& rect, const bool repeatX, const bool repeatY)
p->fillPath(path.platformPath(), QColor(color));
}
-void GraphicsContext::beginPath()
-{
- m_data->clearCurrentPath();
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- if (!m_data->currentPath.elementCount()) {
- m_data->currentPath = path.platformPath();
- return;
- }
- m_data->currentPath.addPath(path.platformPath());
-}
-
bool GraphicsContext::inTransparencyLayer() const
{
return m_data->layerCount;
}
-PlatformPath* GraphicsContext::currentPath()
-{
- return &m_data->currentPath;
-}
-
ContextShadow* GraphicsContext::contextShadow()
{
return &m_data->shadow;
m_data->p()->setClipRect(rect, Qt::IntersectClip);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
if (paintingDisabled())
return;
QPainter* p = m_data->p();
- QPainterPath newPath = m_data->currentPath;
- newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
- p->setClipPath(newPath, Qt::IntersectClip);
+ QPainterPath platformPath = path.platformPath();
+ platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+ p->setClipPath(platformPath, Qt::IntersectClip);
}
void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
if (paintingDisabled())
return;
- QPainterPath path;
+ Path path;
path.addRect(rect);
setStrokeThickness(width);
- m_data->currentPath = path;
-
- strokePath();
+ strokePath(path);
}
void GraphicsContext::setLineCap(LineCap lc)
return;
m_data->p()->translate(x, y);
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
- m_common->state.pathTransform.translate(x, y);
- }
}
void GraphicsContext::rotate(float radians)
return;
m_data->p()->rotate(180 / M_PI*radians);
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.rotate(-180 / M_PI*radians);
- m_common->state.pathTransform.rotate(radians);
- }
}
void GraphicsContext::scale(const FloatSize& s)
return;
m_data->p()->scale(s.width(), s.height());
-
- if (!m_data->currentPath.isEmpty()) {
- QTransform matrix;
- m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
- m_common->state.pathTransform.scaleNonUniform(s.width(), s.height());
- }
}
void GraphicsContext::clipOut(const IntRect& rect)
return;
m_data->p()->setWorldTransform(transform, true);
-
- // Transformations to the context shouldn't transform the currentPath.
- // We have to undo every change made to the context from the currentPath
- // to avoid wrong drawings.
- if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
- QTransform matrix = transform.inverse();
- m_data->currentPath = m_data->currentPath * matrix;
- m_common->state.pathTransform.multiply(transform.toTransformationMatrix());
- }
}
void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToClip);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
platformContext()->drawRect(r);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& pathToFill)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToFill);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
platformContext()->canvas()->drawPath(path, paint);
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& pathToStroke)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToStroke);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
, (stop.alpha + lastStop.alpha) * 0.5f);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
Color c = m_common->state.fillGradient
? gradientAverageColor(m_common->state.fillGradient.get())
: fillColor();
if (!m_data->m_dc)
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) {
notImplemented();
}
-void GraphicsContext::clipPath(WindRule)
+void GraphicsContext::clipPath(const Path&, WindRule)
{
notImplemented();
}
notImplemented();
}
-void GraphicsContext::clipPath(WindRule)
+void GraphicsContext::clipPath(const Path&, WindRule)
{
notImplemented();
}
return InterpolationDefault;
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& path)
{
#if USE(WXGC)
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
if (gc)
gc->FillPath(m_data->currentPath);
#endif
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& path)
{
#if USE(WXGC)
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(path);
+
wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
if (gc)
gc->StrokePath(m_data->currentPath);
#endif
}
-void GraphicsContext::drawPath()
-{
- fillPath();
- strokePath();
-}
-
void GraphicsContext::fillRect(const FloatRect& rect)
{
if (paintingDisabled())
graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
- graphicsContext->addPath(roundedPath);
}
}
} else
path.addRect(holeRect);
- context->beginPath();
- context->addPath(path);
-
context->setFillRule(RULE_EVENODD);
context->setFillColor(fillColor, s->colorSpace());
context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
- context->fillPath();
+ context->fillPath(path);
context->restore();
}
context->save();
context->clip(contentRect);
- context->beginPath();
- context->addPath(path);
context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedRoundedRectOpacity : replacementTextRoundedRectOpacity);
context->setFillColor(m_missingPluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : Color::white, style()->colorSpace());
- context->fillPath();
+ context->fillPath(path);
float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - font.height()) / 2 + font.ascent());
lineDash.append(patWidth);
lineDash.append(whiteSpaceWidth);
graphicsContext->setLineDash(lineDash, patWidth);
- graphicsContext->addPath(borderPath);
- graphicsContext->strokePath();
+ graphicsContext->strokePath(borderPath);
return;
}
case DOUBLE: {
class Color;
class FloatRect;
class GraphicsContext;
+class Path;
class RenderObject;
class RenderStyle;
class RenderSVGResourceSolidColor;
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) = 0;
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) = 0;
- virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short) { }
+ virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short, const Path*) { }
virtual FloatRect resourceBoundingBox(RenderObject*) = 0;
virtual RenderSVGResourceType resourceType() const = 0;
// The SVG specification wants us to clip everything, if clip-path doesn't have a child.
if (clipPath.isEmpty())
clipPath.addRect(FloatRect());
- context->beginPath();
- context->addPath(clipPath);
- context->clipPath(clipRule);
+ context->clipPath(clipPath, clipRule);
return true;
}
return true;
}
-void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode)
+void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode, const Path*)
{
ASSERT(object);
ASSERT(context);
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
- virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
+ virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
virtual FloatRect resourceBoundingBox(RenderObject*);
return true;
}
-void RenderSVGResourceGradient::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode)
+void RenderSVGResourceGradient::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
#else
UNUSED_PARAM(object);
#endif
- } else {
+ } else if (path) {
if (resourceMode & ApplyToFillMode)
- context->fillPath();
+ context->fillPath(*path);
else if (resourceMode & ApplyToStrokeMode)
- context->strokePath();
+ context->strokePath(*path);
}
context->restore();
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
- virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
+ virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
protected:
return true;
}
-void RenderSVGResourcePattern::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode)
+void RenderSVGResourcePattern::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
- if (!(resourceMode & ApplyToTextMode)) {
+ if (path && !(resourceMode & ApplyToTextMode)) {
if (resourceMode & ApplyToFillMode)
- context->fillPath();
+ context->fillPath(*path);
else if (resourceMode & ApplyToStrokeMode)
- context->strokePath();
+ context->strokePath(*path);
}
context->restore();
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
- virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
+ virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
return true;
}
-void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode)
+void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode, const Path* path)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
- if (!(resourceMode & ApplyToTextMode)) {
+ if (path && !(resourceMode & ApplyToTextMode)) {
if (resourceMode & ApplyToFillMode)
- context->fillPath();
+ context->fillPath(*path);
else if (resourceMode & ApplyToStrokeMode)
- context->strokePath();
+ context->strokePath(*path);
}
-
-#if PLATFORM(SKIA)
- // FIXME: Move this into the GraphicsContext
- // WebKit implicitly expects us to reset the path.
- // For example in fillAndStrokePath() of RenderSVGPath.cpp the path is
- // added back to the context after filling. This is because internally it
- // calls CGContextFillPath() which closes the path.
- context->beginPath();
- context->platformContext()->setFillShader(0);
- context->platformContext()->setStrokeShader(0);
-#endif
}
}
virtual void removeClientFromCache(RenderObject*, bool = true) { }
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
- virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode);
+ virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*);
virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
if (resources) {
if (RenderSVGResourceFilter* filter = resources->filter()) {
- filter->postApplyResource(object, paintInfo.context, ApplyToDefaultMode);
+ filter->postApplyResource(object, paintInfo.context, ApplyToDefaultMode, /* path */0);
paintInfo.context = savedContext;
}
}
void RenderSVGPath::fillAndStrokePath(GraphicsContext* context)
{
- context->beginPath();
RenderStyle* style = this->style();
Color fallbackColor;
if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(this, style, fallbackColor)) {
- context->addPath(m_path);
if (fillPaintingResource->applyResource(this, style, context, ApplyToFillMode))
- fillPaintingResource->postApplyResource(this, context, ApplyToFillMode);
+ fillPaintingResource->postApplyResource(this, context, ApplyToFillMode, &m_path);
else if (fallbackColor.isValid()) {
RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
fallbackResource->setColor(fallbackColor);
if (fallbackResource->applyResource(this, style, context, ApplyToFillMode))
- fallbackResource->postApplyResource(this, context, ApplyToFillMode);
+ fallbackResource->postApplyResource(this, context, ApplyToFillMode, &m_path);
}
}
if (!strokePaintingResource)
return;
+ Path path;
+
+ bool nonScalingStroke = style->svgStyle()->vectorEffect() == VE_NON_SCALING_STROKE;
bool restoreContext = false;
- if (style->svgStyle()->vectorEffect() == VE_NON_SCALING_STROKE) {
+ if (nonScalingStroke) {
SVGStyledTransformableElement* element = static_cast<SVGStyledTransformableElement*>(node());
AffineTransform nonScalingStrokeTransform = element->getScreenCTM(SVGLocatable::DisallowStyleUpdate);
if (!nonScalingStrokeTransform.isInvertible())
return;
- Path transformedPath = m_path;
- transformedPath.transform(nonScalingStrokeTransform);
+ path = m_path;
+ path.transform(nonScalingStrokeTransform);
context->save();
context->concatCTM(nonScalingStrokeTransform.inverse());
- context->addPath(transformedPath);
restoreContext = true;
- } else
- context->addPath(m_path);
+ }
if (strokePaintingResource->applyResource(this, style, context, ApplyToStrokeMode))
- strokePaintingResource->postApplyResource(this, context, ApplyToStrokeMode);
+ strokePaintingResource->postApplyResource(this, context, ApplyToStrokeMode, nonScalingStroke ? &path : &m_path);
else if (fallbackColor.isValid()) {
RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
fallbackResource->setColor(fallbackColor);
if (fallbackResource->applyResource(this, style, context, ApplyToStrokeMode))
- fallbackResource->postApplyResource(this, context, ApplyToStrokeMode);
+ fallbackResource->postApplyResource(this, context, ApplyToStrokeMode, nonScalingStroke ? &path : &m_path);
}
if (restoreContext)
return true;
}
-void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context)
+void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context, const Path* path)
{
ASSERT(m_paintingResource);
RenderObject* parentRenderer = parent()->renderer();
ASSERT(parentRenderer);
- m_paintingResource->postApplyResource(parentRenderer, context, m_paintingResourceMode);
+ m_paintingResource->postApplyResource(parentRenderer, context, m_paintingResourceMode, path);
m_paintingResource = 0;
}
void SVGInlineTextBox::restoreGraphicsContextAfterTextPainting(GraphicsContext*& context, TextRun& textRun)
{
- releasePaintingResource(context);
+ releasePaintingResource(context, /* path */0);
#if ENABLE(SVG_FONTS)
textRun.setActivePaintingResource(0);
path.addRect(FloatRect(fragment.x, y, fragment.width, thickness));
context->save();
- context->beginPath();
- context->addPath(path);
if (acquirePaintingResource(context, decorationRenderer, decorationStyle))
- releasePaintingResource(context);
+ releasePaintingResource(context, &path);
context->restore();
}
TextRun constructTextRun(RenderStyle*, const SVGTextFragment&) const;
bool acquirePaintingResource(GraphicsContext*&, RenderObject*, RenderStyle*);
- void releasePaintingResource(GraphicsContext*&);
+ void releasePaintingResource(GraphicsContext*&, const Path*);
bool prepareGraphicsContextForTextPainting(GraphicsContext*&, TextRun&, RenderStyle*);
void restoreGraphicsContextAfterTextPainting(GraphicsContext*&, TextRun&);
Path glyphPath = identifier.pathData;
glyphPath.transform(glyphPathTransform);
- context->beginPath();
- context->addPath(glyphPath);
-
RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0;
if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode))
- activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode);
+ activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode, &glyphPath);
context->restore();
}
+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):
+
2010-11-30 Steve Falkenburg <sfalken@apple.com>
Reviewed by Adam Roben.
graphicsContext.save();
FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
- graphicsContext.addPath(pathWithRoundedRect(outerPathRect, cornerRadius));
graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
- graphicsContext.fillPath();
+ graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
graphicsContext.restore();
graphicsContext.save();