OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrOptDrawState_DEFINED | 8 #ifndef GrOptDrawState_DEFINED |
9 #define GrOptDrawState_DEFINED | 9 #define GrOptDrawState_DEFINED |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /** | 23 /** |
24 * Class that holds an optimized version of a GrDrawState. It is meant to be an
immutable class, | 24 * Class that holds an optimized version of a GrDrawState. It is meant to be an
immutable class, |
25 * and contains all data needed to set the state for a gpu draw. | 25 * and contains all data needed to set the state for a gpu draw. |
26 */ | 26 */ |
27 class GrOptDrawState : public SkRefCnt { | 27 class GrOptDrawState : public SkRefCnt { |
28 public: | 28 public: |
29 SK_DECLARE_INST_COUNT(GrOptDrawState) | 29 SK_DECLARE_INST_COUNT(GrOptDrawState) |
30 | 30 |
31 typedef GrClipMaskManager::ScissorState ScissorState; | 31 typedef GrClipMaskManager::ScissorState ScissorState; |
32 | 32 |
33 /** | 33 GrOptDrawState(const GrDrawState& drawState, GrGpu*, const ScissorState&, |
34 * Returns a snapshot of the current optimized state. The GrOptDrawState is
reffed and ownership | 34 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType); |
35 * is given to the caller. | |
36 */ | |
37 static GrOptDrawState* Create(const GrDrawState& drawState, | |
38 GrGpu*, | |
39 const ScissorState&, | |
40 const GrDeviceCoordTexture* dstCopy, | |
41 GrGpu::DrawType drawType); | |
42 | 35 |
43 bool operator== (const GrOptDrawState& that) const; | 36 bool operator== (const GrOptDrawState& that) const; |
44 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } | 37 bool operator!= (const GrOptDrawState& that) const { return !(*this == that)
; } |
45 | 38 |
46 /////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////// |
47 /// @name Vertex Attributes | 40 /// @name Vertex Attributes |
48 //// | 41 //// |
49 | 42 |
50 enum { | 43 enum { |
51 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4, | 44 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 /// @} | 168 /// @} |
176 | 169 |
177 | 170 |
178 /////////////////////////////////////////////////////////////////////////// | 171 /////////////////////////////////////////////////////////////////////////// |
179 /// @name Boolean Queries | 172 /// @name Boolean Queries |
180 //// | 173 //// |
181 | 174 |
182 bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); } | 175 bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); } |
183 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } | 176 bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } |
184 bool isColorWriteDisabled() const { return SkToBool(fFlags & kDisableColorWr
ite_Flag); } | 177 bool isColorWriteDisabled() const { return SkToBool(fFlags & kDisableColorWr
ite_Flag); } |
| 178 bool mustSkip() const { return NULL == this->getRenderTarget(); } |
185 | 179 |
186 /// @} | 180 /// @} |
187 | 181 |
188 /** | 182 /** |
189 * Gets whether the target is drawing clockwise, counterclockwise, | 183 * Gets whether the target is drawing clockwise, counterclockwise, |
190 * or both faces. | 184 * or both faces. |
191 * @return the current draw face(s). | 185 * @return the current draw face(s). |
192 */ | 186 */ |
193 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } | 187 GrDrawState::DrawFace getDrawFace() const { return fDrawFace; } |
194 | 188 |
195 /// @} | 189 /// @} |
196 | 190 |
197 /////////////////////////////////////////////////////////////////////////// | 191 /////////////////////////////////////////////////////////////////////////// |
198 | 192 |
199 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } | 193 const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ?
&fDstCopy : NULL; } |
200 | 194 |
201 const GrProgramDesc& programDesc() const { return fDesc; } | 195 const GrProgramDesc& programDesc() const { return fDesc; } |
202 | 196 |
203 private: | 197 private: |
204 /** | 198 /** |
205 * Constructs and optimized drawState out of a GrRODrawState. | |
206 */ | |
207 GrOptDrawState(const GrDrawState& drawState, GrDrawState::BlendOpt, | |
208 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff, | |
209 GrGpu*, const ScissorState&, const GrDeviceCoordTexture* dstC
opy, | |
210 GrGpu::DrawType); | |
211 | |
212 /** | |
213 * Loops through all the color stage effects to check if the stage will igno
re color input or | 199 * Loops through all the color stage effects to check if the stage will igno
re color input or |
214 * always output a constant color. In the ignore color input case we can ign
ore all previous | 200 * always output a constant color. In the ignore color input case we can ign
ore all previous |
215 * stages. In the constant color case, we can ignore all previous stages and | 201 * stages. In the constant color case, we can ignore all previous stages and |
216 * the current one and set the state color to the constant color. | 202 * the current one and set the state color to the constant color. |
217 */ | 203 */ |
218 void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescI
nfo*, | 204 void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescI
nfo*, |
219 int* firstColorStageIdx, uint8_t* fixFuncti
onVAToRemove); | 205 int* firstColorStageIdx, uint8_t* fixFuncti
onVAToRemove); |
220 | 206 |
221 /** | 207 /** |
222 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. | 208 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 int fNumColorStages; | 273 int fNumColorStages; |
288 | 274 |
289 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 275 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
290 | 276 |
291 GrProgramDesc fDesc; | 277 GrProgramDesc fDesc; |
292 | 278 |
293 typedef SkRefCnt INHERITED; | 279 typedef SkRefCnt INHERITED; |
294 }; | 280 }; |
295 | 281 |
296 #endif | 282 #endif |
OLD | NEW |