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

Unified Diff: experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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 | « experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h ('k') | gm/beziereffects.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index ab0c46c3501772eec4e9c0f40da31d6796affd8c..b0c60f71610e5e48b2dd9a07ad892bd475e5533d 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -630,13 +630,14 @@ private:
class GrPerlinNoise2Effect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(SkPerlinNoiseShader2::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader2::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
- return new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader2::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader2::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix));
}
virtual ~GrPerlinNoise2Effect() { delete fPaintingData; }
@@ -709,7 +710,7 @@ private:
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoise2Effect);
-const GrFragmentProcessor* GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -1050,12 +1051,14 @@ private:
class GrImprovedPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrFragmentProcessor* Create(int octaves, SkScalar z,
- SkPerlinNoiseShader2::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* gradientTexture,
- const SkMatrix& matrix) {
- return new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
- gradientTexture, matrix);
+ static sk_sp<GrFragmentProcessor> Make(int octaves, SkScalar z,
+ SkPerlinNoiseShader2::PaintingData* paintingData,
+ GrTexture* permutationsTexture,
+ GrTexture* gradientTexture,
+ const SkMatrix& matrix) {
+ return sk_sp<GrFragmentProcessor>(
+ new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
+ gradientTexture, matrix));
}
virtual ~GrImprovedPerlinNoiseEffect() { delete fPaintingData; }
@@ -1118,7 +1121,7 @@ private:
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrImprovedPerlinNoiseEffect);
-const GrFragmentProcessor* GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
0.99f);
SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
@@ -1298,7 +1301,7 @@ void GrGLImprovedPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
GrContext* context,
const SkMatrix& viewM,
const SkMatrix* externalLocalMatrix,
@@ -1333,20 +1336,20 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
SkAutoTUnref<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(context, paintingData->getGradientBitmap(),
textureParams, gammaTreatment));
- return GrImprovedPerlinNoiseEffect::Create(fNumOctaves, fSeed, paintingData,
+ return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
permutationsTexture, gradientTexture, m);
}
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
// Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrConstColorProcessor::Make(0x80404040,
+ GrConstColorProcessor::kModulateRGBA_InputMode));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
// Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
}
SkAutoTUnref<GrTexture> permutationsTexture(
@@ -1357,14 +1360,14 @@ const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
GrTextureParams::ClampNoFilter(), gammaTreatment));
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoise2Effect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+ sk_sp<GrFragmentProcessor> inner(
+ GrPerlinNoise2Effect::Make(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m));
+ return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
delete paintingData;
return nullptr;
« no previous file with comments | « experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h ('k') | gm/beziereffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698