Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: src/gpu/GrOptDrawState.h

Issue 504203004: Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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();
56 63
57 // These flags are needed to protect the code from creating an unused unifor m color/coverage 64 // These flags are needed to protect the code from creating an unused unifor m color/coverage
58 // which will cause shader compiler errors. 65 // which will cause shader compiler errors.
59 bool fInputColorIsUsed; 66 bool fInputColorIsUsed;
60 bool fInputCoverageIsUsed; 67 bool fInputCoverageIsUsed;
61 68
62 SkAutoSTArray<4, GrVertexAttrib> fOptVA; 69 SkAutoSTArray<4, GrVertexAttrib> fOptVA;
63 70
71 BlendOptFlags fBlendOptFlags;
72
73 friend GrOptDrawState* GrDrawState::createOptState() const;
64 typedef GrRODrawState INHERITED; 74 typedef GrRODrawState INHERITED;
65 }; 75 };
66 76
67 #endif 77 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698