Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 SkPerlinNoiseShader2_DEFINED | 8 #ifndef SkPerlinNoiseShader2_DEFINED |
| 9 #define SkPerlinNoiseShader2_DEFINED | 9 #define SkPerlinNoiseShader2_DEFINED |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 * | 54 * |
| 55 * The number of octaves provided should be fairly small, although no limit is enforced. | 55 * The number of octaves provided should be fairly small, although no limit is enforced. |
| 56 * Each octave doubles the frequency, so 10 octaves would produce noise fro m | 56 * Each octave doubles the frequency, so 10 octaves would produce noise fro m |
| 57 * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignific antly small | 57 * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignific antly small |
| 58 * periods and resembles regular unstructured noise rather than Perlin nois e. | 58 * periods and resembles regular unstructured noise rather than Perlin nois e. |
| 59 * | 59 * |
| 60 * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify | 60 * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify |
| 61 * the frequencies so that the noise will be tileable for the given tile si ze. If tileSize | 61 * the frequencies so that the noise will be tileable for the given tile si ze. If tileSize |
| 62 * is NULL or an empty size, the frequencies will be used as is without mod ification. | 62 * is NULL or an empty size, the frequencies will be used as is without mod ification. |
| 63 */ | 63 */ |
| 64 static SkShader* CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFr equencyY, | 64 static sk_sp<SkShader> MakeFractalNoise(SkScalar baseFrequencyX, SkScalar ba seFrequencyY, |
| 65 int numOctaves, SkScalar seed, | 65 int numOctaves, SkScalar seed, |
|
f(malita)
2016/03/08 15:50:35
Nit: indentation mismatch (here and lots of other
reed1
2016/03/08 20:17:14
Done.
| |
| 66 const SkISize* tileSize = NULL); | 66 const SkISize* tileSize = NULL); |
| 67 static SkShader* CreateTurbulence(SkScalar baseFrequencyX, SkScalar baseFreq uencyY, | 67 static sk_sp<SkShader> MakeTurbulence(SkScalar baseFrequencyX, SkScalar base FrequencyY, |
| 68 int numOctaves, SkScalar seed, | 68 int numOctaves, SkScalar seed, |
| 69 const SkISize* tileSize = NULL); | 69 const SkISize* tileSize = NULL); |
| 70 /** | 70 /** |
| 71 * Creates an Improved Perlin Noise shader. The z value is roughly equivalen t to the seed of the | 71 * Creates an Improved Perlin Noise shader. The z value is roughly equivalen t to the seed of the |
| 72 * other two types, but minor variations to z will only slightly change the noise. | 72 * other two types, but minor variations to z will only slightly change the noise. |
| 73 */ | 73 */ |
| 74 static SkShader* CreateImprovedNoise(SkScalar baseFrequencyX, SkScalar baseF requencyY, | 74 static sk_sp<SkShader> MakeImprovedNoise(SkScalar baseFrequencyX, SkScalar b aseFrequencyY, |
| 75 int numOctaves, SkScalar z); | 75 int numOctaves, SkScalar z); |
| 76 /** | 76 /** |
| 77 * Create alias for CreateTurbulunce until all Skia users changed | 77 * Create alias for CreateTurbulunce until all Skia users changed |
| 78 * its code to use the new naming | 78 * its code to use the new naming |
| 79 */ | 79 */ |
| 80 static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequ encyY, | 80 static sk_sp<SkShader> MakeTubulence(SkScalar baseFrequencyX, SkScalar baseF requencyY, |
| 81 int numOctaves, SkScalar seed, | 81 int numOctaves, SkScalar seed, |
| 82 const SkISize* tileSize = NULL) { | 82 const SkISize* tileSize = NULL) { |
| 83 return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed , tileSize); | 83 return MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize); |
| 84 } | 84 } |
| 85 | 85 |
| 86 class PerlinNoiseShaderContext : public SkShader::Context { | 86 class PerlinNoiseShaderContext : public SkShader::Context { |
| 87 public: | 87 public: |
| 88 PerlinNoiseShaderContext(const SkPerlinNoiseShader2& shader, const Conte xtRec&); | 88 PerlinNoiseShaderContext(const SkPerlinNoiseShader2& shader, const Conte xtRec&); |
| 89 virtual ~PerlinNoiseShaderContext(); | 89 virtual ~PerlinNoiseShaderContext(); |
| 90 | 90 |
| 91 void shadeSpan(int x, int y, SkPMColor[], int count) override; | 91 void shadeSpan(int x, int y, SkPMColor[], int count) override; |
| 92 | 92 |
| 93 private: | 93 private: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 const SkScalar fBaseFrequencyY; | 129 const SkScalar fBaseFrequencyY; |
| 130 const int fNumOctaves; | 130 const int fNumOctaves; |
| 131 const SkScalar fSeed; | 131 const SkScalar fSeed; |
| 132 const SkISize fTileSize; | 132 const SkISize fTileSize; |
| 133 const bool fStitchTiles; | 133 const bool fStitchTiles; |
| 134 | 134 |
| 135 typedef SkShader INHERITED; | 135 typedef SkShader INHERITED; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 #endif | 138 #endif |
| OLD | NEW |