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 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 #include "config.h" | 30 #include "config.h" |
31 | 31 |
32 #include "platform/geometry/FloatPolygon.h" | 32 #include "platform/geometry/FloatPolygon.h" |
33 | 33 |
34 #include <gtest/gtest.h> | 34 #include <gtest/gtest.h> |
35 | 35 |
36 namespace WebCore { | 36 namespace blink { |
37 | 37 |
38 class FloatPolygonTestValue { | 38 class FloatPolygonTestValue { |
39 public: | 39 public: |
40 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength,
WindRule fillRule) | 40 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength,
WindRule fillRule) |
41 { | 41 { |
42 ASSERT(!(coordinatesLength % 2)); | 42 ASSERT(!(coordinatesLength % 2)); |
43 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(c
oordinatesLength / 2)); | 43 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(c
oordinatesLength / 2)); |
44 for (unsigned i = 0; i < coordinatesLength; i += 2) | 44 for (unsigned i = 0; i < coordinatesLength; i += 2) |
45 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]); | 45 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]); |
46 m_polygon = adoptPtr(new FloatPolygon(vertices.release(), fillRule)); | 46 m_polygon = adoptPtr(new FloatPolygon(vertices.release(), fillRule)); |
47 } | 47 } |
48 | 48 |
49 const FloatPolygon& polygon() const { return *m_polygon; } | 49 const FloatPolygon& polygon() const { return *m_polygon; } |
50 | 50 |
51 private: | 51 private: |
52 OwnPtr<FloatPolygon> m_polygon; | 52 OwnPtr<FloatPolygon> m_polygon; |
53 }; | 53 }; |
54 | 54 |
55 } // namespace WebCore | 55 } // namespace blink |
56 | 56 |
57 namespace { | 57 namespace { |
58 | 58 |
59 using namespace WebCore; | 59 using namespace blink; |
60 | 60 |
61 static bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEd
ge* edge2) | 61 static bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEd
ge* edge2) |
62 { | 62 { |
63 return edge1->edgeIndex() < edge2->edgeIndex(); | 63 return edge1->edgeIndex() < edge2->edgeIndex(); |
64 } | 64 } |
65 | 65 |
66 static Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon
& polygon, float minY, float maxY) | 66 static Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon
& polygon, float minY, float maxY) |
67 { | 67 { |
68 Vector<const FloatPolygonEdge*> result; | 68 Vector<const FloatPolygonEdge*> result; |
69 polygon.overlappingEdges(minY, maxY, result); | 69 polygon.overlappingEdges(minY, maxY, result); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); | 322 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); |
323 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); | 323 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); |
324 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); | 324 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); |
325 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); | 325 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); |
326 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 326 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
327 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 327 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
328 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); | 328 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); |
329 } | 329 } |
330 | 330 |
331 } // namespace | 331 } // namespace |
OLD | NEW |