Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
PathOpsBoundsTest.cpp File Reference
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkTypes.h"
#include "src/pathops/SkPathOpsBounds.h"
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsCurve.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkPathOpsQuad.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/Test.h"
#include <array>
#include <cstddef>

Go to the source code of this file.

Functions

 DEF_TEST (PathOpsBounds, reporter)
 

Variables

static const SkRect sectTests [][2]
 
static const size_t sectTestsCount = std::size(sectTests)
 
static const SkRect noSectTests [][2]
 
static const size_t noSectTestsCount = std::size(noSectTests)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( PathOpsBounds  ,
reporter   
)

Definition at line 41 of file PathOpsBoundsTest.cpp.

41 {
42 for (size_t index = 0; index < sectTestsCount; ++index) {
43 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(sectTests[index][0]);
44 SkASSERT(ValidBounds(bounds1));
45 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(sectTests[index][1]);
46 SkASSERT(ValidBounds(bounds2));
47 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2);
48 REPORTER_ASSERT(reporter, touches);
49 }
50 for (size_t index = 0; index < noSectTestsCount; ++index) {
51 const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(noSectTests[index][0]);
52 SkASSERT(ValidBounds(bounds1));
53 const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(noSectTests[index][1]);
54 SkASSERT(ValidBounds(bounds2));
55 bool touches = SkPathOpsBounds::Intersects(bounds1, bounds2);
56 REPORTER_ASSERT(reporter, !touches);
57 }
59 bounds.setEmpty();
60 bounds.add(1, 2, 3, 4);
61 SkPathOpsBounds expected;
62 expected.setLTRB(0, 0, 3, 4);
63 REPORTER_ASSERT(reporter, bounds == expected);
64 bounds.setEmpty();
65 SkPathOpsBounds ordinal;
66 ordinal.setLTRB(1, 2, 3, 4);
67 bounds.add(ordinal);
68 REPORTER_ASSERT(reporter, bounds == expected);
69 bounds.setEmpty();
70 SkDPoint botRight = {3, 4};
71 bounds.add(botRight);
72 REPORTER_ASSERT(reporter, bounds == expected);
73 const SkPoint curvePts[] = {{0, 0}, {1, 2}, {3, 4}, {5, 6}};
74 SkDCurve curve;
75 curve.fQuad.set(curvePts);
76 curve.setQuadBounds(curvePts, 1, 0, 1, &bounds);
77 expected.setLTRB(0, 0, 3, 4);
78 REPORTER_ASSERT(reporter, bounds == expected);
79 curve.fCubic.set(curvePts);
80 curve.setCubicBounds(curvePts, 1, 0, 1, &bounds);
81 expected.setLTRB(0, 0, 5, 6);
82 REPORTER_ASSERT(reporter, bounds == expected);
83}
reporter
static const SkRect noSectTests[][2]
static const size_t noSectTestsCount
static const SkRect sectTests[][2]
static const size_t sectTestsCount
bool ValidBounds(const SkPathOpsBounds &bounds)
#define SkASSERT(cond)
Definition SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
Optional< SkRect > bounds
Definition SkRecords.h:189
const SkDCubic & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))
SkDQuad fQuad
void setCubicBounds(const SkPoint curve[4], SkScalar, double s, double e, SkPathOpsBounds *)
SkDCubic fCubic
void setQuadBounds(const SkPoint curve[3], SkScalar, double s, double e, SkPathOpsBounds *)
const SkDQuad & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))
static bool Intersects(const SkPathOpsBounds &a, const SkPathOpsBounds &b)
void setLTRB(float left, float top, float right, float bottom)
Definition SkRect.h:865

Variable Documentation

◆ noSectTests

const SkRect noSectTests[][2]
static
Initial value:
= {
{{2, 0, 4, 1}, {5, 0, 6, 1}},
{{2, 0, 4, 1}, {3, 2, 5, 2}},
}

Definition at line 34 of file PathOpsBoundsTest.cpp.

34 {
35 {{2, 0, 4, 1}, {5, 0, 6, 1}},
36 {{2, 0, 4, 1}, {3, 2, 5, 2}},
37};

◆ noSectTestsCount

const size_t noSectTestsCount = std::size(noSectTests)
static

Definition at line 39 of file PathOpsBoundsTest.cpp.

◆ sectTests

const SkRect sectTests[][2]
static
Initial value:
= {
{{2, 0, 4, 1}, {4, 0, 6, 1}},
{{2, 0, 4, 1}, {3, 0, 5, 1}},
{{2, 0, 4, 1}, {3, 0, 5, 0}},
{{2, 0, 4, 1}, {3, 1, 5, 2}},
{{2, 1, 4, 2}, {1, 0, 5, 3}},
{{2, 1, 5, 3}, {3, 1, 4, 2}},
{{2, 0, 4, 1}, {3, 0, 3, 0}},
{{2, 0, 4, 1}, {4, 1, 5, 2}},
}

Definition at line 21 of file PathOpsBoundsTest.cpp.

21 {
22 {{2, 0, 4, 1}, {4, 0, 6, 1}},
23 {{2, 0, 4, 1}, {3, 0, 5, 1}},
24 {{2, 0, 4, 1}, {3, 0, 5, 0}},
25 {{2, 0, 4, 1}, {3, 1, 5, 2}},
26 {{2, 1, 4, 2}, {1, 0, 5, 3}},
27 {{2, 1, 5, 3}, {3, 1, 4, 2}},
28 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK
29 {{2, 0, 4, 1}, {4, 1, 5, 2}}, // touching just on a corner is OK
30};

◆ sectTestsCount

const size_t sectTestsCount = std::size(sectTests)
static

Definition at line 32 of file PathOpsBoundsTest.cpp.