2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
3 * 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007-2008 Torch Mobile, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <wtf/FastAllocBase.h>
32 #include <wtf/Forward.h>
35 typedef struct CGPath PlatformPath;
36 #elif PLATFORM(OPENVG)
38 class PlatformPathOpenVG;
40 typedef WebCore::PlatformPathOpenVG PlatformPath;
42 #include <qpainterpath.h>
43 typedef QPainterPath PlatformPath;
44 #elif PLATFORM(WX) && USE(WXGC)
46 typedef wxGraphicsPath PlatformPath;
51 typedef WebCore::CairoPath PlatformPath;
54 typedef SkPath PlatformPath;
57 typedef BRegion PlatformPath;
62 typedef WebCore::PlatformPath PlatformPath;
64 typedef void PlatformPath;
68 /* QPainterPath is valued based */
69 typedef PlatformPath PlatformPathPtr;
71 typedef PlatformPath* PlatformPathPtr;
76 class AffineTransform;
80 class GraphicsContext;
81 class StrokeStyleApplier;
88 enum PathElementType {
89 PathElementMoveToPoint,
90 PathElementAddLineToPoint,
91 PathElementAddQuadCurveToPoint,
92 PathElementAddCurveToPoint,
93 PathElementCloseSubpath
101 typedef void (*PathApplierFunction)(void* info, const PathElement*);
104 WTF_MAKE_FAST_ALLOCATED;
110 Path& operator=(const Path&);
112 bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
113 bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const;
114 FloatRect boundingRect() const;
115 FloatRect strokeBoundingRect(StrokeStyleApplier* = 0);
118 FloatPoint pointAtLength(float length, bool& ok);
119 float normalAngleAtLength(float length, bool& ok);
122 bool isEmpty() const;
123 // Gets the current point of the current path, which is conceptually the final point reached by the path so far.
124 // Note the Path can be empty (isEmpty() == true) and still have a current point.
125 bool hasCurrentPoint() const;
126 FloatPoint currentPoint() const;
128 void moveTo(const FloatPoint&);
129 void addLineTo(const FloatPoint&);
130 void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
131 void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
132 void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
135 void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise);
136 void addRect(const FloatRect&);
137 void addEllipse(const FloatRect&);
138 void addRoundedRect(const FloatRect&, const FloatSize& roundingRadii);
139 void addRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
141 void translate(const FloatSize&);
143 PlatformPathPtr platformPath() const { return m_path; }
145 void apply(void* info, PathApplierFunction) const;
146 void transform(const AffineTransform&);
149 PlatformPathPtr m_path;