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

Side by Side Diff: src/gpu/GrDefaultGeoProcFactory.cpp

Issue 1127953003: Remove viewmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup3
Patch Set: Created 5 years, 7 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
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 #include "GrDefaultGeoProcFactory.h" 8 #include "GrDefaultGeoProcFactory.h"
9 9
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 21 matching lines...) Expand all
32 coverage)); 32 coverage));
33 } 33 }
34 34
35 const char* name() const override { return "DefaultGeometryProcessor"; } 35 const char* name() const override { return "DefaultGeometryProcessor"; }
36 36
37 const Attribute* inPosition() const { return fInPosition; } 37 const Attribute* inPosition() const { return fInPosition; }
38 const Attribute* inColor() const { return fInColor; } 38 const Attribute* inColor() const { return fInColor; }
39 const Attribute* inLocalCoords() const { return fInLocalCoords; } 39 const Attribute* inLocalCoords() const { return fInLocalCoords; }
40 const Attribute* inCoverage() const { return fInCoverage; } 40 const Attribute* inCoverage() const { return fInCoverage; }
41 GrColor color() const { return fColor; } 41 GrColor color() const { return fColor; }
42 const SkMatrix& viewMatrix() const { return fViewMatrix; }
42 uint8_t coverage() const { return fCoverage; } 43 uint8_t coverage() const { return fCoverage; }
43 44
44 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override { 45 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
45 BatchTracker* local = bt->cast<BatchTracker>(); 46 BatchTracker* local = bt->cast<BatchTracker>();
46 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, 47 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init,
47 SkToBool(fInColor)); 48 SkToBool(fInColor));
48 49
49 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored ; 50 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored ;
50 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage(); 51 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage();
51 if (init.fCoverageIgnored) { 52 if (init.fCoverageIgnored) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 static inline void GenKey(const GrGeometryProcessor& gp, 116 static inline void GenKey(const GrGeometryProcessor& gp,
116 const GrBatchTracker& bt, 117 const GrBatchTracker& bt,
117 const GrGLSLCaps&, 118 const GrGLSLCaps&,
118 GrProcessorKeyBuilder* b) { 119 GrProcessorKeyBuilder* b) {
119 const DefaultGeoProc& def = gp.cast<DefaultGeoProc>(); 120 const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
120 const BatchTracker& local = bt.cast<BatchTracker>(); 121 const BatchTracker& local = bt.cast<BatchTracker>();
121 uint32_t key = def.fFlags; 122 uint32_t key = def.fFlags;
122 key |= local.fInputColorType << 8 | local.fInputCoverageType << 16; 123 key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
123 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0; 124 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
124 key |= ComputePosKey(gp.viewMatrix()) << 25; 125 key |= ComputePosKey(def.viewMatrix()) << 25;
125 b->add32(key); 126 b->add32(key);
126 } 127 }
127 128
128 virtual void setData(const GrGLProgramDataManager& pdman, 129 virtual void setData(const GrGLProgramDataManager& pdman,
129 const GrPrimitiveProcessor& gp, 130 const GrPrimitiveProcessor& gp,
130 const GrBatchTracker& bt) override { 131 const GrBatchTracker& bt) override {
131 this->setUniformViewMatrix(pdman, gp.viewMatrix()); 132 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
133 this->setUniformViewMatrix(pdman, dgp.viewMatrix());
132 134
133 const BatchTracker& local = bt.cast<BatchTracker>(); 135 const BatchTracker& local = bt.cast<BatchTracker>();
134 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f Color) { 136 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f Color) {
135 GrGLfloat c[4]; 137 GrGLfloat c[4];
136 GrColorToRGBAFloat(local.fColor, c); 138 GrColorToRGBAFloat(local.fColor, c);
137 pdman.set4fv(fColorUniform, 1, c); 139 pdman.set4fv(fColorUniform, 1, c);
138 fColor = local.fColor; 140 fColor = local.fColor;
139 } 141 }
140 if (kUniform_GrGPInput == local.fInputCoverageType && local.fCoverag e != fCoverage) { 142 if (kUniform_GrGPInput == local.fInputCoverageType && local.fCoverag e != fCoverage) {
141 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(local.fCove rage)); 143 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(local.fCove rage));
(...skipping 20 matching lines...) Expand all
162 const GrGLSLCaps&) const ov erride { 164 const GrGLSLCaps&) const ov erride {
163 return SkNEW_ARGS(GLProcessor, (*this, bt)); 165 return SkNEW_ARGS(GLProcessor, (*this, bt));
164 } 166 }
165 167
166 private: 168 private:
167 DefaultGeoProc(uint32_t gpTypeFlags, 169 DefaultGeoProc(uint32_t gpTypeFlags,
168 GrColor color, 170 GrColor color,
169 const SkMatrix& viewMatrix, 171 const SkMatrix& viewMatrix,
170 const SkMatrix& localMatrix, 172 const SkMatrix& localMatrix,
171 uint8_t coverage) 173 uint8_t coverage)
172 : INHERITED(viewMatrix, localMatrix) 174 : INHERITED(localMatrix)
173 , fInPosition(NULL) 175 , fInPosition(NULL)
174 , fInColor(NULL) 176 , fInColor(NULL)
175 , fInLocalCoords(NULL) 177 , fInLocalCoords(NULL)
176 , fInCoverage(NULL) 178 , fInCoverage(NULL)
177 , fColor(color) 179 , fColor(color)
180 , fViewMatrix(viewMatrix)
178 , fCoverage(coverage) 181 , fCoverage(coverage)
179 , fFlags(gpTypeFlags) { 182 , fFlags(gpTypeFlags) {
180 this->initClassID<DefaultGeoProc>(); 183 this->initClassID<DefaultGeoProc>();
181 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G PType); 184 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G PType);
182 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo calCoord_GPType); 185 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo calCoord_GPType);
183 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove rage_GPType); 186 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove rage_GPType);
184 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 187 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
185 if (hasColor) { 188 if (hasColor) {
186 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVer texAttribType)); 189 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVer texAttribType));
187 } 190 }
(...skipping 13 matching lines...) Expand all
201 GrGPInput fInputCoverageType; 204 GrGPInput fInputCoverageType;
202 GrColor fColor; 205 GrColor fColor;
203 GrColor fCoverage; 206 GrColor fCoverage;
204 bool fUsesLocalCoords; 207 bool fUsesLocalCoords;
205 }; 208 };
206 209
207 const Attribute* fInPosition; 210 const Attribute* fInPosition;
208 const Attribute* fInColor; 211 const Attribute* fInColor;
209 const Attribute* fInLocalCoords; 212 const Attribute* fInLocalCoords;
210 const Attribute* fInCoverage; 213 const Attribute* fInCoverage;
211 GrColor fColor; 214 GrColor fColor;
robertphillips 2015/05/14 16:35:24 Can this be const?
215 SkMatrix fViewMatrix;
212 uint8_t fCoverage; 216 uint8_t fCoverage;
213 uint32_t fFlags; 217 uint32_t fFlags;
214 218
215 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 219 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
216 220
217 typedef GrGeometryProcessor INHERITED; 221 typedef GrGeometryProcessor INHERITED;
218 }; 222 };
219 223
220 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); 224 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
221 225
(...skipping 23 matching lines...) Expand all
245 GrColor color, 249 GrColor color,
246 const SkMatrix& viewM atrix, 250 const SkMatrix& viewM atrix,
247 const SkMatrix& local Matrix, 251 const SkMatrix& local Matrix,
248 uint8_t coverage) { 252 uint8_t coverage) {
249 return DefaultGeoProc::Create(gpTypeFlags, 253 return DefaultGeoProc::Create(gpTypeFlags,
250 color, 254 color,
251 viewMatrix, 255 viewMatrix,
252 localMatrix, 256 localMatrix,
253 coverage); 257 coverage);
254 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698