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 "SkOnce.h" | 9 #include "SkOnce.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 SkDEBUGCODE(src.validate();) | 55 SkDEBUGCODE(src.validate();) |
56 if (matrix.isIdentity()) { | 56 if (matrix.isIdentity()) { |
57 if (*dst != &src) { | 57 if (*dst != &src) { |
58 src.ref(); | 58 src.ref(); |
59 dst->reset(const_cast<SkPathRef*>(&src)); | 59 dst->reset(const_cast<SkPathRef*>(&src)); |
60 SkDEBUGCODE((*dst)->validate();) | 60 SkDEBUGCODE((*dst)->validate();) |
61 } | 61 } |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 bool dstUnique = (*dst)->unique(); | 65 if (!(*dst)->unique()) { |
66 if (!dstUnique) { | |
67 dst->reset(SkNEW(SkPathRef)); | 66 dst->reset(SkNEW(SkPathRef)); |
| 67 } |
| 68 |
| 69 if (*dst != &src) { |
68 (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count
()); | 70 (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count
()); |
69 memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), src.fVerbCnt * s
izeof(uint8_t)); | 71 memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), src.fVerbCnt * s
izeof(uint8_t)); |
70 (*dst)->fConicWeights = src.fConicWeights; | 72 (*dst)->fConicWeights = src.fConicWeights; |
71 } | 73 } |
72 | 74 |
| 75 SkASSERT((*dst)->countPoints() == src.countPoints()); |
| 76 SkASSERT((*dst)->countVerbs() == src.countVerbs()); |
| 77 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count()); |
| 78 |
73 // Need to check this here in case (&src == dst) | 79 // Need to check this here in case (&src == dst) |
74 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; | 80 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.c
ountPoints() > 1; |
75 | 81 |
76 matrix.mapPoints((*dst)->fPoints, src.points(), src.fPointCnt); | 82 matrix.mapPoints((*dst)->fPoints, src.points(), src.fPointCnt); |
77 | 83 |
78 /* | 84 /* |
79 * Here we optimize the bounds computation, by noting if the bounds are | 85 * Here we optimize the bounds computation, by noting if the bounds are |
80 * already known, and if so, we just transform those as well and mark | 86 * already known, and if so, we just transform those as well and mark |
81 * them as "known", rather than force the transformed path to have to | 87 * them as "known", rather than force the transformed path to have to |
82 * recompute them. | 88 * recompute them. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 fBounds.fTop - fPoints[i].fY < SK_ScalarNearlyZero && | 347 fBounds.fTop - fPoints[i].fY < SK_ScalarNearlyZero && |
342 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero)); | 348 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero)); |
343 if (!fPoints[i].isFinite()) { | 349 if (!fPoints[i].isFinite()) { |
344 isFinite = false; | 350 isFinite = false; |
345 } | 351 } |
346 } | 352 } |
347 SkASSERT(SkToBool(fIsFinite) == isFinite); | 353 SkASSERT(SkToBool(fIsFinite) == isFinite); |
348 } | 354 } |
349 } | 355 } |
350 #endif | 356 #endif |
OLD | NEW |