diff --git a/gm/perlinnoise.cpp b/gm/perlinnoise.cpp index d61e25e023..5f30772151 100644 --- a/gm/perlinnoise.cpp +++ b/gm/perlinnoise.cpp @@ -25,7 +25,6 @@ namespace { enum class Type { kFractalNoise, kTurbulence, - kImproved, }; class PerlinNoiseGM : public skiagm::GM { @@ -35,7 +34,7 @@ class PerlinNoiseGM : public skiagm::GM { SkString onShortName() override { return SkString("perlinnoise"); } - SkISize onISize() override { return {200, 600}; } + SkISize onISize() override { return {200, 500}; } void drawRect(SkCanvas* canvas, int x, int y, const SkPaint& paint, const SkISize& size) { canvas->save(); @@ -47,33 +46,14 @@ class PerlinNoiseGM : public skiagm::GM { } void test(SkCanvas* canvas, int x, int y, Type type, - float baseFrequencyX, float baseFrequencyY, int numOctaves, float seedOrZ, + float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) { SkISize tileSize = SkISize::Make(fSize.width() / 2, fSize.height() / 2); - sk_sp shader; - switch (type) { - case Type::kFractalNoise: - shader = SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, - baseFrequencyY, - numOctaves, - seedOrZ, - stitchTiles ? &tileSize : nullptr); - break; - case Type::kTurbulence: - shader = SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, - baseFrequencyY, - numOctaves, - seedOrZ, - stitchTiles ? &tileSize : nullptr); - break; - case Type::kImproved: - SkASSERT(!stitchTiles); - shader = SkPerlinNoiseShader::MakeImprovedNoise(baseFrequencyX, - baseFrequencyY, - numOctaves, - seedOrZ); - break; - } + sk_sp shader = (type == Type::kFractalNoise) ? + SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, + seed, stitchTiles ? &tileSize : nullptr) : + SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, + seed, stitchTiles ? &tileSize : nullptr); SkPaint paint; paint.setShader(std::move(shader)); if (stitchTiles) { @@ -111,16 +91,11 @@ class PerlinNoiseGM : public skiagm::GM { test(canvas, 100, 300, Type::kFractalNoise, 0.1f, 0.1f, 3, 4, false); - test(canvas, 0, 400, Type::kImproved, - 0.0125f, 0.0125f, 4, 0, false); - test(canvas, 100, 400, Type::kImproved, - 0.125f, 0.0075f, 2, 0, false); - canvas->scale(0.75f, 1.0f); - test(canvas, 0, 500, Type::kFractalNoise, + test(canvas, 0, 400, Type::kFractalNoise, 0.1f, 0.1f, 2, 0, false); - test(canvas, 100, 500, Type::kFractalNoise, + test(canvas, 100, 400, Type::kFractalNoise, 0.1f, 0.05f, 1, 0, true); } diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp index f429d0bd57..1dc538c4f3 100644 --- a/src/shaders/SkPerlinNoiseShader.cpp +++ b/src/shaders/SkPerlinNoiseShader.cpp @@ -1222,7 +1222,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) { }; SkString samplePerm = this->invokeChild(0, "half4(1)", args, "float2(x, 0.5)"); SkString permFuncName = fragBuilder->getMangledFunctionName("perm"); - SkString permCode = SkStringPrintf("return %s.a * 255;", samplePerm.c_str()); + SkString permCode = SkStringPrintf("return %s.r * 255;", samplePerm.c_str()); fragBuilder->emitFunction(kHalf_GrSLType, permFuncName.c_str(), {permArgs, SK_ARRAY_COUNT(permArgs)}, permCode.c_str());