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 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 * Sets the color to be used for the next draw to be | 258 * Sets the color to be used for the next draw to be |
259 * (r,g,b,a) = (alpha, alpha, alpha, alpha). | 259 * (r,g,b,a) = (alpha, alpha, alpha, alpha). |
260 * | 260 * |
261 * @param alpha The alpha value to set as the color. | 261 * @param alpha The alpha value to set as the color. |
262 */ | 262 */ |
263 void setAlpha(uint8_t a) { | 263 void setAlpha(uint8_t a) { |
264 this->setColor((a << 24) | (a << 16) | (a << 8) | a); | 264 this->setColor((a << 24) | (a << 16) | (a << 8) | a); |
265 } | 265 } |
266 | 266 |
267 /** | 267 /** |
268 * Add a color filter that can be represented by a color and a mode. Applied | |
269 * after color-computing effect stages. | |
270 */ | |
271 void setColorFilter(GrColor c, SkXfermode::Mode mode) { | |
272 fCommon.fColorFilterColor = c; | |
273 fCommon.fColorFilterMode = mode; | |
274 } | |
275 | |
276 GrColor getColorFilterColor() const { return fCommon.fColorFilterColor; } | |
277 SkXfermode::Mode getColorFilterMode() const { return fCommon.fColorFilterMod
e; } | |
278 | |
279 /** | |
280 * Constructor sets the color to be 'color' which is undone by the destructo
r. | 268 * Constructor sets the color to be 'color' which is undone by the destructo
r. |
281 */ | 269 */ |
282 class AutoColorRestore : public ::SkNoncopyable { | 270 class AutoColorRestore : public ::SkNoncopyable { |
283 public: | 271 public: |
284 AutoColorRestore() : fDrawState(NULL), fOldColor(0) {} | 272 AutoColorRestore() : fDrawState(NULL), fOldColor(0) {} |
285 | 273 |
286 AutoColorRestore(GrDrawState* drawState, GrColor color) { | 274 AutoColorRestore(GrDrawState* drawState, GrColor color) { |
287 fDrawState = NULL; | 275 fDrawState = NULL; |
288 this->set(drawState, color); | 276 this->set(drawState, color); |
289 } | 277 } |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 fCommon.fViewMatrix.reset(); | 895 fCommon.fViewMatrix.reset(); |
908 } else { | 896 } else { |
909 fCommon.fViewMatrix = *initialViewMatrix; | 897 fCommon.fViewMatrix = *initialViewMatrix; |
910 } | 898 } |
911 fCommon.fSrcBlend = kOne_GrBlendCoeff; | 899 fCommon.fSrcBlend = kOne_GrBlendCoeff; |
912 fCommon.fDstBlend = kZero_GrBlendCoeff; | 900 fCommon.fDstBlend = kZero_GrBlendCoeff; |
913 fCommon.fBlendConstant = 0x0; | 901 fCommon.fBlendConstant = 0x0; |
914 fCommon.fFlagBits = 0x0; | 902 fCommon.fFlagBits = 0x0; |
915 fCommon.fStencilSettings.setDisabled(); | 903 fCommon.fStencilSettings.setDisabled(); |
916 fCommon.fCoverage = 0xffffffff; | 904 fCommon.fCoverage = 0xffffffff; |
917 fCommon.fColorFilterMode = SkXfermode::kDst_Mode; | |
918 fCommon.fColorFilterColor = 0x0; | |
919 fCommon.fDrawFace = kBoth_DrawFace; | 905 fCommon.fDrawFace = kBoth_DrawFace; |
920 } | 906 } |
921 | 907 |
922 /** Fields that are identical in GrDrawState and GrDrawState::DeferredState.
*/ | 908 /** Fields that are identical in GrDrawState and GrDrawState::DeferredState.
*/ |
923 struct CommonState { | 909 struct CommonState { |
924 // These fields are roughly sorted by decreasing likelihood of being dif
ferent in op== | 910 // These fields are roughly sorted by decreasing likelihood of being dif
ferent in op== |
925 GrColor fColor; | 911 GrColor fColor; |
926 SkMatrix fViewMatrix; | 912 SkMatrix fViewMatrix; |
927 GrBlendCoeff fSrcBlend; | 913 GrBlendCoeff fSrcBlend; |
928 GrBlendCoeff fDstBlend; | 914 GrBlendCoeff fDstBlend; |
929 GrColor fBlendConstant; | 915 GrColor fBlendConstant; |
930 uint32_t fFlagBits; | 916 uint32_t fFlagBits; |
931 const GrVertexAttrib* fVAPtr; | 917 const GrVertexAttrib* fVAPtr; |
932 int fVACount; | 918 int fVACount; |
933 GrStencilSettings fStencilSettings; | 919 GrStencilSettings fStencilSettings; |
934 GrColor fCoverage; | 920 GrColor fCoverage; |
935 SkXfermode::Mode fColorFilterMode; | |
936 GrColor fColorFilterColor; | |
937 DrawFace fDrawFace; | 921 DrawFace fDrawFace; |
938 | 922 |
939 // This is simply a different representation of info in fVertexAttribs a
nd thus does | 923 // This is simply a different representation of info in fVertexAttribs a
nd thus does |
940 // not need to be compared in op==. | 924 // not need to be compared in op==. |
941 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindin
gCnt]; | 925 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindin
gCnt]; |
942 | 926 |
943 bool operator== (const CommonState& other) const { | 927 bool operator== (const CommonState& other) const { |
944 bool result = fColor == other.fColor && | 928 bool result = fColor == other.fColor && |
945 fViewMatrix.cheapEqualTo(other.fViewMatrix) && | 929 fViewMatrix.cheapEqualTo(other.fViewMatrix) && |
946 fSrcBlend == other.fSrcBlend && | 930 fSrcBlend == other.fSrcBlend && |
947 fDstBlend == other.fDstBlend && | 931 fDstBlend == other.fDstBlend && |
948 fBlendConstant == other.fBlendConstant && | 932 fBlendConstant == other.fBlendConstant && |
949 fFlagBits == other.fFlagBits && | 933 fFlagBits == other.fFlagBits && |
950 fVACount == other.fVACount && | 934 fVACount == other.fVACount && |
951 !memcmp(fVAPtr, other.fVAPtr, fVACount * sizeof(GrVert
exAttrib)) && | 935 !memcmp(fVAPtr, other.fVAPtr, fVACount * sizeof(GrVert
exAttrib)) && |
952 fStencilSettings == other.fStencilSettings && | 936 fStencilSettings == other.fStencilSettings && |
953 fCoverage == other.fCoverage && | 937 fCoverage == other.fCoverage && |
954 fColorFilterMode == other.fColorFilterMode && | |
955 fColorFilterColor == other.fColorFilterColor && | |
956 fDrawFace == other.fDrawFace; | 938 fDrawFace == other.fDrawFace; |
957 SkASSERT(!result || 0 == memcmp(fFixedFunctionVertexAttribIndices, | 939 SkASSERT(!result || 0 == memcmp(fFixedFunctionVertexAttribIndices, |
958 other.fFixedFunctionVertexAttribIndi
ces, | 940 other.fFixedFunctionVertexAttribIndi
ces, |
959 sizeof(fFixedFunctionVertexAttribInd
ices))); | 941 sizeof(fFixedFunctionVertexAttribInd
ices))); |
960 return result; | 942 return result; |
961 } | 943 } |
962 bool operator!= (const CommonState& other) const { return !(*this == oth
er); } | 944 bool operator!= (const CommonState& other) const { return !(*this == oth
er); } |
963 }; | 945 }; |
964 | 946 |
965 /** GrDrawState uses GrEffectStages to hold stage state which holds a ref on
GrEffectRef. | 947 /** GrDrawState uses GrEffectStages to hold stage state which holds a ref on
GrEffectRef. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. | 1057 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. |
1076 */ | 1058 */ |
1077 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | 1059 void setVertexAttribs(const GrVertexAttrib attribs[], int count); |
1078 | 1060 |
1079 typedef SkRefCnt INHERITED; | 1061 typedef SkRefCnt INHERITED; |
1080 }; | 1062 }; |
1081 | 1063 |
1082 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 1064 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
1083 | 1065 |
1084 #endif | 1066 #endif |
OLD | NEW |