summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/shapes/PolygonShape.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/shapes/PolygonShape.h')
-rw-r--r--Source/WebCore/rendering/shapes/PolygonShape.h67
1 files changed, 16 insertions, 51 deletions
diff --git a/Source/WebCore/rendering/shapes/PolygonShape.h b/Source/WebCore/rendering/shapes/PolygonShape.h
index 09f714083..6d92c83d3 100644
--- a/Source/WebCore/rendering/shapes/PolygonShape.h
+++ b/Source/WebCore/rendering/shapes/PolygonShape.h
@@ -12,7 +12,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -27,86 +27,51 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PolygonShape_h
-#define PolygonShape_h
+#pragma once
#include "FloatPolygon.h"
#include "Shape.h"
+#include "ShapeInterval.h"
namespace WebCore {
-class OffsetPolygonEdge : public VertexPair {
+class OffsetPolygonEdge final : public VertexPair {
public:
- enum Basis {
- Edge,
- Vertex,
- LineTop
- };
-
OffsetPolygonEdge(const FloatPolygonEdge& edge, const FloatSize& offset)
: m_vertex1(edge.vertex1() + offset)
, m_vertex2(edge.vertex2() + offset)
- , m_edgeIndex(edge.edgeIndex())
- , m_basis(Edge)
{
}
- OffsetPolygonEdge(const FloatPoint& reflexVertex, const FloatSize& offset1, const FloatSize& offset2)
- : m_vertex1(reflexVertex + offset1)
- , m_vertex2(reflexVertex + offset2)
- , m_edgeIndex(-1)
- , m_basis(Vertex)
- {
- }
+ const FloatPoint& vertex1() const override { return m_vertex1; }
+ const FloatPoint& vertex2() const override { return m_vertex2; }
- OffsetPolygonEdge(const FloatPolygon& polygon, float minLogicalIntervalTop, const FloatSize& offset)
- : m_vertex1(FloatPoint(polygon.boundingBox().x(), minLogicalIntervalTop) + offset)
- , m_vertex2(FloatPoint(polygon.boundingBox().maxX(), minLogicalIntervalTop) + offset)
- , m_edgeIndex(-1)
- , m_basis(LineTop)
- {
- }
-
- virtual const FloatPoint& vertex1() const override { return m_vertex1; }
- virtual const FloatPoint& vertex2() const override { return m_vertex2; }
- int edgeIndex() const { return m_edgeIndex; }
- Basis basis() const { return m_basis; }
+ 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;
- int m_edgeIndex;
- Basis m_basis;
};
class PolygonShape : public Shape {
WTF_MAKE_NONCOPYABLE(PolygonShape);
public:
- PolygonShape(PassOwnPtr<Vector<FloatPoint>> vertices, WindRule fillRule)
- : m_polygon(vertices, fillRule)
- , m_marginBounds(nullptr)
- , m_paddingBounds(nullptr)
+ PolygonShape(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule)
+ : m_polygon(WTFMove(vertices), fillRule)
{
}
- virtual LayoutRect shapeMarginLogicalBoundingBox() const override { return static_cast<LayoutRect>(shapeMarginBounds().boundingBox()); }
- virtual LayoutRect shapePaddingLogicalBoundingBox() const override { return static_cast<LayoutRect>(shapePaddingBounds().boundingBox()); }
- virtual bool isEmpty() const override { return m_polygon.isEmpty(); }
- virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
- virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const override;
- virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const FloatSize& minLogicalIntervalSize, LayoutUnit&) const override;
+ LayoutRect shapeMarginLogicalBoundingBox() const override;
+ bool isEmpty() const override { return m_polygon.isEmpty(); }
+ LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const override;
- virtual void buildDisplayPaths(DisplayPaths&) const override;
+ void buildDisplayPaths(DisplayPaths&) const override;
private:
- const FloatPolygon& shapeMarginBounds() const;
- const FloatPolygon& shapePaddingBounds() const;
-
FloatPolygon m_polygon;
- mutable OwnPtr<FloatPolygon> m_marginBounds;
- mutable OwnPtr<FloatPolygon> m_paddingBounds;
};
} // namespace WebCore
-
-#endif // PolygonShape_h