OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
8 #include "SkBuffer.h" | 8 #include "SkBuffer.h" |
9 #include "SkOncePtr.h" | 9 #include "SkOncePtr.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 if (!(*dst)->unique()) { | 69 if (!(*dst)->unique()) { |
70 dst->reset(new SkPathRef); | 70 dst->reset(new SkPathRef); |
71 } | 71 } |
72 | 72 |
73 if (*dst != &src) { | 73 if (*dst != &src) { |
74 (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count
()); | 74 (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count
()); |
75 memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), src.fVerbCnt * s
izeof(uint8_t)); | 75 if (src.verbsMemBegin()) { |
| 76 memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), src.fVerbCnt
* sizeof(uint8_t)); |
| 77 } |
76 (*dst)->fConicWeights = src.fConicWeights; | 78 (*dst)->fConicWeights = src.fConicWeights; |
77 } | 79 } |
78 | 80 |
79 SkASSERT((*dst)->countPoints() == src.countPoints()); | 81 SkASSERT((*dst)->countPoints() == src.countPoints()); |
80 SkASSERT((*dst)->countVerbs() == src.countVerbs()); | 82 SkASSERT((*dst)->countVerbs() == src.countVerbs()); |
81 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); | 83 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); |
82 | 84 |
83 // Need to check this here in case (&src == dst) | 85 // Need to check this here in case (&src == dst) |
84 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; | 86 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; |
85 | 87 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 fConicWeights.bytes() + | 270 fConicWeights.bytes() + |
269 sizeof(SkRect)); | 271 sizeof(SkRect)); |
270 } | 272 } |
271 | 273 |
272 void SkPathRef::copy(const SkPathRef& ref, | 274 void SkPathRef::copy(const SkPathRef& ref, |
273 int additionalReserveVerbs, | 275 int additionalReserveVerbs, |
274 int additionalReservePoints) { | 276 int additionalReservePoints) { |
275 SkDEBUGCODE(this->validate();) | 277 SkDEBUGCODE(this->validate();) |
276 this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), | 278 this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), |
277 additionalReserveVerbs, additionalReservePoints); | 279 additionalReserveVerbs, additionalReservePoints); |
278 memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * sizeof(
uint8_t)); | 280 if (ref.verbsMemBegin()) { |
279 memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint)); | 281 memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * siz
eof(uint8_t)); |
| 282 } |
| 283 if (ref.fPoints) { |
| 284 memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint)); |
| 285 } |
280 fConicWeights = ref.fConicWeights; | 286 fConicWeights = ref.fConicWeights; |
281 fBoundsIsDirty = ref.fBoundsIsDirty; | 287 fBoundsIsDirty = ref.fBoundsIsDirty; |
282 if (!fBoundsIsDirty) { | 288 if (!fBoundsIsDirty) { |
283 fBounds = ref.fBounds; | 289 fBounds = ref.fBounds; |
284 fIsFinite = ref.fIsFinite; | 290 fIsFinite = ref.fIsFinite; |
285 } | 291 } |
286 fSegmentMask = ref.fSegmentMask; | 292 fSegmentMask = ref.fSegmentMask; |
287 fIsOval = ref.fIsOval; | 293 fIsOval = ref.fIsOval; |
288 fIsRRect = ref.fIsRRect; | 294 fIsRRect = ref.fIsRRect; |
289 SkDEBUGCODE(this->validate();) | 295 SkDEBUGCODE(this->validate();) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 break; | 645 break; |
640 default: | 646 default: |
641 SkDEBUGFAIL("Unknown Verb"); | 647 SkDEBUGFAIL("Unknown Verb"); |
642 break; | 648 break; |
643 } | 649 } |
644 } | 650 } |
645 SkASSERT(mask == fSegmentMask); | 651 SkASSERT(mask == fSegmentMask); |
646 #endif // SK_DEBUG_PATH | 652 #endif // SK_DEBUG_PATH |
647 } | 653 } |
648 #endif | 654 #endif |
OLD | NEW |