#ifndef Path_h
#define Path_h
#include "WindRule.h"
#include <wtf/FastMalloc.h>
#include <wtf/Forward.h>
#if USE(CG)
#include <wtf/RetainPtr.h>
#include <CoreGraphics/CGPath.h>
typedef struct CGPath PlatformPath;
#elif USE(CAIRO)
namespace WebCore {
class CairoPath;
}
typedef WebCore::CairoPath PlatformPath;
#elif USE(WINGDI)
namespace WebCore {
class PlatformPath;
}
typedef WebCore::PlatformPath PlatformPath;
#else
typedef void PlatformPath;
#endif
typedef PlatformPath* PlatformPathPtr;
namespace WebCore {
class AffineTransform;
class FloatPoint;
class FloatRect;
class FloatRoundedRect;
class FloatSize;
class GraphicsContext;
class RoundedRect;
class StrokeStyleApplier;
enum PathElementType {
PathElementMoveToPoint, PathElementAddLineToPoint, PathElementAddQuadCurveToPoint, PathElementAddCurveToPoint, PathElementCloseSubpath };
struct PathElement {
PathElementType type;
FloatPoint* points;
};
typedef void (*PathApplierFunction)(void* info, const PathElement*);
class Path {
WTF_MAKE_FAST_ALLOCATED;
public:
Path();
#if USE(CG)
Path(RetainPtr<CGMutablePathRef>);
#endif
~Path();
Path(const Path&);
Path& operator=(const Path&);
bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const;
FloatRect boundingRect() const;
FloatRect fastBoundingRect() const;
FloatRect strokeBoundingRect(StrokeStyleApplier* = 0) const;
float length() const;
FloatPoint pointAtLength(float length, bool& ok) const;
float normalAngleAtLength(float length, bool& ok) const;
void clear();
bool isNull() const { return !m_path; }
bool isEmpty() const;
bool hasCurrentPoint() const;
FloatPoint currentPoint() const;
void moveTo(const FloatPoint&);
void addLineTo(const FloatPoint&);
void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
void closeSubpath();
void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise);
void addRect(const FloatRect&);
void addEllipse(const FloatRect&);
enum RoundedRectStrategy {
PreferNativeRoundedRect,
PreferBezierRoundedRect
};
void addRoundedRect(const FloatRect&, const FloatSize& roundingRadii, RoundedRectStrategy = PreferNativeRoundedRect);
void addRoundedRect(const FloatRoundedRect&, RoundedRectStrategy = PreferNativeRoundedRect);
void addRoundedRect(const RoundedRect&);
void addPath(const Path&, const AffineTransform&);
void translate(const FloatSize&);
PlatformPathPtr platformPath() const { return m_path; }
PlatformPathPtr ensurePlatformPath();
void apply(void* info, PathApplierFunction) const;
void transform(const AffineTransform&);
void addBeziersForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
#if USE(CG)
void platformAddPathForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
#endif
private:
PlatformPathPtr m_path;
};
}
#endif