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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool hasColorVertexAttribute() const { | 163 bool hasColorVertexAttribute() const { |
164 return -1 != fCommon.fFixedFunctionVertexAttribIndices[kColor_GrVertexAt
tribBinding]; | 164 return -1 != fCommon.fFixedFunctionVertexAttribIndices[kColor_GrVertexAt
tribBinding]; |
165 } | 165 } |
166 bool hasCoverageVertexAttribute() const { | 166 bool hasCoverageVertexAttribute() const { |
167 return -1 != fCommon.fFixedFunctionVertexAttribIndices[kCoverage_GrVerte
xAttribBinding]; | 167 return -1 != fCommon.fFixedFunctionVertexAttribIndices[kCoverage_GrVerte
xAttribBinding]; |
168 } | 168 } |
169 | 169 |
170 bool validateVertexAttribs() const; | 170 bool validateVertexAttribs() const; |
171 | 171 |
172 /** | 172 /** |
| 173 * Helper to save/restore vertex attribs |
| 174 */ |
| 175 class AutoVertexAttribRestore { |
| 176 public: |
| 177 AutoVertexAttribRestore(GrDrawState* drawState) { |
| 178 GrAssert(NULL != drawState); |
| 179 fDrawState = drawState; |
| 180 fVertexAttribs = drawState->fCommon.fVertexAttribs; |
| 181 fDrawState->setDefaultVertexAttribs(); |
| 182 } |
| 183 |
| 184 ~AutoVertexAttribRestore(){ |
| 185 fDrawState->fCommon.fVertexAttribs = fVertexAttribs; |
| 186 } |
| 187 |
| 188 private: |
| 189 GrDrawState* fDrawState; |
| 190 GrVertexAttribArray<kMaxVertexAttribCnt> fVertexAttribs; |
| 191 }; |
| 192 |
| 193 /** |
173 * Accessing positions, local coords, or colors, of a vertex within an array
is a hassle | 194 * Accessing positions, local coords, or colors, of a vertex within an array
is a hassle |
174 * involving casts and simple math. These helpers exist to keep GrDrawTarget
clients' code a bit | 195 * involving casts and simple math. These helpers exist to keep GrDrawTarget
clients' code a bit |
175 * nicer looking. | 196 * nicer looking. |
176 */ | 197 */ |
177 | 198 |
178 /** | 199 /** |
179 * Gets a pointer to a GrPoint of a vertex's position or texture | 200 * Gets a pointer to a GrPoint of a vertex's position or texture |
180 * coordinate. | 201 * coordinate. |
181 * @param vertices the vertex array | 202 * @param vertices the vertex array |
182 * @param vertexIndex the index of the vertex in the array | 203 * @param vertexIndex the index of the vertex in the array |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 1145 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
1125 CommonState fCommon; | 1146 CommonState fCommon; |
1126 GrEffectStage fStages[kNumStages]; | 1147 GrEffectStage fStages[kNumStages]; |
1127 | 1148 |
1128 typedef GrRefCnt INHERITED; | 1149 typedef GrRefCnt INHERITED; |
1129 }; | 1150 }; |
1130 | 1151 |
1131 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 1152 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
1132 | 1153 |
1133 #endif | 1154 #endif |
OLD | NEW |