Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 1417123002: Move GrGLShaderVar to GrGLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gyp Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698