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 b->add32(local.fInputColorType); | 79 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; |
| 80 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0
x2 : 0x0; |
| 81 b->add32(local.fInputColorType << 16 | key); |
80 } | 82 } |
81 | 83 |
82 private: | 84 private: |
83 GrColor fColor; | 85 GrColor fColor; |
84 UniformHandle fColorUniform; | 86 UniformHandle fColorUniform; |
85 | 87 |
86 typedef GrGLGeometryProcessor INHERITED; | 88 typedef GrGLGeometryProcessor INHERITED; |
87 }; | 89 }; |
88 | 90 |
89 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
90 | 92 |
91 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, | 93 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, |
92 const GrTextureParams& params, bool use
ColorAttrib, | 94 const GrTextureParams& params, bool use
ColorAttrib, |
93 bool opaqueVertexColors) | 95 bool opaqueVertexColors, const SkMatrix
& localMatrix) |
94 : INHERITED(color, opaqueVertexColors), fTextureAccess(texture, params), fIn
Color(NULL) { | 96 : INHERITED(color, opaqueVertexColors, localMatrix) |
| 97 , fTextureAccess(texture, params) |
| 98 , fInColor(NULL) { |
95 this->initClassID<GrBitmapTextGeoProc>(); | 99 this->initClassID<GrBitmapTextGeoProc>(); |
96 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 100 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
97 if (useColorAttrib) { | 101 if (useColorAttrib) { |
98 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte
xAttribType)); | 102 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte
xAttribType)); |
99 this->setHasVertexColor(); | 103 this->setHasVertexColor(); |
100 } | 104 } |
101 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", | 105 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", |
102 kVec2f_GrVertexAttribT
ype)); | 106 kVec2f_GrVertexAttribT
ype)); |
103 this->addTextureAccess(&fTextureAccess); | 107 this->addTextureAccess(&fTextureAccess); |
104 } | 108 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 SkShader::kMirror_TileMode, | 169 SkShader::kMirror_TileMode, |
166 }; | 170 }; |
167 SkShader::TileMode tileModes[] = { | 171 SkShader::TileMode tileModes[] = { |
168 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 172 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
169 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 173 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
170 }; | 174 }; |
171 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 175 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
172 GrTextureParams::kNon
e_FilterMode); | 176 GrTextureParams::kNon
e_FilterMode); |
173 | 177 |
174 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, | 178 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, |
175 random->nextBool(), random->nextBool()); | 179 random->nextBool(), random->nextBool(), |
| 180 GrProcessorUnitTest::TestMatrix(random)); |
176 } | 181 } |
OLD | NEW |