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 "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 for (int i = 0; i < count; ++i) { | 487 for (int i = 0; i < count; ++i) { |
488 unsigned dither = DITHER_VALUE(x); | 488 unsigned dither = DITHER_VALUE(x); |
489 result[i] = SkDitherRGB32To565(shade(point, stitchData), dither); | 489 result[i] = SkDitherRGB32To565(shade(point, stitchData), dither); |
490 DITHER_INC_X(x); | 490 DITHER_INC_X(x); |
491 point.fX += SK_Scalar1; | 491 point.fX += SK_Scalar1; |
492 } | 492 } |
493 } | 493 } |
494 | 494 |
495 ///////////////////////////////////////////////////////////////////// | 495 ///////////////////////////////////////////////////////////////////// |
496 | 496 |
497 #if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID) | 497 #if SK_SUPPORT_GPU |
498 // CPU noise is faster on Android, so the GPU implementation is only for desktop | |
499 | 498 |
500 #include "GrTBackendEffectFactory.h" | 499 #include "GrTBackendEffectFactory.h" |
501 | 500 |
502 class GrGLNoise : public GrGLEffect { | 501 class GrGLNoise : public GrGLEffect { |
503 public: | 502 public: |
504 GrGLNoise(const GrBackendEffectFactory& factory, | 503 GrGLNoise(const GrBackendEffectFactory& factory, |
505 const GrDrawEffect& drawEffect); | 504 const GrDrawEffect& drawEffect); |
506 virtual ~GrGLNoise() {} | 505 virtual ~GrGLNoise() {} |
507 | 506 |
508 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); | 507 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 const char* uv = "uv"; | 1000 const char* uv = "uv"; |
1002 const char* ab = "ab"; | 1001 const char* ab = "ab"; |
1003 const char* latticeIdx = "latticeIdx"; | 1002 const char* latticeIdx = "latticeIdx"; |
1004 const char* lattice = "lattice"; | 1003 const char* lattice = "lattice"; |
1005 const char* perlinNoise = "4096.0"; | 1004 const char* perlinNoise = "4096.0"; |
1006 const char* inc8bit = "0.00390625"; // 1.0 / 256.0 | 1005 const char* inc8bit = "0.00390625"; // 1.0 / 256.0 |
1007 // This is the math to convert the two 16bit integer packed into rgba 8 bit input into a | 1006 // This is the math to convert the two 16bit integer packed into rgba 8 bit input into a |
1008 // [-1,1] vector and perform a dot product between that vector and the provi ded vector. | 1007 // [-1,1] vector and perform a dot product between that vector and the provi ded vector. |
1009 const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec 2(1.0)), %s);"; | 1008 const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec 2(1.0)), %s);"; |
1010 | 1009 |
1010 GrGLShaderVar::Precision precision = GrGLShaderVar::kDefault_Precision; | |
1011 const char* precisionString = ""; | |
1012 #if defined(SK_BUILD_FOR_ANDROID) | |
bsalomon
2013/06/13 16:11:31
Do we really need this to be an android-only flag?
sugoi
2013/06/13 16:57:13
I can remove it if you want. Note that GrGLShaderV
sugoi
2013/06/13 18:04:42
Done.
| |
1013 // Android precision for NON Tegra devices, like, for example: Nexus 10 (ARM's Mali-T604) | |
1014 // The value of perlinNoise is 4096.0, so we need a high precision float to store this | |
1015 precision = GrGLShaderVar::kHigh_Precision; | |
1016 precisionString = GrGLShaderVar::PrecisionString(precision, builder->ctx Info().binding()); | |
1017 #endif | |
1018 | |
1011 // Add noise function | 1019 // Add noise function |
1012 static const GrGLShaderVar gPerlinNoiseArgs[] = { | 1020 static const GrGLShaderVar gPerlinNoiseArgs[] = { |
1013 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 1021 GrGLShaderVar(chanCoord, kFloat_GrSLType), |
1014 GrGLShaderVar(noiseVec, kVec2f_GrSLType) | 1022 GrGLShaderVar(noiseVec, kVec2f_GrSLType, GrGLShaderVar::kNonArray, preci sion) |
1015 }; | 1023 }; |
1016 | 1024 |
1017 static const GrGLShaderVar gPerlinNoiseStitchArgs[] = { | 1025 static const GrGLShaderVar gPerlinNoiseStitchArgs[] = { |
1018 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 1026 GrGLShaderVar(chanCoord, kFloat_GrSLType), |
1019 GrGLShaderVar(noiseVec, kVec2f_GrSLType), | 1027 GrGLShaderVar(noiseVec, kVec2f_GrSLType, GrGLShaderVar::kNonArray, preci sion), |
1020 GrGLShaderVar(stitchData, kVec4f_GrSLType) | 1028 GrGLShaderVar(stitchData, kVec4f_GrSLType, GrGLShaderVar::kNonArray, pre cision) |
1021 }; | 1029 }; |
1022 | 1030 |
1023 SkString noiseCode; | 1031 SkString noiseCode; |
1024 | 1032 |
1025 noiseCode.appendf( | 1033 noiseCode.appendf( |
1026 "\tvec4 %s = vec4(floor(%s) + vec2(%s), fract(%s));", | 1034 "\t%svec4 %s = vec4(floor(%s) + vec2(%s), fract(%s));", |
1027 noiseXY, noiseVec, perlinNoise, noiseVec); | 1035 precisionString, noiseXY, noiseVec, perlinNoise, noiseVec); |
1028 | 1036 |
1029 // smooth curve : t * t * (3 - 2 * t) | 1037 // smooth curve : t * t * (3 - 2 * t) |
1030 noiseCode.appendf("\n\tvec2 %s = %s.zw * %s.zw * (vec2(3.0) - vec2(2.0) * %s .zw);", | 1038 noiseCode.appendf("\n\tvec2 %s = %s.zw * %s.zw * (vec2(3.0) - vec2(2.0) * %s .zw);", |
1031 noiseSmooth, noiseXY, noiseXY, noiseXY); | 1039 noiseSmooth, noiseXY, noiseXY, noiseXY); |
1032 | 1040 |
1033 // Adjust frequencies if we're stitching tiles | 1041 // Adjust frequencies if we're stitching tiles |
1034 if (fStitchTiles) { | 1042 if (fStitchTiles) { |
1035 noiseCode.appendf("\n\tif(%s.x >= %s.y) { %s.x -= %s.x; }", | 1043 noiseCode.appendf("\n\tif(%s.x >= %s.y) { %s.x -= %s.x; }", |
1036 noiseXY, stitchData, noiseXY, stitchData); | 1044 noiseXY, stitchData, noiseXY, stitchData); |
1037 noiseCode.appendf("\n\tif(%s.x >= (%s.y - 1.0)) { %s.x -= (%s.x - 1.0); }", | 1045 noiseCode.appendf("\n\tif(%s.x >= (%s.y - 1.0)) { %s.x -= (%s.x - 1.0); }", |
(...skipping 18 matching lines...) Expand all Loading... | |
1056 noiseCode.append(".r;"); | 1064 noiseCode.append(".r;"); |
1057 } | 1065 } |
1058 | 1066 |
1059 // Get permutation for x + 1 | 1067 // Get permutation for x + 1 |
1060 { | 1068 { |
1061 SkString xCoords(""); | 1069 SkString xCoords(""); |
1062 xCoords.appendf("vec2(fract(%s.x + %s), 0.5)", noiseXY, inc8bit); | 1070 xCoords.appendf("vec2(fract(%s.x + %s), 0.5)", noiseXY, inc8bit); |
1063 | 1071 |
1064 noiseCode.appendf("\n\t%s.y = ", latticeIdx); | 1072 noiseCode.appendf("\n\t%s.y = ", latticeIdx); |
1065 builder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), k Vec2f_GrSLType); | 1073 builder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), k Vec2f_GrSLType); |
1066 noiseCode.append(".r;"); | 1074 noiseCode.append(".r;"); |
Stephen White
2013/06/13 16:05:15
As mentioned, If you want to move to Ganesh's sing
| |
1067 } | 1075 } |
1068 | 1076 |
1077 #if defined(SK_BUILD_FOR_ANDROID) | |
1078 // Android rounding for Tegra devices, like, for example: Xoom (Tegra 2), Ne xus 7 (Tegra 3) | |
1079 noiseCode.appendf("\n\t%s = floor(%s * vec2(255.0) + vec2(0.5)) * vec2(0.003 921569);", | |
sugoi
2013/06/13 15:34:15
1 / 255 = 0.003921569
Stephen White
2013/06/13 16:05:15
This ^^ should probably be in a comment in the cod
sugoi
2013/06/13 18:04:42
Done.
| |
1080 latticeIdx, latticeIdx); | |
1081 #endif | |
1082 | |
1069 // Get (x,y) coordinates with the permutated x | 1083 // Get (x,y) coordinates with the permutated x |
1070 noiseCode.appendf("\n\t%s = fract(%s + %s.yy);", latticeIdx, latticeIdx, noi seXY); | 1084 noiseCode.appendf("\n\t%s = fract(%s + %s.yy);", latticeIdx, latticeIdx, noi seXY); |
1071 | 1085 |
1072 noiseCode.appendf("\n\tvec2 %s = %s.zw;", fractVal, noiseXY); | 1086 noiseCode.appendf("\n\tvec2 %s = %s.zw;", fractVal, noiseXY); |
1073 | 1087 |
1074 noiseCode.appendf("\n\n\tvec2 %s;", uv); | 1088 noiseCode.appendf("\n\n\tvec2 %s;", uv); |
1075 // Compute u, at offset (0,0) | 1089 // Compute u, at offset (0,0) |
1076 { | 1090 { |
1077 SkString latticeCoords(""); | 1091 SkString latticeCoords(""); |
1078 latticeCoords.appendf("vec2(%s.x, %s)", latticeIdx, chanCoord); | 1092 latticeCoords.appendf("vec2(%s.x, %s)", latticeIdx, chanCoord); |
1079 noiseCode.appendf("\n\tvec4 %s = ", lattice); | 1093 noiseCode.appendf("\n\tvec4 %s = ", lattice); |
1080 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), | 1094 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), |
1081 kVec2f_GrSLType); | 1095 kVec2f_GrSLType); |
1082 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); | 1096 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); |
1083 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1097 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1084 } | 1098 } |
1085 | 1099 |
1086 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal); | 1100 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal); |
1087 // Compute v, at offset (-1,0) | 1101 // Compute v, at offset (-1,0) |
1088 { | 1102 { |
1089 SkString latticeCoords(""); | 1103 SkString latticeCoords(""); |
1090 latticeCoords.appendf("vec2(%s.y, %s)", latticeIdx, chanCoord); | 1104 latticeCoords.appendf("vec2(%s.y, %s)", latticeIdx, chanCoord); |
1091 noiseCode.append("lattice = "); | 1105 noiseCode.append("\n\tlattice = "); |
1092 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), | 1106 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), |
1093 kVec2f_GrSLType); | 1107 kVec2f_GrSLType); |
1094 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); | 1108 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); |
1095 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1109 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1096 } | 1110 } |
1097 | 1111 |
1098 // Compute 'a' as a linear interpolation of 'u' and 'v' | 1112 // Compute 'a' as a linear interpolation of 'u' and 'v' |
1099 noiseCode.appendf("\n\tvec2 %s;", ab); | 1113 noiseCode.appendf("\n\tvec2 %s;", ab); |
1100 noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); | 1114 noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); |
1101 | 1115 |
1102 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal); | 1116 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal); |
1103 // Compute v, at offset (-1,-1) | 1117 // Compute v, at offset (-1,-1) |
1104 { | 1118 { |
1105 SkString latticeCoords(""); | 1119 SkString latticeCoords(""); |
1106 latticeCoords.appendf("vec2(fract(%s.y + %s), %s)", latticeIdx, inc8bit, chanCoord); | 1120 latticeCoords.appendf("vec2(fract(%s.y + %s), %s)", latticeIdx, inc8bit, chanCoord); |
1107 noiseCode.append("lattice = "); | 1121 noiseCode.append("\n\tlattice = "); |
1108 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), | 1122 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), |
1109 kVec2f_GrSLType); | 1123 kVec2f_GrSLType); |
1110 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); | 1124 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); |
1111 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1125 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1112 } | 1126 } |
1113 | 1127 |
1114 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal); | 1128 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal); |
1115 // Compute u, at offset (0,-1) | 1129 // Compute u, at offset (0,-1) |
1116 { | 1130 { |
1117 SkString latticeCoords(""); | 1131 SkString latticeCoords(""); |
1118 latticeCoords.appendf("vec2(fract(%s.x + %s), %s)", latticeIdx, inc8bit, chanCoord); | 1132 latticeCoords.appendf("vec2(fract(%s.x + %s), %s)", latticeIdx, inc8bit, chanCoord); |
1119 noiseCode.append("lattice = "); | 1133 noiseCode.append("\n\tlattice = "); |
1120 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), | 1134 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st r(), |
1121 kVec2f_GrSLType); | 1135 kVec2f_GrSLType); |
1122 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); | 1136 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); |
1123 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1137 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1124 } | 1138 } |
1125 | 1139 |
1126 // Compute 'b' as a linear interpolation of 'u' and 'v' | 1140 // Compute 'b' as a linear interpolation of 'u' and 'v' |
1127 noiseCode.appendf("\n\t%s.y = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); | 1141 noiseCode.appendf("\n\t%s.y = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo th); |
1128 // Compute the noise as a linear interpolation of 'a' and 'b' | 1142 // Compute the noise as a linear interpolation of 'a' and 'b' |
1129 noiseCode.appendf("\n\treturn mix(%s.x, %s.y, %s.y);\n", ab, ab, noiseSmooth ); | 1143 noiseCode.appendf("\n\treturn mix(%s.x, %s.y, %s.y);\n", ab, ab, noiseSmooth ); |
1130 | 1144 |
1131 SkString noiseFuncName; | 1145 SkString noiseFuncName; |
1132 if (fStitchTiles) { | 1146 if (fStitchTiles) { |
1133 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr SLType, "perlinnoise", | 1147 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr SLType, |
1134 SK_ARRAY_COUNT(gPerlinNoiseStitchArgs), gPerlinNoi seStitchArgs, | 1148 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitchAr gs), |
1135 noiseCode.c_str(), &noiseFuncName); | 1149 gPerlinNoiseStitchArgs, noiseCode.c_str(), &noiseF uncName); |
1136 } else { | 1150 } else { |
1137 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr SLType, "perlinnoise", | 1151 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr SLType, |
1138 SK_ARRAY_COUNT(gPerlinNoiseArgs), gPerlinNoiseArgs , | 1152 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs), |
1139 noiseCode.c_str(), &noiseFuncName); | 1153 gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncNam e); |
1140 } | 1154 } |
1141 | 1155 |
1142 // There are rounding errors if the floor operation is not performed here | 1156 // There are rounding errors if the floor operation is not performed here |
1143 builder->fsCodeAppendf("\n\t\tvec2 %s = floor((%s * vec3(%s, 1.0)).xy) * %s; ", | 1157 builder->fsCodeAppendf("\n\t\tvec2 %s = floor((%s * vec3(%s, 1.0)).xy) * %s; ", |
1144 noiseVec, invMatrixUni, vCoords, baseFrequencyUni); | 1158 noiseVec, invMatrixUni, vCoords, baseFrequencyUni); |
1145 | 1159 |
1146 // Clear the color accumulator | 1160 // Clear the color accumulator |
1147 builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor); | 1161 builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor); |
1148 | 1162 |
1149 if (fStitchTiles) { | 1163 if (fStitchTiles) { |
1150 // Set up TurbulenceInitial stitch values. | 1164 // Set up TurbulenceInitial stitch values. |
1151 builder->fsCodeAppendf("\n\t\tvec4 %s = %s;", stitchData, stitchDataUni) ; | 1165 builder->fsCodeAppendf("\n\t\t%s vec4 %s = %s;", precisionString, stitch Data, stitchDataUni); |
1152 } | 1166 } |
1153 | 1167 |
1154 builder->fsCodeAppendf("\n\t\tfloat %s = 1.0;", ratio); | 1168 builder->fsCodeAppendf("\n\t\tfloat %s = 1.0;", ratio); |
1155 | 1169 |
1156 // Loop over all octaves | 1170 // Loop over all octaves |
1157 builder->fsCodeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {" , fNumOctaves); | 1171 builder->fsCodeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {" , fNumOctaves); |
1158 | 1172 |
1159 builder->fsCodeAppendf("\n\t\t\t%s += ", outputColor); | 1173 builder->fsCodeAppendf("\n\t\t\t%s += ", outputColor); |
1160 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { | 1174 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { |
1161 builder->fsCodeAppend("abs("); | 1175 builder->fsCodeAppend("abs("); |
(...skipping 18 matching lines...) Expand all Loading... | |
1180 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { | 1194 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { |
1181 builder->fsCodeAppendf(")"); // end of "abs(" | 1195 builder->fsCodeAppendf(")"); // end of "abs(" |
1182 } | 1196 } |
1183 builder->fsCodeAppendf(" * %s;", ratio); | 1197 builder->fsCodeAppendf(" * %s;", ratio); |
1184 | 1198 |
1185 builder->fsCodeAppendf("\n\t\t\t%s *= vec2(2.0);", noiseVec); | 1199 builder->fsCodeAppendf("\n\t\t\t%s *= vec2(2.0);", noiseVec); |
1186 builder->fsCodeAppendf("\n\t\t\t%s *= 0.5;", ratio); | 1200 builder->fsCodeAppendf("\n\t\t\t%s *= 0.5;", ratio); |
1187 | 1201 |
1188 if (fStitchTiles) { | 1202 if (fStitchTiles) { |
1189 builder->fsCodeAppendf("\n\t\t\t%s.xz *= vec2(2.0);", stitchData); | 1203 builder->fsCodeAppendf("\n\t\t\t%s.xz *= vec2(2.0);", stitchData); |
1190 builder->fsCodeAppendf("\n\t\t\t%s.yw = %s.xz + vec2(%s);", stitchData, stitchData, perlinNoise); | 1204 builder->fsCodeAppendf("\n\t\t\t%s.yw = %s.xz + vec2(%s);", |
1205 stitchData, stitchData, perlinNoise); | |
1191 } | 1206 } |
1192 builder->fsCodeAppend("\n\t\t}"); // end of the for loop on octaves | 1207 builder->fsCodeAppend("\n\t\t}"); // end of the for loop on octaves |
1193 | 1208 |
1194 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) { | 1209 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) { |
1195 // The value of turbulenceFunctionResult comes from ((turbulenceFunction Result) + 1) / 2 | 1210 // The value of turbulenceFunctionResult comes from ((turbulenceFunction Result) + 1) / 2 |
1196 // by fractalNoise and (turbulenceFunctionResult) by turbulence. | 1211 // by fractalNoise and (turbulenceFunctionResult) by turbulence. |
1197 builder->fsCodeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);", outputC olor, outputColor); | 1212 builder->fsCodeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);", outputC olor, outputColor); |
1198 } | 1213 } |
1199 | 1214 |
1200 builder->fsCodeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni); | 1215 builder->fsCodeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1327 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture); | 1342 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture); |
1328 } | 1343 } |
1329 #endif | 1344 #endif |
1330 | 1345 |
1331 return effect; | 1346 return effect; |
1332 } | 1347 } |
1333 | 1348 |
1334 #else | 1349 #else |
1335 | 1350 |
1336 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext*, const SkPaint&) const { | 1351 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext*, const SkPaint&) const { |
1337 #if !defined(SK_BUILD_FOR_ANDROID) | |
1338 SkDEBUGFAIL("Should not call in GPU-less build"); | 1352 SkDEBUGFAIL("Should not call in GPU-less build"); |
1339 #endif | |
1340 return NULL; | 1353 return NULL; |
1341 } | 1354 } |
1342 | 1355 |
1343 #endif | 1356 #endif |
1344 | 1357 |
1345 #ifdef SK_DEVELOPER | 1358 #ifdef SK_DEVELOPER |
1346 void SkPerlinNoiseShader::toString(SkString* str) const { | 1359 void SkPerlinNoiseShader::toString(SkString* str) const { |
1347 str->append("SkPerlinNoiseShader: ("); | 1360 str->append("SkPerlinNoiseShader: ("); |
1348 | 1361 |
1349 str->append("type: "); | 1362 str->append("type: "); |
(...skipping 17 matching lines...) Expand all Loading... | |
1367 str->append(" seed: "); | 1380 str->append(" seed: "); |
1368 str->appendScalar(fSeed); | 1381 str->appendScalar(fSeed); |
1369 str->append(" stitch tiles: "); | 1382 str->append(" stitch tiles: "); |
1370 str->append(fStitchTiles ? "true " : "false "); | 1383 str->append(fStitchTiles ? "true " : "false "); |
1371 | 1384 |
1372 this->INHERITED::toString(str); | 1385 this->INHERITED::toString(str); |
1373 | 1386 |
1374 str->append(")"); | 1387 str->append(")"); |
1375 } | 1388 } |
1376 #endif | 1389 #endif |
OLD | NEW |