blob: 80d81e81296497cf83f569049dcbdaa2767429ce [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
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.com8d0a5242013-07-16 16:11:16 +00007#include "PathOpsTestCommon.h"
caryclark@google.coma2bbc6e2013-11-01 17:36:03 +00008#include "SkPath.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +00009#include "SkPathOpsQuad.h"
caryclark@google.coma2bbc6e2013-11-01 17:36:03 +000010#include "SkRRect.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000011#include "Test.h"
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000012#include "TestClassDef.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000013
14static const SkDQuad tests[] = {
15 {{{1, 1}, {2, 1}, {0, 2}}},
16 {{{0, 0}, {1, 1}, {3, 1}}},
17 {{{2, 0}, {1, 1}, {2, 2}}},
18 {{{4, 0}, {0, 1}, {4, 2}}},
19 {{{0, 0}, {0, 1}, {1, 1}}},
20};
21
22static const SkDPoint inPoint[]= {
23 {1, 1.2},
24 {1, 0.8},
25 {1.8, 1},
26 {1.5, 1},
caryclark@google.coma2bbc6e2013-11-01 17:36:03 +000027 {0.4999, 0.5}, // was 0.5, 0.5; points on the hull are considered outside
caryclark@google.com07393ca2013-04-08 11:47:37 +000028};
29
30static const SkDPoint outPoint[]= {
31 {1, 1.6},
32 {1, 1.5},
33 {2.2, 1},
34 {1.5, 1.5},
35 {1.1, 0.5},
36};
37
caryclark@google.comad65a3e2013-04-15 19:13:59 +000038static const size_t tests_count = SK_ARRAY_COUNT(tests);
caryclark@google.com07393ca2013-04-08 11:47:37 +000039
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000040DEF_TEST(PathOpsDQuad, reporter) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000041 for (size_t index = 0; index < tests_count; ++index) {
42 const SkDQuad& quad = tests[index];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000043 SkASSERT(ValidQuad(quad));
caryclark@google.com07393ca2013-04-08 11:47:37 +000044 bool result = quad.pointInHull(inPoint[index]);
45 if (!result) {
46 SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index);
47 REPORTER_ASSERT(reporter, 0);
48 }
49 result = quad.pointInHull(outPoint[index]);
50 if (result) {
51 SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index);
52 REPORTER_ASSERT(reporter, 0);
53 }
54 }
55}
56
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000057DEF_TEST(PathOpsRRect, reporter) {
caryclark@google.coma2bbc6e2013-11-01 17:36:03 +000058 SkPath path;
59 SkRRect rRect;
60 SkRect rect = {135, 143, 250, 177};
61 SkVector radii[4] = {{8, 8}, {8, 8}, {0, 0}, {0, 0}};
62 rRect.setRectRadii(rect, radii);
63 path.addRRect(rRect);
64}