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 GrRODrawState_DEFINED | 8 #ifndef GrRODrawState_DEFINED |
9 #define GrRODrawState_DEFINED | 9 #define GrRODrawState_DEFINED |
10 | 10 |
| 11 #include "GrEffectStage.h" |
| 12 #include "GrRenderTarget.h" |
11 #include "GrStencil.h" | 13 #include "GrStencil.h" |
12 #include "GrEffectStage.h" | |
13 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
14 | 15 |
15 class GrDrawTargetCaps; | 16 class GrDrawTargetCaps; |
16 class GrPaint; | 17 class GrPaint; |
17 class GrRenderTarget; | |
18 class GrTexture; | 18 class GrTexture; |
19 | 19 |
20 /** | 20 /** |
21 * Read-only base class for GrDrawState. This class contains all the necessary d
ata to represent a | 21 * Read-only base class for GrDrawState. This class contains all the necessary d
ata to represent a |
22 * canonical DrawState. All methods in the class are const, thus once created th
e data in the class | 22 * canonical DrawState. All methods in the class are const, thus once created th
e data in the class |
23 * cannot be changed. | 23 * cannot be changed. |
24 */ | 24 */ |
25 class GrRODrawState : public SkRefCnt { | 25 class GrRODrawState : public SkRefCnt { |
26 public: | 26 public: |
27 SK_DECLARE_INST_COUNT(GrRODrawState) | 27 SK_DECLARE_INST_COUNT(GrRODrawState) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 /////////////////////////////////////////////////////////////////////////// | 232 /////////////////////////////////////////////////////////////////////////// |
233 /// @name Render Target | 233 /// @name Render Target |
234 //// | 234 //// |
235 | 235 |
236 /** | 236 /** |
237 * Retrieves the currently set render-target. | 237 * Retrieves the currently set render-target. |
238 * | 238 * |
239 * @return The currently set render target. | 239 * @return The currently set render target. |
240 */ | 240 */ |
241 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } | 241 GrRenderTarget* getRenderTarget() const { |
| 242 return static_cast<GrRenderTarget*>(fRenderTarget.getResource()); |
| 243 } |
242 | 244 |
243 /// @} | 245 /// @} |
244 | 246 |
245 /////////////////////////////////////////////////////////////////////////// | 247 /////////////////////////////////////////////////////////////////////////// |
246 /// @name Stencil | 248 /// @name Stencil |
247 //// | 249 //// |
248 | 250 |
249 const GrStencilSettings& getStencil() const { return fStencilSettings; } | 251 const GrStencilSettings& getStencil() const { return fStencilSettings; } |
250 | 252 |
251 /// @} | 253 /// @} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 kIncompatible_CombinedState, | 335 kIncompatible_CombinedState, |
334 /** Either draw state can be used in place of the other. */ | 336 /** Either draw state can be used in place of the other. */ |
335 kAOrB_CombinedState, | 337 kAOrB_CombinedState, |
336 /** Use the first draw state. */ | 338 /** Use the first draw state. */ |
337 kA_CombinedState, | 339 kA_CombinedState, |
338 /** Use the second draw state. */ | 340 /** Use the second draw state. */ |
339 kB_CombinedState, | 341 kB_CombinedState, |
340 }; | 342 }; |
341 | 343 |
342 protected: | 344 protected: |
| 345 /** |
| 346 * Converts refs on GrGpuResources owned directly or indirectly by this GrRO
DrawState into |
| 347 * pending reads and writes. This should be called when a GrDrawState is rec
orded into |
| 348 * a GrDrawTarget for later execution. Subclasses of GrRODrawState may add s
etters. However, |
| 349 * once this call has been made the GrRODrawState is immutable. It is also n
o longer copyable. |
| 350 * In the future this conversion will automatically happen when converting a
GrDrawState into |
| 351 * an optimized draw state. |
| 352 */ |
| 353 void convertToPendingExec(); |
| 354 |
| 355 friend class GrDrawTarget; |
| 356 |
| 357 protected: |
343 bool isEqual(const GrRODrawState& that) const; | 358 bool isEqual(const GrRODrawState& that) const; |
344 | 359 |
345 // These fields are roughly sorted by decreasing likelihood of being differe
nt in op== | 360 // These fields are roughly sorted by decreasing likelihood of being differe
nt in op== |
346 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 361 GrProgramResource fRenderTarget; |
347 GrColor fColor; | 362 GrColor fColor; |
348 SkMatrix fViewMatrix; | 363 SkMatrix fViewMatrix; |
349 GrColor fBlendConstant; | 364 GrColor fBlendConstant; |
350 uint32_t fFlagBits; | 365 uint32_t fFlagBits; |
351 const GrVertexAttrib* fVAPtr; | 366 const GrVertexAttrib* fVAPtr; |
352 int fVACount; | 367 int fVACount; |
353 size_t fVAStride; | 368 size_t fVAStride; |
354 GrStencilSettings fStencilSettings; | 369 GrStencilSettings fStencilSettings; |
355 uint8_t fCoverage; | 370 uint8_t fCoverage; |
356 DrawFace fDrawFace; | 371 DrawFace fDrawFace; |
(...skipping 12 matching lines...) Expand all Loading... |
369 // not need to be compared in op==. | 384 // not need to be compared in op==. |
370 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; | 385 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; |
371 | 386 |
372 private: | 387 private: |
373 typedef SkRefCnt INHERITED; | 388 typedef SkRefCnt INHERITED; |
374 }; | 389 }; |
375 | 390 |
376 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); | 391 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); |
377 | 392 |
378 #endif | 393 #endif |
OLD | NEW |