| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 | 7 |
| 8 #include "SkBuffer.h" | 8 #include "SkBuffer.h" |
| 9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 3. if we encounter Move without a preceeding Close, and forceClose is true,
goto #2 | 118 3. if we encounter Move without a preceeding Close, and forceClose is true,
goto #2 |
| 119 4. if we encounter Line | Quad | Cubic after Close, cons up a Move | 119 4. if we encounter Line | Quad | Cubic after Close, cons up a Move |
| 120 */ | 120 */ |
| 121 | 121 |
| 122 //////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////// |
| 123 | 123 |
| 124 // flag to require a moveTo if we begin with something else, like lineTo etc. | 124 // flag to require a moveTo if we begin with something else, like lineTo etc. |
| 125 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 | 125 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 |
| 126 | 126 |
| 127 SkPath::SkPath() | 127 SkPath::SkPath() |
| 128 : fPathRef(SkPathRef::CreateEmpty()) | 128 : fPathRef(SkPathRef::CreateEmpty()) { |
| 129 #ifdef SK_BUILD_FOR_ANDROID | |
| 130 , fSourcePath(NULL) | |
| 131 #endif | |
| 132 { | |
| 133 this->resetFields(); | 129 this->resetFields(); |
| 134 fIsVolatile = false; | 130 fIsVolatile = false; |
| 135 } | 131 } |
| 136 | 132 |
| 137 void SkPath::resetFields() { | 133 void SkPath::resetFields() { |
| 138 //fPathRef is assumed to have been emptied by the caller. | 134 //fPathRef is assumed to have been emptied by the caller. |
| 139 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | 135 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; |
| 140 fFillType = kWinding_FillType; | 136 fFillType = kWinding_FillType; |
| 141 fConvexity = kUnknown_Convexity; | 137 fConvexity = kUnknown_Convexity; |
| 142 fDirection = kUnknown_Direction; | 138 fDirection = kUnknown_Direction; |
| 143 | 139 |
| 144 // We don't touch Android's fSourcePath. It's used to track texture garbage
collection, so we | 140 // We don't touch Android's fSourcePath. It's used to track texture garbage
collection, so we |
| 145 // don't want to muck with it if it's been set to something non-NULL. | 141 // don't want to muck with it if it's been set to something non-NULL. |
| 146 } | 142 } |
| 147 | 143 |
| 148 SkPath::SkPath(const SkPath& that) | 144 SkPath::SkPath(const SkPath& that) |
| 149 : fPathRef(SkRef(that.fPathRef.get())) { | 145 : fPathRef(SkRef(that.fPathRef.get())) { |
| 150 this->copyFields(that); | 146 this->copyFields(that); |
| 151 #ifdef SK_BUILD_FOR_ANDROID | |
| 152 fSourcePath = that.fSourcePath; | |
| 153 #endif | |
| 154 SkDEBUGCODE(that.validate();) | 147 SkDEBUGCODE(that.validate();) |
| 155 } | 148 } |
| 156 | 149 |
| 157 SkPath::~SkPath() { | 150 SkPath::~SkPath() { |
| 158 SkDEBUGCODE(this->validate();) | 151 SkDEBUGCODE(this->validate();) |
| 159 } | 152 } |
| 160 | 153 |
| 161 SkPath& SkPath::operator=(const SkPath& that) { | 154 SkPath& SkPath::operator=(const SkPath& that) { |
| 162 SkDEBUGCODE(that.validate();) | 155 SkDEBUGCODE(that.validate();) |
| 163 | 156 |
| 164 if (this != &that) { | 157 if (this != &that) { |
| 165 fPathRef.reset(SkRef(that.fPathRef.get())); | 158 fPathRef.reset(SkRef(that.fPathRef.get())); |
| 166 this->copyFields(that); | 159 this->copyFields(that); |
| 167 #ifdef SK_BUILD_FOR_ANDROID | |
| 168 fSourcePath = that.fSourcePath; | |
| 169 #endif | |
| 170 } | 160 } |
| 171 SkDEBUGCODE(this->validate();) | 161 SkDEBUGCODE(this->validate();) |
| 172 return *this; | 162 return *this; |
| 173 } | 163 } |
| 174 | 164 |
| 175 void SkPath::copyFields(const SkPath& that) { | 165 void SkPath::copyFields(const SkPath& that) { |
| 176 //fPathRef is assumed to have been set by the caller. | 166 //fPathRef is assumed to have been set by the caller. |
| 177 fLastMoveToIndex = that.fLastMoveToIndex; | 167 fLastMoveToIndex = that.fLastMoveToIndex; |
| 178 fFillType = that.fFillType; | 168 fFillType = that.fFillType; |
| 179 fConvexity = that.fConvexity; | 169 fConvexity = that.fConvexity; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 191 void SkPath::swap(SkPath& that) { | 181 void SkPath::swap(SkPath& that) { |
| 192 SkASSERT(&that != NULL); | 182 SkASSERT(&that != NULL); |
| 193 | 183 |
| 194 if (this != &that) { | 184 if (this != &that) { |
| 195 fPathRef.swap(&that.fPathRef); | 185 fPathRef.swap(&that.fPathRef); |
| 196 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex); | 186 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex); |
| 197 SkTSwap<uint8_t>(fFillType, that.fFillType); | 187 SkTSwap<uint8_t>(fFillType, that.fFillType); |
| 198 SkTSwap<uint8_t>(fConvexity, that.fConvexity); | 188 SkTSwap<uint8_t>(fConvexity, that.fConvexity); |
| 199 SkTSwap<uint8_t>(fDirection, that.fDirection); | 189 SkTSwap<uint8_t>(fDirection, that.fDirection); |
| 200 SkTSwap<SkBool8>(fIsVolatile, that.fIsVolatile); | 190 SkTSwap<SkBool8>(fIsVolatile, that.fIsVolatile); |
| 201 #ifdef SK_BUILD_FOR_ANDROID | |
| 202 SkTSwap<const SkPath*>(fSourcePath, that.fSourcePath); | |
| 203 #endif | |
| 204 } | 191 } |
| 205 } | 192 } |
| 206 | 193 |
| 207 static inline bool check_edge_against_rect(const SkPoint& p0, | 194 static inline bool check_edge_against_rect(const SkPoint& p0, |
| 208 const SkPoint& p1, | 195 const SkPoint& p1, |
| 209 const SkRect& rect, | 196 const SkRect& rect, |
| 210 SkPath::Direction dir) { | 197 SkPath::Direction dir) { |
| 211 const SkPoint* edgeBegin; | 198 const SkPoint* edgeBegin; |
| 212 SkVector v; | 199 SkVector v; |
| 213 if (SkPath::kCW_Direction == dir) { | 200 if (SkPath::kCW_Direction == dir) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 288 } |
| 302 prevPt = pts[nextPt]; | 289 prevPt = pts[nextPt]; |
| 303 } | 290 } |
| 304 } | 291 } |
| 305 | 292 |
| 306 return check_edge_against_rect(prevPt, firstPt, rect, direction); | 293 return check_edge_against_rect(prevPt, firstPt, rect, direction); |
| 307 } | 294 } |
| 308 | 295 |
| 309 uint32_t SkPath::getGenerationID() const { | 296 uint32_t SkPath::getGenerationID() const { |
| 310 uint32_t genID = fPathRef->genID(); | 297 uint32_t genID = fPathRef->genID(); |
| 311 #ifdef SK_BUILD_FOR_ANDROID | 298 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 312 SkASSERT((unsigned)fFillType < (1 << (32 - kPathRefGenIDBitCnt))); | 299 SkASSERT((unsigned)fFillType < (1 << (32 - kPathRefGenIDBitCnt))); |
| 313 genID |= static_cast<uint32_t>(fFillType) << kPathRefGenIDBitCnt; | 300 genID |= static_cast<uint32_t>(fFillType) << kPathRefGenIDBitCnt; |
| 314 #endif | 301 #endif |
| 315 return genID; | 302 return genID; |
| 316 } | 303 } |
| 317 | 304 |
| 318 #ifdef SK_BUILD_FOR_ANDROID | |
| 319 const SkPath* SkPath::getSourcePath() const { | |
| 320 return fSourcePath; | |
| 321 } | |
| 322 | |
| 323 void SkPath::setSourcePath(const SkPath* path) { | |
| 324 fSourcePath = path; | |
| 325 } | |
| 326 #endif | |
| 327 | |
| 328 void SkPath::reset() { | 305 void SkPath::reset() { |
| 329 SkDEBUGCODE(this->validate();) | 306 SkDEBUGCODE(this->validate();) |
| 330 | 307 |
| 331 fPathRef.reset(SkPathRef::CreateEmpty()); | 308 fPathRef.reset(SkPathRef::CreateEmpty()); |
| 332 this->resetFields(); | 309 this->resetFields(); |
| 333 } | 310 } |
| 334 | 311 |
| 335 void SkPath::rewind() { | 312 void SkPath::rewind() { |
| 336 SkDEBUGCODE(this->validate();) | 313 SkDEBUGCODE(this->validate();) |
| 337 | 314 |
| (...skipping 2607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 switch (this->getFillType()) { | 2922 switch (this->getFillType()) { |
| 2946 case SkPath::kEvenOdd_FillType: | 2923 case SkPath::kEvenOdd_FillType: |
| 2947 case SkPath::kInverseEvenOdd_FillType: | 2924 case SkPath::kInverseEvenOdd_FillType: |
| 2948 w &= 1; | 2925 w &= 1; |
| 2949 break; | 2926 break; |
| 2950 default: | 2927 default: |
| 2951 break; | 2928 break; |
| 2952 } | 2929 } |
| 2953 return SkToBool(w); | 2930 return SkToBool(w); |
| 2954 } | 2931 } |
| OLD | NEW |