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" | |
12 #include "GrRODrawState.h" | 11 #include "GrRODrawState.h" |
13 | 12 |
| 13 class GrDrawState; |
| 14 |
14 /** | 15 /** |
15 * Subclass of GrRODrawState that holds an optimized version of a GrDrawState. L
ike it's parent | 16 * 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 | 17 * it is meant to be an immutable class, and simply adds a few helpful data memb
ers not in the |
17 * base class. | 18 * base class. |
18 */ | 19 */ |
19 class GrOptDrawState : public GrRODrawState { | 20 class GrOptDrawState : public GrRODrawState { |
20 public: | 21 public: |
21 bool operator== (const GrOptDrawState& that) const; | |
22 | |
23 bool inputColorIsUsed() const { return fInputColorIsUsed; } | |
24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } | |
25 | |
26 private: | |
27 /** | 22 /** |
28 * Constructs and optimized drawState out of a GrRODrawState. | 23 * Constructs and optimized drawState out of a GrRODrawState. |
29 */ | 24 */ |
30 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, | 25 explicit GrOptDrawState(const GrDrawState& drawState); |
31 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff); | |
32 | 26 |
33 /** | 27 bool operator== (const GrOptDrawState& that) const; |
| 28 |
| 29 private: |
| 30 /* |
34 * Loops through all the color stage effects to check if the stage will igno
re color input or | 31 * 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 | 32 * always output a constant color. In the ignore color input case we can ign
ore all previous |
36 * stages. In the constant color case, we can ignore all previous stages and | 33 * stages. In the constant color case, we can ignore all previous stages and |
37 * the current one and set the state color to the constant color. Once we de
termine the so | 34 * the current one and set the state color to the constant color. Once we de
termine the so |
38 * called first effective stage, we copy all the effective stages into our o
ptimized | 35 * called first effective stage, we copy all the effective stages into our o
ptimized |
39 * state. | 36 * state. |
40 */ | 37 */ |
41 void copyEffectiveColorStages(const GrDrawState& ds); | 38 void copyEffectiveColorStages(const GrDrawState& ds); |
42 | 39 |
43 /** | 40 /* |
44 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. | 41 * Loops through all the coverage stage effects to check if the stage will i
gnore color input. |
45 * If a coverage stage will ignore input, then we can ignore all coverage st
ages before it. We | 42 * If a coverage stage will ignore input, then we can ignore all coverage st
ages before it. We |
46 * loop to determine the first effective coverage stage, and then copy all o
f our effective | 43 * loop to determine the first effective coverage stage, and then copy all o
f our effective |
47 * coverage stages into our optimized state. | 44 * coverage stages into our optimized state. |
48 */ | 45 */ |
49 void copyEffectiveCoverageStages(const GrDrawState& ds); | 46 void copyEffectiveCoverageStages(const GrDrawState& ds); |
50 | 47 |
51 /** | 48 /* |
52 * This function takes in a flag and removes the corresponding fixed functio
n vertex attributes. | 49 * This function takes in a flag and removes the corresponding fixed functio
n vertex attributes. |
53 * The flags are in the same order as GrVertexAttribBinding array. If bit i
of removeVAFlags is | 50 * The flags are in the same order as GrVertexAttribBinding array. If bit i
of removeVAFlags is |
54 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem
oved. | 51 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem
oved. |
55 */ | 52 */ |
56 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); | 53 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); |
57 | 54 |
58 /** | 55 void removeColorVertexAttrib(); |
59 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba
sed on the | |
60 * BlendOptFlags. | |
61 */ | |
62 void adjustFromBlendOpts(); | |
63 | 56 |
64 // These flags are needed to protect the code from creating an unused unifor
m color/coverage | 57 // These flags are needed to protect the code from creating an unused unifor
m color/coverage |
65 // which will cause shader compiler errors. | 58 // which will cause shader compiler errors. |
66 bool fInputColorIsUsed; | 59 bool fInputColorIsUsed; |
67 bool fInputCoverageIsUsed; | 60 bool fInputCoverageIsUsed; |
68 | 61 |
69 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 62 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
70 | 63 |
71 BlendOptFlags fBlendOptFlags; | |
72 | |
73 friend GrOptDrawState* GrDrawState::createOptState() const; | |
74 typedef GrRODrawState INHERITED; | 64 typedef GrRODrawState INHERITED; |
75 }; | 65 }; |
76 | 66 |
77 #endif | 67 #endif |
OLD | NEW |