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

Side by Side Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 264843006: create struct to hold all the params passed around for shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkShader.cpp ('k') | src/effects/SkTransparentShader.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 #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
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 SkBitmap& device, co nst SkPaint& paint, 428 SkShader::Context* SkPerlinNoiseShader::createContext(const ContextRec& rec, voi d* storage) const {
429 const SkMatrix& matrix, vo id* storage) const { 429 if (!this->validContext(rec)) {
430 if (!this->validContext(device, paint, matrix)) {
431 return NULL; 430 return NULL;
432 } 431 }
433 432
434 return SkNEW_PLACEMENT_ARGS(storage, PerlinNoiseShaderContext, (*this, devic e, paint, matrix)); 433 return SkNEW_PLACEMENT_ARGS(storage, PerlinNoiseShaderContext, (*this, rec)) ;
435 } 434 }
436 435
437 size_t SkPerlinNoiseShader::contextSize() const { 436 size_t SkPerlinNoiseShader::contextSize() const {
438 return sizeof(PerlinNoiseShaderContext); 437 return sizeof(PerlinNoiseShaderContext);
439 } 438 }
440 439
441 SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext( 440 SkPerlinNoiseShader::PerlinNoiseShaderContext::PerlinNoiseShaderContext(
442 const SkPerlinNoiseShader& shader, const SkBitmap& device, 441 const SkPerlinNoiseShader& shader, const ContextRec& rec)
443 const SkPaint& paint, const SkMatrix& matrix) 442 : INHERITED(shader, rec)
444 : INHERITED(shader, device, paint, matrix)
445 { 443 {
446 SkMatrix newMatrix = matrix; 444 SkMatrix newMatrix = *rec.fMatrix;
447 newMatrix.postConcat(shader.getLocalMatrix()); 445 newMatrix.postConcat(shader.getLocalMatrix());
448 SkMatrix invMatrix; 446 SkMatrix invMatrix;
449 if (!newMatrix.invert(&invMatrix)) { 447 if (!newMatrix.invert(&invMatrix)) {
450 invMatrix.reset(); 448 invMatrix.reset();
451 } 449 }
452 // This (1,1) translation is due to WebKit's 1 based coordinates for the noi se 450 // This (1,1) translation is due to WebKit's 1 based coordinates for the noi se
453 // (as opposed to 0 based, usually). The same adjustment is in the setData() function. 451 // (as opposed to 0 based, usually). The same adjustment is in the setData() function.
454 newMatrix.postTranslate(SK_Scalar1, SK_Scalar1); 452 newMatrix.postTranslate(SK_Scalar1, SK_Scalar1);
455 newMatrix.postConcat(invMatrix); 453 newMatrix.postConcat(invMatrix);
456 newMatrix.postConcat(invMatrix); 454 newMatrix.postConcat(invMatrix);
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 str->append(" seed: "); 1363 str->append(" seed: ");
1366 str->appendScalar(fSeed); 1364 str->appendScalar(fSeed);
1367 str->append(" stitch tiles: "); 1365 str->append(" stitch tiles: ");
1368 str->append(fStitchTiles ? "true " : "false "); 1366 str->append(fStitchTiles ? "true " : "false ");
1369 1367
1370 this->INHERITED::toString(str); 1368 this->INHERITED::toString(str);
1371 1369
1372 str->append(")"); 1370 str->append(")");
1373 } 1371 }
1374 #endif 1372 #endif
OLDNEW
« no previous file with comments | « src/core/SkShader.cpp ('k') | src/effects/SkTransparentShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698