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

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

Issue 1251173002: Added GrGLFragmentProcessor::EmitArgs struct for use with emitCode() (Closed) Base URL: https://skia.googlesource.com/skia@composeshader_gpu
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 480
481 ///////////////////////////////////////////////////////////////////// 481 /////////////////////////////////////////////////////////////////////
482 482
483 #if SK_SUPPORT_GPU 483 #if SK_SUPPORT_GPU
484 484
485 class GrGLPerlinNoise : public GrGLFragmentProcessor { 485 class GrGLPerlinNoise : public GrGLFragmentProcessor {
486 public: 486 public:
487 GrGLPerlinNoise(const GrProcessor&); 487 GrGLPerlinNoise(const GrProcessor&);
488 virtual ~GrGLPerlinNoise() {} 488 virtual ~GrGLPerlinNoise() {}
489 489
490 virtual void emitCode(GrGLFPBuilder*, 490 virtual void emitCode(EmitArgs&) override;
491 const GrFragmentProcessor&,
492 const char* outputColor,
493 const char* inputColor,
494 const TransformedCoordsArray&,
495 const TextureSamplerArray&) override;
496 491
497 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; 492 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
498 493
499 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b); 494 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b);
500 495
501 private: 496 private:
502 497
503 GrGLProgramDataManager::UniformHandle fStitchDataUni; 498 GrGLProgramDataManager::UniformHandle fStitchDataUni;
504 SkPerlinNoiseShader::Type fType; 499 SkPerlinNoiseShader::Type fType;
505 bool fStitchTiles; 500 bool fStitchTiles;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 627
633 return effect; 628 return effect;
634 } 629 }
635 630
636 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) 631 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
637 : fType(processor.cast<GrPerlinNoiseEffect>().type()) 632 : fType(processor.cast<GrPerlinNoiseEffect>().type())
638 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) 633 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
639 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { 634 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) {
640 } 635 }
641 636
642 void GrGLPerlinNoise::emitCode(GrGLFPBuilder* builder, 637 void GrGLPerlinNoise::emitCode(EmitArgs& args) {
643 const GrFragmentProcessor&, 638 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
644 const char* outputColor, 639 SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
645 const char* inputColor,
646 const TransformedCoordsArray& coords,
647 const TextureSamplerArray& samplers) {
648 sk_ignore_unused_variable(inputColor);
649 640
650 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 641 fBaseFrequencyUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_ Visibility,
651 SkString vCoords = fsBuilder->ensureFSCoords2D(coords, 0);
652
653 fBaseFrequencyUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi lity,
654 kVec2f_GrSLType, kDefault_GrSLPrecis ion, 642 kVec2f_GrSLType, kDefault_GrSLPrecis ion,
655 "baseFrequency"); 643 "baseFrequency");
656 const char* baseFrequencyUni = builder->getUniformCStr(fBaseFrequencyUni); 644 const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyU ni);
657 fAlphaUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 645 fAlphaUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty,
658 kFloat_GrSLType, kDefault_GrSLPrecision, 646 kFloat_GrSLType, kDefault_GrSLPrecision,
659 "alpha"); 647 "alpha");
660 const char* alphaUni = builder->getUniformCStr(fAlphaUni); 648 const char* alphaUni = args.fBuilder->getUniformCStr(fAlphaUni);
661 649
662 const char* stitchDataUni = NULL; 650 const char* stitchDataUni = NULL;
663 if (fStitchTiles) { 651 if (fStitchTiles) {
664 fStitchDataUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility, 652 fStitchDataUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment _Visibility,
665 kVec2f_GrSLType, kDefault_GrSLPreci sion, 653 kVec2f_GrSLType, kDefault_GrSLPreci sion,
666 "stitchData"); 654 "stitchData");
667 stitchDataUni = builder->getUniformCStr(fStitchDataUni); 655 stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
668 } 656 }
669 657
670 // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8 658 // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8
671 const char* chanCoordR = "0.125"; 659 const char* chanCoordR = "0.125";
672 const char* chanCoordG = "0.375"; 660 const char* chanCoordG = "0.375";
673 const char* chanCoordB = "0.625"; 661 const char* chanCoordB = "0.625";
674 const char* chanCoordA = "0.875"; 662 const char* chanCoordA = "0.875";
675 const char* chanCoord = "chanCoord"; 663 const char* chanCoord = "chanCoord";
676 const char* stitchData = "stitchData"; 664 const char* stitchData = "stitchData";
677 const char* ratio = "ratio"; 665 const char* ratio = "ratio";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 // Get texture coordinates and normalize 715 // Get texture coordinates and normalize
728 noiseCode.appendf("\n\t%s = fract(floor(mod(%s, 256.0)) / vec4(256.0));\n", 716 noiseCode.appendf("\n\t%s = fract(floor(mod(%s, 256.0)) / vec4(256.0));\n",
729 floorVal, floorVal); 717 floorVal, floorVal);
730 718
731 // Get permutation for x 719 // Get permutation for x
732 { 720 {
733 SkString xCoords(""); 721 SkString xCoords("");
734 xCoords.appendf("vec2(%s.x, 0.5)", floorVal); 722 xCoords.appendf("vec2(%s.x, 0.5)", floorVal);
735 723
736 noiseCode.appendf("\n\tvec2 %s;\n\t%s.x = ", latticeIdx, latticeIdx); 724 noiseCode.appendf("\n\tvec2 %s;\n\t%s.x = ", latticeIdx, latticeIdx);
737 fsBuilder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), kVec2f_GrSLType); 725 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[0], xCoords.c_ str(),
726 kVec2f_GrSLType);
738 noiseCode.append(".r;"); 727 noiseCode.append(".r;");
739 } 728 }
740 729
741 // Get permutation for x + 1 730 // Get permutation for x + 1
742 { 731 {
743 SkString xCoords(""); 732 SkString xCoords("");
744 xCoords.appendf("vec2(%s.z, 0.5)", floorVal); 733 xCoords.appendf("vec2(%s.z, 0.5)", floorVal);
745 734
746 noiseCode.appendf("\n\t%s.y = ", latticeIdx); 735 noiseCode.appendf("\n\t%s.y = ", latticeIdx);
747 fsBuilder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), kVec2f_GrSLType); 736 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[0], xCoords.c_ str(),
737 kVec2f_GrSLType);
748 noiseCode.append(".r;"); 738 noiseCode.append(".r;");
749 } 739 }
750 740
751 #if defined(SK_BUILD_FOR_ANDROID) 741 #if defined(SK_BUILD_FOR_ANDROID)
752 // Android rounding for Tegra devices, like, for example: Xoom (Tegra 2), Ne xus 7 (Tegra 3). 742 // Android rounding for Tegra devices, like, for example: Xoom (Tegra 2), Ne xus 7 (Tegra 3).
753 // The issue is that colors aren't accurate enough on Tegra devices. For exa mple, if an 8 bit 743 // The issue is that colors aren't accurate enough on Tegra devices. For exa mple, if an 8 bit
754 // value of 124 (or 0.486275 here) is entered, we can get a texture value of 123.513725 744 // value of 124 (or 0.486275 here) is entered, we can get a texture value of 123.513725
755 // (or 0.484368 here). The following rounding operation prevents these preci sion issues from 745 // (or 0.484368 here). The following rounding operation prevents these preci sion issues from
756 // affecting the result of the noise by making sure that we only have multip les of 1/255. 746 // affecting the result of the noise by making sure that we only have multip les of 1/255.
757 // (Note that 1/255 is about 0.003921569, which is the value used here). 747 // (Note that 1/255 is about 0.003921569, which is the value used here).
758 noiseCode.appendf("\n\t%s = floor(%s * vec2(255.0) + vec2(0.5)) * vec2(0.003 921569);", 748 noiseCode.appendf("\n\t%s = floor(%s * vec2(255.0) + vec2(0.5)) * vec2(0.003 921569);",
759 latticeIdx, latticeIdx); 749 latticeIdx, latticeIdx);
760 #endif 750 #endif
761 751
762 // Get (x,y) coordinates with the permutated x 752 // Get (x,y) coordinates with the permutated x
763 noiseCode.appendf("\n\tvec4 %s = fract(%s.xyxy + %s.yyww);", bcoords, lattic eIdx, floorVal); 753 noiseCode.appendf("\n\tvec4 %s = fract(%s.xyxy + %s.yyww);", bcoords, lattic eIdx, floorVal);
764 754
765 noiseCode.appendf("\n\n\tvec2 %s;", uv); 755 noiseCode.appendf("\n\n\tvec2 %s;", uv);
766 // Compute u, at offset (0,0) 756 // Compute u, at offset (0,0)
767 { 757 {
768 SkString latticeCoords(""); 758 SkString latticeCoords("");
769 latticeCoords.appendf("vec2(%s.x, %s)", bcoords, chanCoord); 759 latticeCoords.appendf("vec2(%s.x, %s)", bcoords, chanCoord);
770 noiseCode.appendf("\n\tvec4 %s = ", lattice); 760 noiseCode.appendf("\n\tvec4 %s = ", lattice);
771 fsBuilder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_ str(), 761 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[1], latticeCoo rds.c_str(),
772 kVec2f_GrSLType); 762 kVec2f_GrSLType);
773 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); 763 noiseCode.appendf(".bgra;\n\t%s.x = ", uv);
774 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); 764 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal);
775 } 765 }
776 766
777 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal); 767 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal);
778 // Compute v, at offset (-1,0) 768 // Compute v, at offset (-1,0)
779 { 769 {
780 SkString latticeCoords(""); 770 SkString latticeCoords("");
781 latticeCoords.appendf("vec2(%s.y, %s)", bcoords, chanCoord); 771 latticeCoords.appendf("vec2(%s.y, %s)", bcoords, chanCoord);
782 noiseCode.append("\n\tlattice = "); 772 noiseCode.append("\n\tlattice = ");
783 fsBuilder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_ str(), 773 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[1], latticeCoo rds.c_str(),
784 kVec2f_GrSLType); 774 kVec2f_GrSLType);
785 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); 775 noiseCode.appendf(".bgra;\n\t%s.y = ", uv);
786 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); 776 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal);
787 } 777 }
788 778
789 // Compute 'a' as a linear interpolation of 'u' and 'v' 779 // Compute 'a' as a linear interpolation of 'u' and 'v'
790 noiseCode.appendf("\n\tvec2 %s;", ab); 780 noiseCode.appendf("\n\tvec2 %s;", ab);
791 noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); 781 noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th);
792 782
793 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal); 783 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal);
794 // Compute v, at offset (-1,-1) 784 // Compute v, at offset (-1,-1)
795 { 785 {
796 SkString latticeCoords(""); 786 SkString latticeCoords("");
797 latticeCoords.appendf("vec2(%s.w, %s)", bcoords, chanCoord); 787 latticeCoords.appendf("vec2(%s.w, %s)", bcoords, chanCoord);
798 noiseCode.append("\n\tlattice = "); 788 noiseCode.append("\n\tlattice = ");
799 fsBuilder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_ str(), 789 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[1], latticeCoo rds.c_str(),
800 kVec2f_GrSLType); 790 kVec2f_GrSLType);
801 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); 791 noiseCode.appendf(".bgra;\n\t%s.y = ", uv);
802 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); 792 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal);
803 } 793 }
804 794
805 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal); 795 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal);
806 // Compute u, at offset (0,-1) 796 // Compute u, at offset (0,-1)
807 { 797 {
808 SkString latticeCoords(""); 798 SkString latticeCoords("");
809 latticeCoords.appendf("vec2(%s.z, %s)", bcoords, chanCoord); 799 latticeCoords.appendf("vec2(%s.z, %s)", bcoords, chanCoord);
810 noiseCode.append("\n\tlattice = "); 800 noiseCode.append("\n\tlattice = ");
811 fsBuilder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_ str(), 801 fsBuilder->appendTextureLookup(&noiseCode, args.fSamplers[1], latticeCoo rds.c_str(),
812 kVec2f_GrSLType); 802 kVec2f_GrSLType);
813 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); 803 noiseCode.appendf(".bgra;\n\t%s.x = ", uv);
814 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); 804 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal);
815 } 805 }
816 806
817 // Compute 'b' as a linear interpolation of 'u' and 'v' 807 // Compute 'b' as a linear interpolation of 'u' and 'v'
818 noiseCode.appendf("\n\t%s.y = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); 808 noiseCode.appendf("\n\t%s.y = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th);
819 // Compute the noise as a linear interpolation of 'a' and 'b' 809 // Compute the noise as a linear interpolation of 'a' and 'b'
820 noiseCode.appendf("\n\treturn mix(%s.x, %s.y, %s.y);\n", ab, ab, noiseSmooth ); 810 noiseCode.appendf("\n\treturn mix(%s.x, %s.y, %s.y);\n", ab, ab, noiseSmooth );
821 811
822 SkString noiseFuncName; 812 SkString noiseFuncName;
823 if (fStitchTiles) { 813 if (fStitchTiles) {
824 fsBuilder->emitFunction(kFloat_GrSLType, 814 fsBuilder->emitFunction(kFloat_GrSLType,
825 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitch Args), 815 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitch Args),
826 gPerlinNoiseStitchArgs, noiseCode.c_str(), &nois eFuncName); 816 gPerlinNoiseStitchArgs, noiseCode.c_str(), &nois eFuncName);
827 } else { 817 } else {
828 fsBuilder->emitFunction(kFloat_GrSLType, 818 fsBuilder->emitFunction(kFloat_GrSLType,
829 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs), 819 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs),
830 gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncN ame); 820 gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncN ame);
831 } 821 }
832 822
833 // There are rounding errors if the floor operation is not performed here 823 // There are rounding errors if the floor operation is not performed here
834 fsBuilder->codeAppendf("\n\t\tvec2 %s = floor(%s.xy) * %s;", 824 fsBuilder->codeAppendf("\n\t\tvec2 %s = floor(%s.xy) * %s;",
835 noiseVec, vCoords.c_str(), baseFrequencyUni); 825 noiseVec, vCoords.c_str(), baseFrequencyUni);
836 826
837 // Clear the color accumulator 827 // Clear the color accumulator
838 fsBuilder->codeAppendf("\n\t\t%s = vec4(0.0);", outputColor); 828 fsBuilder->codeAppendf("\n\t\t%s = vec4(0.0);", args.fOutputColor);
839 829
840 if (fStitchTiles) { 830 if (fStitchTiles) {
841 // Set up TurbulenceInitial stitch values. 831 // Set up TurbulenceInitial stitch values.
842 fsBuilder->codeAppendf("\n\t\tvec2 %s = %s;", stitchData, stitchDataUni) ; 832 fsBuilder->codeAppendf("\n\t\tvec2 %s = %s;", stitchData, stitchDataUni) ;
843 } 833 }
844 834
845 fsBuilder->codeAppendf("\n\t\tfloat %s = 1.0;", ratio); 835 fsBuilder->codeAppendf("\n\t\tfloat %s = 1.0;", ratio);
846 836
847 // Loop over all octaves 837 // Loop over all octaves
848 fsBuilder->codeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {" , fNumOctaves); 838 fsBuilder->codeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {" , fNumOctaves);
849 839
850 fsBuilder->codeAppendf("\n\t\t\t%s += ", outputColor); 840 fsBuilder->codeAppendf("\n\t\t\t%s += ", args.fOutputColor);
851 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { 841 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) {
852 fsBuilder->codeAppend("abs("); 842 fsBuilder->codeAppend("abs(");
853 } 843 }
854 if (fStitchTiles) { 844 if (fStitchTiles) {
855 fsBuilder->codeAppendf( 845 fsBuilder->codeAppendf(
856 "vec4(\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s)," 846 "vec4(\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s),"
857 "\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s))", 847 "\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s))",
858 noiseFuncName.c_str(), chanCoordR, noiseVec, stitchData, 848 noiseFuncName.c_str(), chanCoordR, noiseVec, stitchData,
859 noiseFuncName.c_str(), chanCoordG, noiseVec, stitchData, 849 noiseFuncName.c_str(), chanCoordG, noiseVec, stitchData,
860 noiseFuncName.c_str(), chanCoordB, noiseVec, stitchData, 850 noiseFuncName.c_str(), chanCoordB, noiseVec, stitchData,
(...skipping 16 matching lines...) Expand all
877 fsBuilder->codeAppendf("\n\t\t\t%s *= 0.5;", ratio); 867 fsBuilder->codeAppendf("\n\t\t\t%s *= 0.5;", ratio);
878 868
879 if (fStitchTiles) { 869 if (fStitchTiles) {
880 fsBuilder->codeAppendf("\n\t\t\t%s *= vec2(2.0);", stitchData); 870 fsBuilder->codeAppendf("\n\t\t\t%s *= vec2(2.0);", stitchData);
881 } 871 }
882 fsBuilder->codeAppend("\n\t\t}"); // end of the for loop on octaves 872 fsBuilder->codeAppend("\n\t\t}"); // end of the for loop on octaves
883 873
884 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) { 874 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) {
885 // The value of turbulenceFunctionResult comes from ((turbulenceFunction Result) + 1) / 2 875 // The value of turbulenceFunctionResult comes from ((turbulenceFunction Result) + 1) / 2
886 // by fractalNoise and (turbulenceFunctionResult) by turbulence. 876 // by fractalNoise and (turbulenceFunctionResult) by turbulence.
887 fsBuilder->codeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);", outputC olor, outputColor); 877 fsBuilder->codeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);",
878 args.fOutputColor,args.fOutputColor);
888 } 879 }
889 880
890 fsBuilder->codeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni); 881 fsBuilder->codeAppendf("\n\t\t%s.a *= %s;", args.fOutputColor, alphaUni);
891 882
892 // Clamp values 883 // Clamp values
893 fsBuilder->codeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", outputColor, outpu tColor); 884 fsBuilder->codeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.fOutputColor);
894 885
895 // Pre-multiply the result 886 // Pre-multiply the result
896 fsBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", 887 fsBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n",
897 outputColor, outputColor, outputColor, outputColor); 888 args.fOutputColor, args.fOutputColor,
889 args.fOutputColor, args.fOutputColor);
898 } 890 }
899 891
900 void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrGLSLCaps&, 892 void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
901 GrProcessorKeyBuilder* b) { 893 GrProcessorKeyBuilder* b) {
902 const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>( ); 894 const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>( );
903 895
904 uint32_t key = turbulence.numOctaves(); 896 uint32_t key = turbulence.numOctaves();
905 897
906 key = key << 3; // Make room for next 3 bits 898 key = key << 3; // Make room for next 3 bits
907 899
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 str->append(" seed: "); 1027 str->append(" seed: ");
1036 str->appendScalar(fSeed); 1028 str->appendScalar(fSeed);
1037 str->append(" stitch tiles: "); 1029 str->append(" stitch tiles: ");
1038 str->append(fStitchTiles ? "true " : "false "); 1030 str->append(fStitchTiles ? "true " : "false ");
1039 1031
1040 this->INHERITED::toString(str); 1032 this->INHERITED::toString(str);
1041 1033
1042 str->append(")"); 1034 str->append(")");
1043 } 1035 }
1044 #endif 1036 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698