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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 68 |
69 static inline void GenKey(const GrGeometryProcessor& proc, | 69 static inline void GenKey(const GrGeometryProcessor& proc, |
70 const GrBatchTracker& bt, | 70 const GrBatchTracker& bt, |
71 const GrGLCaps&, | 71 const GrGLCaps&, |
72 GrProcessorKeyBuilder* b) { | 72 GrProcessorKeyBuilder* b) { |
73 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); | 73 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); |
74 // We have to put the optional vertex attribute as part of the key. See the comment | 74 // We have to put the optional vertex attribute as part of the key. See the comment |
75 // on addVertexAttrib. | 75 // on addVertexAttrib. |
76 // TODO When we have deferred geometry we can fix this | 76 // TODO When we have deferred geometry we can fix this |
77 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); | 77 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); |
78 b->add32(SkToBool(gp.inColor())); | 78 uint32_t key = 0; |
79 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; | |
80 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0 x4 : 0x0; | |
bsalomon
2014/12/22 21:13:55
0x2?
| |
81 b->add32(key); | |
79 b->add32(local.fInputColorType); | 82 b->add32(local.fInputColorType); |
bsalomon
2014/12/22 21:13:55
Seems like colorInputType would fit in the availab
| |
80 } | 83 } |
81 | 84 |
82 private: | 85 private: |
83 GrColor fColor; | 86 GrColor fColor; |
84 UniformHandle fColorUniform; | 87 UniformHandle fColorUniform; |
85 | 88 |
86 typedef GrGLGeometryProcessor INHERITED; | 89 typedef GrGLGeometryProcessor INHERITED; |
87 }; | 90 }; |
88 | 91 |
89 /////////////////////////////////////////////////////////////////////////////// | 92 /////////////////////////////////////////////////////////////////////////////// |
90 | 93 |
91 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, | 94 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, |
92 const GrTextureParams& params, bool use ColorAttrib, | 95 const GrTextureParams& params, bool use ColorAttrib, |
93 bool opaqueVertexColors) | 96 bool opaqueVertexColors, const SkMatrix & localMatrix) |
94 : INHERITED(color, opaqueVertexColors), fTextureAccess(texture, params), fIn Color(NULL) { | 97 : INHERITED(color, opaqueVertexColors, localMatrix) |
98 , fTextureAccess(texture, params) | |
99 , fInColor(NULL) { | |
95 this->initClassID<GrBitmapTextGeoProc>(); | 100 this->initClassID<GrBitmapTextGeoProc>(); |
96 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); | 101 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); |
97 if (useColorAttrib) { | 102 if (useColorAttrib) { |
98 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte xAttribType)); | 103 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte xAttribType)); |
99 this->setHasVertexColor(); | 104 this->setHasVertexColor(); |
100 } | 105 } |
101 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", | 106 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", |
102 kVec2f_GrVertexAttribT ype)); | 107 kVec2f_GrVertexAttribT ype)); |
103 this->addTextureAccess(&fTextureAccess); | 108 this->addTextureAccess(&fTextureAccess); |
104 } | 109 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 SkShader::kMirror_TileMode, | 170 SkShader::kMirror_TileMode, |
166 }; | 171 }; |
167 SkShader::TileMode tileModes[] = { | 172 SkShader::TileMode tileModes[] = { |
168 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 173 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
169 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 174 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
170 }; | 175 }; |
171 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : | 176 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : |
172 GrTextureParams::kNon e_FilterMode); | 177 GrTextureParams::kNon e_FilterMode); |
173 | 178 |
174 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, | 179 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, |
175 random->nextBool(), random->nextBool()); | 180 random->nextBool(), random->nextBool(), |
181 GrProcessorUnitTest::TestMatrix(random)); | |
176 } | 182 } |
OLD | NEW |