Flutter Engine
The Flutter Engine
Functions
SkPathOpsQuad.cpp File Reference
#include "src/pathops/SkPathOpsQuad.h"
#include "src/pathops/SkIntersections.h"
#include "src/pathops/SkLineParameters.h"
#include "src/pathops/SkPathOpsConic.h"
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsLine.h"
#include "src/pathops/SkPathOpsRect.h"
#include "src/pathops/SkPathOpsTypes.h"
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Functions

static bool pointInTriangle (const SkDPoint fPts[3], const SkDPoint &test)
 
static bool matchesEnd (const SkDPoint fPts[3], const SkDPoint &test)
 
static int handle_zero (const double B, const double C, double s[2])
 
static double interp_quad_coords (const double *src, double t)
 
static void interp_quad_coords (const double *src, double *dst, double t)
 
static int valid_unit_divide (double numer, double denom, double *ratio)
 

Function Documentation

◆ handle_zero()

static int handle_zero ( const double  B,
const double  C,
double  s[2] 
)
static

Definition at line 151 of file SkPathOpsQuad.cpp.

151 {
152 if (approximately_zero(B)) {
153 s[0] = 0;
154 return C == 0;
155 }
156 s[0] = -C / B;
157 return 1;
158}
static bool approximately_zero(double x)
Definition: SkCubics.cpp:153
struct MyStruct s
#define B

◆ interp_quad_coords() [1/2]

static void interp_quad_coords ( const double *  src,
double *  dst,
double  t 
)
static

Definition at line 344 of file SkPathOpsQuad.cpp.

344 {
345 double ab = SkDInterp(src[0], src[2], t);
346 double bc = SkDInterp(src[2], src[4], t);
347 dst[0] = src[0];
348 dst[2] = ab;
349 dst[4] = SkDInterp(ab, bc, t);
350 dst[6] = bc;
351 dst[8] = src[4];
352}
double SkDInterp(double A, double B, double t)
Definition: ab.py:1
const CatchEntryMove ab[]
dst
Definition: cp.py:12

◆ interp_quad_coords() [2/2]

static double interp_quad_coords ( const double *  src,
double  t 
)
static

Definition at line 240 of file SkPathOpsQuad.cpp.

240 {
241 if (0 == t) {
242 return src[0];
243 }
244 if (1 == t) {
245 return src[4];
246 }
247 double ab = SkDInterp(src[0], src[2], t);
248 double bc = SkDInterp(src[2], src[4], t);
249 double abc = SkDInterp(ab, bc, t);
250 return abc;
251}

◆ matchesEnd()

static bool matchesEnd ( const SkDPoint  fPts[3],
const SkDPoint test 
)
static

Definition at line 41 of file SkPathOpsQuad.cpp.

41 {
42 return fPts[0] == test || fPts[2] == test;
43}
SkPoint fPts[2]
#define test(name)

◆ pointInTriangle()

static bool pointInTriangle ( const SkDPoint  fPts[3],
const SkDPoint test 
)
static

Definition at line 21 of file SkPathOpsQuad.cpp.

21 {
22 SkDVector v0 = fPts[2] - fPts[0];
23 SkDVector v1 = fPts[1] - fPts[0];
24 SkDVector v2 = test - fPts[0];
25 double dot00 = v0.dot(v0);
26 double dot01 = v0.dot(v1);
27 double dot02 = v0.dot(v2);
28 double dot11 = v1.dot(v1);
29 double dot12 = v1.dot(v2);
30 // Compute barycentric coordinates
31 double denom = dot00 * dot11 - dot01 * dot01;
32 double u = dot11 * dot02 - dot01 * dot12;
33 double v = dot00 * dot12 - dot01 * dot02;
34 // Check if point is in triangle
35 if (denom >= 0) {
36 return u >= 0 && v >= 0 && u + v < denom;
37 }
38 return u <= 0 && v <= 0 && u + v > denom;
39}
Vec2Value v2
double dot(const SkDVector &a) const

◆ valid_unit_divide()

static int valid_unit_divide ( double  numer,
double  denom,
double *  ratio 
)
static

Definition at line 362 of file SkPathOpsQuad.cpp.

363{
364 if (numer < 0) {
365 numer = -numer;
366 denom = -denom;
367 }
368 if (denom == 0 || numer == 0 || numer >= denom) {
369 return 0;
370 }
371 double r = numer / denom;
372 if (r == 0) { // catch underflow if numer <<<< denom
373 return 0;
374 }
375 *ratio = r;
376 return 1;
377}