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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 227 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
228 kHigh_GrSLPrecision)); | 228 kHigh_GrSLPrecision)); |
229 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 229 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
230 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 230 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
231 } | 231 } |
232 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 232 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
233 kVec2s_GrVertexAttribT
ype)); | 233 kVec2s_GrVertexAttribT
ype)); |
234 this->addTextureAccess(&fTextureAccess); | 234 this->addTextureAccess(&fTextureAccess); |
235 } | 235 } |
236 | 236 |
237 void GrDistanceFieldA8TextGeoProc::getGLProcessorKey(const GrGLSLCaps& caps, | 237 void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
238 GrProcessorKeyBuilder* b) c
onst { | 238 GrProcessorKeyBuilder* b)
const { |
239 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b); | 239 GrGLDistanceFieldA8TextGeoProc::GenKey(*this, caps, b); |
240 } | 240 } |
241 | 241 |
242 GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLInstance(const G
rGLSLCaps&) const { | 242 GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLSLInstance(const
GrGLSLCaps&) const { |
243 return new GrGLDistanceFieldA8TextGeoProc(); | 243 return new GrGLDistanceFieldA8TextGeoProc(); |
244 } | 244 } |
245 | 245 |
246 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
247 | 247 |
248 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); | 248 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); |
249 | 249 |
250 const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
estData* d) { | 250 const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
estData* d) { |
251 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 251 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
252 GrProcessorUnitTest::kAlphaTextureIdx; | 252 GrProcessorUnitTest::kAlphaTextureIdx; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 444 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
445 kHigh_GrSLPrecision)); | 445 kHigh_GrSLPrecision)); |
446 if (flags & kColorAttr_DistanceFieldEffectFlag) { | 446 if (flags & kColorAttr_DistanceFieldEffectFlag) { |
447 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 447 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); |
448 } | 448 } |
449 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 449 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
450 kVec2f_GrVertexAttribTyp
e)); | 450 kVec2f_GrVertexAttribTyp
e)); |
451 this->addTextureAccess(&fTextureAccess); | 451 this->addTextureAccess(&fTextureAccess); |
452 } | 452 } |
453 | 453 |
454 void GrDistanceFieldPathGeoProc::getGLProcessorKey(const GrGLSLCaps& caps, | 454 void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
455 GrProcessorKeyBuilder* b) con
st { | 455 GrProcessorKeyBuilder* b) c
onst { |
456 GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b); | 456 GrGLDistanceFieldPathGeoProc::GenKey(*this, caps, b); |
457 } | 457 } |
458 | 458 |
459 GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLInstance(const GrG
LSLCaps&) const { | 459 GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLSLInstance(const G
rGLSLCaps&) const { |
460 return new GrGLDistanceFieldPathGeoProc(); | 460 return new GrGLDistanceFieldPathGeoProc(); |
461 } | 461 } |
462 | 462 |
463 /////////////////////////////////////////////////////////////////////////////// | 463 /////////////////////////////////////////////////////////////////////////////// |
464 | 464 |
465 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); | 465 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); |
466 | 466 |
467 const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
tData* d) { | 467 const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
tData* d) { |
468 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx | 468 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx |
469 : GrProcessorUnitTest::kAlphaTextureIdx; | 469 : GrProcessorUnitTest::kAlphaTextureIdx; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 , fUsesLocalCoords(usesLocalCoords) { | 714 , fUsesLocalCoords(usesLocalCoords) { |
715 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); | 715 SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_Distan
ceFieldEffectFlag)); |
716 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); | 716 this->initClassID<GrDistanceFieldLCDTextGeoProc>(); |
717 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 717 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
718 kHigh_GrSLPrecision)); | 718 kHigh_GrSLPrecision)); |
719 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 719 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
720 kVec2s_GrVertexAttribTyp
e)); | 720 kVec2s_GrVertexAttribTyp
e)); |
721 this->addTextureAccess(&fTextureAccess); | 721 this->addTextureAccess(&fTextureAccess); |
722 } | 722 } |
723 | 723 |
724 void GrDistanceFieldLCDTextGeoProc::getGLProcessorKey(const GrGLSLCaps& caps, | 724 void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrGLSLCaps& caps, |
725 GrProcessorKeyBuilder* b)
const { | 725 GrProcessorKeyBuilder* b
) const { |
726 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b); | 726 GrGLDistanceFieldLCDTextGeoProc::GenKey(*this, caps, b); |
727 } | 727 } |
728 | 728 |
729 GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLInstance(const
GrGLSLCaps&) const { | 729 GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons
t GrGLSLCaps&) const { |
730 return new GrGLDistanceFieldLCDTextGeoProc(); | 730 return new GrGLDistanceFieldLCDTextGeoProc(); |
731 } | 731 } |
732 | 732 |
733 /////////////////////////////////////////////////////////////////////////////// | 733 /////////////////////////////////////////////////////////////////////////////// |
734 | 734 |
735 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); | 735 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); |
736 | 736 |
737 const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
TestData* d) { | 737 const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
TestData* d) { |
738 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 738 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
739 GrProcessorUnitTest::kAlphaTextureIdx; | 739 GrProcessorUnitTest::kAlphaTextureIdx; |
(...skipping 12 matching lines...) Expand all Loading... |
752 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 752 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
753 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 753 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
754 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 754 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
755 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), | 755 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), |
756 GrTest::TestMatrix(d->fRandom), | 756 GrTest::TestMatrix(d->fRandom), |
757 d->fTextures[texIdx], params, | 757 d->fTextures[texIdx], params, |
758 wa, | 758 wa, |
759 flags, | 759 flags, |
760 d->fRandom->nextBool()); | 760 d->fRandom->nextBool()); |
761 } | 761 } |
OLD | NEW |