Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/pathops/SkPathOpsTypes.h

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include <math.h> // for fabs, sqrt 11 #include <math.h> // for fabs, sqrt
12 12
13 #include "SkFloatingPoint.h" 13 #include "SkFloatingPoint.h"
14 #include "SkPath.h" 14 #include "SkPath.h"
15 #include "SkPathOps.h" 15 #include "SkPathOps.h"
16 #include "SkPathOpsDebug.h" 16 #include "SkPathOpsDebug.h"
17 #include "SkScalar.h" 17 #include "SkScalar.h"
18 18
19 enum SkPathOpsMask { 19 enum SkPathOpsMask {
20 kWinding_PathOpsMask = -1, 20 kWinding_PathOpsMask = -1,
21 kNo_PathOpsMask = 0, 21 kNo_PathOpsMask = 0,
22 kEvenOdd_PathOpsMask = 1 22 kEvenOdd_PathOpsMask = 1
23 }; 23 };
24 24
25 class SkOpCoincidence; 25 class SkOpCoincidence;
26 class SkOpContour; 26 class SkOpContour;
27 27
28 class SkOpGlobalState { 28 class SkOpGlobalState {
29 public: 29 public:
30 SkOpGlobalState(SkOpCoincidence* coincidence PATH_OPS_DEBUG_PARAMS(SkOpCont our* head)) 30 SkOpGlobalState(SkOpCoincidence* coincidence SkDEBUGPARAMS(SkOpContour* hea d))
31 : fCoincidence(coincidence) 31 : fCoincidence(coincidence)
32 , fWindingFailed(false) 32 , fWindingFailed(false)
33 , fAngleCoincidence(false) 33 , fAngleCoincidence(false)
34 #if DEBUG_VALIDATE 34 #if DEBUG_VALIDATE
35 , fPhase(kIntersecting) 35 , fPhase(kIntersecting)
36 #endif 36 #endif
37 PATH_OPS_DEBUG_PARAMS(fHead(head)) 37 SkDEBUGPARAMS(fHead(head))
38 PATH_OPS_DEBUG_PARAMS(fAngleID(0)) 38 SkDEBUGPARAMS(fAngleID(0))
39 PATH_OPS_DEBUG_PARAMS(fContourID(0)) 39 SkDEBUGPARAMS(fContourID(0))
40 PATH_OPS_DEBUG_PARAMS(fPtTID(0)) 40 SkDEBUGPARAMS(fPtTID(0))
41 PATH_OPS_DEBUG_PARAMS(fSegmentID(0)) 41 SkDEBUGPARAMS(fSegmentID(0))
42 PATH_OPS_DEBUG_PARAMS(fSpanID(0)) { 42 SkDEBUGPARAMS(fSpanID(0)) {
43 } 43 }
44 44
45 #if DEBUG_VALIDATE 45 #if DEBUG_VALIDATE
46 enum Phase { 46 enum Phase {
47 kIntersecting, 47 kIntersecting,
48 kWalking 48 kWalking
49 }; 49 };
50 #endif 50 #endif
51 51
52 bool angleCoincidence() { 52 bool angleCoincidence() {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 inline bool way_roughly_equal(double x, double y) { 433 inline bool way_roughly_equal(double x, double y) {
434 return fabs(x - y) < WAY_ROUGH_EPSILON; 434 return fabs(x - y) < WAY_ROUGH_EPSILON;
435 } 435 }
436 436
437 struct SkDPoint; 437 struct SkDPoint;
438 struct SkDVector; 438 struct SkDVector;
439 struct SkDLine; 439 struct SkDLine;
440 struct SkDQuad; 440 struct SkDQuad;
441 struct SkDConic;
441 struct SkDCubic; 442 struct SkDCubic;
442 struct SkDRect; 443 struct SkDRect;
443 444
444 inline SkPath::Verb SkPathOpsPointsToVerb(int points) { 445 inline SkPath::Verb SkPathOpsPointsToVerb(int points) {
445 int verb = (1 << points) >> 1; 446 int verb = (1 << points) >> 1;
446 #ifdef SK_DEBUG 447 #ifdef SK_DEBUG
447 switch (points) { 448 switch (points) {
448 case 0: SkASSERT(SkPath::kMove_Verb == verb); break; 449 case 0: SkASSERT(SkPath::kMove_Verb == verb); break;
449 case 1: SkASSERT(SkPath::kLine_Verb == verb); break; 450 case 1: SkASSERT(SkPath::kLine_Verb == verb); break;
450 case 2: SkASSERT(SkPath::kQuad_Verb == verb); break; 451 case 2: SkASSERT(SkPath::kQuad_Verb == verb); break;
451 case 3: SkASSERT(SkPath::kCubic_Verb == verb); break; 452 case 3: SkASSERT(SkPath::kCubic_Verb == verb); break;
452 default: SkDEBUGFAIL("should not be here"); 453 default: SkDEBUGFAIL("should not be here");
453 } 454 }
454 #endif 455 #endif
455 return (SkPath::Verb)verb; 456 return (SkPath::Verb)verb;
456 } 457 }
457 458
458 inline int SkPathOpsVerbToPoints(SkPath::Verb verb) { 459 inline int SkPathOpsVerbToPoints(SkPath::Verb verb) {
459 int points = (int) verb - ((int) verb >> 2); 460 int points = (int) verb - (((int) verb + 1) >> 2);
460 #ifdef SK_DEBUG 461 #ifdef SK_DEBUG
461 switch (verb) { 462 switch (verb) {
462 case SkPath::kLine_Verb: SkASSERT(1 == points); break; 463 case SkPath::kLine_Verb: SkASSERT(1 == points); break;
463 case SkPath::kQuad_Verb: SkASSERT(2 == points); break; 464 case SkPath::kQuad_Verb: SkASSERT(2 == points); break;
465 case SkPath::kConic_Verb: SkASSERT(2 == points); break;
464 case SkPath::kCubic_Verb: SkASSERT(3 == points); break; 466 case SkPath::kCubic_Verb: SkASSERT(3 == points); break;
465 default: SkDEBUGFAIL("should not get here"); 467 default: SkDEBUGFAIL("should not get here");
466 } 468 }
467 #endif 469 #endif
468 return points; 470 return points;
469 } 471 }
470 472
471 inline double SkDInterp(double A, double B, double t) { 473 inline double SkDInterp(double A, double B, double t) {
472 return A + (B - A) * t; 474 return A + (B - A) * t;
473 } 475 }
(...skipping 16 matching lines...) Expand all
490 */ 492 */
491 inline int SkDSideBit(double x) { 493 inline int SkDSideBit(double x) {
492 return 1 << SKDSide(x); 494 return 1 << SKDSide(x);
493 } 495 }
494 496
495 inline double SkPinT(double t) { 497 inline double SkPinT(double t) {
496 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 : t; 498 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 : t;
497 } 499 }
498 500
499 #endif 501 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698