OLD | NEW |
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 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 ~SkAutoDisableOvalCheck() { | 51 ~SkAutoDisableOvalCheck() { |
52 fPath->fIsOval = fSaved; | 52 fPath->fIsOval = fSaved; |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 SkPath* fPath; | 56 SkPath* fPath; |
57 bool fSaved; | 57 bool fSaved; |
58 }; | 58 }; |
| 59 #define SkAutoDisableOvalCheck(...) SK_REQUIRE_LOCAL_VAR(SkAutoDisableOvalCheck) |
59 | 60 |
60 class SkAutoDisableDirectionCheck { | 61 class SkAutoDisableDirectionCheck { |
61 public: | 62 public: |
62 SkAutoDisableDirectionCheck(SkPath* path) : fPath(path) { | 63 SkAutoDisableDirectionCheck(SkPath* path) : fPath(path) { |
63 fSaved = static_cast<SkPath::Direction>(fPath->fDirection); | 64 fSaved = static_cast<SkPath::Direction>(fPath->fDirection); |
64 } | 65 } |
65 | 66 |
66 ~SkAutoDisableDirectionCheck() { | 67 ~SkAutoDisableDirectionCheck() { |
67 fPath->fDirection = fSaved; | 68 fPath->fDirection = fSaved; |
68 } | 69 } |
69 | 70 |
70 private: | 71 private: |
71 SkPath* fPath; | 72 SkPath* fPath; |
72 SkPath::Direction fSaved; | 73 SkPath::Direction fSaved; |
73 }; | 74 }; |
| 75 #define SkAutoDisableDirectionCheck(...) SK_REQUIRE_LOCAL_VAR(SkAutoDisableDirec
tionCheck) |
74 | 76 |
75 /* This guy's constructor/destructor bracket a path editing operation. It is | 77 /* This guy's constructor/destructor bracket a path editing operation. It is |
76 used when we know the bounds of the amount we are going to add to the path | 78 used when we know the bounds of the amount we are going to add to the path |
77 (usually a new contour, but not required). | 79 (usually a new contour, but not required). |
78 | 80 |
79 It captures some state about the path up front (i.e. if it already has a | 81 It captures some state about the path up front (i.e. if it already has a |
80 cached bounds), and then if it can, it updates the cache bounds explicitly, | 82 cached bounds), and then if it can, it updates the cache bounds explicitly, |
81 avoiding the need to revisit all of the points in getBounds(). | 83 avoiding the need to revisit all of the points in getBounds(). |
82 | 84 |
83 It also notes if the path was originally degenerate, and if so, sets | 85 It also notes if the path was originally degenerate, and if so, sets |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Mark the path's bounds as dirty if (1) they are, or (2) the path | 120 // Mark the path's bounds as dirty if (1) they are, or (2) the path |
119 // is non-finite, and therefore its bounds are not meaningful | 121 // is non-finite, and therefore its bounds are not meaningful |
120 fHasValidBounds = path->hasComputedBounds() && path->isFinite(); | 122 fHasValidBounds = path->hasComputedBounds() && path->isFinite(); |
121 fEmpty = path->isEmpty(); | 123 fEmpty = path->isEmpty(); |
122 if (fHasValidBounds && !fEmpty) { | 124 if (fHasValidBounds && !fEmpty) { |
123 joinNoEmptyChecks(&fRect, fPath->getBounds()); | 125 joinNoEmptyChecks(&fRect, fPath->getBounds()); |
124 } | 126 } |
125 fDegenerate = is_degenerate(*path); | 127 fDegenerate = is_degenerate(*path); |
126 } | 128 } |
127 }; | 129 }; |
| 130 #define SkAutoPathBoundsUpdate(...) SK_REQUIRE_LOCAL_VAR(SkAutoPathBoundsUpdate) |
128 | 131 |
129 //////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////// |
130 | 133 |
131 /* | 134 /* |
132 Stores the verbs and points as they are given to us, with exceptions: | 135 Stores the verbs and points as they are given to us, with exceptions: |
133 - we only record "Close" if it was immediately preceeded by Move | Line | Qu
ad | Cubic | 136 - we only record "Close" if it was immediately preceeded by Move | Line | Qu
ad | Cubic |
134 - we insert a Move(0,0) if Line | Quad | Cubic is our first command | 137 - we insert a Move(0,0) if Line | Quad | Cubic is our first command |
135 | 138 |
136 The iterator does more cleanup, especially if forceClose == true | 139 The iterator does more cleanup, especially if forceClose == true |
137 1. If we encounter degenerate segments, remove them | 140 1. If we encounter degenerate segments, remove them |
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 switch (this->getFillType()) { | 2941 switch (this->getFillType()) { |
2939 case SkPath::kEvenOdd_FillType: | 2942 case SkPath::kEvenOdd_FillType: |
2940 case SkPath::kInverseEvenOdd_FillType: | 2943 case SkPath::kInverseEvenOdd_FillType: |
2941 w &= 1; | 2944 w &= 1; |
2942 break; | 2945 break; |
2943 default: | 2946 default: |
2944 break; | 2947 break; |
2945 } | 2948 } |
2946 return SkToBool(w); | 2949 return SkToBool(w); |
2947 } | 2950 } |
OLD | NEW |