Index: src/effects/SkPerlinNoiseShader.cpp |
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp |
index 7494a54ac4c38d199cab494c32ecdc39003d108e..ed63fafae14c14093c5f66c21f482c9011ffa482 100644 |
--- a/src/effects/SkPerlinNoiseShader.cpp |
+++ b/src/effects/SkPerlinNoiseShader.cpp |
@@ -410,20 +410,8 @@ SkScalar SkPerlinNoiseShader::calculateTurbulenceValueForPoint(int channel, |
} |
SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchData) const { |
- SkMatrix matrix = fMatrix; |
- matrix.postConcat(getLocalMatrix()); |
- SkMatrix invMatrix; |
- if (!matrix.invert(&invMatrix)) { |
- invMatrix.reset(); |
- } else { |
- invMatrix.postConcat(invMatrix); // Square the matrix |
- } |
- // This (1,1) translation is due to WebKit's 1 based coordinates for the noise |
- // (as opposed to 0 based, usually). The same adjustment is in the setData() function. |
- matrix.postTranslate(SK_Scalar1, SK_Scalar1); |
SkPoint newPoint; |
- matrix.mapPoints(&newPoint, &point, 1); |
- invMatrix.mapPoints(&newPoint, &newPoint, 1); |
+ fMatrix.mapPoints(&newPoint, &point, 1); |
newPoint.fX = SkScalarRoundToScalar(newPoint.fX); |
newPoint.fY = SkScalarRoundToScalar(newPoint.fY); |
@@ -437,7 +425,18 @@ SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchDat |
bool SkPerlinNoiseShader::setContext(const SkBitmap& device, const SkPaint& paint, |
const SkMatrix& matrix) { |
- fMatrix = matrix; |
+ SkMatrix newMatrix = matrix; |
+ newMatrix.postConcat(getLocalMatrix()); |
+ SkMatrix invMatrix; |
+ if (!newMatrix.invert(&invMatrix)) { |
+ invMatrix.reset(); |
+ } |
+ // This (1,1) translation is due to WebKit's 1 based coordinates for the noise |
+ // (as opposed to 0 based, usually). The same adjustment is in the setData() function. |
+ newMatrix.postTranslate(SK_Scalar1, SK_Scalar1); |
+ newMatrix.postConcat(invMatrix); |
+ newMatrix.postConcat(invMatrix); |
+ fMatrix = newMatrix; |
return INHERITED::setContext(device, paint, matrix); |
} |