| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 GrGLPrimitiveProcessor* | 245 GrGLPrimitiveProcessor* |
| 246 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, | 246 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, |
| 247 const GrGLSLCaps&) const { | 247 const GrGLSLCaps&) const { |
| 248 return new GrGLDistanceFieldA8TextGeoProc(*this, bt); | 248 return new GrGLDistanceFieldA8TextGeoProc(*this, bt); |
| 249 } | 249 } |
| 250 | 250 |
| 251 /////////////////////////////////////////////////////////////////////////////// | 251 /////////////////////////////////////////////////////////////////////////////// |
| 252 | 252 |
| 253 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); | 253 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); |
| 254 | 254 |
| 255 const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
estData* d) { | 255 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestDat
a* d) { |
| 256 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 256 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
| 257 GrProcessorUnitTest::kAlphaTextureIdx; | 257 GrProcessorUnitTest::kAlphaTextureIdx; |
| 258 static const SkShader::TileMode kTileModes[] = { | 258 static const SkShader::TileMode kTileModes[] = { |
| 259 SkShader::kClamp_TileMode, | 259 SkShader::kClamp_TileMode, |
| 260 SkShader::kRepeat_TileMode, | 260 SkShader::kRepeat_TileMode, |
| 261 SkShader::kMirror_TileMode, | 261 SkShader::kMirror_TileMode, |
| 262 }; | 262 }; |
| 263 SkShader::TileMode tileModes[] = { | 263 SkShader::TileMode tileModes[] = { |
| 264 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 264 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 265 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 265 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 468 |
| 469 GrGLPrimitiveProcessor* | 469 GrGLPrimitiveProcessor* |
| 470 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LSLCaps&) const { | 470 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG
LSLCaps&) const { |
| 471 return new GrGLDistanceFieldPathGeoProc(*this, bt); | 471 return new GrGLDistanceFieldPathGeoProc(*this, bt); |
| 472 } | 472 } |
| 473 | 473 |
| 474 /////////////////////////////////////////////////////////////////////////////// | 474 /////////////////////////////////////////////////////////////////////////////// |
| 475 | 475 |
| 476 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); | 476 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); |
| 477 | 477 |
| 478 const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
tData* d) { | 478 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData*
d) { |
| 479 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx | 479 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx |
| 480 : GrProcessorUnitTest::kAlphaTextureIdx; | 480 : GrProcessorUnitTest::kAlphaTextureIdx; |
| 481 static const SkShader::TileMode kTileModes[] = { | 481 static const SkShader::TileMode kTileModes[] = { |
| 482 SkShader::kClamp_TileMode, | 482 SkShader::kClamp_TileMode, |
| 483 SkShader::kRepeat_TileMode, | 483 SkShader::kRepeat_TileMode, |
| 484 SkShader::kMirror_TileMode, | 484 SkShader::kMirror_TileMode, |
| 485 }; | 485 }; |
| 486 SkShader::TileMode tileModes[] = { | 486 SkShader::TileMode tileModes[] = { |
| 487 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 487 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 488 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 488 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 GrGLPrimitiveProcessor* | 741 GrGLPrimitiveProcessor* |
| 742 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, | 742 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, |
| 743 const GrGLSLCaps&) const { | 743 const GrGLSLCaps&) const { |
| 744 return new GrGLDistanceFieldLCDTextGeoProc(*this, bt); | 744 return new GrGLDistanceFieldLCDTextGeoProc(*this, bt); |
| 745 } | 745 } |
| 746 | 746 |
| 747 /////////////////////////////////////////////////////////////////////////////// | 747 /////////////////////////////////////////////////////////////////////////////// |
| 748 | 748 |
| 749 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); | 749 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); |
| 750 | 750 |
| 751 const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
TestData* d) { | 751 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestDa
ta* d) { |
| 752 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 752 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
| 753 GrProcessorUnitTest::kAlphaTextureIdx; | 753 GrProcessorUnitTest::kAlphaTextureIdx; |
| 754 static const SkShader::TileMode kTileModes[] = { | 754 static const SkShader::TileMode kTileModes[] = { |
| 755 SkShader::kClamp_TileMode, | 755 SkShader::kClamp_TileMode, |
| 756 SkShader::kRepeat_TileMode, | 756 SkShader::kRepeat_TileMode, |
| 757 SkShader::kMirror_TileMode, | 757 SkShader::kMirror_TileMode, |
| 758 }; | 758 }; |
| 759 SkShader::TileMode tileModes[] = { | 759 SkShader::TileMode tileModes[] = { |
| 760 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 760 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 761 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 761 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 762 }; | 762 }; |
| 763 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::
kBilerp_FilterMode : | 763 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::
kBilerp_FilterMode : |
| 764 GrTextureParams::kNone_FilterMode); | 764 GrTextureParams::kNone_FilterMode); |
| 765 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; | 765 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; |
| 766 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 766 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 767 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 767 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 768 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 768 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 769 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), | 769 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), |
| 770 GrTest::TestMatrix(d->fRandom), | 770 GrTest::TestMatrix(d->fRandom), |
| 771 d->fTextures[texIdx], params, | 771 d->fTextures[texIdx], params, |
| 772 wa, | 772 wa, |
| 773 flags, | 773 flags, |
| 774 d->fRandom->nextBool()); | 774 d->fRandom->nextBool()); |
| 775 } | 775 } |
| OLD | NEW |