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 "SkDither.h" | 8 #include "SkDither.h" |
9 #include "SkPerlinNoiseShader.h" | 9 #include "SkPerlinNoiseShader.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 418 |
419 U8CPU rgba[4]; | 419 U8CPU rgba[4]; |
420 for (int channel = 3; channel >= 0; --channel) { | 420 for (int channel = 3; channel >= 0; --channel) { |
421 rgba[channel] = SkScalarFloorToInt(255 * | 421 rgba[channel] = SkScalarFloorToInt(255 * |
422 calculateTurbulenceValueForPoint(channel, *perlinNoiseShader.fPainti
ngData, | 422 calculateTurbulenceValueForPoint(channel, *perlinNoiseShader.fPainti
ngData, |
423 stitchData, newPoint)); | 423 stitchData, newPoint)); |
424 } | 424 } |
425 return SkPreMultiplyARGB(rgba[3], rgba[0], rgba[1], rgba[2]); | 425 return SkPreMultiplyARGB(rgba[3], rgba[0], rgba[1], rgba[2]); |
426 } | 426 } |
427 | 427 |
428 SkShader::Context* SkPerlinNoiseShader::createContext(const ContextRec& rec, voi
d* storage) const { | 428 SkShader::Context* SkPerlinNoiseShader::onCreateContext(const ContextRec& rec, |
429 if (!this->validContext(rec)) { | 429 void* storage) const { |
430 return NULL; | |
431 } | |
432 | |
433 return SkNEW_PLACEMENT_ARGS(storage, PerlinNoiseShaderContext, (*this, rec))
; | 430 return SkNEW_PLACEMENT_ARGS(storage, PerlinNoiseShaderContext, (*this, rec))
; |
434 } | 431 } |
435 | 432 |
436 size_t SkPerlinNoiseShader::contextSize() const { | 433 size_t SkPerlinNoiseShader::contextSize() const { |
437 return sizeof(PerlinNoiseShaderContext); | 434 return sizeof(PerlinNoiseShaderContext); |
438 } | 435 } |
439 | 436 |
440 SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext( | 437 SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext( |
441 const SkPerlinNoiseShader& shader, const ContextRec& rec) | 438 const SkPerlinNoiseShader& shader, const ContextRec& rec) |
442 : INHERITED(shader, rec) | 439 : INHERITED(shader, rec) |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 str->append(" seed: "); | 1360 str->append(" seed: "); |
1364 str->appendScalar(fSeed); | 1361 str->appendScalar(fSeed); |
1365 str->append(" stitch tiles: "); | 1362 str->append(" stitch tiles: "); |
1366 str->append(fStitchTiles ? "true " : "false "); | 1363 str->append(fStitchTiles ? "true " : "false "); |
1367 | 1364 |
1368 this->INHERITED::toString(str); | 1365 this->INHERITED::toString(str); |
1369 | 1366 |
1370 str->append(")"); | 1367 str->append(")"); |
1371 } | 1368 } |
1372 #endif | 1369 #endif |
OLD | NEW |