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