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 #ifndef GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
11 #include "GrBackendEffectFactory.h" | 11 #include "GrBackendEffectFactory.h" |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
13 #include "GrColor.h" | 13 #include "GrColor.h" |
14 #include "GrEffectStage.h" | 14 #include "GrEffectStage.h" |
15 #include "GrPaint.h" | 15 #include "GrPaint.h" |
16 #include "GrPoint.h" | 16 #include "GrPoint.h" |
17 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
18 #include "GrStencil.h" | 18 #include "GrStencil.h" |
19 #include "GrTemplates.h" | 19 #include "GrTemplates.h" |
20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
21 #include "GrTypesPriv.h" | 21 #include "GrTypesPriv.h" |
22 #include "effects/GrSimpleTextureEffect.h" | 22 #include "effects/GrSimpleTextureEffect.h" |
23 | 23 |
24 #include "SkMatrix.h" | 24 #include "SkMatrix.h" |
25 #include "SkPath.h" | |
25 #include "SkXfermode.h" | 26 #include "SkXfermode.h" |
26 | 27 |
27 class GrDrawState : public SkRefCnt { | 28 class GrDrawState : public SkRefCnt { |
28 public: | 29 public: |
29 SK_DECLARE_INST_COUNT(GrDrawState) | 30 SK_DECLARE_INST_COUNT(GrDrawState) |
30 | 31 |
31 GrDrawState() { | 32 GrDrawState() { |
32 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 33 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
33 this->reset(); | 34 this->reset(); |
34 } | 35 } |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 * Shortcut to disable stencil testing and ops. | 715 * Shortcut to disable stencil testing and ops. |
715 */ | 716 */ |
716 void disableStencil() { | 717 void disableStencil() { |
717 fCommon.fStencilSettings.setDisabled(); | 718 fCommon.fStencilSettings.setDisabled(); |
718 } | 719 } |
719 | 720 |
720 const GrStencilSettings& getStencil() const { return fCommon.fStencilSetting s; } | 721 const GrStencilSettings& getStencil() const { return fCommon.fStencilSetting s; } |
721 | 722 |
722 GrStencilSettings* stencil() { return &fCommon.fStencilSettings; } | 723 GrStencilSettings* stencil() { return &fCommon.fStencilSettings; } |
723 | 724 |
725 void setPathStencilFillType(SkPath::FillType fill) { | |
726 fCommon.fPathStencilFillType = fill; | |
727 } | |
728 | |
729 SkPath::FillType getPathStencilFillType() const { | |
730 return fCommon.fPathStencilFillType; | |
731 } | |
732 | |
733 SkPath::FillType* pathStencilFillType() { | |
bsalomon
2013/09/18 14:24:22
Is this really needed? Skia very rarely returns po
| |
734 return &fCommon.fPathStencilFillType; | |
735 } | |
736 | |
737 | |
724 /// @} | 738 /// @} |
725 | 739 |
726 /////////////////////////////////////////////////////////////////////////// | 740 /////////////////////////////////////////////////////////////////////////// |
727 /// @name State Flags | 741 /// @name State Flags |
728 //// | 742 //// |
729 | 743 |
730 /** | 744 /** |
731 * Flags that affect rendering. Controlled using enable/disableState(). All | 745 * Flags that affect rendering. Controlled using enable/disableState(). All |
732 * default to disabled. | 746 * default to disabled. |
733 */ | 747 */ |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 if (NULL == initialViewMatrix) { | 920 if (NULL == initialViewMatrix) { |
907 fCommon.fViewMatrix.reset(); | 921 fCommon.fViewMatrix.reset(); |
908 } else { | 922 } else { |
909 fCommon.fViewMatrix = *initialViewMatrix; | 923 fCommon.fViewMatrix = *initialViewMatrix; |
910 } | 924 } |
911 fCommon.fSrcBlend = kOne_GrBlendCoeff; | 925 fCommon.fSrcBlend = kOne_GrBlendCoeff; |
912 fCommon.fDstBlend = kZero_GrBlendCoeff; | 926 fCommon.fDstBlend = kZero_GrBlendCoeff; |
913 fCommon.fBlendConstant = 0x0; | 927 fCommon.fBlendConstant = 0x0; |
914 fCommon.fFlagBits = 0x0; | 928 fCommon.fFlagBits = 0x0; |
915 fCommon.fStencilSettings.setDisabled(); | 929 fCommon.fStencilSettings.setDisabled(); |
930 fCommon.fPathStencilFillType = SkPath::kWinding_FillType; | |
916 fCommon.fCoverage = 0xffffffff; | 931 fCommon.fCoverage = 0xffffffff; |
917 fCommon.fColorFilterMode = SkXfermode::kDst_Mode; | 932 fCommon.fColorFilterMode = SkXfermode::kDst_Mode; |
918 fCommon.fColorFilterColor = 0x0; | 933 fCommon.fColorFilterColor = 0x0; |
919 fCommon.fDrawFace = kBoth_DrawFace; | 934 fCommon.fDrawFace = kBoth_DrawFace; |
920 } | 935 } |
921 | 936 |
922 /** Fields that are identical in GrDrawState and GrDrawState::DeferredState. */ | 937 /** Fields that are identical in GrDrawState and GrDrawState::DeferredState. */ |
923 struct CommonState { | 938 struct CommonState { |
924 // These fields are roughly sorted by decreasing likelihood of being dif ferent in op== | 939 // These fields are roughly sorted by decreasing likelihood of being dif ferent in op== |
925 GrColor fColor; | 940 GrColor fColor; |
926 SkMatrix fViewMatrix; | 941 SkMatrix fViewMatrix; |
927 GrBlendCoeff fSrcBlend; | 942 GrBlendCoeff fSrcBlend; |
928 GrBlendCoeff fDstBlend; | 943 GrBlendCoeff fDstBlend; |
929 GrColor fBlendConstant; | 944 GrColor fBlendConstant; |
930 uint32_t fFlagBits; | 945 uint32_t fFlagBits; |
931 const GrVertexAttrib* fVAPtr; | 946 const GrVertexAttrib* fVAPtr; |
932 int fVACount; | 947 int fVACount; |
933 GrStencilSettings fStencilSettings; | 948 GrStencilSettings fStencilSettings; |
949 SkPath::FillType fPathStencilFillType; | |
934 GrColor fCoverage; | 950 GrColor fCoverage; |
935 SkXfermode::Mode fColorFilterMode; | 951 SkXfermode::Mode fColorFilterMode; |
936 GrColor fColorFilterColor; | 952 GrColor fColorFilterColor; |
937 DrawFace fDrawFace; | 953 DrawFace fDrawFace; |
938 | 954 |
939 // This is simply a different representation of info in fVertexAttribs a nd thus does | 955 // This is simply a different representation of info in fVertexAttribs a nd thus does |
940 // not need to be compared in op==. | 956 // not need to be compared in op==. |
941 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindin gCnt]; | 957 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindin gCnt]; |
942 | 958 |
943 bool operator== (const CommonState& other) const { | 959 bool operator== (const CommonState& other) const { |
944 bool result = fColor == other.fColor && | 960 bool result = fColor == other.fColor && |
945 fViewMatrix.cheapEqualTo(other.fViewMatrix) && | 961 fViewMatrix.cheapEqualTo(other.fViewMatrix) && |
946 fSrcBlend == other.fSrcBlend && | 962 fSrcBlend == other.fSrcBlend && |
947 fDstBlend == other.fDstBlend && | 963 fDstBlend == other.fDstBlend && |
948 fBlendConstant == other.fBlendConstant && | 964 fBlendConstant == other.fBlendConstant && |
949 fFlagBits == other.fFlagBits && | 965 fFlagBits == other.fFlagBits && |
950 fVACount == other.fVACount && | 966 fVACount == other.fVACount && |
951 !memcmp(fVAPtr, other.fVAPtr, fVACount * sizeof(GrVert exAttrib)) && | 967 !memcmp(fVAPtr, other.fVAPtr, fVACount * sizeof(GrVert exAttrib)) && |
952 fStencilSettings == other.fStencilSettings && | 968 fStencilSettings == other.fStencilSettings && |
969 fPathStencilFillType == other.fPathStencilFillType && | |
953 fCoverage == other.fCoverage && | 970 fCoverage == other.fCoverage && |
954 fColorFilterMode == other.fColorFilterMode && | 971 fColorFilterMode == other.fColorFilterMode && |
955 fColorFilterColor == other.fColorFilterColor && | 972 fColorFilterColor == other.fColorFilterColor && |
956 fDrawFace == other.fDrawFace; | 973 fDrawFace == other.fDrawFace; |
957 SkASSERT(!result || 0 == memcmp(fFixedFunctionVertexAttribIndices, | 974 SkASSERT(!result || 0 == memcmp(fFixedFunctionVertexAttribIndices, |
958 other.fFixedFunctionVertexAttribIndi ces, | 975 other.fFixedFunctionVertexAttribIndi ces, |
959 sizeof(fFixedFunctionVertexAttribInd ices))); | 976 sizeof(fFixedFunctionVertexAttribInd ices))); |
960 return result; | 977 return result; |
961 } | 978 } |
962 bool operator!= (const CommonState& other) const { return !(*this == oth er); } | 979 bool operator!= (const CommonState& other) const { return !(*this == oth er); } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt. | 1092 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt. |
1076 */ | 1093 */ |
1077 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | 1094 void setVertexAttribs(const GrVertexAttrib attribs[], int count); |
1078 | 1095 |
1079 typedef SkRefCnt INHERITED; | 1096 typedef SkRefCnt INHERITED; |
1080 }; | 1097 }; |
1081 | 1098 |
1082 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 1099 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
1083 | 1100 |
1084 #endif | 1101 #endif |
OLD | NEW |