diff options
author | reed <reed@google.com> | 2016-03-25 09:08:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 09:08:00 -0700 |
commit | fe63045f075165b1be5d3e7fc5c710021d85f53b (patch) | |
tree | c60f764504ba1d622613a432c88e43f7f65c0fec /src/effects | |
parent | cce49271124ff75c880dc0dfed1489f02c82890b (diff) |
move setshader to sk_sp, re-using SK_SUPPORT_LEGACY_CREATESHADER_PTR
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1829303002
Review URL: https://codereview.chromium.org/1829303002
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkLayerDrawLooper.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkPerlinNoiseShader.cpp | 39 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 8510767801..526fb4d7e3 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -99,7 +99,7 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo( dst->setMaskFilter(src.getMaskFilter()); } if (bits & kShader_Bit) { - dst->setShader(src.getShader()); + dst->setShader(sk_ref_sp(src.getShader())); } if (bits & kColorFilter_Bit) { dst->setColorFilter(sk_ref_sp(src.getColorFilter())); diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index ef528751dd..72b7e0280d 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -249,18 +249,21 @@ public: #endif }; -SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY, - int numOctaves, SkScalar seed, - const SkISize* tileSize) { - return new SkPerlinNoiseShader(kFractalNoise_Type, baseFrequencyX, baseFrequencyY, numOctaves, - seed, tileSize); +sk_sp<SkShader> SkPerlinNoiseShader::MakeFractalNoise(SkScalar baseFrequencyX, + SkScalar baseFrequencyY, + int numOctaves, SkScalar seed, + const SkISize* tileSize) { + return sk_sp<SkShader>(new SkPerlinNoiseShader(kFractalNoise_Type, baseFrequencyX, + baseFrequencyY, numOctaves, + seed, tileSize)); } -SkShader* SkPerlinNoiseShader::CreateTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY, - int numOctaves, SkScalar seed, - const SkISize* tileSize) { - return new SkPerlinNoiseShader(kTurbulence_Type, baseFrequencyX, baseFrequencyY, numOctaves, - seed, tileSize); +sk_sp<SkShader> SkPerlinNoiseShader::MakeTurbulence(SkScalar baseFrequencyX, + SkScalar baseFrequencyY, + int numOctaves, SkScalar seed, + const SkISize* tileSize) { + return sk_sp<SkShader>(new SkPerlinNoiseShader(kTurbulence_Type, baseFrequencyX, baseFrequencyY, + numOctaves, seed, tileSize)); } SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, @@ -295,9 +298,11 @@ SkFlattenable* SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) { switch (type) { case kFractalNoise_Type: - return SkPerlinNoiseShader::CreateFractalNoise(freqX, freqY, octaves, seed, &tileSize); + return SkPerlinNoiseShader::MakeFractalNoise(freqX, freqY, octaves, seed, + &tileSize).release(); case kTurbulence_Type: - return SkPerlinNoiseShader::CreateTubulence(freqX, freqY, octaves, seed, &tileSize); + return SkPerlinNoiseShader::MakeTurbulence(freqX, freqY, octaves, seed, + &tileSize).release(); default: return nullptr; } @@ -580,11 +585,11 @@ const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f, 0.99f); - SkAutoTUnref<SkShader> shader(d->fRandom->nextBool() ? - SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, - stitchTiles ? &tileSize : nullptr) : - SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, - stitchTiles ? &tileSize : nullptr)); + sk_sp<SkShader> shader(d->fRandom->nextBool() ? + SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, + stitchTiles ? &tileSize : nullptr) : + SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, + stitchTiles ? &tileSize : nullptr)); return shader->asFragmentProcessor(d->fContext, GrTest::TestMatrix(d->fRandom), nullptr, |