| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 bool opaqueVertexColors, | 28 bool opaqueVertexColors, |
| 29 uint8_t coverage) { | 29 uint8_t coverage) { |
| 30 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, | 30 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, |
| 31 color, | 31 color, |
| 32 viewMatrix, | 32 viewMatrix, |
| 33 localMatrix, | 33 localMatrix, |
| 34 opaqueVertexColors, | 34 opaqueVertexColors, |
| 35 coverage)); | 35 coverage)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces
sor"; } | 38 const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } |
| 39 | 39 |
| 40 const GrAttribute* inPosition() const { return fInPosition; } | 40 const GrAttribute* inPosition() const { return fInPosition; } |
| 41 const GrAttribute* inColor() const { return fInColor; } | 41 const GrAttribute* inColor() const { return fInColor; } |
| 42 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } | 42 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } |
| 43 const GrAttribute* inCoverage() const { return fInCoverage; } | 43 const GrAttribute* inCoverage() const { return fInCoverage; } |
| 44 uint8_t coverage() const { return fCoverage; } | 44 uint8_t coverage() const { return fCoverage; } |
| 45 | 45 |
| 46 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 46 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 47 BatchTracker* local = bt->cast<BatchTracker>(); | 47 BatchTracker* local = bt->cast<BatchTracker>(); |
| 48 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, | 48 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 76 theirs.fInputColorType, theirs.fColor) && | 76 theirs.fInputColorType, theirs.fColor) && |
| 77 CanCombineOutput(mine.fInputCoverageType, mine.fCoverage, | 77 CanCombineOutput(mine.fInputCoverageType, mine.fCoverage, |
| 78 theirs.fInputCoverageType, theirs.fCoverage); | 78 theirs.fInputCoverageType, theirs.fCoverage); |
| 79 } | 79 } |
| 80 | 80 |
| 81 class GLProcessor : public GrGLGeometryProcessor { | 81 class GLProcessor : public GrGLGeometryProcessor { |
| 82 public: | 82 public: |
| 83 GLProcessor(const GrGeometryProcessor& gp, const GrBatchTracker&) | 83 GLProcessor(const GrGeometryProcessor& gp, const GrBatchTracker&) |
| 84 : fColor(GrColor_ILLEGAL), fCoverage(0xff) {} | 84 : fColor(GrColor_ILLEGAL), fCoverage(0xff) {} |
| 85 | 85 |
| 86 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 86 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
| 87 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>(); | 87 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>(); |
| 88 GrGLGPBuilder* pb = args.fPB; | 88 GrGLGPBuilder* pb = args.fPB; |
| 89 GrGLVertexBuilder* vs = pb->getVertexShaderBuilder(); | 89 GrGLVertexBuilder* vs = pb->getVertexShaderBuilder(); |
| 90 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder(); | 90 GrGLGPFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder(); |
| 91 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 91 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
| 92 | 92 |
| 93 vs->codeAppendf("%s = %s;", vs->positionCoords(), gp.inPosition()->f
Name); | 93 vs->codeAppendf("%s = %s;", vs->positionCoords(), gp.inPosition()->f
Name); |
| 94 | 94 |
| 95 // Setup pass through color | 95 // Setup pass through color |
| 96 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, gp.inColor(), | 96 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, gp.inColor(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 typedef GrGLGeometryProcessor INHERITED; | 168 typedef GrGLGeometryProcessor INHERITED; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 171 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 172 const GrGLCaps& caps, | 172 const GrGLCaps& caps, |
| 173 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 173 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 174 GLProcessor::GenKey(*this, bt, caps, b); | 174 GLProcessor::GenKey(*this, bt, caps, b); |
| 175 } | 175 } |
| 176 | 176 |
| 177 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 177 GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_O
VERRIDE { |
| 178 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 178 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 DefaultGeoProc(uint32_t gpTypeFlags, | 182 DefaultGeoProc(uint32_t gpTypeFlags, |
| 183 GrColor color, | 183 GrColor color, |
| 184 const SkMatrix& viewMatrix, | 184 const SkMatrix& viewMatrix, |
| 185 const SkMatrix& localMatrix, | 185 const SkMatrix& localMatrix, |
| 186 bool opaqueVertexColors, | 186 bool opaqueVertexColors, |
| 187 uint8_t coverage) | 187 uint8_t coverage) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 205 fInLocalCoords = &this->addVertexAttrib(GrAttribute("inLocalCoord", | 205 fInLocalCoords = &this->addVertexAttrib(GrAttribute("inLocalCoord", |
| 206 kVec2f_GrVertexA
ttribType)); | 206 kVec2f_GrVertexA
ttribType)); |
| 207 this->setHasLocalCoords(); | 207 this->setHasLocalCoords(); |
| 208 } | 208 } |
| 209 if (hasCoverage) { | 209 if (hasCoverage) { |
| 210 fInCoverage = &this->addVertexAttrib(GrAttribute("inCoverage", | 210 fInCoverage = &this->addVertexAttrib(GrAttribute("inCoverage", |
| 211 kFloat_GrVertexAttr
ibType)); | 211 kFloat_GrVertexAttr
ibType)); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 215 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 216 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); | 216 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); |
| 217 return gp.fFlags == this->fFlags; | 217 return gp.fFlags == this->fFlags; |
| 218 } | 218 } |
| 219 | 219 |
| 220 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 220 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { |
| 221 if (fInCoverage) { | 221 if (fInCoverage) { |
| 222 out->setUnknownSingleComponent(); | 222 out->setUnknownSingleComponent(); |
| 223 } else { | 223 } else { |
| 224 // uniform coverage | 224 // uniform coverage |
| 225 out->setKnownSingleComponent(this->coverage()); | 225 out->setKnownSingleComponent(this->coverage()); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 struct BatchTracker { | 229 struct BatchTracker { |
| 230 GrGPInput fInputColorType; | 230 GrGPInput fInputColorType; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const SkMatrix& local
Matrix, | 277 const SkMatrix& local
Matrix, |
| 278 bool opaqueVertexColo
rs, | 278 bool opaqueVertexColo
rs, |
| 279 uint8_t coverage) { | 279 uint8_t coverage) { |
| 280 return DefaultGeoProc::Create(gpTypeFlags, | 280 return DefaultGeoProc::Create(gpTypeFlags, |
| 281 color, | 281 color, |
| 282 viewMatrix, | 282 viewMatrix, |
| 283 localMatrix, | 283 localMatrix, |
| 284 opaqueVertexColors, | 284 opaqueVertexColors, |
| 285 coverage); | 285 coverage); |
| 286 } | 286 } |
| OLD | NEW |