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 #include "GrDefaultGeoProcFactory.h" | 8 #include "GrDefaultGeoProcFactory.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
11 #include "GrInvariantOutput.h" | 11 #include "GrInvariantOutput.h" |
12 #include "gl/GrGLGeometryProcessor.h" | 12 #include "gl/GrGLGeometryProcessor.h" |
13 #include "gl/builders/GrGLProgramBuilder.h" | 13 #include "gl/builders/GrGLProgramBuilder.h" |
14 | 14 |
15 /* | 15 /* |
16 * The default Geometry Processor simply takes position and multiplies it by the
uniform view | 16 * The default Geometry Processor simply takes position and multiplies it by the
uniform view |
17 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per
vertex color or | 17 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per
vertex color or |
18 * local coords. | 18 * local coords. |
19 */ | 19 */ |
20 typedef GrDefaultGeoProcFactory Flag; | 20 typedef GrDefaultGeoProcFactory Flag; |
21 | 21 |
22 class DefaultGeoProc : public GrGeometryProcessor { | 22 class DefaultGeoProc : public GrGeometryProcessor { |
23 public: | 23 public: |
24 static GrGeometryProcessor* Create(GrColor color, uint8_t coverage, uint32_t
gpTypeFlags, | 24 static GrGeometryProcessor* Create(uint32_t gpTypeFlags, |
25 bool opaqueVertexColors, const SkMatrix&
localMatrix) { | 25 GrColor color, |
26 return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueV
ertexColors, | 26 const SkMatrix& viewMatrix, |
27 localMatrix)); | 27 const SkMatrix& localMatrix, |
| 28 bool opaqueVertexColors, |
| 29 uint8_t coverage) { |
| 30 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, |
| 31 color, |
| 32 viewMatrix, |
| 33 localMatrix, |
| 34 opaqueVertexColors, |
| 35 coverage)); |
28 } | 36 } |
29 | 37 |
30 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces
sor"; } | 38 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces
sor"; } |
31 | 39 |
32 const GrAttribute* inPosition() const { return fInPosition; } | 40 const GrAttribute* inPosition() const { return fInPosition; } |
33 const GrAttribute* inColor() const { return fInColor; } | 41 const GrAttribute* inColor() const { return fInColor; } |
34 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } | 42 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } |
35 const GrAttribute* inCoverage() const { return fInCoverage; } | 43 const GrAttribute* inCoverage() const { return fInCoverage; } |
36 uint8_t coverage() const { return fCoverage; } | 44 uint8_t coverage() const { return fCoverage; } |
37 | 45 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 const GrGLCaps& caps, | 167 const GrGLCaps& caps, |
160 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 168 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
161 GLProcessor::GenKey(*this, bt, caps, b); | 169 GLProcessor::GenKey(*this, bt, caps, b); |
162 } | 170 } |
163 | 171 |
164 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 172 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { |
165 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 173 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
166 } | 174 } |
167 | 175 |
168 private: | 176 private: |
169 DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool o
paqueVertexColors, | 177 DefaultGeoProc(uint32_t gpTypeFlags, |
170 const SkMatrix& localMatrix) | 178 GrColor color, |
171 : INHERITED(color, opaqueVertexColors, localMatrix) | 179 const SkMatrix& viewMatrix, |
| 180 const SkMatrix& localMatrix, |
| 181 bool opaqueVertexColors, |
| 182 uint8_t coverage) |
| 183 : INHERITED(color, viewMatrix, localMatrix, opaqueVertexColors) |
172 , fInPosition(NULL) | 184 , fInPosition(NULL) |
173 , fInColor(NULL) | 185 , fInColor(NULL) |
174 , fInLocalCoords(NULL) | 186 , fInLocalCoords(NULL) |
175 , fInCoverage(NULL) | 187 , fInCoverage(NULL) |
176 , fCoverage(coverage) | 188 , fCoverage(coverage) |
177 , fFlags(gpTypeFlags) { | 189 , fFlags(gpTypeFlags) { |
178 this->initClassID<DefaultGeoProc>(); | 190 this->initClassID<DefaultGeoProc>(); |
179 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); | 191 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); |
180 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); | 192 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); |
181 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); | 193 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (random->nextBool()) { | 251 if (random->nextBool()) { |
240 flags |= GrDefaultGeoProcFactory::kColor_GPType; | 252 flags |= GrDefaultGeoProcFactory::kColor_GPType; |
241 } | 253 } |
242 if (random->nextBool()) { | 254 if (random->nextBool()) { |
243 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; | 255 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; |
244 } | 256 } |
245 if (random->nextBool()) { | 257 if (random->nextBool()) { |
246 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; | 258 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; |
247 } | 259 } |
248 | 260 |
249 return DefaultGeoProc::Create(GrRandomColor(random), GrRandomCoverage(random
), | 261 return DefaultGeoProc::Create(flags, |
250 flags, random->nextBool(), | 262 GrRandomColor(random), |
251 GrProcessorUnitTest::TestMatrix(random)); | 263 GrProcessorUnitTest::TestMatrix(random), |
| 264 GrProcessorUnitTest::TestMatrix(random), |
| 265 random->nextBool(), |
| 266 GrRandomCoverage(random)); |
252 } | 267 } |
253 | 268 |
254 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(GrColor color, | 269 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, |
255 uint32_t gpTypeFlags, | 270 GrColor color, |
| 271 const SkMatrix& viewM
atrix, |
| 272 const SkMatrix& local
Matrix, |
256 bool opaqueVertexColo
rs, | 273 bool opaqueVertexColo
rs, |
257 uint8_t coverage, | 274 uint8_t coverage) { |
258 const SkMatrix& local
Matrix) { | 275 return DefaultGeoProc::Create(gpTypeFlags, |
259 return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColo
rs, localMatrix); | 276 color, |
| 277 viewMatrix, |
| 278 localMatrix, |
| 279 opaqueVertexColors, |
| 280 coverage); |
260 } | 281 } |
OLD | NEW |