2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
3 * 2006 Rob Buis <buis@kde.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 typedef struct CGPath PlatformPath
;
39 typedef QPainterPath PlatformPath
;
40 #elif PLATFORM(WX) && USE(WXGC)
42 typedef wxGraphicsPath PlatformPath
;
47 typedef WebCore::CairoPath PlatformPath
;
50 typedef SkPath PlatformPath
;
52 typedef void PlatformPath
;
60 class GraphicsContext
;
62 class StrokeStyleApplier
;
63 class TransformationMatrix
;
70 enum PathElementType
{
71 PathElementMoveToPoint
,
72 PathElementAddLineToPoint
,
73 PathElementAddQuadCurveToPoint
,
74 PathElementAddCurveToPoint
,
75 PathElementCloseSubpath
83 typedef void (*PathApplierFunction
)(void* info
, const PathElement
*);
91 Path
& operator=(const Path
&);
93 void swap(Path
& other
) { std::swap(m_path
, other
.m_path
); }
95 bool contains(const FloatPoint
&, WindRule rule
= RULE_NONZERO
) const;
96 bool strokeContains(StrokeStyleApplier
*, const FloatPoint
&) const;
97 FloatRect
boundingRect() const;
98 FloatRect
strokeBoundingRect(StrokeStyleApplier
* = 0);
101 FloatPoint
pointAtLength(float length
, bool& ok
);
102 float normalAngleAtLength(float length
, bool& ok
);
105 bool isEmpty() const;
107 void moveTo(const FloatPoint
&);
108 void addLineTo(const FloatPoint
&);
109 void addQuadCurveTo(const FloatPoint
& controlPoint
, const FloatPoint
& endPoint
);
110 void addBezierCurveTo(const FloatPoint
& controlPoint1
, const FloatPoint
& controlPoint2
, const FloatPoint
& endPoint
);
111 void addArcTo(const FloatPoint
&, const FloatPoint
&, float radius
);
114 void addArc(const FloatPoint
&, float radius
, float startAngle
, float endAngle
, bool anticlockwise
);
115 void addRect(const FloatRect
&);
116 void addEllipse(const FloatRect
&);
118 void translate(const FloatSize
&);
120 String
debugString() const;
122 PlatformPath
* platformPath() const { return m_path
; }
124 static Path
createRoundedRectangle(const FloatRect
&, const FloatSize
& roundingRadii
);
125 static Path
createRoundedRectangle(const FloatRect
&, const FloatSize
& topLeftRadius
, const FloatSize
& topRightRadius
, const FloatSize
& bottomLeftRadius
, const FloatSize
& bottomRightRadius
);
126 static Path
createRectangle(const FloatRect
&);
127 static Path
createEllipse(const FloatPoint
& center
, float rx
, float ry
);
128 static Path
createCircle(const FloatPoint
& center
, float r
);
129 static Path
createLine(const FloatPoint
&, const FloatPoint
&);
131 void apply(void* info
, PathApplierFunction
) const;
132 void transform(const TransformationMatrix
&);
135 PlatformPath
* m_path
;