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 sk_careful_memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), |
| 76 src.fVerbCnt * sizeof(uint8_t)); |
76 (*dst)->fConicWeights = src.fConicWeights; | 77 (*dst)->fConicWeights = src.fConicWeights; |
77 } | 78 } |
78 | 79 |
79 SkASSERT((*dst)->countPoints() == src.countPoints()); | 80 SkASSERT((*dst)->countPoints() == src.countPoints()); |
80 SkASSERT((*dst)->countVerbs() == src.countVerbs()); | 81 SkASSERT((*dst)->countVerbs() == src.countVerbs()); |
81 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); | 82 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); |
82 | 83 |
83 // Need to check this here in case (&src == dst) | 84 // Need to check this here in case (&src == dst) |
84 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; | 85 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; |
85 | 86 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 fConicWeights.bytes() + | 269 fConicWeights.bytes() + |
269 sizeof(SkRect)); | 270 sizeof(SkRect)); |
270 } | 271 } |
271 | 272 |
272 void SkPathRef::copy(const SkPathRef& ref, | 273 void SkPathRef::copy(const SkPathRef& ref, |
273 int additionalReserveVerbs, | 274 int additionalReserveVerbs, |
274 int additionalReservePoints) { | 275 int additionalReservePoints) { |
275 SkDEBUGCODE(this->validate();) | 276 SkDEBUGCODE(this->validate();) |
276 this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), | 277 this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), |
277 additionalReserveVerbs, additionalReservePoints); | 278 additionalReserveVerbs, additionalReservePoints); |
278 memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * sizeof(
uint8_t)); | 279 sk_careful_memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCn
t*sizeof(uint8_t)); |
279 memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint)); | 280 sk_careful_memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint
)); |
280 fConicWeights = ref.fConicWeights; | 281 fConicWeights = ref.fConicWeights; |
281 fBoundsIsDirty = ref.fBoundsIsDirty; | 282 fBoundsIsDirty = ref.fBoundsIsDirty; |
282 if (!fBoundsIsDirty) { | 283 if (!fBoundsIsDirty) { |
283 fBounds = ref.fBounds; | 284 fBounds = ref.fBounds; |
284 fIsFinite = ref.fIsFinite; | 285 fIsFinite = ref.fIsFinite; |
285 } | 286 } |
286 fSegmentMask = ref.fSegmentMask; | 287 fSegmentMask = ref.fSegmentMask; |
287 fIsOval = ref.fIsOval; | 288 fIsOval = ref.fIsOval; |
288 fIsRRect = ref.fIsRRect; | 289 fIsRRect = ref.fIsRRect; |
289 SkDEBUGCODE(this->validate();) | 290 SkDEBUGCODE(this->validate();) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 break; | 640 break; |
640 default: | 641 default: |
641 SkDEBUGFAIL("Unknown Verb"); | 642 SkDEBUGFAIL("Unknown Verb"); |
642 break; | 643 break; |
643 } | 644 } |
644 } | 645 } |
645 SkASSERT(mask == fSegmentMask); | 646 SkASSERT(mask == fSegmentMask); |
646 #endif // SK_DEBUG_PATH | 647 #endif // SK_DEBUG_PATH |
647 } | 648 } |
648 #endif | 649 #endif |
OLD | NEW |