Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsQuadReduceOrderTest.cpp
Go to the documentation of this file.
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 */
14#include "tests/Test.h"
15
16#include <array>
17#include <cstddef>
18
19static const QuadPts testSet[] = {
20 {{{1, 1}, {2, 2}, {1, 1.000003}}},
21 {{{1, 0}, {2, 6}, {3, 0}}}
22};
23
24static const size_t testSetCount = std::size(testSet);
25
27 for (size_t index = 0; index < testSetCount; ++index) {
28 const QuadPts& q = testSet[index];
29 SkDQuad quad;
30 quad.debugSet(q.fPts);
31 SkReduceOrder reducer;
32 SkDEBUGCODE(int result = ) reducer.reduce(quad);
33 SkASSERT(result == 3);
34 }
35}
36
38 size_t index;
39 SkReduceOrder reducer;
40 int order;
41 enum {
42 RunAll,
43 RunQuadraticLines,
44 RunQuadraticModLines,
45 RunNone
46 } run = RunAll;
47 int firstTestIndex = 0;
48#if 0
49 run = RunQuadraticLines;
50 firstTestIndex = 1;
51#endif
52 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ? firstTestIndex
53 : SK_MaxS32;
54 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLines ? firstTestIndex
55 : SK_MaxS32;
56
57 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
58 const QuadPts& q = quadraticLines[index];
59 SkDQuad quad;
60 quad.debugSet(q.fPts);
61 order = reducer.reduce(quad);
62 if (order != 2) {
63 SkDebugf("[%d] line quad order=%d\n", (int) index, order);
64 }
65 }
66 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
67 const QuadPts& q = quadraticModEpsilonLines[index];
68 SkDQuad quad;
69 quad.debugSet(q.fPts);
70 order = reducer.reduce(quad);
71 if (order != 2 && order != 3) { // FIXME: data probably is not good
72 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order);
73 }
74 }
75}
76
77DEF_TEST(PathOpsReduceOrderQuad, reporter) {
80}
reporter
const size_t quadraticLines_count
const QuadPts quadraticModEpsilonLines[]
const size_t quadraticModEpsilonLines_count
const QuadPts quadraticLines[]
static void standardTestCases(skiatest::Reporter *reporter)
static void oneOffTest(skiatest::Reporter *reporter)
static const QuadPts testSet[]
static const size_t testSetCount
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21
#define DEF_TEST(name, reporter)
Definition Test.h:312
GAsyncResult * result
Definition run.py:1
SkDPoint fPts[kPointCount]
void debugSet(const SkDPoint *pts)
int reduce(const SkDCubic &cubic, Quadratics)