| 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 "SkDither.h" | 8 #include "SkDither.h" |
| 9 #include "SkPerlinNoiseShader.h" | 9 #include "SkPerlinNoiseShader.h" |
| 10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 public: | 524 public: |
| 525 GrGLPerlinNoise(const GrBackendEffectFactory& factory, | 525 GrGLPerlinNoise(const GrBackendEffectFactory& factory, |
| 526 const GrDrawEffect& drawEffect) | 526 const GrDrawEffect& drawEffect) |
| 527 : GrGLNoise(factory, drawEffect) {} | 527 : GrGLNoise(factory, drawEffect) {} |
| 528 virtual ~GrGLPerlinNoise() {} | 528 virtual ~GrGLPerlinNoise() {} |
| 529 | 529 |
| 530 virtual void emitCode(GrGLShaderBuilder*, | 530 virtual void emitCode(GrGLShaderBuilder*, |
| 531 const GrDrawEffect&, | 531 const GrDrawEffect&, |
| 532 EffectKey, | 532 EffectKey, |
| 533 const char* outputColor, | 533 const char* outputColor, |
| 534 const char* inputColor, | 534 const GrGLSLExpr4& inputColor, |
| 535 const TransformedCoordsArray&, | 535 const TransformedCoordsArray&, |
| 536 const TextureSamplerArray&) SK_OVERRIDE; | 536 const TextureSamplerArray&) SK_OVERRIDE; |
| 537 | 537 |
| 538 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 538 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
| 539 | 539 |
| 540 private: | 540 private: |
| 541 GrGLUniformManager::UniformHandle fStitchDataUni; | 541 GrGLUniformManager::UniformHandle fStitchDataUni; |
| 542 | 542 |
| 543 typedef GrGLNoise INHERITED; | 543 typedef GrGLNoise INHERITED; |
| 544 }; | 544 }; |
| 545 | 545 |
| 546 class GrGLSimplexNoise : public GrGLNoise { | 546 class GrGLSimplexNoise : public GrGLNoise { |
| 547 // Note : This is for reference only. GrGLPerlinNoise is used for processing
. | 547 // Note : This is for reference only. GrGLPerlinNoise is used for processing
. |
| 548 public: | 548 public: |
| 549 GrGLSimplexNoise(const GrBackendEffectFactory& factory, | 549 GrGLSimplexNoise(const GrBackendEffectFactory& factory, |
| 550 const GrDrawEffect& drawEffect) | 550 const GrDrawEffect& drawEffect) |
| 551 : GrGLNoise(factory, drawEffect) {} | 551 : GrGLNoise(factory, drawEffect) {} |
| 552 | 552 |
| 553 virtual ~GrGLSimplexNoise() {} | 553 virtual ~GrGLSimplexNoise() {} |
| 554 | 554 |
| 555 virtual void emitCode(GrGLShaderBuilder*, | 555 virtual void emitCode(GrGLShaderBuilder*, |
| 556 const GrDrawEffect&, | 556 const GrDrawEffect&, |
| 557 EffectKey, | 557 EffectKey, |
| 558 const char* outputColor, | 558 const char* outputColor, |
| 559 const char* inputColor, | 559 const GrGLSLExpr4& inputColor, |
| 560 const TransformedCoordsArray&, | 560 const TransformedCoordsArray&, |
| 561 const TextureSamplerArray&) SK_OVERRIDE; | 561 const TextureSamplerArray&) SK_OVERRIDE; |
| 562 | 562 |
| 563 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 563 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
| 564 | 564 |
| 565 private: | 565 private: |
| 566 GrGLUniformManager::UniformHandle fSeedUni; | 566 GrGLUniformManager::UniformHandle fSeedUni; |
| 567 | 567 |
| 568 typedef GrGLNoise INHERITED; | 568 typedef GrGLNoise INHERITED; |
| 569 }; | 569 }; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 747 |
| 748 return effect; | 748 return effect; |
| 749 } | 749 } |
| 750 | 750 |
| 751 ///////////////////////////////////////////////////////////////////// | 751 ///////////////////////////////////////////////////////////////////// |
| 752 | 752 |
| 753 void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, | 753 void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, |
| 754 const GrDrawEffect&, | 754 const GrDrawEffect&, |
| 755 EffectKey key, | 755 EffectKey key, |
| 756 const char* outputColor, | 756 const char* outputColor, |
| 757 const char* inputColor, | 757 const GrGLSLExpr4& inputColor, |
| 758 const TransformedCoordsArray& coords, | 758 const TransformedCoordsArray& coords, |
| 759 const TextureSamplerArray&) { | 759 const TextureSamplerArray&) { |
| 760 sk_ignore_unused_variable(inputColor); | 760 sk_ignore_unused_variable(inputColor); |
| 761 | 761 |
| 762 SkString vCoords = builder->ensureFSCoords2D(coords, 0); | 762 SkString vCoords = builder->ensureFSCoords2D(coords, 0); |
| 763 | 763 |
| 764 fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 764 fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
| 765 kFloat_GrSLType, "seed"); | 765 kFloat_GrSLType, "seed"); |
| 766 const char* seedUni = builder->getUniformCStr(fSeedUni); | 766 const char* seedUni = builder->getUniformCStr(fSeedUni); |
| 767 fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 767 fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 963 |
| 964 // Pre-multiply the result | 964 // Pre-multiply the result |
| 965 builder->fsCodeAppendf("\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", | 965 builder->fsCodeAppendf("\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", |
| 966 outputColor, outputColor, outputColor, outputColor); | 966 outputColor, outputColor, outputColor, outputColor); |
| 967 } | 967 } |
| 968 | 968 |
| 969 void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder, | 969 void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder, |
| 970 const GrDrawEffect&, | 970 const GrDrawEffect&, |
| 971 EffectKey key, | 971 EffectKey key, |
| 972 const char* outputColor, | 972 const char* outputColor, |
| 973 const char* inputColor, | 973 const GrGLSLExpr4& inputColor, |
| 974 const TransformedCoordsArray& coords, | 974 const TransformedCoordsArray& coords, |
| 975 const TextureSamplerArray& samplers) { | 975 const TextureSamplerArray& samplers) { |
| 976 sk_ignore_unused_variable(inputColor); | 976 sk_ignore_unused_variable(inputColor); |
| 977 | 977 |
| 978 SkString vCoords = builder->ensureFSCoords2D(coords, 0); | 978 SkString vCoords = builder->ensureFSCoords2D(coords, 0); |
| 979 | 979 |
| 980 fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 980 fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
| 981 kMat33f_GrSLType, "invMatrix"); | 981 kMat33f_GrSLType, "invMatrix"); |
| 982 const char* invMatrixUni = builder->getUniformCStr(fInvMatrixUni); | 982 const char* invMatrixUni = builder->getUniformCStr(fInvMatrixUni); |
| 983 fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibil
ity, | 983 fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibil
ity, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 str->append(" seed: "); | 1368 str->append(" seed: "); |
| 1369 str->appendScalar(fSeed); | 1369 str->appendScalar(fSeed); |
| 1370 str->append(" stitch tiles: "); | 1370 str->append(" stitch tiles: "); |
| 1371 str->append(fStitchTiles ? "true " : "false "); | 1371 str->append(fStitchTiles ? "true " : "false "); |
| 1372 | 1372 |
| 1373 this->INHERITED::toString(str); | 1373 this->INHERITED::toString(str); |
| 1374 | 1374 |
| 1375 str->append(")"); | 1375 str->append(")"); |
| 1376 } | 1376 } |
| 1377 #endif | 1377 #endif |
| OLD | NEW |