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

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

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix Created 6 years 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/GrDrawTarget.cpp ('k') | src/gpu/GrInOrderDrawBuffer.h » ('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 2013 Google Inc. 2 * Copyright 2013 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 GrGeometryProcessor_DEFINED 8 #ifndef GrGeometryProcessor_DEFINED
9 #define GrGeometryProcessor_DEFINED 9 #define GrGeometryProcessor_DEFINED
10 10
11 #include "GrColor.h"
11 #include "GrGeometryData.h" 12 #include "GrGeometryData.h"
12 #include "GrProcessor.h" 13 #include "GrProcessor.h"
13 #include "GrShaderVar.h" 14 #include "GrShaderVar.h"
14 15
15 /* 16 /*
16 * A struct for tracking batching decisions. While this lives on GrOptState, it is managed 17 * A struct for tracking batching decisions. While this lives on GrOptState, it is managed
17 * entirely by the derived classes of the GP. 18 * entirely by the derived classes of the GP.
18 */ 19 */
19 class GrBatchTracker { 20 class GrBatchTracker {
20 public: 21 public:
(...skipping 22 matching lines...) Expand all
43 * add support for custom vertex attributes. A GrGemeotryProcessor is typically 44 * add support for custom vertex attributes. A GrGemeotryProcessor is typically
44 * tied to the code that does a specific type of high-level primitive rendering 45 * tied to the code that does a specific type of high-level primitive rendering
45 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is 46 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is
46 * specified using GrDrawState. There can only be one geometry processor active for 47 * specified using GrDrawState. There can only be one geometry processor active for
47 * a draw. The custom vertex attributes required by the geometry processor must be 48 * a draw. The custom vertex attributes required by the geometry processor must be
48 * added to the vertex attribute array specified on the GrDrawState. 49 * added to the vertex attribute array specified on the GrDrawState.
49 * GrGeometryProcessor subclasses should be immutable after construction. 50 * GrGeometryProcessor subclasses should be immutable after construction.
50 */ 51 */
51 class GrGeometryProcessor : public GrProcessor { 52 class GrGeometryProcessor : public GrProcessor {
52 public: 53 public:
53 GrGeometryProcessor() 54 GrGeometryProcessor(GrColor color, uint8_t coverage = 0xff)
54 : fVertexStride(0) 55 : fVertexStride(0)
56 , fColor(color)
57 , fCoverage(coverage)
55 , fWillUseGeoShader(false) 58 , fWillUseGeoShader(false)
56 , fHasVertexColor(false) 59 , fHasVertexColor(false)
57 , fHasVertexCoverage(false) 60 , fHasVertexCoverage(false)
58 , fHasLocalCoords(false) {} 61 , fHasLocalCoords(false) {}
59 62
60 virtual const char* name() const = 0; 63 virtual const char* name() const = 0;
61 64
62 /** Implemented using GLProcessor::GenKey as described in this class's comme nt. */ 65 /** Implemented using GLProcessor::GenKey as described in this class's comme nt. */
63 virtual void getGLProcessorKey(const GrBatchTracker& bt, 66 virtual void getGLProcessorKey(const GrBatchTracker& bt,
64 const GrGLCaps& caps, 67 const GrGLCaps& caps,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 /** Returns true if this and other processor conservatively draw identically . It can only return 103 /** Returns true if this and other processor conservatively draw identically . It can only return
101 true when the two prcoessors are of the same subclass (i.e. they return the same object from 104 true when the two prcoessors are of the same subclass (i.e. they return the same object from
102 from getFactory()). 105 from getFactory()).
103 A return value of true from isEqual() should not be used to test whether the processors 106 A return value of true from isEqual() should not be used to test whether the processors
104 would generate the same shader code. To test for identical code generati on use the 107 would generate the same shader code. To test for identical code generati on use the
105 processors' keys computed by the GrBackendEffectFactory. */ 108 processors' keys computed by the GrBackendEffectFactory. */
106 bool isEqual(const GrGeometryProcessor& that) const { 109 bool isEqual(const GrGeometryProcessor& that) const {
107 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(t hat)) { 110 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(t hat)) {
108 return false; 111 return false;
109 } 112 }
113
114 if (!fHasVertexColor && this->getColor() != that.getColor()) {
115 return false;
116 }
117
118 if (!fHasVertexCoverage && this->getCoverage() != that.getCoverage()) {
119 return false;
120 }
110 return this->onIsEqual(that); 121 return this->onIsEqual(that);
111 } 122 }
112 123
113 struct InitBT { 124 struct InitBT {
114 bool fOutputColor; 125 bool fOutputColor;
115 bool fOutputCoverage; 126 bool fOutputCoverage;
116 GrColor fColor; 127 GrColor fColor;
117 GrColor fCoverage; 128 GrColor fCoverage;
118 }; 129 };
119 130
120 virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {} 131 virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
121 132
133 GrColor getColor() const { return fColor; }
134 uint8_t getCoverage() const { return fCoverage; }
135
122 // TODO this is a total hack until the gp can own whether or not it uses uni form 136 // TODO this is a total hack until the gp can own whether or not it uses uni form
123 // color / coverage 137 // color / coverage
124 bool hasVertexColor() const { return fHasVertexColor; } 138 bool hasVertexColor() const { return fHasVertexColor; }
125 bool hasVertexCoverage() const { return fHasVertexCoverage; } 139 bool hasVertexCoverage() const { return fHasVertexCoverage; }
126 bool hasLocalCoords() const { return fHasLocalCoords; } 140 bool hasLocalCoords() const { return fHasLocalCoords; }
127 141
142 void computeInvariantColor(GrInvariantOutput* inout) const;
143
128 protected: 144 protected:
129 /** 145 /**
130 * Subclasses call this from their constructor to register vertex attributes . Attributes 146 * Subclasses call this from their constructor to register vertex attributes . Attributes
131 * will be padded to the nearest 4 bytes for performance reasons. 147 * will be padded to the nearest 4 bytes for performance reasons.
132 * TODO After deferred geometry, we should do all of this inline in Generate Geometry alongside 148 * TODO After deferred geometry, we should do all of this inline in Generate Geometry alongside
133 * the struct used to actually populate the attributes 149 * the struct used to actually populate the attributes
134 */ 150 */
135 const GrAttribute& addVertexAttrib(const GrAttribute& attribute) { 151 const GrAttribute& addVertexAttrib(const GrAttribute& attribute) {
136 fVertexStride += attribute.fOffset; 152 fVertexStride += attribute.fOffset;
137 return fAttribs.push_back(attribute); 153 return fAttribs.push_back(attribute);
138 } 154 }
139 155
140 void setWillUseGeoShader() { fWillUseGeoShader = true; } 156 void setWillUseGeoShader() { fWillUseGeoShader = true; }
141 157
142 // TODO hack see above 158 // TODO hack see above
143 void setHasVertexColor() { fHasVertexColor = true; } 159 void setHasVertexColor() { fHasVertexColor = true; }
144 void setHasVertexCoverage() { fHasVertexCoverage = true; } 160 void setHasVertexCoverage() { fHasVertexCoverage = true; }
145 void setHasLocalCoords() { fHasLocalCoords = true; } 161 void setHasLocalCoords() { fHasLocalCoords = true; }
146 162
147 private: 163 private:
148 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; 164 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
149 165
150 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; 166 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs;
151 size_t fVertexStride; 167 size_t fVertexStride;
168 GrColor fColor;
169 uint8_t fCoverage;
152 bool fWillUseGeoShader; 170 bool fWillUseGeoShader;
153 bool fHasVertexColor; 171 bool fHasVertexColor;
154 bool fHasVertexCoverage; 172 bool fHasVertexCoverage;
155 bool fHasLocalCoords; 173 bool fHasLocalCoords;
156 174
157 typedef GrProcessor INHERITED; 175 typedef GrProcessor INHERITED;
158 }; 176 };
159 #endif 177 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698