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