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

Side by Side Diff: include/effects/SkPerlinNoiseShader.h

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, 8 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 unified diff | Download patch
« no previous file with comments | « include/core/SkPaint.h ('k') | samplecode/SampleCamera.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef SkPerlinNoiseShader_DEFINED 8 #ifndef SkPerlinNoiseShader_DEFINED
9 #define SkPerlinNoiseShader_DEFINED 9 #define SkPerlinNoiseShader_DEFINED
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * 48 *
49 * The number of octaves provided should be fairly small, although no limit is enforced. 49 * The number of octaves provided should be fairly small, although no limit is enforced.
50 * Each octave doubles the frequency, so 10 octaves would produce noise fro m 50 * Each octave doubles the frequency, so 10 octaves would produce noise fro m
51 * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignific antly small 51 * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignific antly small
52 * periods and resembles regular unstructured noise rather than Perlin nois e. 52 * periods and resembles regular unstructured noise rather than Perlin nois e.
53 * 53 *
54 * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify 54 * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify
55 * the frequencies so that the noise will be tileable for the given tile si ze. If tileSize 55 * the frequencies so that the noise will be tileable for the given tile si ze. If tileSize
56 * is NULL or an empty size, the frequencies will be used as is without mod ification. 56 * is NULL or an empty size, the frequencies will be used as is without mod ification.
57 */ 57 */
58 static sk_sp<SkShader> MakeFractalNoise(SkScalar baseFrequencyX, SkScalar ba seFrequencyY,
59 int numOctaves, SkScalar seed,
60 const SkISize* tileSize = nullptr);
61 static sk_sp<SkShader> MakeTurbulence(SkScalar baseFrequencyX, SkScalar base FrequencyY,
62 int numOctaves, SkScalar seed,
63 const SkISize* tileSize = nullptr);
64
65 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
58 static SkShader* CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFr equencyY, 66 static SkShader* CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFr equencyY,
59 int numOctaves, SkScalar seed, 67 int numOctaves, SkScalar seed,
60 const SkISize* tileSize = NULL); 68 const SkISize* tileSize = NULL) {
69 return MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed , tileSize).release();
70 }
61 static SkShader* CreateTurbulence(SkScalar baseFrequencyX, SkScalar baseFreq uencyY, 71 static SkShader* CreateTurbulence(SkScalar baseFrequencyX, SkScalar baseFreq uencyY,
62 int numOctaves, SkScalar seed, 72 int numOctaves, SkScalar seed,
63 const SkISize* tileSize = NULL); 73 const SkISize* tileSize = NULL) {
64 /** 74 return MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize).release();
65 * Create alias for CreateTurbulunce until all Skia users changed 75 }
66 * its code to use the new naming
67 */
68 static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequ encyY, 76 static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequ encyY,
69 int numOctaves, SkScalar seed, 77 int numOctaves, SkScalar seed,
70 const SkISize* tileSize = NULL) { 78 const SkISize* tileSize = NULL) {
71 return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed , tileSize); 79 return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed , tileSize);
72 } 80 }
81 #endif
73 82
74 class PerlinNoiseShaderContext : public SkShader::Context { 83 class PerlinNoiseShaderContext : public SkShader::Context {
75 public: 84 public:
76 PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const Contex tRec&); 85 PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const Contex tRec&);
77 virtual ~PerlinNoiseShaderContext(); 86 virtual ~PerlinNoiseShaderContext();
78 87
79 void shadeSpan(int x, int y, SkPMColor[], int count) override; 88 void shadeSpan(int x, int y, SkPMColor[], int count) override;
80 89
81 private: 90 private:
82 SkPMColor shade(const SkPoint& point, StitchData& stitchData) const; 91 SkPMColor shade(const SkPoint& point, StitchData& stitchData) const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const SkScalar fBaseFrequencyY; 125 const SkScalar fBaseFrequencyY;
117 const int fNumOctaves; 126 const int fNumOctaves;
118 const SkScalar fSeed; 127 const SkScalar fSeed;
119 const SkISize fTileSize; 128 const SkISize fTileSize;
120 const bool fStitchTiles; 129 const bool fStitchTiles;
121 130
122 typedef SkShader INHERITED; 131 typedef SkShader INHERITED;
123 }; 132 };
124 133
125 #endif 134 #endif
OLDNEW
« no previous file with comments | « include/core/SkPaint.h ('k') | samplecode/SampleCamera.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698