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 "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 int numOctaves = d->fRandom->nextRangeU(2, 10); | 595 int numOctaves = d->fRandom->nextRangeU(2, 10); |
596 bool stitchTiles = d->fRandom->nextBool(); | 596 bool stitchTiles = d->fRandom->nextBool(); |
597 SkScalar seed = SkIntToScalar(d->fRandom->nextU()); | 597 SkScalar seed = SkIntToScalar(d->fRandom->nextU()); |
598 SkISize tileSize = SkISize::Make(d->fRandom->nextRangeU(4, 4096), | 598 SkISize tileSize = SkISize::Make(d->fRandom->nextRangeU(4, 4096), |
599 d->fRandom->nextRangeU(4, 4096)); | 599 d->fRandom->nextRangeU(4, 4096)); |
600 SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f, | 600 SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f, |
601 0.99f); | 601 0.99f); |
602 SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f, | 602 SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f, |
603 0.99f); | 603 0.99f); |
604 | 604 |
605 SkShader* shader = d->fRandom->nextBool() ? | 605 SkAutoTUnref<SkShader> shader(d->fRandom->nextBool() ? |
606 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY,
numOctaves, seed, | 606 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY,
numOctaves, seed, |
607 stitchTiles ? &tileSize : nullpt
r) : | 607 stitchTiles ? &tileSize : nullpt
r) : |
608 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu
mOctaves, seed, | 608 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu
mOctaves, seed, |
609 stitchTiles ? &tileSize : nullptr); | 609 stitchTiles ? &tileSize : nullptr))
; |
610 | 610 |
611 GrPaint grPaint; | 611 GrPaint grPaint; |
612 return shader->asFragmentProcessor(d->fContext, | 612 return shader->asFragmentProcessor(d->fContext, |
613 GrTest::TestMatrix(d->fRandom), nullptr, | 613 GrTest::TestMatrix(d->fRandom), nullptr, |
614 kNone_SkFilterQuality, | 614 kNone_SkFilterQuality, |
615 grPaint.getProcessorDataManager()); | 615 grPaint.getProcessorDataManager()); |
616 } | 616 } |
617 | 617 |
618 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) | 618 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) |
619 : fType(processor.cast<GrPerlinNoiseEffect>().type()) | 619 : fType(processor.cast<GrPerlinNoiseEffect>().type()) |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 str->append(" seed: "); | 996 str->append(" seed: "); |
997 str->appendScalar(fSeed); | 997 str->appendScalar(fSeed); |
998 str->append(" stitch tiles: "); | 998 str->append(" stitch tiles: "); |
999 str->append(fStitchTiles ? "true " : "false "); | 999 str->append(fStitchTiles ? "true " : "false "); |
1000 | 1000 |
1001 this->INHERITED::toString(str); | 1001 this->INHERITED::toString(str); |
1002 | 1002 |
1003 str->append(")"); | 1003 str->append(")"); |
1004 } | 1004 } |
1005 #endif | 1005 #endif |
OLD | NEW |