00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef Path_h
00029 #define Path_h
00030
00031 #if PLATFORM(CG)
00032 typedef struct CGPath PlatformPath;
00033 #elif PLATFORM(QT)
00034 class QPainterPath;
00035 typedef QPainterPath PlatformPath;
00036 #elif PLATFORM(CAIRO)
00037 namespace WebCore {
00038 struct CairoPath;
00039 }
00040 typedef WebCore::CairoPath PlatformPath;
00041 #elif defined __OWB__
00042 #include "AffineTransform.h"
00043 typedef void PlatformPath;
00044 #else
00045 typedef void PlatformPath;
00046 #endif
00047
00048 namespace WebCore {
00049
00050 class AffineTransform;
00051 class FloatPoint;
00052 class FloatSize;
00053 class FloatRect;
00054 class String;
00055
00056 enum WindRule {
00057 RULE_NONZERO = 0,
00058 RULE_EVENODD = 1
00059 };
00060
00061 enum PathElementType {
00062 PathElementMoveToPoint,
00063 PathElementAddLineToPoint,
00064 PathElementAddQuadCurveToPoint,
00065 PathElementAddCurveToPoint,
00066 PathElementCloseSubpath
00067 };
00068
00069 struct PathElement {
00070 PathElementType type;
00071 FloatPoint* points;
00072 };
00073
00074 typedef void (*PathApplierFunction) (void* info, const PathElement*);
00075
00076 class Path {
00077 public:
00078 Path();
00079 ~Path();
00080
00081 Path(const Path&);
00082 Path& operator=(const Path&);
00083
00084 bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
00085 FloatRect boundingRect() const;
00086
00087 float length();
00088 FloatPoint pointAtLength(float length, bool& ok);
00089 float normalAngleAtLength(float length, bool& ok);
00090
00091 void clear();
00092 bool isEmpty() const;
00093
00094 void moveTo(const FloatPoint&);
00095 void addLineTo(const FloatPoint&);
00096 void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
00097 void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
00098 void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
00099 void closeSubpath();
00100
00101 void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool clockwise);
00102 void addRect(const FloatRect&);
00103 void addEllipse(const FloatRect&);
00104
00105 void translate(const FloatSize&);
00106
00107 void setWindingRule(WindRule rule) { m_rule = rule; }
00108 WindRule windingRule() const { return m_rule; }
00109
00110 String debugString() const;
00111
00112 PlatformPath* platformPath() const { return m_path; }
00113
00114 static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);
00115 static Path createRoundedRectangle(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
00116 static Path createRectangle(const FloatRect&);
00117 static Path createEllipse(const FloatPoint& center, float rx, float ry);
00118 static Path createCircle(const FloatPoint& center, float r);
00119 static Path createLine(const FloatPoint&, const FloatPoint&);
00120
00121 void apply(void* info, PathApplierFunction) const;
00122 void transform(const AffineTransform&);
00123
00124 private:
00125 PlatformPath* m_path;
00126 WindRule m_rule;
00127 };
00128
00129 }
00130
00131 #endif