Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
SkDPoint Struct Reference

#include <SkPathOpsPoint.h>

Public Member Functions

void set (const SkPoint &pt)
 
void operator= (const SkPoint &pt)
 
void operator+= (const SkDVector &v)
 
void operator-= (const SkDVector &v)
 
SkDPoint operator+ (const SkDVector &v)
 
SkDPoint operator- (const SkDVector &v)
 
bool approximatelyDEqual (const SkDPoint &a) const
 
bool approximatelyDEqual (const SkPoint &a) const
 
bool approximatelyEqual (const SkDPoint &a) const
 
bool approximatelyEqual (const SkPoint &a) const
 
bool approximatelyZero () const
 
SkPoint asSkPoint () const
 
double distance (const SkDPoint &a) const
 
double distanceSquared (const SkDPoint &a) const
 
bool roughlyEqual (const SkDPoint &a) const
 
void dump () const
 

Static Public Member Functions

static bool ApproximatelyEqual (const SkPoint &a, const SkPoint &b)
 
static SkDPoint Mid (const SkDPoint &a, const SkDPoint &b)
 
static bool RoughlyEqual (const SkPoint &a, const SkPoint &b)
 
static bool WayRoughlyEqual (const SkPoint &a, const SkPoint &b)
 
static void Dump (const SkPoint &pt)
 
static void DumpHex (const SkPoint &pt)
 

Public Attributes

double fX
 
double fY
 

Friends

SkDVector operator- (const SkDPoint &a, const SkDPoint &b)
 
bool operator== (const SkDPoint &a, const SkDPoint &b)
 
bool operator!= (const SkDPoint &a, const SkDPoint &b)
 

Detailed Description

Definition at line 102 of file SkPathOpsPoint.h.

Member Function Documentation

◆ approximatelyDEqual() [1/2]

bool SkDPoint::approximatelyDEqual ( const SkDPoint a) const
inline

Definition at line 157 of file SkPathOpsPoint.h.

157 {
158 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) {
159 return true;
160 }
161 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) {
162 return false;
163 }
164 double dist = distance(a); // OPTIMIZATION: can we compare against distSq instead ?
165 double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
166 double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
167 largest = std::max(largest, -tiniest);
168 return AlmostDequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
169 }
bool RoughlyEqualUlps(float a, float b)
bool AlmostDequalUlps(float a, float b)
bool approximately_equal(double x, double y)
struct MyStruct a[10]
double distance(const SkDPoint &a) const

◆ approximatelyDEqual() [2/2]

bool SkDPoint::approximatelyDEqual ( const SkPoint a) const
inline

Definition at line 171 of file SkPathOpsPoint.h.

171 {
172 SkDPoint dA;
173 dA.set(a);
174 return approximatelyDEqual(dA);
175 }
void set(const SkPoint &pt)
bool approximatelyDEqual(const SkDPoint &a) const

◆ approximatelyEqual() [1/2]

bool SkDPoint::approximatelyEqual ( const SkDPoint a) const
inline

Definition at line 177 of file SkPathOpsPoint.h.

177 {
178 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) {
179 return true;
180 }
181 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) {
182 return false;
183 }
184 double dist = distance(a); // OPTIMIZATION: can we compare against distSq instead ?
185 double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
186 double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
187 largest = std::max(largest, -tiniest);
188 return AlmostPequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
189 }
bool AlmostPequalUlps(float a, float b)

◆ approximatelyEqual() [2/2]

bool SkDPoint::approximatelyEqual ( const SkPoint a) const
inline

Definition at line 191 of file SkPathOpsPoint.h.

191 {
192 SkDPoint dA;
193 dA.set(a);
194 return approximatelyEqual(dA);
195 }
bool approximatelyEqual(const SkDPoint &a) const

◆ ApproximatelyEqual()

static bool SkDPoint::ApproximatelyEqual ( const SkPoint a,
const SkPoint b 
)
inlinestatic

Definition at line 197 of file SkPathOpsPoint.h.

197 {
198 if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY)) {
199 return true;
200 }
201 if (!RoughlyEqualUlps(a.fX, b.fX) || !RoughlyEqualUlps(a.fY, b.fY)) {
202 return false;
203 }
204 SkDPoint dA, dB;
205 dA.set(a);
206 dB.set(b);
207 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
208 float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
209 float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
210 largest = std::max(largest, -tiniest);
211 return AlmostDequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
212 }
static bool b

◆ approximatelyZero()

bool SkDPoint::approximatelyZero ( ) const
inline

Definition at line 215 of file SkPathOpsPoint.h.

215 {
217 }
static bool approximately_zero(double x)
Definition SkCubics.cpp:153

◆ asSkPoint()

SkPoint SkDPoint::asSkPoint ( ) const
inline

Definition at line 219 of file SkPathOpsPoint.h.

219 {
221 return pt;
222 }
#define SkDoubleToScalar(x)
Definition SkScalar.h:64

◆ distance()

double SkDPoint::distance ( const SkDPoint a) const
inline

Definition at line 224 of file SkPathOpsPoint.h.

224 {
225 SkDVector temp = *this - a;
226 return temp.length();
227 }
double length() const

◆ distanceSquared()

double SkDPoint::distanceSquared ( const SkDPoint a) const
inline

Definition at line 229 of file SkPathOpsPoint.h.

229 {
230 SkDVector temp = *this - a;
231 return temp.lengthSquared();
232 }
double lengthSquared() const

◆ dump()

void SkDPoint::dump ( ) const

Definition at line 181 of file PathOpsDebug.cpp.

