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 "SkPerlinNoiseShader2.h" | 9 #include "SkPerlinNoiseShader2.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 noiseOctavesCode.append("p *= 2.0;"); | 1285 noiseOctavesCode.append("p *= 2.0;"); |
1286 noiseOctavesCode.append("ratio *= 2.0;"); | 1286 noiseOctavesCode.append("ratio *= 2.0;"); |
1287 noiseOctavesCode.append("}"); | 1287 noiseOctavesCode.append("}"); |
1288 noiseOctavesCode.append("return (result + 1.0) / 2.0;"); | 1288 noiseOctavesCode.append("return (result + 1.0) / 2.0;"); |
1289 fsBuilder->emitFunction(kFloat_GrSLType, "noiseOctaves", SK_ARRAY_COUNT(nois
eOctavesArgs), | 1289 fsBuilder->emitFunction(kFloat_GrSLType, "noiseOctaves", SK_ARRAY_COUNT(nois
eOctavesArgs), |
1290 noiseOctavesArgs, noiseOctavesCode.c_str(), &noiseOc
tavesFuncName); | 1290 noiseOctavesArgs, noiseOctavesCode.c_str(), &noiseOc
tavesFuncName); |
1291 | 1291 |
1292 fsBuilder->codeAppendf("vec2 coords = %s * %s;", vCoords.c_str(), baseFreque
ncyUni); | 1292 fsBuilder->codeAppendf("vec2 coords = %s * %s;", vCoords.c_str(), baseFreque
ncyUni); |
1293 fsBuilder->codeAppendf("float r = %s(vec3(coords, %s), %s);", noiseOctavesFu
ncName.c_str(), | 1293 fsBuilder->codeAppendf("float r = %s(vec3(coords, %s), %s);", noiseOctavesFu
ncName.c_str(), |
1294 zUni, octavesUni); | 1294 zUni, octavesUni); |
1295 fsBuilder->codeAppendf("float g = %s(vec3(coords, %s + 1000.0), %s);", | 1295 fsBuilder->codeAppendf("float g = %s(vec3(coords, %s + 0000.0), %s);", |
1296 noiseOctavesFuncName.c_str(), zUni, octavesUni); | 1296 noiseOctavesFuncName.c_str(), zUni, octavesUni); |
1297 fsBuilder->codeAppendf("float b = %s(vec3(coords, %s + 2000.0), %s);", | 1297 fsBuilder->codeAppendf("float b = %s(vec3(coords, %s + 0000.0), %s);", |
1298 noiseOctavesFuncName.c_str(), zUni, octavesUni); | 1298 noiseOctavesFuncName.c_str(), zUni, octavesUni); |
1299 fsBuilder->codeAppendf("float a = %s(vec3(coords, %s + 3000.0), %s);", | 1299 fsBuilder->codeAppendf("float a = %s(vec3(coords, %s + 0000.0), %s);", |
1300 noiseOctavesFuncName.c_str(), zUni, octavesUni); | 1300 noiseOctavesFuncName.c_str(), zUni, octavesUni); |
1301 fsBuilder->codeAppendf("%s = vec4(r, g, b, a);", args.fOutputColor); | 1301 fsBuilder->codeAppendf("%s = vec4(r, g, b, a);", args.fOutputColor); |
1302 | 1302 |
1303 // Clamp values | 1303 // Clamp values |
1304 fsBuilder->codeAppendf("%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.
fOutputColor); | 1304 fsBuilder->codeAppendf("%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.
fOutputColor); |
1305 | 1305 |
1306 // Pre-multiply the result | 1306 // Pre-multiply the result |
1307 fsBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", | 1307 fsBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", |
1308 args.fOutputColor, args.fOutputColor, | 1308 args.fOutputColor, args.fOutputColor, |
1309 args.fOutputColor, args.fOutputColor); | 1309 args.fOutputColor, args.fOutputColor); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 str->append(" seed: "); | 1426 str->append(" seed: "); |
1427 str->appendScalar(fSeed); | 1427 str->appendScalar(fSeed); |
1428 str->append(" stitch tiles: "); | 1428 str->append(" stitch tiles: "); |
1429 str->append(fStitchTiles ? "true " : "false "); | 1429 str->append(fStitchTiles ? "true " : "false "); |
1430 | 1430 |
1431 this->INHERITED::toString(str); | 1431 this->INHERITED::toString(str); |
1432 | 1432 |
1433 str->append(")"); | 1433 str->append(")"); |
1434 } | 1434 } |
1435 #endif | 1435 #endif |
OLD | NEW |