OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 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 12 matching lines...) Expand all Loading... |
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
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 #include "platform/geometry/FloatPolygon.h" | 30 #include "platform/geometry/FloatPolygon.h" |
31 | 31 |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "wtf/PtrUtil.h" |
| 34 #include <memory> |
33 | 35 |
34 namespace blink { | 36 namespace blink { |
35 | 37 |
36 class FloatPolygonTestValue { | 38 class FloatPolygonTestValue { |
37 public: | 39 public: |
38 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength,
WindRule fillRule) | 40 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength,
WindRule fillRule) |
39 { | 41 { |
40 ASSERT(!(coordinatesLength % 2)); | 42 ASSERT(!(coordinatesLength % 2)); |
41 OwnPtr<Vector<FloatPoint>> vertices = adoptPtr(new Vector<FloatPoint>(co
ordinatesLength / 2)); | 43 std::unique_ptr<Vector<FloatPoint>> vertices = wrapUnique(new Vector<Flo
atPoint>(coordinatesLength / 2)); |
42 for (unsigned i = 0; i < coordinatesLength; i += 2) | 44 for (unsigned i = 0; i < coordinatesLength; i += 2) |
43 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]); | 45 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]); |
44 m_polygon = adoptPtr(new FloatPolygon(std::move(vertices), fillRule)); | 46 m_polygon = wrapUnique(new FloatPolygon(std::move(vertices), fillRule)); |
45 } | 47 } |
46 | 48 |
47 const FloatPolygon& polygon() const { return *m_polygon; } | 49 const FloatPolygon& polygon() const { return *m_polygon; } |
48 | 50 |
49 private: | 51 private: |
50 OwnPtr<FloatPolygon> m_polygon; | 52 std::unique_ptr<FloatPolygon> m_polygon; |
51 }; | 53 }; |
52 | 54 |
53 namespace { | 55 namespace { |
54 | 56 |
55 bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEdge* edg
e2) | 57 bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEdge* edg
e2) |
56 { | 58 { |
57 return edge1->edgeIndex() < edge2->edgeIndex(); | 59 return edge1->edgeIndex() < edge2->edgeIndex(); |
58 } | 60 } |
59 | 61 |
60 Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon& polyg
on, float minY, float maxY) | 62 Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon& polyg
on, float minY, float maxY) |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); | 320 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); |
319 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); | 321 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); |
320 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); | 322 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); |
321 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); | 323 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); |
322 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 324 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
323 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 325 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
324 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); | 326 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); |
325 } | 327 } |
326 | 328 |
327 } // namespace blink | 329 } // namespace blink |
OLD | NEW |