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 #include "SkPerlinNoiseShader.h" | 8 #include "SkPerlinNoiseShader.h" |
9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 , fSeed(seed) | 279 , fSeed(seed) |
280 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize) | 280 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize) |
281 , fStitchTiles(!fTileSize.isEmpty()) | 281 , fStitchTiles(!fTileSize.isEmpty()) |
282 { | 282 { |
283 SkASSERT(numOctaves >= 0 && numOctaves < 256); | 283 SkASSERT(numOctaves >= 0 && numOctaves < 256); |
284 } | 284 } |
285 | 285 |
286 SkPerlinNoiseShader::~SkPerlinNoiseShader() { | 286 SkPerlinNoiseShader::~SkPerlinNoiseShader() { |
287 } | 287 } |
288 | 288 |
289 SkFlattenable* SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) { | 289 sk_sp<SkFlattenable> SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) { |
290 Type type = (Type)buffer.readInt(); | 290 Type type = (Type)buffer.readInt(); |
291 SkScalar freqX = buffer.readScalar(); | 291 SkScalar freqX = buffer.readScalar(); |
292 SkScalar freqY = buffer.readScalar(); | 292 SkScalar freqY = buffer.readScalar(); |
293 int octaves = buffer.readInt(); | 293 int octaves = buffer.readInt(); |
294 SkScalar seed = buffer.readScalar(); | 294 SkScalar seed = buffer.readScalar(); |
295 SkISize tileSize; | 295 SkISize tileSize; |
296 tileSize.fWidth = buffer.readInt(); | 296 tileSize.fWidth = buffer.readInt(); |
297 tileSize.fHeight = buffer.readInt(); | 297 tileSize.fHeight = buffer.readInt(); |
298 | 298 |
299 switch (type) { | 299 switch (type) { |
300 case kFractalNoise_Type: | 300 case kFractalNoise_Type: |
301 return SkPerlinNoiseShader::MakeFractalNoise(freqX, freqY, octaves,
seed, | 301 return SkPerlinNoiseShader::MakeFractalNoise(freqX, freqY, octaves,
seed, |
302 &tileSize).release(); | 302 &tileSize); |
303 case kTurbulence_Type: | 303 case kTurbulence_Type: |
304 return SkPerlinNoiseShader::MakeTurbulence(freqX, freqY, octaves, se
ed, | 304 return SkPerlinNoiseShader::MakeTurbulence(freqX, freqY, octaves, se
ed, |
305 &tileSize).release(); | 305 &tileSize); |
306 default: | 306 default: |
307 return nullptr; | 307 return nullptr; |
308 } | 308 } |
309 } | 309 } |
310 | 310 |
311 void SkPerlinNoiseShader::flatten(SkWriteBuffer& buffer) const { | 311 void SkPerlinNoiseShader::flatten(SkWriteBuffer& buffer) const { |
312 buffer.writeInt((int) fType); | 312 buffer.writeInt((int) fType); |
313 buffer.writeScalar(fBaseFrequencyX); | 313 buffer.writeScalar(fBaseFrequencyX); |
314 buffer.writeScalar(fBaseFrequencyY); | 314 buffer.writeScalar(fBaseFrequencyY); |
315 buffer.writeInt(fNumOctaves); | 315 buffer.writeInt(fNumOctaves); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 str->append(" seed: "); | 975 str->append(" seed: "); |
976 str->appendScalar(fSeed); | 976 str->appendScalar(fSeed); |
977 str->append(" stitch tiles: "); | 977 str->append(" stitch tiles: "); |
978 str->append(fStitchTiles ? "true " : "false "); | 978 str->append(fStitchTiles ? "true " : "false "); |
979 | 979 |
980 this->INHERITED::toString(str); | 980 this->INHERITED::toString(str); |
981 | 981 |
982 str->append(")"); | 982 str->append(")"); |
983 } | 983 } |
984 #endif | 984 #endif |
OLD | NEW |