From 967717af5423377c967781471ee106e2bb4e11c8 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 22 Jul 2010 15:37:06 +0100 Subject: Merge WebKit at r63859 : Initial merge by git. Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62 --- WebCore/platform/graphics/qt/PathQt.cpp | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'WebCore/platform/graphics/qt/PathQt.cpp') diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp index a367212..a8adb31 100644 --- a/WebCore/platform/graphics/qt/PathQt.cpp +++ b/WebCore/platform/graphics/qt/PathQt.cpp @@ -121,15 +121,18 @@ bool Path::contains(const FloatPoint& point, WindRule rule) const return contains; } +static GraphicsContext* scratchContext() +{ + static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); + return scratch->context(); +} + bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const { ASSERT(applier); - // FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer - // on each call. - OwnPtr scratchImage = ImageBuffer::create(IntSize(1, 1)); - GraphicsContext* gc = scratchImage->context(); QPainterPathStroker stroke; + GraphicsContext* gc = scratchContext(); applier->strokeStyle(gc); QPen pen = gc->pen(); @@ -157,10 +160,7 @@ FloatRect Path::boundingRect() const FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) { - // FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer - // on each call. - OwnPtr scratchImage = ImageBuffer::create(IntSize(1, 1)); - GraphicsContext* gc = scratchImage->context(); + GraphicsContext* gc = scratchContext(); QPainterPathStroker stroke; if (applier) { applier->strokeStyle(gc); @@ -198,22 +198,8 @@ void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) { - // Make sure there is a subpath for p1, the behavior depend on the last element of the subpath. - // When the user agent is to ensure there is a subpath for a coordinate (x, y), the user agent must - // check to see if the context has any subpaths, and if it does not, then the user agent must create - // a new subpath with the point (x, y) as its first (and only) point, as if the moveTo() method had been called. - if (!m_path.elementCount()) { - m_path.moveTo(p1); - return; - } - FloatPoint p0(m_path.currentPosition()); - if ((p1.x() == p0.x() && p1.y() == p0.y()) || (p1.x() == p2.x() && p1.y() == p2.y()) || radius == 0.f) { - m_path.lineTo(p1); - return; - } - FloatPoint p1p0((p0.x() - p1.x()), (p0.y() - p1.y())); FloatPoint p1p2((p2.x() - p1.x()), (p2.y() - p1.y())); float p1p0_length = sqrtf(p1p0.x() * p1p0.x() + p1p0.y() * p1p0.y()); @@ -362,6 +348,11 @@ bool Path::hasCurrentPoint() const return !isEmpty(); } +FloatPoint Path::currentPoint() const +{ + return m_path.currentPosition(); +} + String Path::debugString() const { QString ret; -- cgit v1.1