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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 prevOffset = 0; | 829 prevOffset = 0; |
830 } | 830 } |
831 | 831 |
832 size_t offset = fWriter.bytesWritten(); | 832 size_t offset = fWriter.bytesWritten(); |
833 this->addInt(prevOffset); | 833 this->addInt(prevOffset); |
834 fRestoreOffsetStack.top() = offset; | 834 fRestoreOffsetStack.top() = offset; |
835 return offset; | 835 return offset; |
836 } | 836 } |
837 #endif | 837 #endif |
838 | 838 |
839 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 839 void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { |
840 | 840 |
841 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 841 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
842 fMCMgr.clipRect(rect, op, doAA); | 842 fMCMgr.clipRect(rect, op, doAA); |
843 #else | 843 #else |
844 this->recordClipRect(rect, op, doAA); | 844 this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
845 #endif | 845 #endif |
846 return this->INHERITED::clipRect(rect, op, doAA); | 846 this->INHERITED::onClipRect(rect, op, edgeStyle); |
847 } | 847 } |
848 | 848 |
849 int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool do
AA) { | 849 int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool do
AA) { |
850 // id + rect + clip params | 850 // id + rect + clip params |
851 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; | 851 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; |
852 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 852 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
853 size += kUInt32Size; // + restore offset | 853 size += kUInt32Size; // + restore offset |
854 #else | 854 #else |
855 // recordRestoreOffsetPlaceholder doesn't always write an offset | 855 // recordRestoreOffsetPlaceholder doesn't always write an offset |
856 if (!fRestoreOffsetStack.isEmpty()) { | 856 if (!fRestoreOffsetStack.isEmpty()) { |
857 // + restore offset | 857 // + restore offset |
858 size += kUInt32Size; | 858 size += kUInt32Size; |
859 } | 859 } |
860 #endif | 860 #endif |
861 size_t initialOffset = this->addDraw(CLIP_RECT, &size); | 861 size_t initialOffset = this->addDraw(CLIP_RECT, &size); |
862 this->addRect(rect); | 862 this->addRect(rect); |
863 this->addInt(ClipParams_pack(op, doAA)); | 863 this->addInt(ClipParams_pack(op, doAA)); |
864 int offset = this->recordRestoreOffsetPlaceholder(op); | 864 int offset = this->recordRestoreOffsetPlaceholder(op); |
865 | 865 |
866 this->validate(initialOffset, size); | 866 this->validate(initialOffset, size); |
867 return offset; | 867 return offset; |
868 } | 868 } |
869 | 869 |
870 bool SkPictureRecord::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA
) { | 870 void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdg
eStyle edgeStyle) { |
871 if (rrect.isRect()) { | |
872 return this->SkPictureRecord::clipRect(rrect.getBounds(), op, doAA); | |
873 } | |
874 | 871 |
875 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 872 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
876 fMCMgr.clipRRect(rrect, op, doAA); | 873 fMCMgr.clipRRect(rrect, op, doAA); |
877 #else | 874 #else |
878 this->recordClipRRect(rrect, op, doAA); | 875 this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
879 #endif | 876 #endif |
880 if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { | 877 if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { |
881 return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op,
false); | 878 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); |
882 } else { | 879 } else { |
883 return this->INHERITED::clipRRect(rrect, op, doAA); | 880 this->INHERITED::onClipRRect(rrect, op, edgeStyle); |
884 } | 881 } |
885 } | 882 } |
886 | 883 |
887 int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool
doAA) { | 884 int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool
doAA) { |
888 // op + rrect + clip params | 885 // op + rrect + clip params |
889 uint32_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size; | 886 uint32_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size; |
890 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 887 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
891 size += kUInt32Size; // + restore offset | 888 size += kUInt32Size; // + restore offset |
892 #else | 889 #else |
893 // recordRestoreOffsetPlaceholder doesn't always write an offset | 890 // recordRestoreOffsetPlaceholder doesn't always write an offset |
894 if (!fRestoreOffsetStack.isEmpty()) { | 891 if (!fRestoreOffsetStack.isEmpty()) { |
895 // + restore offset | 892 // + restore offset |
896 size += kUInt32Size; | 893 size += kUInt32Size; |
897 } | 894 } |
898 #endif | 895 #endif |
899 size_t initialOffset = this->addDraw(CLIP_RRECT, &size); | 896 size_t initialOffset = this->addDraw(CLIP_RRECT, &size); |
900 this->addRRect(rrect); | 897 this->addRRect(rrect); |
901 this->addInt(ClipParams_pack(op, doAA)); | 898 this->addInt(ClipParams_pack(op, doAA)); |
902 int offset = recordRestoreOffsetPlaceholder(op); | 899 int offset = recordRestoreOffsetPlaceholder(op); |
903 this->validate(initialOffset, size); | 900 this->validate(initialOffset, size); |
904 return offset; | 901 return offset; |
905 } | 902 } |
906 | 903 |
907 bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { | 904 void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { |
908 | |
909 SkRect r; | |
910 if (!path.isInverseFillType() && path.isRect(&r)) { | |
911 return this->clipRect(r, op, doAA); | |
912 } | |
913 | 905 |
914 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 906 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
915 fMCMgr.clipPath(path, op, doAA); | 907 fMCMgr.clipPath(path, op, doAA); |
916 #else | 908 #else |
917 int pathID = this->addPathToHeap(path); | 909 int pathID = this->addPathToHeap(path); |
918 this->recordClipPath(pathID, op, doAA); | 910 this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle); |
919 #endif | 911 #endif |
920 | 912 |
921 if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { | 913 if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { |
922 return this->updateClipConservativelyUsingBounds(path.getBounds(), op, | 914 this->updateClipConservativelyUsingBounds(path.getBounds(), op, |
923 path.isInverseFillType(
)); | 915 path.isInverseFillType()); |
924 } else { | 916 } else { |
925 return this->INHERITED::clipPath(path, op, doAA); | 917 this->INHERITED::onClipPath(path, op, edgeStyle); |
926 } | 918 } |
927 } | 919 } |
928 | 920 |
929 int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) { | 921 int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) { |
930 // op + path index + clip params | 922 // op + path index + clip params |
931 uint32_t size = 3 * kUInt32Size; | 923 uint32_t size = 3 * kUInt32Size; |
932 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 924 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
933 size += kUInt32Size; // + restore offset | 925 size += kUInt32Size; // + restore offset |
934 #else | 926 #else |
935 // recordRestoreOffsetPlaceholder doesn't always write an offset | 927 // recordRestoreOffsetPlaceholder doesn't always write an offset |
936 if (!fRestoreOffsetStack.isEmpty()) { | 928 if (!fRestoreOffsetStack.isEmpty()) { |
937 // + restore offset | 929 // + restore offset |
938 size += kUInt32Size; | 930 size += kUInt32Size; |
939 } | 931 } |
940 #endif | 932 #endif |
941 size_t initialOffset = this->addDraw(CLIP_PATH, &size); | 933 size_t initialOffset = this->addDraw(CLIP_PATH, &size); |
942 this->addInt(pathID); | 934 this->addInt(pathID); |
943 this->addInt(ClipParams_pack(op, doAA)); | 935 this->addInt(ClipParams_pack(op, doAA)); |
944 int offset = recordRestoreOffsetPlaceholder(op); | 936 int offset = recordRestoreOffsetPlaceholder(op); |
945 this->validate(initialOffset, size); | 937 this->validate(initialOffset, size); |
946 return offset; | 938 return offset; |
947 } | 939 } |
948 | 940 |
949 bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) { | 941 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) { |
950 | 942 |
951 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 943 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
952 fMCMgr.clipRegion(region, op); | 944 fMCMgr.clipRegion(region, op); |
953 #else | 945 #else |
954 this->recordClipRegion(region, op); | 946 this->recordClipRegion(region, op); |
955 #endif | 947 #endif |
956 return this->INHERITED::clipRegion(region, op); | 948 this->INHERITED::onClipRegion(region, op); |
957 } | 949 } |
958 | 950 |
959 int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) { | 951 int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) { |
960 // op + clip params + region | 952 // op + clip params + region |
961 uint32_t size = 2 * kUInt32Size + region.writeToMemory(NULL); | 953 uint32_t size = 2 * kUInt32Size + region.writeToMemory(NULL); |
962 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 954 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
963 size += kUInt32Size; // + restore offset | 955 size += kUInt32Size; // + restore offset |
964 #else | 956 #else |
965 // recordRestoreOffsetPlaceholder doesn't always write an offset | 957 // recordRestoreOffsetPlaceholder doesn't always write an offset |
966 if (!fRestoreOffsetStack.isEmpty()) { | 958 if (!fRestoreOffsetStack.isEmpty()) { |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 void SkPictureRecord::validateRegions() const { | 1788 void SkPictureRecord::validateRegions() const { |
1797 int count = fRegions.count(); | 1789 int count = fRegions.count(); |
1798 SkASSERT((unsigned) count < 0x1000); | 1790 SkASSERT((unsigned) count < 0x1000); |
1799 for (int index = 0; index < count; index++) { | 1791 for (int index = 0; index < count; index++) { |
1800 const SkFlatData* region = fRegions[index]; | 1792 const SkFlatData* region = fRegions[index]; |
1801 SkASSERT(region); | 1793 SkASSERT(region); |
1802 // region->validate(); | 1794 // region->validate(); |
1803 } | 1795 } |
1804 } | 1796 } |
1805 #endif | 1797 #endif |
OLD | NEW |