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

Side by Side Diff: include/core/SkPath.h

Issue 25787002: Move more of SkPath into SkPathRef (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleaned up Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/core/SkPathRef.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPath_DEFINED 10 #ifndef SkPath_DEFINED
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 /** Returns true if the filltype is one of the Inverse variants */ 86 /** Returns true if the filltype is one of the Inverse variants */
87 bool isInverseFillType() const { return IsInverseFillType((FillType)fFillTyp e); } 87 bool isInverseFillType() const { return IsInverseFillType((FillType)fFillTyp e); }
88 88
89 /** 89 /**
90 * Toggle between inverse and normal filltypes. This reverse the return 90 * Toggle between inverse and normal filltypes. This reverse the return
91 * value of isInverseFillType() 91 * value of isInverseFillType()
92 */ 92 */
93 void toggleInverseFillType() { 93 void toggleInverseFillType() {
94 fFillType ^= 2; 94 fFillType ^= 2;
95 GEN_ID_INC; 95 GEN_ID_INC;
96 } 96 }
97 97
98 enum Convexity { 98 enum Convexity {
99 kUnknown_Convexity, 99 kUnknown_Convexity = SkPathRef::kUnknown_Convexity,
100 kConvex_Convexity, 100 kConvex_Convexity = SkPathRef::kConvex_Convexity,
101 kConcave_Convexity 101 kConcave_Convexity = SkPathRef::kConcave_Convexity
caryclark 2013/10/03 20:36:15 I don't agree with exposing the implementation in
bsalomon 2013/10/03 20:40:23 Would it make sense to promote Convexity to SkConv
102 }; 102 };
103 103
104 /** 104 /**
105 * Return the path's convexity, as stored in the path. If it is currently u nknown, 105 * Return the path's convexity, as stored in the path. If it is currently u nknown,
106 * then this function will attempt to compute the convexity (and cache the result). 106 * then this function will attempt to compute the convexity (and cache the result).
107 */ 107 */
108 Convexity getConvexity() const { 108 Convexity getConvexity() const {
109 if (kUnknown_Convexity != fConvexity) { 109 return static_cast<Convexity>(fPathRef->getConvexity());
110 return static_cast<Convexity>(fConvexity);
111 } else {
112 return this->internalGetConvexity();
113 }
114 } 110 }
115 111
116 /** 112 /**
117 * Return the currently cached value for convexity, even if that is set to 113 * Return the currently cached value for convexity, even if that is set to
118 * kUnknown_Convexity. Note: getConvexity() will automatically call 114 * kUnknown_Convexity. Note: getConvexity() will automatically call
119 * ComputeConvexity and cache its return value if the current setting is 115 * ComputeConvexity and cache its return value if the current setting is
120 * kUnknown. 116 * kUnknown.
121 */ 117 */
122 Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; } 118 Convexity getConvexityOrUnknown() const {
119 return static_cast<Convexity>(fPathRef->getConvexityOrUnknown());
120 }
123 121
124 /** 122 /**
125 * Store a convexity setting in the path. There is no automatic check to 123 * Store a convexity setting in the path. There is no automatic check to
126 * see if this value actually agrees with the return value that would be 124 * see if this value actually agrees with the return value that would be
127 * computed by getConvexity(). 125 * computed by getConvexity().
128 * 126 *
129 * Note: even if this is set to a "known" value, if the path is later 127 * Note: even if this is set to a "known" value, if the path is later
130 * changed (e.g. lineTo(), addRect(), etc.) then the cached value will be 128 * changed (e.g. lineTo(), addRect(), etc.) then the cached value will be
131 * reset to kUnknown_Convexity. 129 * reset to kUnknown_Convexity.
132 */ 130 */
133 void setConvexity(Convexity); 131 void setConvexity(Convexity);
134 132
135 /** 133 /**
136 * DEPRECATED: use getConvexity() 134 * DEPRECATED: use getConvexity()
137 * Returns true if the path is flagged as being convex. This is not a 135 * Returns true if the path is flagged as being convex. This is not a
138 * confirmed by any analysis, it is just the value set earlier. 136 * confirmed by any analysis, it is just the value set earlier.
139 */ 137 */
140 bool isConvex() const { 138 bool isConvex() const {
141 return kConvex_Convexity == this->getConvexity(); 139 return SkPathRef::kConvex_Convexity == this->getConvexity();
caryclark 2013/10/03 20:36:15 why is this change needed? Isn't the contract that
142 } 140 }
143 141
144 /** 142 /**
145 * DEPRECATED: use setConvexity() 143 * DEPRECATED: use setConvexity()
146 * Set the isConvex flag to true or false. Convex paths may draw faster if 144 * Set the isConvex flag to true or false. Convex paths may draw faster if
147 * this flag is set, though setting this to true on a path that is in fact 145 * this flag is set, though setting this to true on a path that is in fact
148 * not convex can give undefined results when drawn. Paths default to 146 * not convex can give undefined results when drawn. Paths default to
149 * isConvex == false 147 * isConvex == false
150 */ 148 */
151 void setIsConvex(bool isConvex) { 149 void setIsConvex(bool isConvex) {
152 this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity); 150 this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
153 } 151 }
154 152
155 /** Returns true if the path is an oval. 153 /** Returns true if the path is an oval.
156 * 154 *
157 * @param rect returns the bounding rect of this oval. It's a circle 155 * @param rect returns the bounding rect of this oval. It's a circle
158 * if the height and width are the same. 156 * if the height and width are the same.
159 * 157 *
160 * @return true if this path is an oval. 158 * @return true if this path is an oval.
161 * Tracking whether a path is an oval is considered an 159 * Tracking whether a path is an oval is considered an
162 * optimization for performance and so some paths that are in 160 * optimization for performance and so some paths that are in
163 * fact ovals can report false. 161 * fact ovals can report false.
164 */ 162 */
165 bool isOval(SkRect* rect) const; 163 bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); }
166 164
167 /** Clear any lines and curves from the path, making it empty. This frees up 165 /** Clear any lines and curves from the path, making it empty. This frees up
168 internal storage associated with those segments. 166 internal storage associated with those segments.
169 On Android, does not change fSourcePath. 167 On Android, does not change fSourcePath.
170 */ 168 */
171 void reset(); 169 void reset();
172 170
173 /** Similar to reset(), in that all lines and curves are removed from the 171 /** Similar to reset(), in that all lines and curves are removed from the
174 path. However, any internal storage for those lines/curves is retained, 172 path. However, any internal storage for those lines/curves is retained,
175 making reuse of the path potentially faster. 173 making reuse of the path potentially faster.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 this contour, to specify the 1st control point of a cubic curve 448 this contour, to specify the 1st control point of a cubic curve
451 @param dx2 The amount to add to the x-coordinate of the last point on 449 @param dx2 The amount to add to the x-coordinate of the last point on
452 this contour, to specify the 2nd control point of a cubic curve 450 this contour, to specify the 2nd control point of a cubic curve
453 @param dy2 The amount to add to the y-coordinate of the last point on 451 @param dy2 The amount to add to the y-coordinate of the last point on
454 this contour, to specify the 2nd control point of a cubic curve 452 this contour, to specify the 2nd control point of a cubic curve
455 @param dx3 The amount to add to the x-coordinate of the last point on 453 @param dx3 The amount to add to the x-coordinate of the last point on
456 this contour, to specify the end point of a cubic curve 454 this contour, to specify the end point of a cubic curve
457 @param dy3 The amount to add to the y-coordinate of the last point on 455 @param dy3 The amount to add to the y-coordinate of the last point on
458 this contour, to specify the end point of a cubic curve 456 this contour, to specify the end point of a cubic curve
459 */ 457 */
460 void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 458 void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
461 SkScalar x3, SkScalar y3); 459 SkScalar x3, SkScalar y3);
462 460
463 /** Append the specified arc to the path as a new contour. If the start of 461 /** Append the specified arc to the path as a new contour. If the start of
464 the path is different from the path's current last point, then an 462 the path is different from the path's current last point, then an
465 automatic lineTo() is added to connect the current contour to the start 463 automatic lineTo() is added to connect the current contour to the start
466 of the arc. However, if the path is empty, then we call moveTo() with 464 of the arc. However, if the path is empty, then we call moveTo() with
467 the first point of the arc. The sweep angle is treated mod 360. 465 the first point of the arc. The sweep angle is treated mod 360.
468 466
469 @param oval The bounding oval defining the shape and size of the arc 467 @param oval The bounding oval defining the shape and size of the arc
470 @param startAngle Starting angle (in degrees) where the arc begins 468 @param startAngle Starting angle (in degrees) where the arc begins
471 @param sweepAngle Sweep angle (in degrees) measured clockwise. This is 469 @param sweepAngle Sweep angle (in degrees) measured clockwise. This is
472 treated mod 360. 470 treated mod 360.
473 @param forceMoveTo If true, always begin a new contour with the arc 471 @param forceMoveTo If true, always begin a new contour with the arc
474 */ 472 */
475 void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, 473 void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
476 bool forceMoveTo); 474 bool forceMoveTo);
477 475
478 /** Append a line and arc to the current path. This is the same as the 476 /** Append a line and arc to the current path. This is the same as the
479 PostScript call "arct". 477 PostScript call "arct".
480 */ 478 */
481 void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 479 void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
482 SkScalar radius); 480 SkScalar radius);
483 481
484 /** Append a line and arc to the current path. This is the same as the 482 /** Append a line and arc to the current path. This is the same as the
485 PostScript call "arct". 483 PostScript call "arct".
486 */ 484 */
487 void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) { 485 void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
488 this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius); 486 this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
489 } 487 }
490 488
491 /** Close the current contour. If the current point is not equal to the 489 /** Close the current contour. If the current point is not equal to the
492 first point of the contour, a line segment is automatically added. 490 first point of the contour, a line segment is automatically added.
493 */ 491 */
494 void close(); 492 void close();
495 493
496 enum Direction { 494 enum Direction {
497 /** Direction either has not been or could not be computed */ 495 /** Direction either has not been or could not be computed */
498 kUnknown_Direction, 496 kUnknown_Direction = SkPathRef::kUnknown_Direction,
499 /** clockwise direction for adding closed contours */ 497 /** clockwise direction for adding closed contours */
500 kCW_Direction, 498 kCW_Direction = SkPathRef::kCW_Direction,
501 /** counter-clockwise direction for adding closed contours */ 499 /** counter-clockwise direction for adding closed contours */
502 kCCW_Direction, 500 kCCW_Direction = SkPathRef::kCCW_Direction,
caryclark 2013/10/03 20:36:15 same feedback as convexity change above; would pre
503 }; 501 };
504 502
505 /** 503 /**
506 * Return the opposite of the specified direction. kUnknown is its own 504 * Return the opposite of the specified direction. kUnknown is its own
507 * opposite. 505 * opposite.
508 */ 506 */
509 static Direction OppositeDirection(Direction dir) { 507 static Direction OppositeDirection(Direction dir) {
510 static const Direction gOppositeDir[] = { 508 return (Direction) SkPathRef::OppositeDirection((SkPathRef::Direction)di r);
caryclark 2013/10/03 20:36:15 you have static casts in similar changes above
511 kUnknown_Direction, kCCW_Direction, kCW_Direction
512 };
513 return gOppositeDir[dir];
514 } 509 }
515 510
516 /** 511 /**
517 * Returns whether or not a fill type is inverted 512 * Returns whether or not a fill type is inverted
518 * 513 *
519 * kWinding_FillType -> false 514 * kWinding_FillType -> false
520 * kEvenOdd_FillType -> false 515 * kEvenOdd_FillType -> false
521 * kInverseWinding_FillType -> true 516 * kInverseWinding_FillType -> true
522 * kInverseEvenOdd_FillType -> true 517 * kInverseEvenOdd_FillType -> true
523 */ 518 */
(...skipping 21 matching lines...) Expand all
545 return (FillType)(fill & 1); 540 return (FillType)(fill & 1);
546 } 541 }
547 542
548 /** 543 /**
549 * Tries to quickly compute the direction of the first non-degenerate 544 * Tries to quickly compute the direction of the first non-degenerate
550 * contour. If it can be computed, return true and set dir to that 545 * contour. If it can be computed, return true and set dir to that
551 * direction. If it cannot be (quickly) determined, return false and ignore 546 * direction. If it cannot be (quickly) determined, return false and ignore
552 * the dir parameter. If the direction was determined, it is cached to make 547 * the dir parameter. If the direction was determined, it is cached to make
553 * subsequent calls return quickly. 548 * subsequent calls return quickly.
554 */ 549 */
555 bool cheapComputeDirection(Direction* dir) const; 550 bool cheapComputeDirection(Direction* dir) const {
551 return fPathRef->cheapComputeDirection((SkPathRef::Direction*) dir);
caryclark 2013/10/03 20:36:15 static cast
552 }
556 553
557 /** 554 /**
558 * Returns true if the path's direction can be computed via 555 * Returns true if the path's direction can be computed via
559 * cheapComputDirection() and if that computed direction matches the 556 * cheapComputDirection() and if that computed direction matches the
560 * specified direction. If dir is kUnknown, returns true if the direction 557 * specified direction. If dir is kUnknown, returns true if the direction
561 * cannot be computed. 558 * cannot be computed.
562 */ 559 */
563 bool cheapIsDirection(Direction dir) const { 560 bool cheapIsDirection(Direction dir) const {
564 Direction computedDir = kUnknown_Direction; 561 Direction computedDir = kUnknown_Direction;
565 (void)this->cheapComputeDirection(&computedDir); 562 (void)this->cheapComputeDirection(&computedDir);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 /** Set the last point on the path. If no points have been added, moveTo(p) 768 /** Set the last point on the path. If no points have been added, moveTo(p)
772 is automatically called. 769 is automatically called.
773 770
774 @param p The new location for the last point 771 @param p The new location for the last point
775 */ 772 */
776 void setLastPt(const SkPoint& p) { 773 void setLastPt(const SkPoint& p) {
777 this->setLastPt(p.fX, p.fY); 774 this->setLastPt(p.fX, p.fY);
778 } 775 }
779 776
780 enum SegmentMask { 777 enum SegmentMask {
781 kLine_SegmentMask = 1 << 0, 778 kLine_SegmentMask = SkPathRef::kLine_SegmentMask,
782 kQuad_SegmentMask = 1 << 1, 779 kQuad_SegmentMask = SkPathRef::kQuad_SegmentMask,
783 kConic_SegmentMask = 1 << 2, 780 kConic_SegmentMask = SkPathRef::kConic_SegmentMask,
784 kCubic_SegmentMask = 1 << 3, 781 kCubic_SegmentMask = SkPathRef::kCubic_SegmentMask,
caryclark 2013/10/03 20:36:15 Additionally, this change makes Skia harder to use
785 }; 782 };
786 783
787 /** 784 /**
788 * Returns a mask, where each bit corresponding to a SegmentMask is 785 * Returns a mask, where each bit corresponding to a SegmentMask is
789 * set if the path contains 1 or more segments of that type. 786 * set if the path contains 1 or more segments of that type.
790 * Returns 0 for an empty path (no segments). 787 * Returns 0 for an empty path (no segments).
791 */ 788 */
792 uint32_t getSegmentMasks() const { return fSegmentMask; } 789 uint32_t getSegmentMasks() const { return fPathRef->getSegmentMasks(); }
793 790
794 enum Verb { 791 enum Verb {
795 kMove_Verb, //!< iter.next returns 1 point 792 kMove_Verb = SkPathRef::kMove_Verb, //!< iter.next returns 1 point
796 kLine_Verb, //!< iter.next returns 2 points 793 kLine_Verb = SkPathRef::kLine_Verb, //!< iter.next returns 2 points
797 kQuad_Verb, //!< iter.next returns 3 points 794 kQuad_Verb = SkPathRef::kQuad_Verb, //!< iter.next returns 3 points
798 kConic_Verb, //!< iter.next returns 3 points + iter.conicWeight() 795 kConic_Verb = SkPathRef::kConic_Verb, //!< iter.next returns 3 points + iter.conicWeight()
799 kCubic_Verb, //!< iter.next returns 4 points 796 kCubic_Verb = SkPathRef::kCubic_Verb, //!< iter.next returns 4 points
800 kClose_Verb, //!< iter.next returns 1 point (contour's moveTo pt) 797 kClose_Verb = SkPathRef::kClose_Verb, //!< iter.next returns 1 point (co ntour's moveTo pt)
801 kDone_Verb, //!< iter.next returns 0 points 798 kDone_Verb = SkPathRef::kDone_Verb, //!< iter.next returns 0 points
caryclark 2013/10/03 20:36:15 another place to have compile time asserts
802 }; 799 };
803 800
804 /** Iterate through all of the segments (lines, quadratics, cubics) of 801 /** Iterate through all of the segments (lines, quadratics, cubics) of
805 each contours in a path. 802 each contours in a path.
806 803
807 The iterator cleans up the segments along the way, removing degenerate 804 The iterator cleans up the segments along the way, removing degenerate
808 segments and adding close verbs where necessary. When the forceClose 805 segments and adding close verbs where necessary. When the forceClose
809 argument is provided, each contour (as defined by a new starting 806 argument is provided, each contour (as defined by a new starting
810 move command) will be completed with a close verb regardless of the 807 move command) will be completed with a close verb regardless of the
811 contour's contents. 808 contour's contents.
812 */ 809 */
813 class SK_API Iter { 810 class SK_API Iter {
814 public: 811 public:
815 Iter(); 812 Iter();
816 Iter(const SkPath&, bool forceClose); 813 Iter(const SkPath&, bool forceClose);
814 Iter(const SkPathRef*, bool forceClose);
817 815
818 void setPath(const SkPath&, bool forceClose); 816 void setPath(const SkPath&, bool forceClose);
817 void setPathRef(const SkPathRef*, bool forceClose);
819 818
820 /** Return the next verb in this iteration of the path. When all 819 /** Return the next verb in this iteration of the path. When all
821 segments have been visited, return kDone_Verb. 820 segments have been visited, return kDone_Verb.
822 821
823 @param pts The points representing the current verb and/or segment 822 @param pts The points representing the current verb and/or segment
824 @param doConsumeDegerates If true, first scan for segments that are 823 @param doConsumeDegerates If true, first scan for segments that are
825 deemed degenerate (too short) and skip those. 824 deemed degenerate (too short) and skip those.
826 @return The verb for the current segment 825 @return The verb for the current segment
827 */ 826 */
828 Verb next(SkPoint pts[4], bool doConsumeDegerates = true) { 827 Verb next(SkPoint pts[4], bool doConsumeDegerates = true) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 const SkPath* getSourcePath() const; 924 const SkPath* getSourcePath() const;
926 void setSourcePath(const SkPath* path); 925 void setSourcePath(const SkPath* path);
927 #endif 926 #endif
928 927
929 SkDEBUGCODE(void validate() const;) 928 SkDEBUGCODE(void validate() const;)
930 929
931 private: 930 private:
932 enum SerializationOffsets { 931 enum SerializationOffsets {
933 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 932 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
934 kNewFormat_SerializationShift = 28, // requires 1 bit 933 kNewFormat_SerializationShift = 28, // requires 1 bit
934 kOldDirection_SerializationShift = 26, // requires 2 bits
935 kOldIsFinite_SerializationShift = 25, // 1 bit
936 kOldIsOval_SerializationShift = 24, // requires 1 bit
937 kOldConvexity_SerializationShift = 16, // requires 8 bits
938 #endif
939 // TODO: make this shift be 0
940 kFillType_SerializationShift = 8, // requires 8 bits
941 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
942 kOldSegmentMask_SerializationShift = 0 // requires 4 bits
935 #endif 943 #endif
936 kDirection_SerializationShift = 26, // requires 2 bits
937 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
938 // rename to kUnused_SerializationShift
939 kOldIsFinite_SerializationShift = 25, // 1 bit
940 #endif
941 kIsOval_SerializationShift = 24, // requires 1 bit
942 kConvexity_SerializationShift = 16, // requires 8 bits
943 kFillType_SerializationShift = 8, // requires 8 bits
944 kSegmentMask_SerializationShift = 0 // requires 4 bits
945 }; 944 };
946 945
947 SkAutoTUnref<SkPathRef> fPathRef; 946 SkAutoTUnref<SkPathRef> fPathRef;
948 947
949 int fLastMoveToIndex;
950 uint8_t fFillType; 948 uint8_t fFillType;
951 uint8_t fSegmentMask;
952 mutable uint8_t fConvexity;
953 mutable uint8_t fDirection;
954 mutable SkBool8 fIsOval;
955 #ifdef SK_BUILD_FOR_ANDROID 949 #ifdef SK_BUILD_FOR_ANDROID
956 uint32_t fGenerationID; 950 uint32_t fGenerationID;
957 const SkPath* fSourcePath; 951 const SkPath* fSourcePath;
958 #endif 952 #endif
959 953
960 /** Resets all fields other than fPathRef to their initial 'empty' values. 954 /** Resets all fields other than fPathRef to their initial 'empty' values.
961 * Assumes the caller has already emptied fPathRef. 955 * Assumes the caller has already emptied fPathRef.
962 * On Android increments fGenerationID without reseting it. 956 * On Android increments fGenerationID without reseting it.
963 */ 957 */
964 void resetFields(); 958 void resetFields();
(...skipping 12 matching lines...) Expand all
977 automatically set to (0,0). 971 automatically set to (0,0).
978 */ 972 */
979 void pathTo(const SkPath& path); 973 void pathTo(const SkPath& path);
980 974
981 /* Append, in reverse order, the first contour of path, ignoring path's 975 /* Append, in reverse order, the first contour of path, ignoring path's
982 last point. If no moveTo() call has been made for this contour, the 976 last point. If no moveTo() call has been made for this contour, the
983 first point is automatically set to (0,0). 977 first point is automatically set to (0,0).
984 */ 978 */
985 void reversePathTo(const SkPath&); 979 void reversePathTo(const SkPath&);
986 980
987 // called before we add points for lineTo, quadTo, cubicTo, checking to see
988 // if we need to inject a leading moveTo first
989 //
990 // SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
991 // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previou s moveTo)
992 //
993 inline void injectMoveToIfNeeded();
994
995 inline bool hasOnlyMoveTos() const; 981 inline bool hasOnlyMoveTos() const;
996 982
997 Convexity internalGetConvexity() const;
998
999 bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts, 983 bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts,
1000 bool* isClosed, Direction* direction) const; 984 bool* isClosed, Direction* direction) const;
1001 985
1002 /** Returns if the path can return a bound at no cost (true) or will have to 986 /** Returns if the path can return a bound at no cost (true) or will have to
1003 perform some computation (false). 987 perform some computation (false).
1004 */ 988 */
1005 bool hasComputedBounds() const { 989 bool hasComputedBounds() const {
1006 SkDEBUGCODE(this->validate();) 990 SkDEBUGCODE(this->validate();)
1007 return fPathRef->hasComputedBounds(); 991 return fPathRef->hasComputedBounds();
1008 } 992 }
1009 993
1010 994
1011 // 'rect' needs to be sorted 995 // 'rect' needs to be sorted
1012 void setBounds(const SkRect& rect) { 996 void setBounds(const SkRect& rect) {
1013 fPathRef->setBounds(rect); 997 fPathRef->setBounds(rect);
1014 } 998 }
1015 999
1000 Direction getDirection() const {
1001 return static_cast<Direction>(fPathRef->getDirection());
1002 }
1003 void setDirection(Direction dir) {
1004 fPathRef->setDirection(static_cast<SkPathRef::Direction>(dir));
1005 }
1006
1007 void setIsOval(bool isOval) { fPathRef->setIsOval(isOval); }
1008
1016 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 1009 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
1017 friend class SkPathRef; // just for SerializationOffsets 1010 friend class SkPathRef; // just for SerializationOffsets
1018 #endif 1011 #endif
1019 friend class SkAutoPathBoundsUpdate; 1012 friend class SkAutoPathBoundsUpdate;
1020 friend class SkAutoDisableOvalCheck;
1021 friend class SkAutoDisableDirectionCheck;
1022 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo 1013 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
1023 }; 1014 };
1024 1015
1025 #endif 1016 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPathRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698