caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 7 | #include "PathOpsTestCommon.h" |
caryclark@google.com | a2bbc6e | 2013-11-01 17:36:03 +0000 | [diff] [blame] | 8 | #include "SkPath.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 9 | #include "SkPathOpsQuad.h" |
caryclark@google.com | a2bbc6e | 2013-11-01 17:36:03 +0000 | [diff] [blame] | 10 | #include "SkRRect.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 11 | #include "Test.h" |
| 12 | |
| 13 | static const SkDQuad tests[] = { |
| 14 | {{{1, 1}, {2, 1}, {0, 2}}}, |
| 15 | {{{0, 0}, {1, 1}, {3, 1}}}, |
| 16 | {{{2, 0}, {1, 1}, {2, 2}}}, |
| 17 | {{{4, 0}, {0, 1}, {4, 2}}}, |
| 18 | {{{0, 0}, {0, 1}, {1, 1}}}, |
| 19 | }; |
| 20 | |
| 21 | static const SkDPoint inPoint[]= { |
| 22 | {1, 1.2}, |
| 23 | {1, 0.8}, |
| 24 | {1.8, 1}, |
| 25 | {1.5, 1}, |
caryclark@google.com | a2bbc6e | 2013-11-01 17:36:03 +0000 | [diff] [blame] | 26 | {0.4999, 0.5}, // was 0.5, 0.5; points on the hull are considered outside |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | static const SkDPoint outPoint[]= { |
| 30 | {1, 1.6}, |
| 31 | {1, 1.5}, |
| 32 | {2.2, 1}, |
| 33 | {1.5, 1.5}, |
| 34 | {1.1, 0.5}, |
| 35 | }; |
| 36 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 37 | static const size_t tests_count = SK_ARRAY_COUNT(tests); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 38 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 39 | DEF_TEST(PathOpsDQuad, reporter) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 40 | for (size_t index = 0; index < tests_count; ++index) { |
| 41 | const SkDQuad& quad = tests[index]; |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 42 | SkASSERT(ValidQuad(quad)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 43 | bool result = quad.pointInHull(inPoint[index]); |
| 44 | if (!result) { |
| 45 | SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index); |
| 46 | REPORTER_ASSERT(reporter, 0); |
| 47 | } |
| 48 | result = quad.pointInHull(outPoint[index]); |
| 49 | if (result) { |
| 50 | SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index); |
| 51 | REPORTER_ASSERT(reporter, 0); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 56 | DEF_TEST(PathOpsRRect, reporter) { |
caryclark@google.com | a2bbc6e | 2013-11-01 17:36:03 +0000 | [diff] [blame] | 57 | SkPath path; |
| 58 | SkRRect rRect; |
| 59 | SkRect rect = {135, 143, 250, 177}; |
| 60 | SkVector radii[4] = {{8, 8}, {8, 8}, {0, 0}, {0, 0}}; |
| 61 | rRect.setRectRadii(rect, radii); |
| 62 | path.addRRect(rRect); |
| 63 | } |