| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 const char* ab = "ab"; | 651 const char* ab = "ab"; |
| 652 const char* latticeIdx = "latticeIdx"; | 652 const char* latticeIdx = "latticeIdx"; |
| 653 const char* bcoords = "bcoords"; | 653 const char* bcoords = "bcoords"; |
| 654 const char* lattice = "lattice"; | 654 const char* lattice = "lattice"; |
| 655 const char* inc8bit = "0.00390625"; // 1.0 / 256.0 | 655 const char* inc8bit = "0.00390625"; // 1.0 / 256.0 |
| 656 // This is the math to convert the two 16bit integer packed into rgba 8 bit
input into a | 656 // This is the math to convert the two 16bit integer packed into rgba 8 bit
input into a |
| 657 // [-1,1] vector and perform a dot product between that vector and the provi
ded vector. | 657 // [-1,1] vector and perform a dot product between that vector and the provi
ded vector. |
| 658 const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec
2(1.0)), %s);"; | 658 const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec
2(1.0)), %s);"; |
| 659 | 659 |
| 660 // Add noise function | 660 // Add noise function |
| 661 static const GrGLShaderVar gPerlinNoiseArgs[] = { | 661 static const GrGLSLShaderVar gPerlinNoiseArgs[] = { |
| 662 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 662 GrGLSLShaderVar(chanCoord, kFloat_GrSLType), |
| 663 GrGLShaderVar(noiseVec, kVec2f_GrSLType) | 663 GrGLSLShaderVar(noiseVec, kVec2f_GrSLType) |
| 664 }; | 664 }; |
| 665 | 665 |
| 666 static const GrGLShaderVar gPerlinNoiseStitchArgs[] = { | 666 static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = { |
| 667 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 667 GrGLSLShaderVar(chanCoord, kFloat_GrSLType), |
| 668 GrGLShaderVar(noiseVec, kVec2f_GrSLType), | 668 GrGLSLShaderVar(noiseVec, kVec2f_GrSLType), |
| 669 GrGLShaderVar(stitchData, kVec2f_GrSLType) | 669 GrGLSLShaderVar(stitchData, kVec2f_GrSLType) |
| 670 }; | 670 }; |
| 671 | 671 |
| 672 SkString noiseCode; | 672 SkString noiseCode; |
| 673 | 673 |
| 674 noiseCode.appendf("\tvec4 %s;\n", floorVal); | 674 noiseCode.appendf("\tvec4 %s;\n", floorVal); |
| 675 noiseCode.appendf("\t%s.xy = floor(%s);\n", floorVal, noiseVec); | 675 noiseCode.appendf("\t%s.xy = floor(%s);\n", floorVal, noiseVec); |
| 676 noiseCode.appendf("\t%s.zw = %s.xy + vec2(1.0);\n", floorVal, floorVal); | 676 noiseCode.appendf("\t%s.zw = %s.xy + vec2(1.0);\n", floorVal, floorVal); |
| 677 noiseCode.appendf("\tvec2 %s = fract(%s);\n", fractVal, noiseVec); | 677 noiseCode.appendf("\tvec2 %s = fract(%s);\n", fractVal, noiseVec); |
| 678 | 678 |
| 679 // smooth curve : t * t * (3 - 2 * t) | 679 // smooth curve : t * t * (3 - 2 * t) |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 str->append(" seed: "); | 993 str->append(" seed: "); |
| 994 str->appendScalar(fSeed); | 994 str->appendScalar(fSeed); |
| 995 str->append(" stitch tiles: "); | 995 str->append(" stitch tiles: "); |
| 996 str->append(fStitchTiles ? "true " : "false "); | 996 str->append(fStitchTiles ? "true " : "false "); |
| 997 | 997 |
| 998 this->INHERITED::toString(str); | 998 this->INHERITED::toString(str); |
| 999 | 999 |
| 1000 str->append(")"); | 1000 str->append(")"); |
| 1001 } | 1001 } |
| 1002 #endif | 1002 #endif |
| OLD | NEW |