181 {
182 SkDebugf("{");
184 SkDebugf(", ");
186 SkDebugf("}");
187}
void DebugDumpDouble(double x)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ Dump()

void SkDPoint::Dump ( const SkPoint pt)
static

Definition at line 189 of file PathOpsDebug.cpp.

189 {
190 SkDebugf("{");
191 DebugDumpFloat(pt.fX);
192 SkDebugf(", ");
193 DebugDumpFloat(pt.fY);
194 SkDebugf("}");
195}
void DebugDumpFloat(float x)
float fX
x-axis value
float fY
y-axis value

◆ DumpHex()

void SkDPoint::DumpHex ( const SkPoint pt)
static

Definition at line 197 of file PathOpsDebug.cpp.

197 {
198 SkDebugf("{");
200 SkDebugf(", ");
202 SkDebugf("}");
203}
void DebugDumpHexFloat(float x)

◆ Mid()

static SkDPoint SkDPoint::Mid ( const SkDPoint a,
const SkDPoint b 
)
inlinestatic

Definition at line 234 of file SkPathOpsPoint.h.

234 {
236 result.fX = (a.fX + b.fX) / 2;
237 result.fY = (a.fY + b.fY) / 2;
238 return result;
239 }
GAsyncResult * result

◆ operator+()

SkDPoint SkDPoint::operator+ ( const SkDVector v)
inline

Definition at line 141 of file SkPathOpsPoint.h.

141 {
142 SkDPoint result = *this;
143 result += v;
144 return result;
145 }

◆ operator+=()

void SkDPoint::operator+= ( const SkDVector v)
inline

Definition at line 129 of file SkPathOpsPoint.h.

129 {
130 fX += v.fX;
131 fY += v.fY;
132 }

◆ operator-()

SkDPoint SkDPoint::operator- ( const SkDVector v)
inline

Definition at line 148 of file SkPathOpsPoint.h.

148 {
149 SkDPoint result = *this;
150 result -= v;
151 return result;
152 }

◆ operator-=()

void SkDPoint::operator-= ( const SkDVector v)
inline

Definition at line 135 of file SkPathOpsPoint.h.

135 {
136 fX -= v.fX;
137 fY -= v.fY;
138 }

◆ operator=()

void SkDPoint::operator= ( const SkPoint pt)
inline

Definition at line 123 of file SkPathOpsPoint.h.

123 {
124 fX = pt.fX;
125 fY = pt.fY;
126 }

◆ roughlyEqual()

bool SkDPoint::roughlyEqual ( const SkDPoint a) const
inline

Definition at line 241 of file SkPathOpsPoint.h.

241 {
242 if (roughly_equal(fX, a.fX) && roughly_equal(fY, a.fY)) {
243 return true;
244 }
245 double dist = distance(a); // OPTIMIZATION: can we compare against distSq instead ?
246 double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
247 double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
248 largest = std::max(largest, -tiniest);
249 return RoughlyEqualUlps(largest, largest + dist); // is the dist within ULPS tolerance?
250 }
bool roughly_equal(double x, double y)

◆ RoughlyEqual()

static bool SkDPoint::RoughlyEqual ( const SkPoint a,
const SkPoint b 
)
inlinestatic

Definition at line 252 of file SkPathOpsPoint.h.

252 {
253 if (!RoughlyEqualUlps(a.fX, b.fX) && !RoughlyEqualUlps(a.fY, b.fY)) {
254 return false;
255 }
256 SkDPoint dA, dB;
257 dA.set(a);
258 dB.set(b);
259 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
260 float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
261 float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
262 largest = std::max(largest, -tiniest);
263 return RoughlyEqualUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
264 }

◆ set()

void SkDPoint::set ( const SkPoint pt)
inline

Definition at line 106 of file SkPathOpsPoint.h.

106 {
107 fX = pt.fX;
108 fY = pt.fY;
109 }

◆ WayRoughlyEqual()

static bool SkDPoint::WayRoughlyEqual ( const SkPoint a,
const SkPoint b 
)
inlinestatic

Definition at line 267 of file SkPathOpsPoint.h.

267 {
268 float largestNumber = std::max(SkTAbs(a.fX), std::max(SkTAbs(a.fY),
269 std::max(SkTAbs(b.fX), SkTAbs(b.fY))));
270 SkVector diffs = a - b;
271 float largestDiff = std::max(diffs.fX, diffs.fY);
272 return roughly_zero_when_compared_to(largestDiff, largestNumber);
273 }
bool roughly_zero_when_compared_to(double x, double y)
static T SkTAbs(T value)
Definition SkTemplates.h:43

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const SkDPoint a,
const SkDPoint b 
)
friend

Definition at line 119 of file SkPathOpsPoint.h.

119 {
120 return a.fX != b.fX || a.fY != b.fY;
121 }

◆ operator-

SkDVector operator- ( const SkDPoint a,
const SkDPoint b 
)
friend

Definition at line 111 of file SkPathOpsPoint.h.

111 {
112 return { a.fX - b.fX, a.fY - b.fY };
113 }

◆ operator==

bool operator== ( const SkDPoint a,
const SkDPoint b 
)
friend

Definition at line 115 of file SkPathOpsPoint.h.

115 {
116 return a.fX == b.fX && a.fY == b.fY;
117 }

Member Data Documentation

◆ fX

double SkDPoint::fX

Definition at line 103 of file SkPathOpsPoint.h.

◆ fY

double SkDPoint::fY

Definition at line 104 of file SkPathOpsPoint.h.


The documentation for this struct was generated from the following files: