Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "GrBitmapTextGeoProc.h" | 8 #include "GrBitmapTextGeoProc.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); | 29 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); |
| 30 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack er>(); | 30 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack er>(); |
| 31 | 31 |
| 32 GrGLGPBuilder* pb = args.fPB; | 32 GrGLGPBuilder* pb = args.fPB; |
| 33 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 33 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 34 | 34 |
| 35 // emit attributes | 35 // emit attributes |
| 36 vsBuilder->emitAttributes(cte); | 36 vsBuilder->emitAttributes(cte); |
| 37 | 37 |
| 38 GrGLVertToFrag v(kVec2f_GrSLType); | 38 GrGLVertToFrag v(kVec2f_GrSLType); |
| 39 pb->addVarying("TextureCoords", &v); | 39 pb->addVarying("TextureCoords", &v); |
|
robertphillips
2015/02/13 16:10:42
Don't we have #defines for these ?
Also comment ?
jvanverth1
2015/02/13 19:58:56
Done.
| |
| 40 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fNa me); | 40 vsBuilder->codeAppendf("%s = vec2(0.0009765625, 0.00048828125)*%s;", v.v sOut(), |
| 41 cte.inTextureCoords()->fName); | |
| 41 | 42 |
| 42 // Setup pass through color | 43 // Setup pass through color |
| 43 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , cte.inColor(), | 44 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor , cte.inColor(), |
| 44 &fColorUniform); | 45 &fColorUniform); |
| 45 | 46 |
| 46 // Setup position | 47 // Setup position |
| 47 this->setupPosition(pb, gpArgs, cte.inPosition()->fName, cte.viewMatrix( )); | 48 this->setupPosition(pb, gpArgs, cte.inPosition()->fName, cte.viewMatrix( )); |
| 48 | 49 |
| 49 // emit transforms | 50 // emit transforms |
| 50 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f Name, | 51 this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->f Name, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 , fMaskFormat(format) { | 116 , fMaskFormat(format) { |
| 116 this->initClassID<GrBitmapTextGeoProc>(); | 117 this->initClassID<GrBitmapTextGeoProc>(); |
| 117 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); | 118 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType)); |
| 118 | 119 |
| 119 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; | 120 bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat; |
| 120 if (hasVertexColor) { | 121 if (hasVertexColor) { |
| 121 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); | 122 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); |
| 122 this->setHasVertexColor(); | 123 this->setHasVertexColor(); |
| 123 } | 124 } |
| 124 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 125 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
| 125 kVec2f_GrVertexAttribTyp e)); | 126 kVec2s_GrVertexAttribTyp e)); |
| 126 this->addTextureAccess(&fTextureAccess); | 127 this->addTextureAccess(&fTextureAccess); |
| 127 } | 128 } |
| 128 | 129 |
| 129 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const { | 130 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const { |
| 130 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>(); | 131 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>(); |
| 131 return SkToBool(this->inColor()) == SkToBool(gp.inColor()); | 132 return SkToBool(this->inColor()) == SkToBool(gp.inColor()); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out) const { | 135 void GrBitmapTextGeoProc::onGetInvariantOutputColor(GrInitInvariantOutput* out) const { |
| 135 if (kARGB_GrMaskFormat == fMaskFormat) { | 136 if (kARGB_GrMaskFormat == fMaskFormat) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 break; | 218 break; |
| 218 case 2: | 219 case 2: |
| 219 format = kARGB_GrMaskFormat; | 220 format = kARGB_GrMaskFormat; |
| 220 break; | 221 break; |
| 221 } | 222 } |
| 222 | 223 |
| 223 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, | 224 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, |
| 224 format, random->nextBool(), | 225 format, random->nextBool(), |
| 225 GrProcessorUnitTest::TestMatrix(random)); | 226 GrProcessorUnitTest::TestMatrix(random)); |
| 226 } | 227 } |
| OLD | NEW |