OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrOptDrawState_DEFINED |
| 9 #define GrOptDrawState_DEFINED |
| 10 |
| 11 #include "GrRODrawState.h" |
| 12 |
| 13 class GrDrawState; |
| 14 |
| 15 /** |
| 16 * 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 |
| 18 * base class. |
| 19 */ |
| 20 class GrOptDrawState : public GrRODrawState { |
| 21 public: |
| 22 /** |
| 23 * Constructs and optimized drawState out of a GrRODrawState. |
| 24 */ |
| 25 explicit GrOptDrawState(const GrDrawState& drawState); |
| 26 |
| 27 bool operator== (const GrOptDrawState& that) const; |
| 28 |
| 29 private: |
| 30 /* |
| 31 * 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 |
| 33 * 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 |
| 35 * called first effective stage, we copy all the effective stages into our o
ptimized |
| 36 * state. |
| 37 */ |
| 38 void copyEffectiveColorStages(const GrDrawState& ds); |
| 39 |
| 40 /* |
| 41 * 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 |
| 43 * loop to determine the first effective coverage stage, and then copy all o
f our effective |
| 44 * coverage stages into our optimized state. |
| 45 */ |
| 46 void copyEffectiveCoverageStages(const GrDrawState& ds); |
| 47 |
| 48 /* |
| 49 * 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 |
| 51 * set, then vertex attributes with binding (GrVertexAttribute)i will be rem
oved. |
| 52 */ |
| 53 void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags); |
| 54 |
| 55 void removeColorVertexAttrib(); |
| 56 |
| 57 // These flags are needed to protect the code from creating an unused unifor
m color/coverage |
| 58 // which will cause shader compiler errors. |
| 59 bool fInputColorIsUsed; |
| 60 bool fInputCoverageIsUsed; |
| 61 |
| 62 SkAutoSTArray<4, GrVertexAttrib> fOptVA; |
| 63 |
| 64 typedef GrRODrawState INHERITED; |
| 65 }; |
| 66 |
| 67 #endif |
OLD | NEW |