OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 15 matching lines...) Expand all Loading... |
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef PolygonShape_h | 30 #ifndef PolygonShape_h |
31 #define PolygonShape_h | 31 #define PolygonShape_h |
32 | 32 |
33 #include "core/layout/shapes/Shape.h" | 33 #include "core/layout/shapes/Shape.h" |
34 #include "core/layout/shapes/ShapeInterval.h" | 34 #include "core/layout/shapes/ShapeInterval.h" |
35 #include "platform/geometry/FloatPolygon.h" | 35 #include "platform/geometry/FloatPolygon.h" |
| 36 #include <memory> |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 class OffsetPolygonEdge final : public VertexPair { | 40 class OffsetPolygonEdge final : public VertexPair { |
40 DISALLOW_NEW(); | 41 DISALLOW_NEW(); |
41 public: | 42 public: |
42 OffsetPolygonEdge(const FloatPolygonEdge& edge, const FloatSize& offset) | 43 OffsetPolygonEdge(const FloatPolygonEdge& edge, const FloatSize& offset) |
43 : m_vertex1(edge.vertex1() + offset) | 44 : m_vertex1(edge.vertex1() + offset) |
44 , m_vertex2(edge.vertex2() + offset) | 45 , m_vertex2(edge.vertex2() + offset) |
45 { | 46 { |
46 } | 47 } |
47 | 48 |
48 const FloatPoint& vertex1() const override { return m_vertex1; } | 49 const FloatPoint& vertex1() const override { return m_vertex1; } |
49 const FloatPoint& vertex2() const override { return m_vertex2; } | 50 const FloatPoint& vertex2() const override { return m_vertex2; } |
50 | 51 |
51 bool isWithinYRange(float y1, float y2) const { return y1 <= minY() && y2 >=
maxY(); } | 52 bool isWithinYRange(float y1, float y2) const { return y1 <= minY() && y2 >=
maxY(); } |
52 bool overlapsYRange(float y1, float y2) const { return y2 >= minY() && y1 <=
maxY(); } | 53 bool overlapsYRange(float y1, float y2) const { return y2 >= minY() && y1 <=
maxY(); } |
53 float xIntercept(float y) const; | 54 float xIntercept(float y) const; |
54 FloatShapeInterval clippedEdgeXRange(float y1, float y2) const; | 55 FloatShapeInterval clippedEdgeXRange(float y1, float y2) const; |
55 | 56 |
56 private: | 57 private: |
57 FloatPoint m_vertex1; | 58 FloatPoint m_vertex1; |
58 FloatPoint m_vertex2; | 59 FloatPoint m_vertex2; |
59 }; | 60 }; |
60 | 61 |
61 class PolygonShape final : public Shape { | 62 class PolygonShape final : public Shape { |
62 WTF_MAKE_NONCOPYABLE(PolygonShape); | 63 WTF_MAKE_NONCOPYABLE(PolygonShape); |
63 public: | 64 public: |
64 PolygonShape(PassOwnPtr<Vector<FloatPoint>> vertices, WindRule fillRule) | 65 PolygonShape(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule
) |
65 : Shape() | 66 : Shape() |
66 , m_polygon(std::move(vertices), fillRule) | 67 , m_polygon(std::move(vertices), fillRule) |
67 { | 68 { |
68 } | 69 } |
69 | 70 |
70 LayoutRect shapeMarginLogicalBoundingBox() const override; | 71 LayoutRect shapeMarginLogicalBoundingBox() const override; |
71 bool isEmpty() const override { return m_polygon.isEmpty(); } | 72 bool isEmpty() const override { return m_polygon.isEmpty(); } |
72 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei
ght) const override; | 73 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei
ght) const override; |
73 void buildDisplayPaths(DisplayPaths&) const override; | 74 void buildDisplayPaths(DisplayPaths&) const override; |
74 | 75 |
75 private: | 76 private: |
76 FloatPolygon m_polygon; | 77 FloatPolygon m_polygon; |
77 }; | 78 }; |
78 | 79 |
79 } // namespace blink | 80 } // namespace blink |
80 | 81 |
81 #endif // PolygonShape_h | 82 #endif // PolygonShape_h |
OLD | NEW |