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 |
11 #include "GrDrawState.h" | 11 #include "GrDrawState.h" |
12 #include "GrRODrawState.h" | 12 #include "GrRODrawState.h" |
13 | 13 |
14 /** | 14 /** |
15 * Subclass of GrRODrawState that holds an optimized version of a GrDrawState. L
ike it's parent | 15 * Subclass of GrRODrawState that holds an optimized version of a GrDrawState. L
ike it's parent |
16 * it is meant to be an immutable class, and simply adds a few helpful data memb
ers not in the | 16 * it is meant to be an immutable class, and simply adds a few helpful data memb
ers not in the |
17 * base class. | 17 * base class. |
18 */ | 18 */ |
19 class GrOptDrawState : public GrRODrawState { | 19 class GrOptDrawState : public GrRODrawState { |
20 public: | 20 public: |
21 bool operator== (const GrOptDrawState& that) const; | 21 bool operator== (const GrOptDrawState& that) const; |
22 | 22 |
23 bool inputColorIsUsed() const { return fInputColorIsUsed; } | 23 bool inputColorIsUsed() const { return fInputColorIsUsed; } |
24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } | 24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } |
25 | 25 |
| 26 bool readsDst() const { return fReadsDst; } |
| 27 bool readsFragPosition() const { return fReadsFragPosition; } |
| 28 bool requiresVertexShader() const { return fRequiresVertexShader; } |
| 29 bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; } |
| 30 |
26 private: | 31 private: |
27 /** | 32 /** |
28 * Constructs and optimized drawState out of a GrRODrawState. | 33 * Constructs and optimized drawState out of a GrRODrawState. |
29 */ | 34 */ |
30 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, | 35 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, |
31 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff); | 36 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff); |
32 | 37 |
33 /** | 38 /** |
34 * Loops through all the color stage effects to check if the stage will igno
re color input or | 39 * Loops through all the color stage effects to check if the stage will igno
re color input or |
35 * always output a constant color. In the ignore color input case we can ign
ore all previous | 40 * always output a constant color. In the ignore color input case we can ign
ore all previous |
(...skipping 18 matching lines...) Expand all Loading... |
54 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem
oved. | 59 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem
oved. |
55 */ | 60 */ |
56 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); | 61 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); |
57 | 62 |
58 /** | 63 /** |
59 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba
sed on the | 64 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba
sed on the |
60 * BlendOptFlags. | 65 * BlendOptFlags. |
61 */ | 66 */ |
62 void adjustFromBlendOpts(); | 67 void adjustFromBlendOpts(); |
63 | 68 |
| 69 /** |
| 70 * Loop over the effect stages to determine various info like what data they
will read and what |
| 71 * shaders they require. |
| 72 */ |
| 73 void getStageStats(); |
| 74 |
64 // These flags are needed to protect the code from creating an unused unifor
m color/coverage | 75 // These flags are needed to protect the code from creating an unused unifor
m color/coverage |
65 // which will cause shader compiler errors. | 76 // which will cause shader compiler errors. |
66 bool fInputColorIsUsed; | 77 bool fInputColorIsUsed; |
67 bool fInputCoverageIsUsed; | 78 bool fInputCoverageIsUsed; |
68 | 79 |
| 80 // These flags give aggregated info on the effect stages that are used when
building programs. |
| 81 bool fReadsDst; |
| 82 bool fReadsFragPosition; |
| 83 bool fRequiresVertexShader; |
| 84 bool fRequiresLocalCoordAttrib; |
| 85 |
69 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 86 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
70 | 87 |
71 BlendOptFlags fBlendOptFlags; | 88 BlendOptFlags fBlendOptFlags; |
72 | 89 |
73 friend GrOptDrawState* GrDrawState::createOptState() const; | 90 friend GrOptDrawState* GrDrawState::createOptState() const; |
74 typedef GrRODrawState INHERITED; | 91 typedef GrRODrawState INHERITED; |
75 }; | 92 }; |
76 | 93 |
77 #endif | 94 #endif |
OLD | NEW |