2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #include "PathOpsQuadIntersectionTestData.h"
8 #include "SkIntersections.h"
9 #include "SkPathOpsRect.h"
10 #include "SkReduceOrder.h"
13 static const SkDQuad testSet[] = {
14 {{{1, 1}, {2, 2}, {1, 1.000003}}},
15 {{{1, 0}, {2, 6}, {3, 0}}}
18 static const size_t testSetCount = SK_ARRAY_COUNT(testSet);
20 static void oneOffTest(skiatest::Reporter* reporter) {
21 for (size_t index = 0; index < testSetCount; ++index) {
22 const SkDQuad& quad = testSet[index];
23 SkReduceOrder reducer;
24 SkDEBUGCODE(int result = ) reducer.reduce(quad);
25 SkASSERT(result == 3);
29 static void standardTestCases(skiatest::Reporter* reporter) {
31 SkReduceOrder reducer;
39 int firstTestIndex = 0;
41 run = RunQuadraticLines;
44 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ? firstTestIndex
46 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLines ? firstTestIndex
49 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
50 const SkDQuad& quad = quadraticLines[index];
51 order = reducer.reduce(quad);
53 SkDebugf("[%d] line quad order=%d\n", (int) index, order);
56 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
57 const SkDQuad& quad = quadraticModEpsilonLines[index];
58 order = reducer.reduce(quad);
60 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order);
65 DEF_TEST(PathOpsReduceOrderQuad, reporter) {
67 standardTestCases(reporter);