| 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 #define SK_CONIC_SUPPORT_ENABLED 1 |
| 11 |
| 10 #include <float.h> // for FLT_EPSILON | 12 #include <float.h> // for FLT_EPSILON |
| 11 #include <math.h> // for fabs, sqrt | 13 #include <math.h> // for fabs, sqrt |
| 12 | 14 |
| 13 #include "SkFloatingPoint.h" | 15 #include "SkFloatingPoint.h" |
| 16 #include "SkPath.h" |
| 14 #include "SkPathOps.h" | 17 #include "SkPathOps.h" |
| 15 #include "SkPathOpsDebug.h" | 18 #include "SkPathOpsDebug.h" |
| 16 #include "SkScalar.h" | 19 #include "SkScalar.h" |
| 17 | 20 |
| 18 enum SkPathOpsMask { | 21 enum SkPathOpsMask { |
| 19 kWinding_PathOpsMask = -1, | 22 kWinding_PathOpsMask = -1, |
| 20 kNo_PathOpsMask = 0, | 23 kNo_PathOpsMask = 0, |
| 21 kEvenOdd_PathOpsMask = 1 | 24 kEvenOdd_PathOpsMask = 1 |
| 22 }; | 25 }; |
| 23 | 26 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 185 } |
| 183 | 186 |
| 184 struct SkDPoint; | 187 struct SkDPoint; |
| 185 struct SkDVector; | 188 struct SkDVector; |
| 186 struct SkDLine; | 189 struct SkDLine; |
| 187 struct SkDQuad; | 190 struct SkDQuad; |
| 188 struct SkDTriangle; | 191 struct SkDTriangle; |
| 189 struct SkDCubic; | 192 struct SkDCubic; |
| 190 struct SkDRect; | 193 struct SkDRect; |
| 191 | 194 |
| 195 #if SK_CONIC_SUPPORT_ENABLED |
| 196 |
| 197 inline SkPath::Verb SkPathOpsPointsToVerb(int points) { |
| 198 int verb = (1 << points) >> 1; |
| 199 #ifdef SK_DEBUG |
| 200 switch (points) { |
| 201 case 0: SkASSERT(SkPath::kMove_Verb == verb); break; |
| 202 case 1: SkASSERT(SkPath::kLine_Verb == verb); break; |
| 203 case 2: SkASSERT(SkPath::kQuad_Verb == verb); break; |
| 204 case 3: SkASSERT(SkPath::kCubic_Verb == verb); break; |
| 205 default: SkASSERT(!"should not be here"); |
| 206 } |
| 207 #endif |
| 208 return (SkPath::Verb)verb; |
| 209 } |
| 210 |
| 211 inline int SkPathOpsVerbToPoints(SkPath::Verb verb) { |
| 212 int points = (int) verb - ((int) verb >> 2); |
| 213 #ifdef SK_DEBUG |
| 214 switch (verb) { |
| 215 case SkPath::kLine_Verb: SkASSERT(1 == points); break; |
| 216 case SkPath::kQuad_Verb: SkASSERT(2 == points); break; |
| 217 case SkPath::kCubic_Verb: SkASSERT(3 == points); break; |
| 218 default: SkASSERT(!"should not get here"); |
| 219 } |
| 220 #endif |
| 221 return points; |
| 222 } |
| 223 |
| 224 #else |
| 225 |
| 226 inline SkPath::Verb SkOpPointsToVerb(int points) { |
| 227 return (SkPath::Verb) (points); |
| 228 } |
| 229 |
| 230 inline SkPath::Verb SkOpVerbToPoints(SkPath::Verb verb) { |
| 231 return (int) verb ; |
| 232 } |
| 233 |
| 234 #endif |
| 235 |
| 192 inline double SkDInterp(double A, double B, double t) { | 236 inline double SkDInterp(double A, double B, double t) { |
| 193 return A + (B - A) * t; | 237 return A + (B - A) * t; |
| 194 } | 238 } |
| 195 | 239 |
| 196 double SkDCubeRoot(double x); | 240 double SkDCubeRoot(double x); |
| 197 | 241 |
| 198 /* Returns -1 if negative, 0 if zero, 1 if positive | 242 /* Returns -1 if negative, 0 if zero, 1 if positive |
| 199 */ | 243 */ |
| 200 inline int SkDSign(double x) { | 244 inline int SkDSign(double x) { |
| 201 return (x > 0) - (x < 0); | 245 return (x > 0) - (x < 0); |
| 202 } | 246 } |
| 203 | 247 |
| 204 /* Returns 0 if negative, 1 if zero, 2 if positive | 248 /* Returns 0 if negative, 1 if zero, 2 if positive |
| 205 */ | 249 */ |
| 206 inline int SKDSide(double x) { | 250 inline int SKDSide(double x) { |
| 207 return (x > 0) + (x >= 0); | 251 return (x > 0) + (x >= 0); |
| 208 } | 252 } |
| 209 | 253 |
| 210 /* Returns 1 if negative, 2 if zero, 4 if positive | 254 /* Returns 1 if negative, 2 if zero, 4 if positive |
| 211 */ | 255 */ |
| 212 inline int SkDSideBit(double x) { | 256 inline int SkDSideBit(double x) { |
| 213 return 1 << SKDSide(x); | 257 return 1 << SKDSide(x); |
| 214 } | 258 } |
| 215 | 259 |
| 216 #endif | 260 #endif |
| OLD | NEW |