Chromium Code Reviews| 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 "GrRODrawState.h" | 12 #include "GrRODrawState.h" |
| 12 | 13 |
| 13 class GrDrawState; | |
| 14 | |
| 15 /** | 14 /** |
| 16 * 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 |
| 17 * 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 |
| 18 * base class. | 17 * base class. |
| 19 */ | 18 */ |
| 20 class GrOptDrawState : public GrRODrawState { | 19 class GrOptDrawState : public GrRODrawState { |
| 21 public: | 20 public: |
| 21 bool operator== (const GrOptDrawState& that) const; | |
| 22 | |
| 23 bool inputColorIsUsed() const { return fInputColorIsUsed; } | |
| 24 bool inputCoverageIsUsed() const { return fInputCoverageIsUsed; } | |
| 25 | |
| 26 private: | |
| 22 /** | 27 /** |
| 23 * Constructs and optimized drawState out of a GrRODrawState. | 28 * Constructs and optimized drawState out of a GrRODrawState. |
| 24 */ | 29 */ |
| 25 explicit GrOptDrawState(const GrDrawState& drawState); | 30 GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags, |
| 31 GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff); | |
| 26 | 32 |
| 27 bool operator== (const GrOptDrawState& that) const; | 33 /** |
| 28 | |
| 29 private: | |
| 30 /* | |
| 31 * Loops through all the color stage effects to check if the stage will igno re color input or | 34 * Loops through all the color stage effects to check if the stage will igno re color input or |
| 32 * always output a constant color. In the ignore color input case we can ign ore all previous | 35 * always output a constant color. In the ignore color input case we can ign ore all previous |
| 33 * stages. In the constant color case, we can ignore all previous stages and | 36 * stages. In the constant color case, we can ignore all previous stages and |
| 34 * the current one and set the state color to the constant color. Once we de termine the so | 37 * the current one and set the state color to the constant color. Once we de termine the so |
| 35 * called first effective stage, we copy all the effective stages into our o ptimized | 38 * called first effective stage, we copy all the effective stages into our o ptimized |
| 36 * state. | 39 * state. |
| 37 */ | 40 */ |
| 38 void copyEffectiveColorStages(const GrDrawState& ds); | 41 void copyEffectiveColorStages(const GrDrawState& ds); |
| 39 | 42 |
| 40 /* | 43 /** |
| 41 * Loops through all the coverage stage effects to check if the stage will i gnore color input. | 44 * Loops through all the coverage stage effects to check if the stage will i gnore color input. |
| 42 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We | 45 * If a coverage stage will ignore input, then we can ignore all coverage st ages before it. We |
| 43 * loop to determine the first effective coverage stage, and then copy all o f our effective | 46 * loop to determine the first effective coverage stage, and then copy all o f our effective |
| 44 * coverage stages into our optimized state. | 47 * coverage stages into our optimized state. |
| 45 */ | 48 */ |
| 46 void copyEffectiveCoverageStages(const GrDrawState& ds); | 49 void copyEffectiveCoverageStages(const GrDrawState& ds); |
| 47 | 50 |
| 48 /* | 51 /** |
| 49 * This function takes in a flag and removes the corresponding fixed functio n vertex attributes. | 52 * This function takes in a flag and removes the corresponding fixed functio n vertex attributes. |
| 50 * The flags are in the same order as GrVertexAttribBinding array. If bit i of removeVAFlags is | 53 * The flags are in the same order as GrVertexAttribBinding array. If bit i of removeVAFlags is |
| 51 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem oved. | 54 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem oved. |
| 52 */ | 55 */ |
| 53 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); | 56 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); |
| 54 | 57 |
| 55 void removeColorVertexAttrib(); | 58 /** |
| 59 * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) ba sed on the | |
| 60 * BlendOptFlags. | |
| 61 */ | |
| 62 void adjustFromBlendOpts(); | |
| 63 | |
| 64 /** | |
| 65 * Set the VAIndexMap to basically return the idenity of the VA's that were passed in from the | |
| 66 * DrawState. | |
| 67 */ | |
| 68 void initializeVAIndexMap(); | |
| 69 | |
| 70 /** | |
| 71 * Loop over the various effect stages and remap any non-fixed function VA's to have the corret | |
| 72 * index based off of fVAIndexMap | |
| 73 */ | |
| 74 void remapEffectStagesVAIndices(); | |
| 56 | 75 |
| 57 // These flags are needed to protect the code from creating an unused unifor m color/coverage | 76 // These flags are needed to protect the code from creating an unused unifor m color/coverage |
| 58 // which will cause shader compiler errors. | 77 // which will cause shader compiler errors. |
| 59 bool fInputColorIsUsed; | 78 bool fInputColorIsUsed; |
| 60 bool fInputCoverageIsUsed; | 79 bool fInputCoverageIsUsed; |
| 61 | 80 |
| 62 SkAutoSTArray<4, GrVertexAttrib> fOptVA; | 81 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
| 82 SkAutoSTArray<4, int> fVAIndexMap; | |
| 63 | 83 |
| 84 BlendOptFlags fBlendOptFlags; | |
| 85 | |
| 86 friend GrOptDrawState* GrDrawState::createOptState() const; | |
|
bsalomon
2014/09/15 14:04:34
Is it possible that GrOptState's cons just take a
egdaniel
2014/09/15 17:51:35
In order to keep all the blendOpt flag stuff priva
| |
| 64 typedef GrRODrawState INHERITED; | 87 typedef GrRODrawState INHERITED; |
| 65 }; | 88 }; |
| 66 | 89 |
| 67 #endif | 90 #endif |
| OLD | NEW |