Flutter Engine
The Flutter Engine
Functions
SkReduceOrder.cpp File Reference
#include "src/pathops/SkReduceOrder.h"
#include "include/core/SkPoint.h"
#include "src/core/SkGeometry.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkPathOpsTypes.h"
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Functions

static int coincident_line (const SkDQuad &quad, SkDQuad &reduction)
 
static int reductionLineCount (const SkDQuad &reduction)
 
static int vertical_line (const SkDQuad &quad, SkDQuad &reduction)
 
static int horizontal_line (const SkDQuad &quad, SkDQuad &reduction)
 
static int check_linear (const SkDQuad &quad, int minX, int maxX, int minY, int maxY, SkDQuad &reduction)
 
static int coincident_line (const SkDCubic &cubic, SkDCubic &reduction)
 
static int reductionLineCount (const SkDCubic &reduction)
 
static int vertical_line (const SkDCubic &cubic, SkDCubic &reduction)
 
static int horizontal_line (const SkDCubic &cubic, SkDCubic &reduction)
 
static int check_quadratic (const SkDCubic &cubic, SkDCubic &reduction)
 
static int check_linear (const SkDCubic &cubic, int minX, int maxX, int minY, int maxY, SkDCubic &reduction)
 

Function Documentation

◆ check_linear() [1/2]

static int check_linear ( const SkDCubic cubic,
int  minX,
int  maxX,
int  minY,
int  maxY,
SkDCubic reduction 
)
static

Definition at line 158 of file SkReduceOrder.cpp.

159 {
160 if (!cubic.isLinear(0, 3)) {
161 return 0;
162 }
163 // four are colinear: return line formed by outside
164 reduction[0] = cubic[0];
165 reduction[1] = cubic[3];
166 return reductionLineCount(reduction);
167}
static int reductionLineCount(const SkDQuad &reduction)
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:195

◆ check_linear() [2/2]

static int check_linear ( const SkDQuad quad,
int  minX,
int  maxX,
int  minY,
int  maxY,
SkDQuad reduction 
)
static

Definition at line 45 of file SkReduceOrder.cpp.

46 {
47 if (!quad.isLinear(0, 2)) {
48 return 0;
49 }
50 // four are colinear: return line formed by outside
51 reduction[0] = quad[0];
52 reduction[1] = quad[2];
53 return reductionLineCount(reduction);
54}
bool isLinear(int startIndex, int endIndex) const

◆ check_quadratic()

static int check_quadratic ( const SkDCubic cubic,
SkDCubic reduction 
)
static

Definition at line 132 of file SkReduceOrder.cpp.

132 {
133 double dx10 = cubic[1].fX - cubic[0].fX;
134 double dx23 = cubic[2].fX - cubic[3].fX;
135 double midX = cubic[0].fX + dx10 * 3 / 2;
136 double sideAx = midX - cubic[3].fX;
137 double sideBx = dx23 * 3 / 2;
138 if (approximately_zero(sideAx) ? !approximately_equal(sideAx, sideBx)
139 : !AlmostEqualUlps_Pin(sideAx, sideBx)) {
140 return 0;
141 }
142 double dy10 = cubic[1].fY - cubic[0].fY;
143 double dy23 = cubic[2].fY - cubic[3].fY;
144 double midY = cubic[0].fY + dy10 * 3 / 2;
145 double sideAy = midY - cubic[3].fY;
146 double sideBy = dy23 * 3 / 2;
147 if (approximately_zero(sideAy) ? !approximately_equal(sideAy, sideBy)
148 : !AlmostEqualUlps_Pin(sideAy, sideBy)) {
149 return 0;
150 }
151 reduction[0] = cubic[0];
152 reduction[1].fX = midX;
153 reduction[1].fY = midY;
154 reduction[2] = cubic[3];
155 return 3;
156}
static bool approximately_zero(double x)
Definition: SkCubics.cpp:153
bool AlmostEqualUlps_Pin(float a, float b)
bool approximately_equal(double x, double y)

◆ coincident_line() [1/2]

static int coincident_line ( const SkDCubic cubic,
SkDCubic reduction 
)
static

Definition at line 110 of file SkReduceOrder.cpp.

110 {
111 reduction[0] = reduction[1] = cubic[0];
112 return 1;
113}

◆ coincident_line() [2/2]

static int coincident_line ( const SkDQuad quad,
SkDQuad reduction 
)
static

Definition at line 24 of file SkReduceOrder.cpp.

24 {
25 reduction[0] = reduction[1] = quad[0];
26 return 1;
27}

◆ horizontal_line() [1/2]

static int horizontal_line ( const SkDCubic cubic,
SkDCubic reduction 
)
static

Definition at line 125 of file SkReduceOrder.cpp.

125 {
126 reduction[0] = cubic[0];
127 reduction[1] = cubic[3];
128 return reductionLineCount(reduction);
129}

◆ horizontal_line() [2/2]

static int horizontal_line ( const SkDQuad quad,
SkDQuad reduction 
)
static

Definition at line 39 of file SkReduceOrder.cpp.

39 {
40 reduction[0] = quad[0];
41 reduction[1] = quad[2];
42 return reductionLineCount(reduction);
43}

◆ reductionLineCount() [1/2]

static int reductionLineCount ( const SkDCubic reduction)
static

Definition at line 115 of file SkReduceOrder.cpp.

115 {
116 return 1 + !reduction[0].approximatelyEqual(reduction[1]);
117}

◆ reductionLineCount() [2/2]

static int reductionLineCount ( const SkDQuad reduction)
static

Definition at line 29 of file SkReduceOrder.cpp.

29 {
30 return 1 + !reduction[0].approximatelyEqual(reduction[1]);
31}

◆ vertical_line() [1/2]

static int vertical_line ( const SkDCubic cubic,
SkDCubic reduction 
)
static

Definition at line 119 of file SkReduceOrder.cpp.

119 {
120 reduction[0] = cubic[0];
121 reduction[1] = cubic[3];
122 return reductionLineCount(reduction);
123}

◆ vertical_line() [2/2]

static int vertical_line ( const SkDQuad quad,
SkDQuad reduction 
)
static

Definition at line 33 of file SkReduceOrder.cpp.

33 {
34 reduction[0] = quad[0];
35 reduction[1] = quad[2];
36 return reductionLineCount(reduction);
37}