Flutter Engine
The Flutter Engine
Functions
FuzzCubicRoots.cpp File Reference
#include "fuzz/Fuzz.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"
#include "src/base/SkCubics.h"
#include "src/base/SkQuads.h"
#include "src/base/SkUtils.h"
#include <cmath>

Go to the source code of this file.

Functions

static void fuzz_cubic_real_roots (double A, double B, double C, double D)
 
static void fuzz_cubic_roots_valid_t (double A, double B, double C, double D)
 
static void fuzz_cubic_roots_binary_search (double A, double B, double C, double D)
 
 DEF_FUZZ (CubicRoots, fuzz)
 

Function Documentation

◆ DEF_FUZZ()

DEF_FUZZ ( CubicRoots  ,
fuzz   
)

Definition at line 75 of file FuzzCubicRoots.cpp.

75 {
76 double A, B, C, D;
77 fuzz->next(&A);
78 fuzz->next(&B);
79 fuzz->next(&C);
80 fuzz->next(&D);
81
82 // Uncomment for easy test case creation
83// SkDebugf("A %16e (0x%lx) B %16e (0x%lx) C %16e (0x%lx) D %16e (0x%lx)\n",
84// A, sk_bit_cast<uint64_t>(A), B, sk_bit_cast<uint64_t>(B),
85// C, sk_bit_cast<uint64_t>(C), D, sk_bit_cast<uint64_t>(D));
87
89
91}
static void fuzz_cubic_roots_binary_search(double A, double B, double C, double D)
static void fuzz_cubic_real_roots(double A, double B, double C, double D)
static void fuzz_cubic_roots_valid_t(double A, double B, double C, double D)
#define C(TEST_CATEGORY)
Definition: colrv1.cpp:248
#define B

◆ fuzz_cubic_real_roots()

static void fuzz_cubic_real_roots ( double  A,
double  B,
double  C,
double  D 
)
static

Definition at line 17 of file FuzzCubicRoots.cpp.

17 {
18 double roots[3];
19 const int numSolutions = SkCubics::RootsReal(A, B, C, D, roots);
20 SkASSERT_RELEASE(numSolutions >= 0 && numSolutions <= 3);
21 for (int i = 0; i < numSolutions; i++) {
23 }
24 // Roots should not be duplicated
25 if (numSolutions >= 2) {
27 }
28 if (numSolutions == 3) {
31 }
32}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
bool sk_doubles_nearly_equal_ulps(double a, double b, uint8_t maxUlpsDiff=16)
static int RootsReal(double A, double B, double C, double D, double solution[3])
Definition: SkCubics.cpp:38
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003

◆ fuzz_cubic_roots_binary_search()

static void fuzz_cubic_roots_binary_search ( double  A,
double  B,
double  C,
double  D 
)
static

Definition at line 53 of file FuzzCubicRoots.cpp.

53 {
54 double roots[3];
55 const int numSolutions = SkCubics::BinarySearchRootsValidT(A, B, C, D, roots);
56 SkASSERT_RELEASE(numSolutions >= 0 && numSolutions <= 3);
57 for (int i = 0; i < numSolutions; i++) {
59 SkASSERT_RELEASE(roots[i] >= 0.0);
60 SkASSERT_RELEASE(roots[i] <= 1.0);
61 double actual = SkCubics::EvalAt(A, B, C, D, roots[i]);
62 // The binary search algorithm *should* be accurate regardless of the inputs.
63 SkASSERT_RELEASE(std::abs(actual) < 0.001);
64 }
65 // Roots should not be duplicated
66 if (numSolutions >= 2) {
68 }
69 if (numSolutions == 3) {
72 }
73}
static int BinarySearchRootsValidT(double A, double B, double C, double D, double solution[3])
Definition: SkCubics.cpp:208
static double EvalAt(double A, double B, double C, double D, double t)
Definition: SkCubics.h:51
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707

◆ fuzz_cubic_roots_valid_t()

static void fuzz_cubic_roots_valid_t ( double  A,
double  B,
double  C,
double  D 
)
static

Definition at line 34 of file FuzzCubicRoots.cpp.

34 {
35 double roots[3];
36 const int numSolutions = SkCubics::RootsValidT(A, B, C, D, roots);
37 SkASSERT_RELEASE(numSolutions >= 0 && numSolutions <= 3);
38 for (int i = 0; i < numSolutions; i++) {
40 SkASSERT_RELEASE(roots[i] >= 0.0);
41 SkASSERT_RELEASE(roots[i] <= 1.0);
42 }
43 // Roots should not be duplicated
44 if (numSolutions >= 2) {
46 }
47 if (numSolutions == 3) {
50 }
51}
static int RootsValidT(double A, double B, double C, double D, double solution[3])
Definition: SkCubics.cpp:127