| 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" | 
| 11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" | 
| 12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" | 
| 13 #include "SkShader.h" | 13 #include "SkShader.h" | 
| 14 #include "SkUnPreMultiply.h" | 14 #include "SkUnPreMultiply.h" | 
| 15 #include "SkString.h" | 15 #include "SkString.h" | 
| 16 | 16 | 
| 17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU | 
| 18 #include "GrContext.h" | 18 #include "GrContext.h" | 
| 19 #include "GrCoordTransform.h" | 19 #include "GrCoordTransform.h" | 
| 20 #include "GrInvariantOutput.h" | 20 #include "GrInvariantOutput.h" | 
| 21 #include "SkGr.h" | 21 #include "SkGr.h" | 
| 22 #include "effects/GrConstColorProcessor.h" | 22 #include "effects/GrConstColorProcessor.h" | 
| 23 #include "gl/GrGLFragmentProcessor.h" | 23 #include "gl/GrGLFragmentProcessor.h" | 
| 24 #include "gl/builders/GrGLProgramBuilder.h" | 24 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 
|  | 25 #include "glsl/GrGLSLProgramBuilder.h" | 
| 25 #include "glsl/GrGLSLProgramDataManager.h" | 26 #include "glsl/GrGLSLProgramDataManager.h" | 
| 26 #endif | 27 #endif | 
| 27 | 28 | 
| 28 static const int kBlockSize = 256; | 29 static const int kBlockSize = 256; | 
| 29 static const int kBlockMask = kBlockSize - 1; | 30 static const int kBlockMask = kBlockSize - 1; | 
| 30 static const int kPerlinNoise = 4096; | 31 static const int kPerlinNoise = 4096; | 
| 31 static const int kRandMaximum = SK_MaxS32; // 2**31 - 1 | 32 static const int kRandMaximum = SK_MaxS32; // 2**31 - 1 | 
| 32 | 33 | 
| 33 namespace { | 34 namespace { | 
| 34 | 35 | 
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 613                                        kNone_SkFilterQuality); | 614                                        kNone_SkFilterQuality); | 
| 614 } | 615 } | 
| 615 | 616 | 
| 616 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) | 617 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) | 
| 617   : fType(processor.cast<GrPerlinNoiseEffect>().type()) | 618   : fType(processor.cast<GrPerlinNoiseEffect>().type()) | 
| 618   , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) | 619   , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) | 
| 619   , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { | 620   , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { | 
| 620 } | 621 } | 
| 621 | 622 | 
| 622 void GrGLPerlinNoise::emitCode(EmitArgs& args) { | 623 void GrGLPerlinNoise::emitCode(EmitArgs& args) { | 
| 623     GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); | 624     GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
      ; | 
| 624     SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 625     SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 
| 625 | 626 | 
| 626     fBaseFrequencyUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_
      Visibility, | 627     fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragmen
      t_Visibility, | 
| 627                                             kVec2f_GrSLType, kDefault_GrSLPrecis
      ion, | 628                                             kVec2f_GrSLType, kDefault_GrSLPrecis
      ion, | 
| 628                                             "baseFrequency"); | 629                                             "baseFrequency"); | 
| 629     const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyU
      ni); | 630     const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyU
      ni); | 
| 630 | 631 | 
| 631     const char* stitchDataUni = nullptr; | 632     const char* stitchDataUni = nullptr; | 
| 632     if (fStitchTiles) { | 633     if (fStitchTiles) { | 
| 633         fStitchDataUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment
      _Visibility, | 634         fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme
      nt_Visibility, | 
| 634                                              kVec2f_GrSLType, kDefault_GrSLPreci
      sion, | 635                                              kVec2f_GrSLType, kDefault_GrSLPreci
      sion, | 
| 635                                              "stitchData"); | 636                                              "stitchData"); | 
| 636         stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni); | 637         stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni); | 
| 637     } | 638     } | 
| 638 | 639 | 
| 639     // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8 | 640     // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8 | 
| 640     const char* chanCoordR  = "0.125"; | 641     const char* chanCoordR  = "0.125"; | 
| 641     const char* chanCoordG  = "0.375"; | 642     const char* chanCoordG  = "0.375"; | 
| 642     const char* chanCoordB  = "0.625"; | 643     const char* chanCoordB  = "0.625"; | 
| 643     const char* chanCoordA  = "0.875"; | 644     const char* chanCoordA  = "0.875"; | 
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 995     str->append(" seed: "); | 996     str->append(" seed: "); | 
| 996     str->appendScalar(fSeed); | 997     str->appendScalar(fSeed); | 
| 997     str->append(" stitch tiles: "); | 998     str->append(" stitch tiles: "); | 
| 998     str->append(fStitchTiles ? "true " : "false "); | 999     str->append(fStitchTiles ? "true " : "false "); | 
| 999 | 1000 | 
| 1000     this->INHERITED::toString(str); | 1001     this->INHERITED::toString(str); | 
| 1001 | 1002 | 
| 1002     str->append(")"); | 1003     str->append(")"); | 
| 1003 } | 1004 } | 
| 1004 #endif | 1005 #endif | 
| OLD | NEW | 
|---|