Flutter Engine
The Flutter Engine
PathOpsThreeWayTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 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 */
15#include "tests/Test.h"
16
17#include <array>
18
19// check intersections for consistency
20
21struct Curve {
23 CubicPts curve; // largest can hold lines / quads/ cubics
24};
25
26static const Curve testSet0[] = { // extracted from skpClip2
27 {4, {{{134,11414}, {131.990234,11414}, {130.32666,11415.4824}, {130.042755,11417.4131}}} },
28 {4, {{{130.042755,11417.4131}, {130.233124,11418.3193}, {131.037079,11419}, {132,11419}}} },
29 {4, {{{132,11419}, {130.895432,11419}, {130,11418.1045}, {130,11417}}} },
30};
31
32static const Curve testSet1[] = { // extracted from cubicOp85i
33 {4, {{{3,4}, {1,5}, {4,3}, {6,4}}} },
34 {1, {{{6,4}, {3,4}}} },
35 {4, {{{3,4}, {4,6}, {4,3}, {5,1}}} },
36 {1, {{{5,1}, {3,4}}} },
37};
38
39static const struct TestSet {
40 const Curve* tests;
42} testSets[] = {
45};
46
47static const int testSetsCount = (int) std::size(testSets);
48
49static void testSetTest(skiatest::Reporter* reporter, int index) {
50 const TestSet& testSet = testSets[index];
51 int testCount = testSet.testCount;
54 for (int outer = 0; outer < testCount - 1; ++outer) {
55 const Curve& oTest = testSet.tests[outer];
56 for (int inner = outer + 1; inner < testCount; ++inner) {
57 const Curve& iTest = testSet.tests[inner];
58 SkIntersections* i = combos.append();
59 sk_bzero(i, sizeof(SkIntersections));
60 SkDLine oLine = {{ oTest.curve.fPts[0], oTest.curve.fPts[1] }};
61 SkDLine iLine = {{ iTest.curve.fPts[0], iTest.curve.fPts[1] }};
62 SkDCubic iCurve, oCurve;
63 iCurve.debugSet(iTest.curve.fPts);
64 oCurve.debugSet(oTest.curve.fPts);
65 if (oTest.ptCount == 1 && iTest.ptCount == 1) {
66 i->intersect(oLine, iLine);
67 } else if (oTest.ptCount == 1 && iTest.ptCount == 4) {
68 i->intersect(iCurve, oLine);
69 } else if (oTest.ptCount == 4 && iTest.ptCount == 1) {
70 i->intersect(oCurve, iLine);
71 } else if (oTest.ptCount == 4 && iTest.ptCount == 4) {
72 i->intersect(oCurve, iCurve);
73 } else {
74 SkASSERT(0);
75 }
76// i->dump();
77 }
78 }
79}
80
81DEF_TEST(PathOpsThreeWay, reporter) {
82 for (int index = 0; index < testSetsCount; ++index) {
83 testSetTest(reporter, index);
84 reporter->bumpTestCount();
85 }
86}
87
88DEF_TEST(PathOpsThreeWayOneOff, reporter) {
89 int index = 0;
90 testSetTest(reporter, index);
91}
sk_bzero(glyphs, sizeof(glyphs))
reporter
Definition: FontMgrTest.cpp:39
static const size_t testCount
static const ConicPts testSet[]
static const int testSetsCount
static const Curve testSet1[]
static void testSetTest(skiatest::Reporter *reporter, int index)
DEF_TEST(PathOpsThreeWay, reporter)
static const Curve testSet0[]
static const struct TestSet testSets[]
#define SkASSERT(cond)
Definition: SkAssert.h:116
T * append()
Definition: SkTDArray.h:191
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkDPoint fPts[kPointCount]
CubicPts curve
void debugSet(const SkDPoint *pts)
const Curve * tests