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 "SkLazyPtr.h" | 9 #include "SkLazyPtr.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 * them as "known", rather than force the transformed path to have to | 80 * them as "known", rather than force the transformed path to have to |
81 * recompute them. | 81 * recompute them. |
82 * | 82 * |
83 * Special gotchas if the path is effectively empty (<= 1 point) or | 83 * Special gotchas if the path is effectively empty (<= 1 point) or |
84 * if it is non-finite. In those cases bounds need to stay empty, | 84 * if it is non-finite. In those cases bounds need to stay empty, |
85 * regardless of the matrix. | 85 * regardless of the matrix. |
86 */ | 86 */ |
87 if (canXformBounds) { | 87 if (canXformBounds) { |
88 (*dst)->fBoundsIsDirty = false; | 88 (*dst)->fBoundsIsDirty = false; |
89 if (src.fIsFinite) { | 89 if (src.fIsFinite) { |
90 matrix.mapRect((*dst)->fBounds.get(), src.fBounds); | 90 matrix.mapRect(&(*dst)->fBounds, src.fBounds); |
91 if (!((*dst)->fIsFinite = (*dst)->fBounds->isFinite())) { | 91 if (!((*dst)->fIsFinite = (*dst)->fBounds.isFinite())) { |
92 (*dst)->fBounds->setEmpty(); | 92 (*dst)->fBounds.setEmpty(); |
93 } | 93 } |
94 } else { | 94 } else { |
95 (*dst)->fIsFinite = false; | 95 (*dst)->fIsFinite = false; |
96 (*dst)->fBounds->setEmpty(); | 96 (*dst)->fBounds.setEmpty(); |
97 } | 97 } |
98 } else { | 98 } else { |
99 (*dst)->fBoundsIsDirty = true; | 99 (*dst)->fBoundsIsDirty = true; |
100 } | 100 } |
101 | 101 |
102 (*dst)->fSegmentMask = src.fSegmentMask; | 102 (*dst)->fSegmentMask = src.fSegmentMask; |
103 | 103 |
104 // It's an oval only if it stays a rect. | 104 // It's an oval only if it stays a rect. |
105 (*dst)->fIsOval = src.fIsOval && matrix.rectStaysRect(); | 105 (*dst)->fIsOval = src.fIsOval && matrix.rectStaysRect(); |
106 | 106 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); | 442 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); |
443 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo
ints) >= 0); | 443 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo
ints) >= 0); |
444 SkASSERT((NULL == fPoints) == (NULL == fVerbs)); | 444 SkASSERT((NULL == fPoints) == (NULL == fVerbs)); |
445 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); | 445 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); |
446 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); | 446 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); |
447 SkASSERT(!(NULL == fPoints && fPointCnt)); | 447 SkASSERT(!(NULL == fPoints && fPointCnt)); |
448 SkASSERT(!(NULL == fVerbs && fVerbCnt)); | 448 SkASSERT(!(NULL == fVerbs && fVerbCnt)); |
449 SkASSERT(this->currSize() == | 449 SkASSERT(this->currSize() == |
450 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe
rbCnt); | 450 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe
rbCnt); |
451 | 451 |
452 if (!fBoundsIsDirty && !fBounds->isEmpty()) { | 452 if (!fBoundsIsDirty && !fBounds.isEmpty()) { |
453 bool isFinite = true; | 453 bool isFinite = true; |
454 for (int i = 0; i < fPointCnt; ++i) { | 454 for (int i = 0; i < fPointCnt; ++i) { |
455 SkASSERT(!fPoints[i].isFinite() || ( | 455 SkASSERT(!fPoints[i].isFinite() || ( |
456 fBounds->fLeft - fPoints[i].fX < SK_ScalarNearlyZero && | 456 fBounds.fLeft - fPoints[i].fX < SK_ScalarNearlyZero && |
457 fPoints[i].fX - fBounds->fRight < SK_ScalarNearlyZero && | 457 fPoints[i].fX - fBounds.fRight < SK_ScalarNearlyZero && |
458 fBounds->fTop - fPoints[i].fY < SK_ScalarNearlyZero && | 458 fBounds.fTop - fPoints[i].fY < SK_ScalarNearlyZero && |
459 fPoints[i].fY - fBounds->fBottom < SK_ScalarNearlyZero)); | 459 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero)); |
460 if (!fPoints[i].isFinite()) { | 460 if (!fPoints[i].isFinite()) { |
461 isFinite = false; | 461 isFinite = false; |
462 } | 462 } |
463 } | 463 } |
464 SkASSERT(SkToBool(fIsFinite) == isFinite); | 464 SkASSERT(SkToBool(fIsFinite) == isFinite); |
465 } | 465 } |
466 | 466 |
467 #ifdef SK_DEBUG_PATH | 467 #ifdef SK_DEBUG_PATH |
468 uint32_t mask = 0; | 468 uint32_t mask = 0; |
469 for (int i = 0; i < fVerbCnt; ++i) { | 469 for (int i = 0; i < fVerbCnt; ++i) { |
(...skipping 19 matching lines...) Expand all Loading... |
489 break; | 489 break; |
490 default: | 490 default: |
491 SkDEBUGFAIL("Unknown Verb"); | 491 SkDEBUGFAIL("Unknown Verb"); |
492 break; | 492 break; |
493 } | 493 } |
494 } | 494 } |
495 SkASSERT(mask == fSegmentMask); | 495 SkASSERT(mask == fSegmentMask); |
496 #endif // SK_DEBUG_PATH | 496 #endif // SK_DEBUG_PATH |
497 } | 497 } |
498 #endif | 498 #endif |
OLD | NEW |