OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
9 #include "SkTSearch.h" | 9 #include "SkTSearch.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 void SkPictureRecord::recordRestore(bool fillInSkips) { | 657 void SkPictureRecord::recordRestore(bool fillInSkips) { |
658 uint32_t initialOffset, size; | 658 uint32_t initialOffset, size; |
659 if (fillInSkips) { | 659 if (fillInSkips) { |
660 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWrite
r.bytesWritten()); | 660 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWrite
r.bytesWritten()); |
661 } | 661 } |
662 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code | 662 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code |
663 initialOffset = this->addDraw(RESTORE, &size); | 663 initialOffset = this->addDraw(RESTORE, &size); |
664 this->validate(initialOffset, size); | 664 this->validate(initialOffset, size); |
665 } | 665 } |
666 | 666 |
667 void SkPictureRecord::didTranslate(SkScalar dx, SkScalar dy) { | 667 void SkPictureRecord::recordTranslate(const SkMatrix& m) { |
668 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 668 SkASSERT(SkMatrix::kTranslate_Mask == m.getType()); |
669 fMCMgr.translate(dx, dy); | 669 |
670 #else | |
671 // op + dx + dy | 670 // op + dx + dy |
672 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); | 671 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
673 size_t initialOffset = this->addDraw(TRANSLATE, &size); | 672 size_t initialOffset = this->addDraw(TRANSLATE, &size); |
674 this->addScalar(dx); | 673 this->addScalar(m.getTranslateX()); |
675 this->addScalar(dy); | 674 this->addScalar(m.getTranslateY()); |
676 this->validate(initialOffset, size); | 675 this->validate(initialOffset, size); |
677 #endif | |
678 this->INHERITED::didTranslate(dx, dy); | |
679 } | 676 } |
680 | 677 |
681 void SkPictureRecord::didScale(SkScalar sx, SkScalar sy) { | 678 void SkPictureRecord::recordScale(const SkMatrix& m) { |
| 679 SkASSERT(SkMatrix::kScale_Mask == m.getType()); |
682 | 680 |
683 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
684 fMCMgr.scale(sx, sy); | |
685 #else | |
686 // op + sx + sy | 681 // op + sx + sy |
687 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); | 682 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
688 size_t initialOffset = this->addDraw(SCALE, &size); | 683 size_t initialOffset = this->addDraw(SCALE, &size); |
689 this->addScalar(sx); | 684 this->addScalar(m.getScaleX()); |
690 this->addScalar(sy); | 685 this->addScalar(m.getScaleY()); |
691 this->validate(initialOffset, size); | 686 this->validate(initialOffset, size); |
692 #endif | |
693 this->INHERITED::didScale(sx, sy); | |
694 } | |
695 | |
696 void SkPictureRecord::didRotate(SkScalar degrees) { | |
697 | |
698 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
699 fMCMgr.rotate(degrees); | |
700 #else | |
701 // op + degrees | |
702 uint32_t size = 1 * kUInt32Size + sizeof(SkScalar); | |
703 size_t initialOffset = this->addDraw(ROTATE, &size); | |
704 this->addScalar(degrees); | |
705 this->validate(initialOffset, size); | |
706 #endif | |
707 this->INHERITED::didRotate(degrees); | |
708 } | |
709 | |
710 void SkPictureRecord::didSkew(SkScalar sx, SkScalar sy) { | |
711 | |
712 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
713 fMCMgr.skew(sx, sy); | |
714 #else | |
715 // op + sx + sy | |
716 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); | |
717 size_t initialOffset = this->addDraw(SKEW, &size); | |
718 this->addScalar(sx); | |
719 this->addScalar(sy); | |
720 this->validate(initialOffset, size); | |
721 #endif | |
722 this->INHERITED::didSkew(sx, sy); | |
723 } | 687 } |
724 | 688 |
725 void SkPictureRecord::didConcat(const SkMatrix& matrix) { | 689 void SkPictureRecord::didConcat(const SkMatrix& matrix) { |
726 | 690 |
727 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 691 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
728 fMCMgr.concat(matrix); | 692 fMCMgr.concat(matrix); |
729 #else | 693 #else |
730 this->recordConcat(matrix); | 694 switch (matrix.getType()) { |
| 695 case SkMatrix::kTranslate_Mask: |
| 696 this->recordTranslate(matrix); |
| 697 break; |
| 698 case SkMatrix::kScale_Mask: |
| 699 this->recordScale(matrix); |
| 700 break; |
| 701 default: |
| 702 this->recordConcat(matrix); |
| 703 break; |
| 704 } |
731 #endif | 705 #endif |
732 this->INHERITED::didConcat(matrix); | 706 this->INHERITED::didConcat(matrix); |
733 } | 707 } |
734 | 708 |
735 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { | 709 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { |
736 this->validate(fWriter.bytesWritten(), 0); | 710 this->validate(fWriter.bytesWritten(), 0); |
737 // op + matrix | 711 // op + matrix |
738 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL); | 712 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL); |
739 size_t initialOffset = this->addDraw(CONCAT, &size); | 713 size_t initialOffset = this->addDraw(CONCAT, &size); |
740 this->addMatrix(matrix); | 714 this->addMatrix(matrix); |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 void SkPictureRecord::validateRegions() const { | 1841 void SkPictureRecord::validateRegions() const { |
1868 int count = fRegions.count(); | 1842 int count = fRegions.count(); |
1869 SkASSERT((unsigned) count < 0x1000); | 1843 SkASSERT((unsigned) count < 0x1000); |
1870 for (int index = 0; index < count; index++) { | 1844 for (int index = 0; index < count; index++) { |
1871 const SkFlatData* region = fRegions[index]; | 1845 const SkFlatData* region = fRegions[index]; |
1872 SkASSERT(region); | 1846 SkASSERT(region); |
1873 // region->validate(); | 1847 // region->validate(); |
1874 } | 1848 } |
1875 } | 1849 } |
1876 #endif | 1850 #endif |
OLD | NEW |