Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: gm/perlinnoise.cpp

Issue 1829303002: move setshader to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: addressing comments from #8 Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/lightingshader.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/perlinnoise.cpp
diff --git a/gm/perlinnoise.cpp b/gm/perlinnoise.cpp
index 92f0f963c3ee70bcb4b0efe53b713237cd10974d..b3ece9dcb6a1a998f304740933a1aa7d6835b493 100644
--- a/gm/perlinnoise.cpp
+++ b/gm/perlinnoise.cpp
@@ -37,13 +37,13 @@ protected:
float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed,
bool stitchTiles) {
SkISize tileSize = SkISize::Make(fSize.width() / 2, fSize.height() / 2);
- SkShader* shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ?
- SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves,
- seed, stitchTiles ? &tileSize : nullptr) :
- SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves,
+ sk_sp<SkShader> shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ?
+ SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves,
+ seed, stitchTiles ? &tileSize : nullptr) :
+ SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves,
seed, stitchTiles ? &tileSize : nullptr);
SkPaint paint;
- paint.setShader(shader)->unref();
+ paint.setShader(std::move(shader));
if (stitchTiles) {
drawRect(canvas, x, y, paint, tileSize);
x += tileSize.width();
@@ -110,12 +110,12 @@ protected:
void install(SkPaint* paint, SkPerlinNoiseShader::Type type,
float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed,
bool stitchTiles) {
- SkShader* shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ?
- SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves,
- seed, stitchTiles ? &fSize : nullptr) :
- SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves,
- seed, stitchTiles ? &fSize : nullptr);
- paint->setShader(shader)->unref();
+ sk_sp<SkShader> shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ?
+ SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves,
+ seed, stitchTiles ? &fSize : nullptr) :
+ SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves,
+ seed, stitchTiles ? &fSize : nullptr);
+ paint->setShader(std::move(shader));
}
virtual void onDraw(SkCanvas* canvas) {
« no previous file with comments | « gm/lightingshader.cpp ('k') | gm/pictureshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698