#ifndef PolygonShape_h
#define PolygonShape_h
#include "FloatPolygon.h"
#include "Shape.h"
#include "ShapeInterval.h"
namespace WebCore {
class OffsetPolygonEdge : public VertexPair {
public:
OffsetPolygonEdge(const FloatPolygonEdge& edge, const FloatSize& offset)
: m_vertex1(edge.vertex1() + offset)
, m_vertex2(edge.vertex2() + offset)
{
}
virtual const FloatPoint& vertex1() const override { return m_vertex1; }
virtual const FloatPoint& vertex2() const override { return m_vertex2; }
bool isWithinYRange(float y1, float y2) const { return y1 <= minY() && y2 >= maxY(); }
bool overlapsYRange(float y1, float y2) const { return y2 >= minY() && y1 <= maxY(); }
float xIntercept(float y) const;
FloatShapeInterval clippedEdgeXRange(float y1, float y2) const;
private:
FloatPoint m_vertex1;
FloatPoint m_vertex2;
};
class PolygonShape : public Shape {
WTF_MAKE_NONCOPYABLE(PolygonShape);
public:
PolygonShape(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule)
: m_polygon(WTF::move(vertices), fillRule)
{
}
virtual LayoutRect shapeMarginLogicalBoundingBox() const override;
virtual bool isEmpty() const override { return m_polygon.isEmpty(); }
virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
virtual void buildDisplayPaths(DisplayPaths&) const override;
private:
FloatPolygon m_polygon;
};
}
#endif // PolygonShape_h