| 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 "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 class GrGLPerlinNoise : public GrGLFragmentProcessor { | 487 class GrGLPerlinNoise : public GrGLFragmentProcessor { |
| 488 public: | 488 public: |
| 489 GrGLPerlinNoise(const GrProcessor&); | 489 GrGLPerlinNoise(const GrProcessor&); |
| 490 virtual ~GrGLPerlinNoise() {} | 490 virtual ~GrGLPerlinNoise() {} |
| 491 | 491 |
| 492 virtual void emitCode(GrGLFPBuilder*, | 492 virtual void emitCode(GrGLFPBuilder*, |
| 493 const GrFragmentProcessor&, | 493 const GrFragmentProcessor&, |
| 494 const char* outputColor, | 494 const char* outputColor, |
| 495 const char* inputColor, | 495 const char* inputColor, |
| 496 const TransformedCoordsArray&, | 496 const TransformedCoordsArray&, |
| 497 const TextureSamplerArray&) SK_OVERRIDE; | 497 const TextureSamplerArray&) override; |
| 498 | 498 |
| 499 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; | 499 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; |
| 500 | 500 |
| 501 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder* b); | 501 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder* b); |
| 502 | 502 |
| 503 private: | 503 private: |
| 504 | 504 |
| 505 GrGLProgramDataManager::UniformHandle fStitchDataUni; | 505 GrGLProgramDataManager::UniformHandle fStitchDataUni; |
| 506 SkPerlinNoiseShader::Type fType; | 506 SkPerlinNoiseShader::Type fType; |
| 507 bool fStitchTiles; | 507 bool fStitchTiles; |
| 508 int fNumOctaves; | 508 int fNumOctaves; |
| 509 GrGLProgramDataManager::UniformHandle fBaseFrequencyUni; | 509 GrGLProgramDataManager::UniformHandle fBaseFrequencyUni; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 523 GrTexture* permutationsTexture, GrTexture
* noiseTexture, | 523 GrTexture* permutationsTexture, GrTexture
* noiseTexture, |
| 524 const SkMatrix& matrix, uint8_t alpha) { | 524 const SkMatrix& matrix, uint8_t alpha) { |
| 525 return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, p
aintingData, | 525 return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, p
aintingData, |
| 526 permutationsTexture, noiseTextur
e, matrix, alpha)); | 526 permutationsTexture, noiseTextur
e, matrix, alpha)); |
| 527 } | 527 } |
| 528 | 528 |
| 529 virtual ~GrPerlinNoiseEffect() { | 529 virtual ~GrPerlinNoiseEffect() { |
| 530 SkDELETE(fPaintingData); | 530 SkDELETE(fPaintingData); |
| 531 } | 531 } |
| 532 | 532 |
| 533 const char* name() const SK_OVERRIDE { return "PerlinNoise"; } | 533 const char* name() const override { return "PerlinNoise"; } |
| 534 | 534 |
| 535 virtual void getGLProcessorKey(const GrGLCaps& caps, | 535 virtual void getGLProcessorKey(const GrGLCaps& caps, |
| 536 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 536 GrProcessorKeyBuilder* b) const override { |
| 537 GrGLPerlinNoise::GenKey(*this, caps, b); | 537 GrGLPerlinNoise::GenKey(*this, caps, b); |
| 538 } | 538 } |
| 539 | 539 |
| 540 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { | 540 GrGLFragmentProcessor* createGLInstance() const override { |
| 541 return SkNEW_ARGS(GrGLPerlinNoise, (*this)); | 541 return SkNEW_ARGS(GrGLPerlinNoise, (*this)); |
| 542 } | 542 } |
| 543 | 543 |
| 544 const SkPerlinNoiseShader::StitchData& stitchData() const { return fPainting
Data->fStitchDataInit; } | 544 const SkPerlinNoiseShader::StitchData& stitchData() const { return fPainting
Data->fStitchDataInit; } |
| 545 | 545 |
| 546 SkPerlinNoiseShader::Type type() const { return fType; } | 546 SkPerlinNoiseShader::Type type() const { return fType; } |
| 547 bool stitchTiles() const { return fStitchTiles; } | 547 bool stitchTiles() const { return fStitchTiles; } |
| 548 const SkVector& baseFrequency() const { return fPaintingData->fBaseFrequency
; } | 548 const SkVector& baseFrequency() const { return fPaintingData->fBaseFrequency
; } |
| 549 int numOctaves() const { return fNumOctaves; } | 549 int numOctaves() const { return fNumOctaves; } |
| 550 const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); } | 550 const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); } |
| 551 uint8_t alpha() const { return fAlpha; } | 551 uint8_t alpha() const { return fAlpha; } |
| 552 | 552 |
| 553 private: | 553 private: |
| 554 bool onIsEqual(const GrFragmentProcessor& sBase) const SK_OVERRIDE { | 554 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
| 555 const GrPerlinNoiseEffect& s = sBase.cast<GrPerlinNoiseEffect>(); | 555 const GrPerlinNoiseEffect& s = sBase.cast<GrPerlinNoiseEffect>(); |
| 556 return fType == s.fType && | 556 return fType == s.fType && |
| 557 fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency
&& | 557 fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency
&& |
| 558 fNumOctaves == s.fNumOctaves && | 558 fNumOctaves == s.fNumOctaves && |
| 559 fStitchTiles == s.fStitchTiles && | 559 fStitchTiles == s.fStitchTiles && |
| 560 fAlpha == s.fAlpha && | 560 fAlpha == s.fAlpha && |
| 561 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni
t; | 561 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni
t; |
| 562 } | 562 } |
| 563 | 563 |
| 564 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { | 564 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 565 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); | 565 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); |
| 566 } | 566 } |
| 567 | 567 |
| 568 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, | 568 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, |
| 569 int numOctaves, bool stitchTiles, | 569 int numOctaves, bool stitchTiles, |
| 570 SkPerlinNoiseShader::PaintingData* paintingData, | 570 SkPerlinNoiseShader::PaintingData* paintingData, |
| 571 GrTexture* permutationsTexture, GrTexture* noiseTexture, | 571 GrTexture* permutationsTexture, GrTexture* noiseTexture, |
| 572 const SkMatrix& matrix, uint8_t alpha) | 572 const SkMatrix& matrix, uint8_t alpha) |
| 573 : fType(type) | 573 : fType(type) |
| 574 , fNumOctaves(numOctaves) | 574 , fNumOctaves(numOctaves) |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 str->append(" seed: "); | 1032 str->append(" seed: "); |
| 1033 str->appendScalar(fSeed); | 1033 str->appendScalar(fSeed); |
| 1034 str->append(" stitch tiles: "); | 1034 str->append(" stitch tiles: "); |
| 1035 str->append(fStitchTiles ? "true " : "false "); | 1035 str->append(fStitchTiles ? "true " : "false "); |
| 1036 | 1036 |
| 1037 this->INHERITED::toString(str); | 1037 this->INHERITED::toString(str); |
| 1038 | 1038 |
| 1039 str->append(")"); | 1039 str->append(")"); |
| 1040 } | 1040 } |
| 1041 #endif | 1041 #endif |
| OLD | NEW |