Flutter Engine
The Flutter Engine
Functions | Variables
PathOpsDRectTest.cpp File Reference
#include "include/core/SkTypes.h"
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkPathOpsQuad.h"
#include "src/pathops/SkPathOpsRect.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/Test.h"
#include <array>
#include <cstddef>

Go to the source code of this file.

Functions

static void setRawBounds (const SkDQuad &quad, SkDRect *rect)
 
static void setRawBounds (const SkDCubic &cubic, SkDRect *rect)
 
 DEF_TEST (PathOpsDRect, reporter)
 

Variables

static const QuadPts quadTests []
 
static const CubicPts cubicTests []
 
static const size_t quadTests_count = std::size(quadTests)
 
static const size_t cubicTests_count = std::size(cubicTests)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( PathOpsDRect  ,
reporter   
)

Definition at line 48 of file PathOpsDRectTest.cpp.

48 {
49 size_t index;
50 SkDRect rect, rect2;
51 for (index = 0; index < quadTests_count; ++index) {
52 const QuadPts& q = quadTests[index];
53 SkDQuad quad;
54 quad.debugSet(q.fPts);
55 SkASSERT(ValidQuad(quad));
56 setRawBounds(quad, &rect);
57 rect2.setBounds(quad);
58 REPORTER_ASSERT(reporter, rect.intersects(rect2));
59 // FIXME: add a recursive box subdivision method to verify that tight bounds is correct
60 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
61 REPORTER_ASSERT(reporter, rect.contains(leftTop));
62 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
63 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
64 }
65 for (index = 0; index < cubicTests_count; ++index) {
66 const CubicPts& c = cubicTests[index];
68 cubic.debugSet(c.fPts);
71 rect2.setBounds(cubic);
72 REPORTER_ASSERT(reporter, rect.intersects(rect2));
73 // FIXME: add a recursive box subdivision method to verify that tight bounds is correct
74 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
75 REPORTER_ASSERT(reporter, rect.contains(leftTop));
76 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
77 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
78 }
79}
reporter
Definition: FontMgrTest.cpp:39
static void setRawBounds(const SkDQuad &quad, SkDRect *rect)
static const size_t cubicTests_count
static const QuadPts quadTests[]
static const size_t quadTests_count
static const CubicPts cubicTests[]
bool ValidCubic(const SkDCubic &cubic)
bool ValidQuad(const SkDQuad &quad)
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:195
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
void debugSet(const SkDPoint *pts)
double fTop
Definition: SkPathOpsRect.h:22
double fRight
Definition: SkPathOpsRect.h:22
double fBottom
Definition: SkPathOpsRect.h:22
void setBounds(const SkDConic &curve)
Definition: SkPathOpsRect.h:59
double fLeft
Definition: SkPathOpsRect.h:22

◆ setRawBounds() [1/2]

static void setRawBounds ( const SkDCubic cubic,
SkDRect rect 
)
static

Definition at line 41 of file PathOpsDRectTest.cpp.

41 {
42 rect->set(cubic[0]);
43 rect->add(cubic[1]);
44 rect->add(cubic[2]);
45 rect->add(cubic[3]);
46}

◆ setRawBounds() [2/2]

static void setRawBounds ( const SkDQuad quad,
SkDRect rect 
)
static

Definition at line 35 of file PathOpsDRectTest.cpp.

35 {
36 rect->set(quad[0]);
37 rect->add(quad[1]);
38 rect->add(quad[2]);
39}

Variable Documentation

◆ cubicTests

const CubicPts cubicTests[]
static
Initial value:
= {
{{{2, 0}, {3, 1}, {2, 2}, {1, 1}}},
{{{3, 1}, {2, 2}, {1, 1}, {2, 0}}},
{{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
}

Definition at line 26 of file PathOpsDRectTest.cpp.

◆ cubicTests_count

const size_t cubicTests_count = std::size(cubicTests)
static

Definition at line 33 of file PathOpsDRectTest.cpp.

◆ quadTests

const QuadPts quadTests[]
static
Initial value:
= {
{{{1, 1}, {2, 1}, {0, 2}}},
{{{0, 0}, {1, 1}, {3, 1}}},
{{{2, 0}, {1, 1}, {2, 2}}},
{{{4, 0}, {0, 1}, {4, 2}}},
{{{0, 0}, {0, 1}, {1, 1}}},
}

Definition at line 18 of file PathOpsDRectTest.cpp.

◆ quadTests_count

const size_t quadTests_count = std::size(quadTests)
static

Definition at line 32 of file PathOpsDRectTest.cpp.