| 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 "GrDistanceFieldGeoProc.h" | 8 #include "GrDistanceFieldGeoProc.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // adjust based on gamma | 50 // adjust based on gamma |
| 51 const char* distanceAdjustUniName = nullptr; | 51 const char* distanceAdjustUniName = nullptr; |
| 52 // width, height, 1/(3*width) | 52 // width, height, 1/(3*width) |
| 53 fDistanceAdjustUni = uniformHandler->addUniform(GrGLSLUniformHandler::kF
ragment_Visibility, | 53 fDistanceAdjustUni = uniformHandler->addUniform(GrGLSLUniformHandler::kF
ragment_Visibility, |
| 54 kFloat_GrSLType, kDefaul
t_GrSLPrecision, | 54 kFloat_GrSLType, kDefaul
t_GrSLPrecision, |
| 55 "DistanceAdjust", &dista
nceAdjustUniName); | 55 "DistanceAdjust", &dista
nceAdjustUniName); |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 // Setup pass through color | 58 // Setup pass through color |
| 59 if (!dfTexEffect.colorIgnored()) { | 59 if (!dfTexEffect.colorIgnored()) { |
| 60 if (dfTexEffect.hasVertexColor()) { | 60 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.
fOutputColor); |
| 61 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), a
rgs.fOutputColor); | |
| 62 } else { | |
| 63 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu
tColor, | |
| 64 &fColorUniform); | |
| 65 } | |
| 66 } | 61 } |
| 67 | 62 |
| 68 // Setup position | 63 // Setup position |
| 69 this->setupPosition(vertBuilder, | 64 this->setupPosition(vertBuilder, |
| 70 uniformHandler, | 65 uniformHandler, |
| 71 gpArgs, | 66 gpArgs, |
| 72 dfTexEffect.inPosition()->fName, | 67 dfTexEffect.inPosition()->fName, |
| 73 dfTexEffect.viewMatrix(), | 68 dfTexEffect.viewMatrix(), |
| 74 &fViewMatrixUniform); | 69 &fViewMatrixUniform); |
| 75 | 70 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 162 } |
| 168 #endif | 163 #endif |
| 169 const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8
TextGeoProc>(); | 164 const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8
TextGeoProc>(); |
| 170 | 165 |
| 171 if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8g
p.viewMatrix())) { | 166 if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8g
p.viewMatrix())) { |
| 172 fViewMatrix = dfa8gp.viewMatrix(); | 167 fViewMatrix = dfa8gp.viewMatrix(); |
| 173 float viewMatrix[3 * 3]; | 168 float viewMatrix[3 * 3]; |
| 174 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); | 169 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 175 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 170 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 176 } | 171 } |
| 177 | |
| 178 if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) { | |
| 179 float c[4]; | |
| 180 GrColorToRGBAFloat(dfa8gp.color(), c); | |
| 181 pdman.set4fv(fColorUniform, 1, c); | |
| 182 fColor = dfa8gp.color(); | |
| 183 } | |
| 184 } | 172 } |
| 185 | 173 |
| 186 static inline void GenKey(const GrGeometryProcessor& gp, | 174 static inline void GenKey(const GrGeometryProcessor& gp, |
| 187 const GrGLSLCaps&, | 175 const GrGLSLCaps&, |
| 188 GrProcessorKeyBuilder* b) { | 176 GrProcessorKeyBuilder* b) { |
| 189 const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFiel
dA8TextGeoProc>(); | 177 const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFiel
dA8TextGeoProc>(); |
| 190 uint32_t key = dfTexEffect.getFlags(); | 178 uint32_t key = dfTexEffect.getFlags(); |
| 191 key |= dfTexEffect.hasVertexColor() << 16; | 179 key |= dfTexEffect.colorIgnored() << 16; |
| 192 key |= dfTexEffect.colorIgnored() << 17; | |
| 193 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 180 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
| 194 b->add32(key); | 181 b->add32(key); |
| 195 | 182 |
| 196 // Currently we hardcode numbers to convert atlas coordinates to normali
zed floating point | 183 // Currently we hardcode numbers to convert atlas coordinates to normali
zed floating point |
| 197 SkASSERT(gp.numTextures() == 1); | 184 SkASSERT(gp.numTextures() == 1); |
| 198 GrTexture* atlas = gp.textureAccess(0).getTexture(); | 185 GrTexture* atlas = gp.textureAccess(0).getTexture(); |
| 199 SkASSERT(atlas); | 186 SkASSERT(atlas); |
| 200 b->add32(atlas->width()); | 187 b->add32(atlas->width()); |
| 201 b->add32(atlas->height()); | 188 b->add32(atlas->height()); |
| 202 } | 189 } |
| 203 | 190 |
| 204 private: | 191 private: |
| 205 SkMatrix fViewMatrix; | 192 SkMatrix fViewMatrix; |
| 206 GrColor fColor; | 193 GrColor fColor; |
| 207 UniformHandle fColorUniform; | |
| 208 UniformHandle fViewMatrixUniform; | 194 UniformHandle fViewMatrixUniform; |
| 209 #ifdef SK_GAMMA_APPLY_TO_A8 | 195 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 210 float fDistanceAdjust; | 196 float fDistanceAdjust; |
| 211 UniformHandle fDistanceAdjustUni; | 197 UniformHandle fDistanceAdjustUni; |
| 212 #endif | 198 #endif |
| 213 | 199 |
| 214 typedef GrGLSLGeometryProcessor INHERITED; | 200 typedef GrGLSLGeometryProcessor INHERITED; |
| 215 }; | 201 }; |
| 216 | 202 |
| 217 /////////////////////////////////////////////////////////////////////////////// | 203 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 13 matching lines...) Expand all Loading... |
| 231 #ifdef SK_GAMMA_APPLY_TO_A8 | 217 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 232 , fDistanceAdjust(distanceAdjust) | 218 , fDistanceAdjust(distanceAdjust) |
| 233 #endif | 219 #endif |
| 234 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 220 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
| 235 , fInColor(nullptr) | 221 , fInColor(nullptr) |
| 236 , fUsesLocalCoords(usesLocalCoords) { | 222 , fUsesLocalCoords(usesLocalCoords) { |
| 237 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 223 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
| 238 this->initClassID<GrDistanceFieldA8TextGeoProc>(); | 224 this->initClassID<GrDistanceFieldA8TextGeoProc>(); |
| 239 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 225 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
| 240 kHigh_GrSLPrecision)); | 226 kHigh_GrSLPrecision)); |
| 241 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 227 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttri
bType)); |
| 242 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | |
| 243 } | |
| 244 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 228 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
| 245 kVec2s_GrVertexAttribT
ype)); | 229 kVec2s_GrVertexAttribT
ype)); |
| 246 this->addTextureAccess(&fTextureAccess); | 230 this->addTextureAccess(&fTextureAccess); |
| 247 } | 231 } |
| 248 | 232 |
| 249 void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, | 233 void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
| 250 GrProcessorKeyBuilder* b)
const { | 234 GrProcessorKeyBuilder* b)
const { |
| 251 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b); | 235 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b); |
| 252 } | 236 } |
| 253 | 237 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 290 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 307 | 291 |
| 308 // emit attributes | 292 // emit attributes |
| 309 varyingHandler->emitAttributes(dfTexEffect); | 293 varyingHandler->emitAttributes(dfTexEffect); |
| 310 | 294 |
| 311 GrGLSLVertToFrag v(kVec2f_GrSLType); | 295 GrGLSLVertToFrag v(kVec2f_GrSLType); |
| 312 varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); | 296 varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); |
| 313 | 297 |
| 314 // setup pass through color | 298 // setup pass through color |
| 315 if (!dfTexEffect.colorIgnored()) { | 299 if (!dfTexEffect.colorIgnored()) { |
| 316 if (dfTexEffect.hasVertexColor()) { | 300 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.
fOutputColor); |
| 317 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), a
rgs.fOutputColor); | |
| 318 } else { | |
| 319 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu
tColor, | |
| 320 &fColorUniform); | |
| 321 } | |
| 322 } | 301 } |
| 323 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoo
rds()->fName); | 302 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoo
rds()->fName); |
| 324 | 303 |
| 325 // Setup position | 304 // Setup position |
| 326 this->setupPosition(vertBuilder, | 305 this->setupPosition(vertBuilder, |
| 327 uniformHandler, | 306 uniformHandler, |
| 328 gpArgs, | 307 gpArgs, |
| 329 dfTexEffect.inPosition()->fName, | 308 dfTexEffect.inPosition()->fName, |
| 330 dfTexEffect.viewMatrix(), | 309 dfTexEffect.viewMatrix(), |
| 331 &fViewMatrixUniform); | 310 &fViewMatrixUniform); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 387 } |
| 409 | 388 |
| 410 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG
eoProc>(); | 389 const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathG
eoProc>(); |
| 411 | 390 |
| 412 if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.
viewMatrix())) { | 391 if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.
viewMatrix())) { |
| 413 fViewMatrix = dfpgp.viewMatrix(); | 392 fViewMatrix = dfpgp.viewMatrix(); |
| 414 float viewMatrix[3 * 3]; | 393 float viewMatrix[3 * 3]; |
| 415 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); | 394 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 416 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 395 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 417 } | 396 } |
| 418 | |
| 419 if (dfpgp.color() != fColor && !dfpgp.hasVertexColor()) { | |
| 420 float c[4]; | |
| 421 GrColorToRGBAFloat(dfpgp.color(), c); | |
| 422 pdman.set4fv(fColorUniform, 1, c); | |
| 423 fColor = dfpgp.color(); | |
| 424 } | |
| 425 } | 397 } |
| 426 | 398 |
| 427 static inline void GenKey(const GrGeometryProcessor& gp, | 399 static inline void GenKey(const GrGeometryProcessor& gp, |
| 428 const GrGLSLCaps&, | 400 const GrGLSLCaps&, |
| 429 GrProcessorKeyBuilder* b) { | 401 GrProcessorKeyBuilder* b) { |
| 430 const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldP
athGeoProc>(); | 402 const GrDistanceFieldPathGeoProc& dfTexEffect = gp.cast<GrDistanceFieldP
athGeoProc>(); |
| 431 | 403 |
| 432 uint32_t key = dfTexEffect.getFlags(); | 404 uint32_t key = dfTexEffect.getFlags(); |
| 433 key |= dfTexEffect.colorIgnored() << 16; | 405 key |= dfTexEffect.colorIgnored() << 16; |
| 434 key |= dfTexEffect.hasVertexColor() << 17; | |
| 435 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 406 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
| 436 b->add32(key); | 407 b->add32(key); |
| 437 } | 408 } |
| 438 | 409 |
| 439 private: | 410 private: |
| 440 UniformHandle fColorUniform; | |
| 441 UniformHandle fTextureSizeUni; | 411 UniformHandle fTextureSizeUni; |
| 442 UniformHandle fViewMatrixUniform; | 412 UniformHandle fViewMatrixUniform; |
| 443 SkMatrix fViewMatrix; | 413 SkMatrix fViewMatrix; |
| 444 GrColor fColor; | 414 GrColor fColor; |
| 445 SkISize fTextureSize; | 415 SkISize fTextureSize; |
| 446 | 416 |
| 447 typedef GrGLSLGeometryProcessor INHERITED; | 417 typedef GrGLSLGeometryProcessor INHERITED; |
| 448 }; | 418 }; |
| 449 | 419 |
| 450 /////////////////////////////////////////////////////////////////////////////// | 420 /////////////////////////////////////////////////////////////////////////////// |
| 451 | 421 |
| 452 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( | 422 GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( |
| 453 GrColor color, | 423 GrColor color, |
| 454 const SkMatrix& viewMatrix, | 424 const SkMatrix& viewMatrix, |
| 455 GrTexture* texture, | 425 GrTexture* texture, |
| 456 const GrTextureParams& params, | 426 const GrTextureParams& params, |
| 457 uint32_t flags, | 427 uint32_t flags, |
| 458 bool usesLocalCoords) | 428 bool usesLocalCoords) |
| 459 : fColor(color) | 429 : fColor(color) |
| 460 , fViewMatrix(viewMatrix) | 430 , fViewMatrix(viewMatrix) |
| 461 , fTextureAccess(texture, params) | 431 , fTextureAccess(texture, params) |
| 462 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) | 432 , fFlags(flags & kNonLCD_DistanceFieldEffectMask) |
| 463 , fInColor(nullptr) | 433 , fInColor(nullptr) |
| 464 , fUsesLocalCoords(usesLocalCoords) { | 434 , fUsesLocalCoords(usesLocalCoords) { |
| 465 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 435 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
| 466 this->initClassID<GrDistanceFieldPathGeoProc>(); | 436 this->initClassID<GrDistanceFieldPathGeoProc>(); |
| 467 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 437 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
| 468 kHigh_GrSLPrecision)); | 438 kHigh_GrSLPrecision)); |
| 469 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 439 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttri
bType)); |
| 470 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | |
| 471 } | |
| 472 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 440 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
| 473 kVec2f_GrVertexAttribTyp
e)); | 441 kVec2f_GrVertexAttribTyp
e)); |
| 474 this->addTextureAccess(&fTextureAccess); | 442 this->addTextureAccess(&fTextureAccess); |
| 475 } | 443 } |
| 476 | 444 |
| 477 void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, | 445 void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
| 478 GrProcessorKeyBuilder* b) c
onst { | 446 GrProcessorKeyBuilder* b) c
onst { |
| 479 GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b); | 447 GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b); |
| 480 } | 448 } |
| 481 | 449 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; | 496 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; |
| 529 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 497 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 530 | 498 |
| 531 // emit attributes | 499 // emit attributes |
| 532 varyingHandler->emitAttributes(dfTexEffect); | 500 varyingHandler->emitAttributes(dfTexEffect); |
| 533 | 501 |
| 534 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 502 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 535 | 503 |
| 536 // setup pass through color | 504 // setup pass through color |
| 537 if (!dfTexEffect.colorIgnored()) { | 505 if (!dfTexEffect.colorIgnored()) { |
| 538 if (dfTexEffect.hasVertexColor()) { | 506 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.
fOutputColor); |
| 539 varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), a
rgs.fOutputColor); | |
| 540 } else { | |
| 541 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu
tColor, | |
| 542 &fColorUniform); | |
| 543 } | |
| 544 } | 507 } |
| 545 | 508 |
| 546 // Setup position | 509 // Setup position |
| 547 this->setupPosition(vertBuilder, | 510 this->setupPosition(vertBuilder, |
| 548 uniformHandler, | 511 uniformHandler, |
| 549 gpArgs, | 512 gpArgs, |
| 550 dfTexEffect.inPosition()->fName, | 513 dfTexEffect.inPosition()->fName, |
| 551 dfTexEffect.viewMatrix(), | 514 dfTexEffect.viewMatrix(), |
| 552 &fViewMatrixUniform); | 515 &fViewMatrixUniform); |
| 553 | 516 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 wa.fB); | 656 wa.fB); |
| 694 fDistanceAdjust = wa; | 657 fDistanceAdjust = wa; |
| 695 } | 658 } |
| 696 | 659 |
| 697 if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd.
viewMatrix())) { | 660 if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd.
viewMatrix())) { |
| 698 fViewMatrix = dflcd.viewMatrix(); | 661 fViewMatrix = dflcd.viewMatrix(); |
| 699 float viewMatrix[3 * 3]; | 662 float viewMatrix[3 * 3]; |
| 700 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); | 663 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 701 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 664 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 702 } | 665 } |
| 703 | |
| 704 if (dflcd.color() != fColor && !dflcd.hasVertexColor()) { | |
| 705 float c[4]; | |
| 706 GrColorToRGBAFloat(dflcd.color(), c); | |
| 707 pdman.set4fv(fColorUniform, 1, c); | |
| 708 fColor = dflcd.color(); | |
| 709 } | |
| 710 } | 666 } |
| 711 | 667 |
| 712 static inline void GenKey(const GrGeometryProcessor& gp, | 668 static inline void GenKey(const GrGeometryProcessor& gp, |
| 713 const GrGLSLCaps&, | 669 const GrGLSLCaps&, |
| 714 GrProcessorKeyBuilder* b) { | 670 GrProcessorKeyBuilder* b) { |
| 715 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFie
ldLCDTextGeoProc>(); | 671 const GrDistanceFieldLCDTextGeoProc& dfTexEffect = gp.cast<GrDistanceFie
ldLCDTextGeoProc>(); |
| 716 | 672 |
| 717 uint32_t key = dfTexEffect.getFlags(); | 673 uint32_t key = dfTexEffect.getFlags(); |
| 718 key |= dfTexEffect.colorIgnored() << 16; | 674 key |= dfTexEffect.colorIgnored() << 16; |
| 719 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; | 675 key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 748 : fColor(color) | 704 : fColor(color) |
| 749 , fViewMatrix(viewMatrix) | 705 , fViewMatrix(viewMatrix) |
| 750 , fTextureAccess(texture, params) | 706 , fTextureAccess(texture, params) |
| 751 , fDistanceAdjust(distanceAdjust) | 707 , fDistanceAdjust(distanceAdjust) |
| 752 , fFlags(flags & kLCD_DistanceFieldEffectMask) | 708 , fFlags(flags & kLCD_DistanceFieldEffectMask) |
| 753 , fUsesLocalCoords(usesLocalCoords) { | 709 , fUsesLocalCoords(usesLocalCoords) { |
| 754 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); | 710 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); |
| 755 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); | 711 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); |
| 756 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 712 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
| 757 kHigh_GrSLPrecision)); | 713 kHigh_GrSLPrecision)); |
| 758 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 714 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttri
bType)); |
| 759 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | |
| 760 } | |
| 761 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 715 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
| 762 kVec2s_GrVertexAttribTyp
e)); | 716 kVec2s_GrVertexAttribTyp
e)); |
| 763 this->addTextureAccess(&fTextureAccess); | 717 this->addTextureAccess(&fTextureAccess); |
| 764 } | 718 } |
| 765 | 719 |
| 766 void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, | 720 void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
| 767 GrProcessorKeyBuilder* b
) const { | 721 GrProcessorKeyBuilder* b
) const { |
| 768 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b); | 722 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b); |
| 769 } | 723 } |
| 770 | 724 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 794 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 748 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 795 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 749 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 796 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 750 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 797 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), | 751 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), |
| 798 GrTest::TestMatrix(d->fRandom), | 752 GrTest::TestMatrix(d->fRandom), |
| 799 d->fTextures[texIdx], params, | 753 d->fTextures[texIdx], params, |
| 800 wa, | 754 wa, |
| 801 flags, | 755 flags, |
| 802 d->fRandom->nextBool()); | 756 d->fRandom->nextBool()); |
| 803 } | 757 } |
| OLD | NEW |