diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/graphics/qt/PathQt.cpp | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/graphics/qt/PathQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/PathQt.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp index 76f375c..bd0192c 100644 --- a/WebCore/platform/graphics/qt/PathQt.cpp +++ b/WebCore/platform/graphics/qt/PathQt.cpp @@ -29,9 +29,12 @@ #include "config.h" #include "Path.h" +#include "TransformationMatrix.h" #include "FloatRect.h" +#include "GraphicsContext.h" +#include "ImageBuffer.h" #include "PlatformString.h" -#include "AffineTransform.h" +#include "StrokeStyleApplier.h" #include <QPainterPath> #include <QMatrix> #include <QString> @@ -39,6 +42,10 @@ #define _USE_MATH_DEFINES #include <math.h> +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + namespace WebCore { Path::Path() @@ -77,6 +84,28 @@ bool Path::contains(const FloatPoint& point, WindRule rule) const return contains; } +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. + std::auto_ptr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1), false); + GraphicsContext* gc = scratchImage->context(); + QPainterPathStroker stroke; + applier->strokeStyle(gc); + + QPen pen = gc->pen(); + stroke.setWidth(pen.widthF()); + stroke.setCapStyle(pen.capStyle()); + stroke.setJoinStyle(pen.joinStyle()); + stroke.setMiterLimit(pen.miterLimit()); + stroke.setDashPattern(pen.dashPattern()); + stroke.setDashOffset(pen.dashOffset()); + + return (stroke.createStroke(*platformPath())).contains(point); +} + void Path::translate(const FloatSize& size) { QMatrix matrix; @@ -89,6 +118,27 @@ FloatRect Path::boundingRect() const return m_path->boundingRect(); } +FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) +{ + // FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer + // on each call. + std::auto_ptr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1), false); + GraphicsContext* gc = scratchImage->context(); + QPainterPathStroker stroke; + if (applier) { + applier->strokeStyle(gc); + + QPen pen = gc->pen(); + stroke.setWidth(pen.widthF()); + stroke.setCapStyle(pen.capStyle()); + stroke.setJoinStyle(pen.joinStyle()); + stroke.setMiterLimit(pen.miterLimit()); + stroke.setDashPattern(pen.dashPattern()); + stroke.setDashOffset(pen.dashOffset()); + } + return (stroke.createStroke(*platformPath())).boundingRect(); +} + void Path::moveTo(const FloatPoint& point) { m_path->moveTo(point); @@ -263,7 +313,7 @@ void Path::apply(void* info, PathApplierFunction function) const } } -void Path::transform(const AffineTransform& transform) +void Path::transform(const TransformationMatrix& transform) { if (m_path) { QMatrix mat = transform; |