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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 polygon.overlappingEdges(minY, maxY, result); | 67 polygon.overlappingEdges(minY, maxY, result); |
68 std::sort(result.begin(), result.end(), compareEdgeIndex); | 68 std::sort(result.begin(), result.end(), compareEdgeIndex); |
69 return result; | 69 return result; |
70 } | 70 } |
71 | 71 |
72 } // anonymous namespace | 72 } // anonymous namespace |
73 | 73 |
74 #define SIZEOF_ARRAY(p) (sizeof(p) / sizeof(p[0])) | 74 #define SIZEOF_ARRAY(p) (sizeof(p) / sizeof(p[0])) |
75 | 75 |
76 /** | 76 /** |
77 * Checks a right triangle. This test covers all of the trivial FloatPolygon acc
essors. | 77 * Checks a right triangle. This test covers all of the trivial FloatPolygon |
| 78 * accessors. |
78 * | 79 * |
79 * 200,100 | 80 * 200,100 |
80 * /| | 81 * /| |
81 * / | | 82 * / | |
82 * / | | 83 * / | |
83 * ----- | 84 * ----- |
84 * 100,200 200,200 | 85 * 100,200 200,200 |
85 */ | 86 */ |
86 TEST(FloatPolygonTest, basics) { | 87 TEST(FloatPolygonTest, basics) { |
87 const float triangleCoordinates[] = {200, 100, 200, 200, 100, 200}; | 88 const float triangleCoordinates[] = {200, 100, 200, 200, 100, 200}; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 TEST_EMPTY(emptyCoordinates4); | 251 TEST_EMPTY(emptyCoordinates4); |
251 | 252 |
252 const float emptyCoordinates5[] = {0, 0, 0, 1, 0, 2, 0, 3, 0, 1}; | 253 const float emptyCoordinates5[] = {0, 0, 0, 1, 0, 2, 0, 3, 0, 1}; |
253 TEST_EMPTY(emptyCoordinates5); | 254 TEST_EMPTY(emptyCoordinates5); |
254 | 255 |
255 const float emptyCoordinates6[] = {0, 0, 1, 0, 2, 0, 3, 0, 1, 0}; | 256 const float emptyCoordinates6[] = {0, 0, 1, 0, 2, 0, 3, 0, 1, 0}; |
256 TEST_EMPTY(emptyCoordinates6); | 257 TEST_EMPTY(emptyCoordinates6); |
257 } | 258 } |
258 | 259 |
259 /* | 260 /* |
260 * Test FloatPolygon::contains() with a trapezoid. The vertices are listed in co
unter-clockwise order. | 261 * Test FloatPolygon::contains() with a trapezoid. The vertices are listed in |
| 262 * counter-clockwise order. |
261 * | 263 * |
262 * 150,100 250,100 | 264 * 150,100 250,100 |
263 * +----------+ | 265 * +----------+ |
264 * / \ | 266 * / \ |
265 * / \ | 267 * / \ |
266 * +----------------+ | 268 * +----------------+ |
267 * 100,150 300,150 | 269 * 100,150 300,150 |
268 */ | 270 */ |
269 TEST(FloatPolygonTest, trapezoid) { | 271 TEST(FloatPolygonTest, trapezoid) { |
270 const float trapezoidCoordinates[] = {100, 150, 300, 150, 250, 100, 150, 100}; | 272 const float trapezoidCoordinates[] = {100, 150, 300, 150, 250, 100, 150, 100}; |
271 FloatPolygonTestValue trapezoidTestValue( | 273 FloatPolygonTestValue trapezoidTestValue( |
272 trapezoidCoordinates, SIZEOF_ARRAY(trapezoidCoordinates), RULE_EVENODD); | 274 trapezoidCoordinates, SIZEOF_ARRAY(trapezoidCoordinates), RULE_EVENODD); |
273 const FloatPolygon& trapezoid = trapezoidTestValue.polygon(); | 275 const FloatPolygon& trapezoid = trapezoidTestValue.polygon(); |
274 | 276 |
275 EXPECT_FALSE(trapezoid.isEmpty()); | 277 EXPECT_FALSE(trapezoid.isEmpty()); |
276 EXPECT_EQ(4u, trapezoid.numberOfVertices()); | 278 EXPECT_EQ(4u, trapezoid.numberOfVertices()); |
277 EXPECT_EQ(FloatRect(100, 100, 200, 50), trapezoid.boundingBox()); | 279 EXPECT_EQ(FloatRect(100, 100, 200, 50), trapezoid.boundingBox()); |
278 | 280 |
279 EXPECT_TRUE(trapezoid.contains(FloatPoint(150, 100))); | 281 EXPECT_TRUE(trapezoid.contains(FloatPoint(150, 100))); |
280 EXPECT_TRUE(trapezoid.contains(FloatPoint(150, 101))); | 282 EXPECT_TRUE(trapezoid.contains(FloatPoint(150, 101))); |
281 EXPECT_TRUE(trapezoid.contains(FloatPoint(200, 125))); | 283 EXPECT_TRUE(trapezoid.contains(FloatPoint(200, 125))); |
282 EXPECT_FALSE(trapezoid.contains(FloatPoint(149, 100))); | 284 EXPECT_FALSE(trapezoid.contains(FloatPoint(149, 100))); |
283 EXPECT_FALSE(trapezoid.contains(FloatPoint(301, 150))); | 285 EXPECT_FALSE(trapezoid.contains(FloatPoint(301, 150))); |
284 } | 286 } |
285 | 287 |
286 /* | 288 /* |
287 * Test FloatPolygon::contains() with a non-convex rectilinear polygon. The poly
gon has the same shape | 289 * Test FloatPolygon::contains() with a non-convex rectilinear polygon. The |
288 * as the letter "H": | 290 * polygon has the same shape as the letter "H": |
289 * | 291 * |
290 * 100,100 150,100 200,100 250,100 | 292 * 100,100 150,100 200,100 250,100 |
291 * +--------+ +--------+ | 293 * +--------+ +--------+ |
292 * | | | | | 294 * | | | | |
293 * | | | | | 295 * | | | | |
294 * | +--------+ | | 296 * | +--------+ | |
295 * | 150,150 200,150 | | 297 * | 150,150 200,150 | |
296 * | | | 298 * | | |
297 * | 150,200 200,200 | | 299 * | 150,200 200,200 | |
298 * | +--------+ | | 300 * | +--------+ | |
(...skipping 29 matching lines...) Expand all Loading... |
328 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); | 330 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); |
329 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); | 331 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); |
330 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); | 332 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); |
331 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); | 333 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); |
332 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 334 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
333 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); | 335 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); |
334 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); | 336 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); |
335 } | 337 } |
336 | 338 |
337 } // namespace blink | 339 } // namespace blink |
OLD | NEW |