OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #ifndef SkPathOpsTypes_DEFINED | 7 #ifndef SkPathOpsTypes_DEFINED |
8 #define SkPathOpsTypes_DEFINED | 8 #define SkPathOpsTypes_DEFINED |
9 | 9 |
10 #include <float.h> // for FLT_EPSILON | 10 #include <float.h> // for FLT_EPSILON |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 inline bool approximately_zero_sqrt(double x) { | 136 inline bool approximately_zero_sqrt(double x) { |
137 return fabs(x) < FLT_EPSILON_SQRT; | 137 return fabs(x) < FLT_EPSILON_SQRT; |
138 } | 138 } |
139 | 139 |
140 inline bool roughly_zero(double x) { | 140 inline bool roughly_zero(double x) { |
141 return fabs(x) < ROUGH_EPSILON; | 141 return fabs(x) < ROUGH_EPSILON; |
142 } | 142 } |
143 | 143 |
144 #if 0 // unused for now | |
145 inline bool way_roughly_zero(double x) { | |
146 return fabs(x) < WAY_ROUGH_EPSILON; | |
147 } | |
148 #endif | |
149 | |
150 inline bool approximately_zero_inverse(double x) { | 144 inline bool approximately_zero_inverse(double x) { |
151 return fabs(x) > FLT_EPSILON_INVERSE; | 145 return fabs(x) > FLT_EPSILON_INVERSE; |
152 } | 146 } |
153 | 147 |
154 // OPTIMIZATION: if called multiple times with the same denom, we want to pass 1
/y instead | 148 // OPTIMIZATION: if called multiple times with the same denom, we want to pass 1
/y instead |
155 inline bool approximately_zero_when_compared_to(double x, double y) { | 149 inline bool approximately_zero_when_compared_to(double x, double y) { |
156 return x == 0 || fabs(x) < fabs(y * FLT_EPSILON); | 150 return x == 0 || fabs(x) < fabs(y * FLT_EPSILON); |
157 } | 151 } |
158 | 152 |
159 // Use this for comparing Ts in the range of 0 to 1. For general numbers (larger
and smaller) use | 153 // Use this for comparing Ts in the range of 0 to 1. For general numbers (larger
and smaller) use |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 */ | 371 */ |
378 inline int SkDSideBit(double x) { | 372 inline int SkDSideBit(double x) { |
379 return 1 << SKDSide(x); | 373 return 1 << SKDSide(x); |
380 } | 374 } |
381 | 375 |
382 inline double SkPinT(double t) { | 376 inline double SkPinT(double t) { |
383 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; | 377 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; |
384 } | 378 } |
385 | 379 |
386 #endif | 380 #endif |
OLD | NEW |