2 * Copyright (C) 2007-2009 Torch Mobile, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef PlatformPathWinCE_h
21 #define PlatformPathWinCE_h
23 #include "FloatPoint.h"
24 #include "FloatRect.h"
26 #include <wtf/Vector.h>
30 class GraphicsContext;
35 const float& x() const { return m_x; }
36 const float& y() const { return m_y; }
37 void set(float x, float y)
42 operator FloatPoint() const { return FloatPoint(m_x, m_y); }
43 void move(const FloatSize& offset)
45 m_x += offset.width();
46 m_y += offset.height();
48 PathPoint& operator=(const FloatPoint& p)
54 void clear() { m_x = m_y = 0; }
57 struct PathPolygon: public Vector<PathPoint> {
58 void move(const FloatSize& offset);
59 void transform(const AffineTransform& t);
60 bool contains(const FloatPoint& point) const;
63 class PlatformPathElement {
65 enum PlaformPathElementType {
94 struct BezierCurveTo {
100 PlatformPathElement(): m_type(PathCloseSubpath) { m_data.m_points[0].set(0, 0); }
101 PlatformPathElement(const MoveTo& data): m_type(PathMoveTo) { m_data.m_moveToData = data; }
102 PlatformPathElement(const LineTo& data): m_type(PathLineTo) { m_data.m_lineToData = data; }
103 PlatformPathElement(const ArcTo& data): m_type(PathArcTo) { m_data.m_arcToData = data; }
104 PlatformPathElement(const QuadCurveTo& data): m_type(PathQuadCurveTo) { m_data.m_quadCurveToData = data; }
105 PlatformPathElement(const BezierCurveTo& data): m_type(PathBezierCurveTo) { m_data.m_bezierCurveToData = data; }
107 const MoveTo& moveTo() const { return m_data.m_moveToData; }
108 const LineTo& lineTo() const { return m_data.m_lineToData; }
109 const ArcTo& arcTo() const { return m_data.m_arcToData; }
110 const QuadCurveTo& quadCurveTo() const { return m_data.m_quadCurveToData; }
111 const BezierCurveTo& bezierCurveTo() const { return m_data.m_bezierCurveToData; }
112 const PathPoint& lastPoint() const
115 return n > 1 ? m_data.m_points[n - 1] : m_data.m_points[0];
117 const PathPoint& pointAt(int index) const { return m_data.m_points[index]; }
118 int numPoints() const;
119 int numControlPoints() const;
120 void move(const FloatSize& offset);
121 void transform(const AffineTransform& t);
122 PathElementType type() const;
123 PlaformPathElementType platformType() const { return m_type; }
124 void inflateRectToContainMe(FloatRect& r, const FloatPoint& lastPoint) const;
127 PlaformPathElementType m_type;
132 QuadCurveTo m_quadCurveToData;
133 BezierCurveTo m_bezierCurveToData;
134 PathPoint m_points[4];
138 typedef Vector<PlatformPathElement> PlatformPathElements;
143 const PlatformPathElements& elements() const { return m_elements; }
144 void append(const PlatformPathElement& e);
145 void append(const PlatformPath& p);
147 bool isEmpty() const { return m_elements.isEmpty(); }
149 void strokePath(HDC, const AffineTransform* tr) const;
150 void fillPath(HDC, const AffineTransform* tr) const;
151 FloatPoint lastPoint() const { return m_elements.isEmpty() ? FloatPoint(0, 0) : m_elements.last().lastPoint(); }
153 const FloatRect& boundingRect() const { return m_boundingRect; }
154 bool contains(const FloatPoint& point, WindRule rule) const;
155 void translate(const FloatSize& size);
156 void transform(const AffineTransform& t);
158 void moveTo(const FloatPoint&);
159 void addLineTo(const FloatPoint&);
160 void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
161 void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
162 void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
164 void addEllipse(const FloatPoint& p, float a, float b, float sar, float ear, bool anticlockwise);
165 void addRect(const FloatRect& r);
166 void addEllipse(const FloatRect& r);
167 void apply(void* info, PathApplierFunction function) const;
170 void ensureSubpath();
171 void addToSubpath(const PlatformPathElement& e);
173 PlatformPathElements m_elements;
174 FloatRect m_boundingRect;
175 Vector<PathPolygon> m_subpaths;
176 PathPoint m_currentPoint;
182 #endif // PlatformPathWinCE_h