diff options
author | Ben Murdoch <benm@google.com> | 2010-07-22 15:37:06 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-07-27 10:20:25 +0100 |
commit | 967717af5423377c967781471ee106e2bb4e11c8 (patch) | |
tree | 1e701dc0a12f7f07cce1df4a7681717de77a211b /WebCore/platform/graphics/qt/PathQt.cpp | |
parent | dcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff) | |
download | external_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2 |
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebCore/platform/graphics/qt/PathQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/PathQt.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
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<ImageBuffer> 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<ImageBuffer> 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; |