| 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 "GrFontAtlasSizes.h" | 9 #include "GrFontAtlasSizes.h" |
| 10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 85 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
| 86 GrGLfloat c[4]; | 86 GrGLfloat c[4]; |
| 87 GrColorToRGBAFloat(local.fColor, c); | 87 GrColorToRGBAFloat(local.fColor, c); |
| 88 pdman.set4fv(fColorUniform, 1, c); | 88 pdman.set4fv(fColorUniform, 1, c); |
| 89 fColor = local.fColor; | 89 fColor = local.fColor; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 static inline void GenKey(const GrGeometryProcessor& proc, | 93 static inline void GenKey(const GrGeometryProcessor& proc, |
| 94 const GrBatchTracker& bt, | 94 const GrBatchTracker& bt, |
| 95 const GrGLCaps&, | 95 const GrGLSLCaps&, |
| 96 GrProcessorKeyBuilder* b) { | 96 GrProcessorKeyBuilder* b) { |
| 97 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); | 97 const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); |
| 98 // We have to put the optional vertex attribute as part of the key. See
the comment | 98 // We have to put the optional vertex attribute as part of the key. See
the comment |
| 99 // on addVertexAttrib. | 99 // on addVertexAttrib. |
| 100 // TODO When we have deferred geometry we can fix this | 100 // TODO When we have deferred geometry we can fix this |
| 101 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); | 101 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); |
| 102 uint32_t key = 0; | 102 uint32_t key = 0; |
| 103 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; | 103 key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; |
| 104 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0
x2 : 0x0; | 104 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0
x2 : 0x0; |
| 105 key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0; | 105 key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } else { | 157 } else { |
| 158 out->setUnknownFourComponents(); | 158 out->setUnknownFourComponents(); |
| 159 out->setUsingLCDCoverage(); | 159 out->setUsingLCDCoverage(); |
| 160 } | 160 } |
| 161 } else { | 161 } else { |
| 162 out->setKnownSingleComponent(0xff); | 162 out->setKnownSingleComponent(0xff); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, | 166 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt, |
| 167 const GrGLCaps& caps, | 167 const GrGLSLCaps& caps, |
| 168 GrProcessorKeyBuilder* b) const { | 168 GrProcessorKeyBuilder* b) const { |
| 169 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b); | 169 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b); |
| 170 } | 170 } |
| 171 | 171 |
| 172 GrGLPrimitiveProcessor* | 172 GrGLPrimitiveProcessor* |
| 173 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, | 173 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, |
| 174 const GrGLCaps& caps) const { | 174 const GrGLSLCaps& caps) const { |
| 175 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); | 175 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI
nfo& init) const { | 178 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const GrPipelineI
nfo& init) const { |
| 179 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); | 179 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); |
| 180 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | 180 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, |
| 181 SkToBool(fInColor)); | 181 SkToBool(fInColor)); |
| 182 local->fUsesLocalCoords = init.fUsesLocalCoords; | 182 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 183 } | 183 } |
| 184 | 184 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 break; | 227 break; |
| 228 case 2: | 228 case 2: |
| 229 format = kARGB_GrMaskFormat; | 229 format = kARGB_GrMaskFormat; |
| 230 break; | 230 break; |
| 231 } | 231 } |
| 232 | 232 |
| 233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, | 233 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, |
| 234 format, random->nextBool(), | 234 format, random->nextBool(), |
| 235 GrProcessorUnitTest::TestMatrix(random)); | 235 GrProcessorUnitTest::TestMatrix(random)); |
| 236 } | 236 } |
| OLD | NEW |