OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 REPORTER_ASSERT(reporter, path.isOval(NULL)); | 2320 REPORTER_ASSERT(reporter, path.isOval(NULL)); |
2321 | 2321 |
2322 // copy path | 2322 // copy path |
2323 path.reset(); | 2323 path.reset(); |
2324 tmp.reset(); | 2324 tmp.reset(); |
2325 tmp.addOval(rect); | 2325 tmp.addOval(rect); |
2326 path = tmp; | 2326 path = tmp; |
2327 REPORTER_ASSERT(reporter, path.isOval(NULL)); | 2327 REPORTER_ASSERT(reporter, path.isOval(NULL)); |
2328 } | 2328 } |
2329 | 2329 |
2330 static void TestPath(skiatest::Reporter* reporter) { | 2330 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) { |
2331 SkTSize<SkScalar>::Make(3,4); | 2331 SkPath empty; |
2332 | |
2333 SkPath p, p2; | |
2334 SkRect bounds, bounds2; | |
2335 | 2332 |
2336 REPORTER_ASSERT(reporter, p.isEmpty()); | 2333 REPORTER_ASSERT(reporter, p.isEmpty()); |
2337 REPORTER_ASSERT(reporter, 0 == p.countPoints()); | 2334 REPORTER_ASSERT(reporter, 0 == p.countPoints()); |
2338 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); | 2335 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); |
2339 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); | 2336 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); |
2340 REPORTER_ASSERT(reporter, p.isConvex()); | 2337 REPORTER_ASSERT(reporter, p.isConvex()); |
2341 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); | 2338 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); |
2342 REPORTER_ASSERT(reporter, !p.isInverseFillType()); | 2339 REPORTER_ASSERT(reporter, !p.isInverseFillType()); |
2343 REPORTER_ASSERT(reporter, p == p2); | 2340 REPORTER_ASSERT(reporter, p == empty); |
2344 REPORTER_ASSERT(reporter, !(p != p2)); | 2341 REPORTER_ASSERT(reporter, !(p != empty)); |
| 2342 } |
| 2343 |
| 2344 static void TestPath(skiatest::Reporter* reporter) { |
| 2345 SkTSize<SkScalar>::Make(3,4); |
| 2346 |
| 2347 SkPath p, empty; |
| 2348 SkRect bounds, bounds2; |
| 2349 test_empty(reporter, p); |
2345 | 2350 |
2346 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); | 2351 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); |
2347 | 2352 |
2348 bounds.set(0, 0, SK_Scalar1, SK_Scalar1); | 2353 bounds.set(0, 0, SK_Scalar1, SK_Scalar1); |
2349 | 2354 |
2350 p.addRoundRect(bounds, SK_Scalar1, SK_Scalar1); | 2355 p.addRoundRect(bounds, SK_Scalar1, SK_Scalar1); |
2351 check_convex_bounds(reporter, p, bounds); | 2356 check_convex_bounds(reporter, p, bounds); |
2352 // we have quads or cubics | 2357 // we have quads or cubics |
2353 REPORTER_ASSERT(reporter, p.getSegmentMasks() & kCurveSegmentMask); | 2358 REPORTER_ASSERT(reporter, p.getSegmentMasks() & kCurveSegmentMask); |
2354 REPORTER_ASSERT(reporter, !p.isEmpty()); | 2359 REPORTER_ASSERT(reporter, !p.isEmpty()); |
2355 | 2360 |
2356 p.reset(); | 2361 p.reset(); |
2357 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); | 2362 test_empty(reporter, p); |
2358 REPORTER_ASSERT(reporter, p.isEmpty()); | |
2359 | 2363 |
2360 p.addOval(bounds); | 2364 p.addOval(bounds); |
2361 check_convex_bounds(reporter, p, bounds); | 2365 check_convex_bounds(reporter, p, bounds); |
2362 REPORTER_ASSERT(reporter, !p.isEmpty()); | 2366 REPORTER_ASSERT(reporter, !p.isEmpty()); |
2363 | 2367 |
2364 p.reset(); | 2368 p.rewind(); |
| 2369 test_empty(reporter, p); |
| 2370 |
2365 p.addRect(bounds); | 2371 p.addRect(bounds); |
2366 check_convex_bounds(reporter, p, bounds); | 2372 check_convex_bounds(reporter, p, bounds); |
2367 // we have only lines | 2373 // we have only lines |
2368 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks()); | 2374 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks()); |
2369 REPORTER_ASSERT(reporter, !p.isEmpty()); | 2375 REPORTER_ASSERT(reporter, !p.isEmpty()); |
2370 | 2376 |
2371 REPORTER_ASSERT(reporter, p != p2); | 2377 REPORTER_ASSERT(reporter, p != empty); |
2372 REPORTER_ASSERT(reporter, !(p == p2)); | 2378 REPORTER_ASSERT(reporter, !(p == empty)); |
2373 | 2379 |
2374 // do getPoints and getVerbs return the right result | 2380 // do getPoints and getVerbs return the right result |
2375 REPORTER_ASSERT(reporter, p.getPoints(NULL, 0) == 4); | 2381 REPORTER_ASSERT(reporter, p.getPoints(NULL, 0) == 4); |
2376 REPORTER_ASSERT(reporter, p.getVerbs(NULL, 0) == 5); | 2382 REPORTER_ASSERT(reporter, p.getVerbs(NULL, 0) == 5); |
2377 SkPoint pts[4]; | 2383 SkPoint pts[4]; |
2378 int count = p.getPoints(pts, 4); | 2384 int count = p.getPoints(pts, 4); |
2379 REPORTER_ASSERT(reporter, count == 4); | 2385 REPORTER_ASSERT(reporter, count == 4); |
2380 uint8_t verbs[6]; | 2386 uint8_t verbs[6]; |
2381 verbs[5] = 0xff; | 2387 verbs[5] = 0xff; |
2382 p.getVerbs(verbs, 5); | 2388 p.getVerbs(verbs, 5); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 test_addrect_isfinite(reporter); | 2435 test_addrect_isfinite(reporter); |
2430 test_tricky_cubic(); | 2436 test_tricky_cubic(); |
2431 test_clipped_cubic(); | 2437 test_clipped_cubic(); |
2432 test_crbug_170666(); | 2438 test_crbug_170666(); |
2433 test_bad_cubic_crbug229478(); | 2439 test_bad_cubic_crbug229478(); |
2434 test_bad_cubic_crbug234190(); | 2440 test_bad_cubic_crbug234190(); |
2435 } | 2441 } |
2436 | 2442 |
2437 #include "TestClassDef.h" | 2443 #include "TestClassDef.h" |
2438 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 2444 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) |
OLD | NEW |