Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 195793012: De-virtualize SkCanvas matrix ops. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool SkPictureRecord::translate(SkScalar dx, SkScalar dy) { 667 void SkPictureRecord::didTranslate(SkScalar dx, SkScalar dy) {
668 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 668 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
669 fMCMgr.translate(dx, dy); 669 fMCMgr.translate(dx, dy);
670 #else 670 #else
671 // op + dx + dy 671 // op + dx + dy
672 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); 672 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
673 size_t initialOffset = this->addDraw(TRANSLATE, &size); 673 size_t initialOffset = this->addDraw(TRANSLATE, &size);
674 this->addScalar(dx); 674 this->addScalar(dx);
675 this->addScalar(dy); 675 this->addScalar(dy);
676 this->validate(initialOffset, size); 676 this->validate(initialOffset, size);
677 #endif 677 #endif
678 return this->INHERITED::translate(dx, dy); 678 this->INHERITED::didTranslate(dx, dy);
679 } 679 }
680 680
681 bool SkPictureRecord::scale(SkScalar sx, SkScalar sy) { 681 void SkPictureRecord::didScale(SkScalar sx, SkScalar sy) {
682 682
683 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 683 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
684 fMCMgr.scale(sx, sy); 684 fMCMgr.scale(sx, sy);
685 #else 685 #else
686 // op + sx + sy 686 // op + sx + sy
687 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); 687 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
688 size_t initialOffset = this->addDraw(SCALE, &size); 688 size_t initialOffset = this->addDraw(SCALE, &size);
689 this->addScalar(sx); 689 this->addScalar(sx);
690 this->addScalar(sy); 690 this->addScalar(sy);
691 this->validate(initialOffset, size); 691 this->validate(initialOffset, size);
692 #endif 692 #endif
693 return this->INHERITED::scale(sx, sy); 693 this->INHERITED::didScale(sx, sy);
694 } 694 }
695 695
696 bool SkPictureRecord::rotate(SkScalar degrees) { 696 void SkPictureRecord::didRotate(SkScalar degrees) {
697 697
698 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 698 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
699 fMCMgr.rotate(degrees); 699 fMCMgr.rotate(degrees);
700 #else 700 #else
701 // op + degrees 701 // op + degrees
702 uint32_t size = 1 * kUInt32Size + sizeof(SkScalar); 702 uint32_t size = 1 * kUInt32Size + sizeof(SkScalar);
703 size_t initialOffset = this->addDraw(ROTATE, &size); 703 size_t initialOffset = this->addDraw(ROTATE, &size);
704 this->addScalar(degrees); 704 this->addScalar(degrees);
705 this->validate(initialOffset, size); 705 this->validate(initialOffset, size);
706 #endif 706 #endif
707 return this->INHERITED::rotate(degrees); 707 this->INHERITED::didRotate(degrees);
708 } 708 }
709 709
710 bool SkPictureRecord::skew(SkScalar sx, SkScalar sy) { 710 void SkPictureRecord::didSkew(SkScalar sx, SkScalar sy) {
711 711
712 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 712 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
713 fMCMgr.skew(sx, sy); 713 fMCMgr.skew(sx, sy);
714 #else 714 #else
715 // op + sx + sy 715 // op + sx + sy
716 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); 716 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
717 size_t initialOffset = this->addDraw(SKEW, &size); 717 size_t initialOffset = this->addDraw(SKEW, &size);
718 this->addScalar(sx); 718 this->addScalar(sx);
719 this->addScalar(sy); 719 this->addScalar(sy);
720 this->validate(initialOffset, size); 720 this->validate(initialOffset, size);
721 #endif 721 #endif
722 return this->INHERITED::skew(sx, sy); 722 this->INHERITED::didSkew(sx, sy);
723 } 723 }
724 724
725 bool SkPictureRecord::concat(const SkMatrix& matrix) { 725 void SkPictureRecord::didConcat(const SkMatrix& matrix) {
726 726
727 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 727 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
728 fMCMgr.concat(matrix); 728 fMCMgr.concat(matrix);
729 #else 729 #else
730 this->recordConcat(matrix); 730 this->recordConcat(matrix);
731 #endif 731 #endif
732 return this->INHERITED::concat(matrix); 732 this->INHERITED::didConcat(matrix);
733 } 733 }
734 734
735 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { 735 void SkPictureRecord::recordConcat(const SkMatrix& matrix) {
736 this->validate(fWriter.bytesWritten(), 0); 736 this->validate(fWriter.bytesWritten(), 0);
737 // op + matrix 737 // op + matrix
738 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL); 738 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL);
739 size_t initialOffset = this->addDraw(CONCAT, &size); 739 size_t initialOffset = this->addDraw(CONCAT, &size);
740 this->addMatrix(matrix); 740 this->addMatrix(matrix);
741 this->validate(initialOffset, size); 741 this->validate(initialOffset, size);
742 } 742 }
743 743
744 void SkPictureRecord::setMatrix(const SkMatrix& matrix) { 744 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) {
745 745
746 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 746 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
747 fMCMgr.setMatrix(matrix); 747 fMCMgr.setMatrix(matrix);
748 #else 748 #else
749 this->validate(fWriter.bytesWritten(), 0); 749 this->validate(fWriter.bytesWritten(), 0);
750 // op + matrix 750 // op + matrix
751 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL); 751 uint32_t size = kUInt32Size + matrix.writeToMemory(NULL);
752 size_t initialOffset = this->addDraw(SET_MATRIX, &size); 752 size_t initialOffset = this->addDraw(SET_MATRIX, &size);
753 this->addMatrix(matrix); 753 this->addMatrix(matrix);
754 this->validate(initialOffset, size); 754 this->validate(initialOffset, size);
755 #endif 755 #endif
756 this->INHERITED::setMatrix(matrix); 756 this->INHERITED::didSetMatrix(matrix);
757 } 757 }
758 758
759 static bool regionOpExpands(SkRegion::Op op) { 759 static bool regionOpExpands(SkRegion::Op op) {
760 switch (op) { 760 switch (op) {
761 case SkRegion::kUnion_Op: 761 case SkRegion::kUnion_Op:
762 case SkRegion::kXOR_Op: 762 case SkRegion::kXOR_Op:
763 case SkRegion::kReverseDifference_Op: 763 case SkRegion::kReverseDifference_Op:
764 case SkRegion::kReplace_Op: 764 case SkRegion::kReplace_Op:
765 return true; 765 return true;
766 case SkRegion::kIntersect_Op: 766 case SkRegion::kIntersect_Op:
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 void SkPictureRecord::validateRegions() const { 1884 void SkPictureRecord::validateRegions() const {
1885 int count = fRegions.count(); 1885 int count = fRegions.count();
1886 SkASSERT((unsigned) count < 0x1000); 1886 SkASSERT((unsigned) count < 0x1000);
1887 for (int index = 0; index < count; index++) { 1887 for (int index = 0; index < count; index++) {
1888 const SkFlatData* region = fRegions[index]; 1888 const SkFlatData* region = fRegions[index];
1889 SkASSERT(region); 1889 SkASSERT(region);
1890 // region->validate(); 1890 // region->validate();
1891 } 1891 }
1892 } 1892 }
1893 #endif 1893 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698