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 // Android precision fix for NON Tegra devices, like, for example: Nexus 10
(ARM's Mali-T604) |
| 1011 // The value of perlinNoise is 4096.0, so we need a high precision float to
store this |
| 1012 const GrGLShaderVar::Precision precision = GrGLShaderVar::kHigh_Precision; |
| 1013 const char* precisionString = |
| 1014 GrGLShaderVar::PrecisionString(precision, builder->ctxInfo().binding()); |
| 1015 |
1011 // Add noise function | 1016 // Add noise function |
1012 static const GrGLShaderVar gPerlinNoiseArgs[] = { | 1017 static const GrGLShaderVar gPerlinNoiseArgs[] = { |
1013 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 1018 GrGLShaderVar(chanCoord, kFloat_GrSLType), |
1014 GrGLShaderVar(noiseVec, kVec2f_GrSLType) | 1019 GrGLShaderVar(noiseVec, kVec2f_GrSLType, GrGLShaderVar::kNonArray, preci
sion) |
1015 }; | 1020 }; |
1016 | 1021 |
1017 static const GrGLShaderVar gPerlinNoiseStitchArgs[] = { | 1022 static const GrGLShaderVar gPerlinNoiseStitchArgs[] = { |
1018 GrGLShaderVar(chanCoord, kFloat_GrSLType), | 1023 GrGLShaderVar(chanCoord, kFloat_GrSLType), |
1019 GrGLShaderVar(noiseVec, kVec2f_GrSLType), | 1024 GrGLShaderVar(noiseVec, kVec2f_GrSLType, GrGLShaderVar::kNonArray, preci
sion), |
1020 GrGLShaderVar(stitchData, kVec4f_GrSLType) | 1025 GrGLShaderVar(stitchData, kVec4f_GrSLType, GrGLShaderVar::kNonArray, pre
cision) |
1021 }; | 1026 }; |
1022 | 1027 |
1023 SkString noiseCode; | 1028 SkString noiseCode; |
1024 | 1029 |
1025 noiseCode.appendf( | 1030 noiseCode.appendf( |
1026 "\tvec4 %s = vec4(floor(%s) + vec2(%s), fract(%s));", | 1031 "\t%svec4 %s = vec4(floor(%s) + vec2(%s), fract(%s));", |
1027 noiseXY, noiseVec, perlinNoise, noiseVec); | 1032 precisionString, noiseXY, noiseVec, perlinNoise, noiseVec); |
1028 | 1033 |
1029 // smooth curve : t * t * (3 - 2 * t) | 1034 // 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);", | 1035 noiseCode.appendf("\n\tvec2 %s = %s.zw * %s.zw * (vec2(3.0) - vec2(2.0) * %s
.zw);", |
1031 noiseSmooth, noiseXY, noiseXY, noiseXY); | 1036 noiseSmooth, noiseXY, noiseXY, noiseXY); |
1032 | 1037 |
1033 // Adjust frequencies if we're stitching tiles | 1038 // Adjust frequencies if we're stitching tiles |
1034 if (fStitchTiles) { | 1039 if (fStitchTiles) { |
1035 noiseCode.appendf("\n\tif(%s.x >= %s.y) { %s.x -= %s.x; }", | 1040 noiseCode.appendf("\n\tif(%s.x >= %s.y) { %s.x -= %s.x; }", |
1036 noiseXY, stitchData, noiseXY, stitchData); | 1041 noiseXY, stitchData, noiseXY, stitchData); |
1037 noiseCode.appendf("\n\tif(%s.x >= (%s.y - 1.0)) { %s.x -= (%s.x - 1.0);
}", | 1042 noiseCode.appendf("\n\tif(%s.x >= (%s.y - 1.0)) { %s.x -= (%s.x - 1.0);
}", |
(...skipping 21 matching lines...) Expand all Loading... |
1059 // Get permutation for x + 1 | 1064 // Get permutation for x + 1 |
1060 { | 1065 { |
1061 SkString xCoords(""); | 1066 SkString xCoords(""); |
1062 xCoords.appendf("vec2(fract(%s.x + %s), 0.5)", noiseXY, inc8bit); | 1067 xCoords.appendf("vec2(fract(%s.x + %s), 0.5)", noiseXY, inc8bit); |
1063 | 1068 |
1064 noiseCode.appendf("\n\t%s.y = ", latticeIdx); | 1069 noiseCode.appendf("\n\t%s.y = ", latticeIdx); |
1065 builder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), k
Vec2f_GrSLType); | 1070 builder->appendTextureLookup(&noiseCode, samplers[0], xCoords.c_str(), k
Vec2f_GrSLType); |
1066 noiseCode.append(".r;"); | 1071 noiseCode.append(".r;"); |
1067 } | 1072 } |
1068 | 1073 |
| 1074 #if defined(SK_BUILD_FOR_ANDROID) |
| 1075 // Android rounding for Tegra devices, like, for example: Xoom (Tegra 2), Ne
xus 7 (Tegra 3). |
| 1076 // The issue is that colors aren't accurate enough on Tegra devices. For exa
mple, if an 8 bit |
| 1077 // value of 124 (or 0.486275 here) is entered, we can get a texture value of
123.513725 |
| 1078 // (or 0.484368 here). The following rounding operation prevents these preci
sion issues from |
| 1079 // affecting the result of the noise by making sure that we only have multip
les of 1/255. |
| 1080 // (Note that 1/255 is about 0.003921569, which is the value used here). |
| 1081 noiseCode.appendf("\n\t%s = floor(%s * vec2(255.0) + vec2(0.5)) * vec2(0.003
921569);", |
| 1082 latticeIdx, latticeIdx); |
| 1083 #endif |
| 1084 |
1069 // Get (x,y) coordinates with the permutated x | 1085 // Get (x,y) coordinates with the permutated x |
1070 noiseCode.appendf("\n\t%s = fract(%s + %s.yy);", latticeIdx, latticeIdx, noi
seXY); | 1086 noiseCode.appendf("\n\t%s = fract(%s + %s.yy);", latticeIdx, latticeIdx, noi
seXY); |
1071 | 1087 |
1072 noiseCode.appendf("\n\tvec2 %s = %s.zw;", fractVal, noiseXY); | 1088 noiseCode.appendf("\n\tvec2 %s = %s.zw;", fractVal, noiseXY); |
1073 | 1089 |
1074 noiseCode.appendf("\n\n\tvec2 %s;", uv); | 1090 noiseCode.appendf("\n\n\tvec2 %s;", uv); |
1075 // Compute u, at offset (0,0) | 1091 // Compute u, at offset (0,0) |
1076 { | 1092 { |
1077 SkString latticeCoords(""); | 1093 SkString latticeCoords(""); |
1078 latticeCoords.appendf("vec2(%s.x, %s)", latticeIdx, chanCoord); | 1094 latticeCoords.appendf("vec2(%s.x, %s)", latticeIdx, chanCoord); |
1079 noiseCode.appendf("\n\tvec4 %s = ", lattice); | 1095 noiseCode.appendf("\n\tvec4 %s = ", lattice); |
1080 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), | 1096 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), |
1081 kVec2f_GrSLType); | 1097 kVec2f_GrSLType); |
1082 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); | 1098 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); |
1083 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1099 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1084 } | 1100 } |
1085 | 1101 |
1086 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal); | 1102 noiseCode.appendf("\n\t%s.x -= 1.0;", fractVal); |
1087 // Compute v, at offset (-1,0) | 1103 // Compute v, at offset (-1,0) |
1088 { | 1104 { |
1089 SkString latticeCoords(""); | 1105 SkString latticeCoords(""); |
1090 latticeCoords.appendf("vec2(%s.y, %s)", latticeIdx, chanCoord); | 1106 latticeCoords.appendf("vec2(%s.y, %s)", latticeIdx, chanCoord); |
1091 noiseCode.append("lattice = "); | 1107 noiseCode.append("\n\tlattice = "); |
1092 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), | 1108 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), |
1093 kVec2f_GrSLType); | 1109 kVec2f_GrSLType); |
1094 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); | 1110 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); |
1095 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1111 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1096 } | 1112 } |
1097 | 1113 |
1098 // Compute 'a' as a linear interpolation of 'u' and 'v' | 1114 // Compute 'a' as a linear interpolation of 'u' and 'v' |
1099 noiseCode.appendf("\n\tvec2 %s;", ab); | 1115 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); | 1116 noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmoo
th); |
1101 | 1117 |
1102 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal); | 1118 noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal); |
1103 // Compute v, at offset (-1,-1) | 1119 // Compute v, at offset (-1,-1) |
1104 { | 1120 { |
1105 SkString latticeCoords(""); | 1121 SkString latticeCoords(""); |
1106 latticeCoords.appendf("vec2(fract(%s.y + %s), %s)", latticeIdx, inc8bit,
chanCoord); | 1122 latticeCoords.appendf("vec2(fract(%s.y + %s), %s)", latticeIdx, inc8bit,
chanCoord); |
1107 noiseCode.append("lattice = "); | 1123 noiseCode.append("\n\tlattice = "); |
1108 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), | 1124 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), |
1109 kVec2f_GrSLType); | 1125 kVec2f_GrSLType); |
1110 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); | 1126 noiseCode.appendf(".bgra;\n\t%s.y = ", uv); |
1111 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1127 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1112 } | 1128 } |
1113 | 1129 |
1114 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal); | 1130 noiseCode.appendf("\n\t%s.x += 1.0;", fractVal); |
1115 // Compute u, at offset (0,-1) | 1131 // Compute u, at offset (0,-1) |
1116 { | 1132 { |
1117 SkString latticeCoords(""); | 1133 SkString latticeCoords(""); |
1118 latticeCoords.appendf("vec2(fract(%s.x + %s), %s)", latticeIdx, inc8bit,
chanCoord); | 1134 latticeCoords.appendf("vec2(fract(%s.x + %s), %s)", latticeIdx, inc8bit,
chanCoord); |
1119 noiseCode.append("lattice = "); | 1135 noiseCode.append("\n\tlattice = "); |
1120 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), | 1136 builder->appendTextureLookup(&noiseCode, samplers[1], latticeCoords.c_st
r(), |
1121 kVec2f_GrSLType); | 1137 kVec2f_GrSLType); |
1122 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); | 1138 noiseCode.appendf(".bgra;\n\t%s.x = ", uv); |
1123 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); | 1139 noiseCode.appendf(dotLattice, lattice, lattice, inc8bit, fractVal); |
1124 } | 1140 } |
1125 | 1141 |
1126 // Compute 'b' as a linear interpolation of 'u' and 'v' | 1142 // 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); | 1143 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' | 1144 // 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
); | 1145 noiseCode.appendf("\n\treturn mix(%s.x, %s.y, %s.y);\n", ab, ab, noiseSmooth
); |
1130 | 1146 |
1131 SkString noiseFuncName; | 1147 SkString noiseFuncName; |
1132 if (fStitchTiles) { | 1148 if (fStitchTiles) { |
1133 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr
SLType, "perlinnoise", | 1149 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr
SLType, |
1134 SK_ARRAY_COUNT(gPerlinNoiseStitchArgs), gPerlinNoi
seStitchArgs, | 1150 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitchAr
gs), |
1135 noiseCode.c_str(), &noiseFuncName); | 1151 gPerlinNoiseStitchArgs, noiseCode.c_str(), &noiseF
uncName); |
1136 } else { | 1152 } else { |
1137 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr
SLType, "perlinnoise", | 1153 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_Gr
SLType, |
1138 SK_ARRAY_COUNT(gPerlinNoiseArgs), gPerlinNoiseArgs
, | 1154 "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs), |
1139 noiseCode.c_str(), &noiseFuncName); | 1155 gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncNam
e); |
1140 } | 1156 } |
1141 | 1157 |
1142 // There are rounding errors if the floor operation is not performed here | 1158 // 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;
", | 1159 builder->fsCodeAppendf("\n\t\tvec2 %s = floor((%s * vec3(%s, 1.0)).xy) * %s;
", |
1144 noiseVec, invMatrixUni, vCoords, baseFrequencyUni); | 1160 noiseVec, invMatrixUni, vCoords, baseFrequencyUni); |
1145 | 1161 |
1146 // Clear the color accumulator | 1162 // Clear the color accumulator |
1147 builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor); | 1163 builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor); |
1148 | 1164 |
1149 if (fStitchTiles) { | 1165 if (fStitchTiles) { |
1150 // Set up TurbulenceInitial stitch values. | 1166 // Set up TurbulenceInitial stitch values. |
1151 builder->fsCodeAppendf("\n\t\tvec4 %s = %s;", stitchData, stitchDataUni)
; | 1167 builder->fsCodeAppendf("\n\t\t%s vec4 %s = %s;", precisionString, stitch
Data, stitchDataUni); |
1152 } | 1168 } |
1153 | 1169 |
1154 builder->fsCodeAppendf("\n\t\tfloat %s = 1.0;", ratio); | 1170 builder->fsCodeAppendf("\n\t\tfloat %s = 1.0;", ratio); |
1155 | 1171 |
1156 // Loop over all octaves | 1172 // Loop over all octaves |
1157 builder->fsCodeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {"
, fNumOctaves); | 1173 builder->fsCodeAppendf("\n\t\tfor (int octave = 0; octave < %d; ++octave) {"
, fNumOctaves); |
1158 | 1174 |
1159 builder->fsCodeAppendf("\n\t\t\t%s += ", outputColor); | 1175 builder->fsCodeAppendf("\n\t\t\t%s += ", outputColor); |
1160 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { | 1176 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { |
1161 builder->fsCodeAppend("abs("); | 1177 builder->fsCodeAppend("abs("); |
(...skipping 18 matching lines...) Expand all Loading... |
1180 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { | 1196 if (fType != SkPerlinNoiseShader::kFractalNoise_Type) { |
1181 builder->fsCodeAppendf(")"); // end of "abs(" | 1197 builder->fsCodeAppendf(")"); // end of "abs(" |
1182 } | 1198 } |
1183 builder->fsCodeAppendf(" * %s;", ratio); | 1199 builder->fsCodeAppendf(" * %s;", ratio); |
1184 | 1200 |
1185 builder->fsCodeAppendf("\n\t\t\t%s *= vec2(2.0);", noiseVec); | 1201 builder->fsCodeAppendf("\n\t\t\t%s *= vec2(2.0);", noiseVec); |
1186 builder->fsCodeAppendf("\n\t\t\t%s *= 0.5;", ratio); | 1202 builder->fsCodeAppendf("\n\t\t\t%s *= 0.5;", ratio); |
1187 | 1203 |
1188 if (fStitchTiles) { | 1204 if (fStitchTiles) { |
1189 builder->fsCodeAppendf("\n\t\t\t%s.xz *= vec2(2.0);", stitchData); | 1205 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); | 1206 builder->fsCodeAppendf("\n\t\t\t%s.yw = %s.xz + vec2(%s);", |
| 1207 stitchData, stitchData, perlinNoise); |
1191 } | 1208 } |
1192 builder->fsCodeAppend("\n\t\t}"); // end of the for loop on octaves | 1209 builder->fsCodeAppend("\n\t\t}"); // end of the for loop on octaves |
1193 | 1210 |
1194 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) { | 1211 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) { |
1195 // The value of turbulenceFunctionResult comes from ((turbulenceFunction
Result) + 1) / 2 | 1212 // The value of turbulenceFunctionResult comes from ((turbulenceFunction
Result) + 1) / 2 |
1196 // by fractalNoise and (turbulenceFunctionResult) by turbulence. | 1213 // by fractalNoise and (turbulenceFunctionResult) by turbulence. |
1197 builder->fsCodeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);", outputC
olor, outputColor); | 1214 builder->fsCodeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);", outputC
olor, outputColor); |
1198 } | 1215 } |
1199 | 1216 |
1200 builder->fsCodeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni); | 1217 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); | 1344 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture); |
1328 } | 1345 } |
1329 #endif | 1346 #endif |
1330 | 1347 |
1331 return effect; | 1348 return effect; |
1332 } | 1349 } |
1333 | 1350 |
1334 #else | 1351 #else |
1335 | 1352 |
1336 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext*, const SkPaint&) const
{ | 1353 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext*, const SkPaint&) const
{ |
1337 #if !defined(SK_BUILD_FOR_ANDROID) | |
1338 SkDEBUGFAIL("Should not call in GPU-less build"); | 1354 SkDEBUGFAIL("Should not call in GPU-less build"); |
1339 #endif | |
1340 return NULL; | 1355 return NULL; |
1341 } | 1356 } |
1342 | 1357 |
1343 #endif | 1358 #endif |
1344 | 1359 |
1345 #ifdef SK_DEVELOPER | 1360 #ifdef SK_DEVELOPER |
1346 void SkPerlinNoiseShader::toString(SkString* str) const { | 1361 void SkPerlinNoiseShader::toString(SkString* str) const { |
1347 str->append("SkPerlinNoiseShader: ("); | 1362 str->append("SkPerlinNoiseShader: ("); |
1348 | 1363 |
1349 str->append("type: "); | 1364 str->append("type: "); |
(...skipping 17 matching lines...) Expand all Loading... |
1367 str->append(" seed: "); | 1382 str->append(" seed: "); |
1368 str->appendScalar(fSeed); | 1383 str->appendScalar(fSeed); |
1369 str->append(" stitch tiles: "); | 1384 str->append(" stitch tiles: "); |
1370 str->append(fStitchTiles ? "true " : "false "); | 1385 str->append(fStitchTiles ? "true " : "false "); |
1371 | 1386 |
1372 this->INHERITED::toString(str); | 1387 this->INHERITED::toString(str); |
1373 | 1388 |
1374 str->append(")"); | 1389 str->append(")"); |
1375 } | 1390 } |
1376 #endif | 1391 #endif |
OLD | NEW |