diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-30 14:57:55 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-30 14:57:55 +0000 |
commit | 7950a9eba71f65365d88021680a16f245ad3fa68 (patch) | |
tree | 4906a9e50f93585672a93c984683600b3714acb2 /src/pathops/SkPathOpsTypes.h | |
parent | a5d3e77420621c912383c3b22e542d9413d68278 (diff) |
add asserts to point<-->verb helpers
patch from issue 16153005
BUG=
Review URL: https://codereview.chromium.org/16195004
git-svn-id: http://skia.googlecode.com/svn/trunk@9344 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pathops/SkPathOpsTypes.h')
-rw-r--r-- | src/pathops/SkPathOpsTypes.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/pathops/SkPathOpsTypes.h b/src/pathops/SkPathOpsTypes.h index 5a5394a0e7..0f689d818e 100644 --- a/src/pathops/SkPathOpsTypes.h +++ b/src/pathops/SkPathOpsTypes.h @@ -7,10 +7,13 @@ #ifndef SkPathOpsTypes_DEFINED #define SkPathOpsTypes_DEFINED +#define SK_CONIC_SUPPORT_ENABLED 1 + #include <float.h> // for FLT_EPSILON #include <math.h> // for fabs, sqrt #include "SkFloatingPoint.h" +#include "SkPath.h" #include "SkPathOps.h" #include "SkPathOpsDebug.h" #include "SkScalar.h" @@ -189,6 +192,47 @@ struct SkDTriangle; struct SkDCubic; struct SkDRect; +#if SK_CONIC_SUPPORT_ENABLED + +inline SkPath::Verb SkPathOpsPointsToVerb(int points) { + int verb = (1 << points) >> 1; +#ifdef SK_DEBUG + switch (points) { + case 0: SkASSERT(SkPath::kMove_Verb == verb); break; + case 1: SkASSERT(SkPath::kLine_Verb == verb); break; + case 2: SkASSERT(SkPath::kQuad_Verb == verb); break; + case 3: SkASSERT(SkPath::kCubic_Verb == verb); break; + default: SkASSERT(!"should not be here"); + } +#endif + return (SkPath::Verb)verb; +} + +inline int SkPathOpsVerbToPoints(SkPath::Verb verb) { + int points = (int) verb - ((int) verb >> 2); +#ifdef SK_DEBUG + switch (verb) { + case SkPath::kLine_Verb: SkASSERT(1 == points); break; + case SkPath::kQuad_Verb: SkASSERT(2 == points); break; + case SkPath::kCubic_Verb: SkASSERT(3 == points); break; + default: SkASSERT(!"should not get here"); + } +#endif + return points; +} + +#else + +inline SkPath::Verb SkOpPointsToVerb(int points) { + return (SkPath::Verb) (points); +} + +inline SkPath::Verb SkOpVerbToPoints(SkPath::Verb verb) { + return (int) verb ; +} + +#endif + inline double SkDInterp(double A, double B, double t) { return A + (B - A) * t; } |