Index: src/effects/SkPerlinNoiseShader.cpp |
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp |
index c59bd8c120ee673af9d066a71426b830bcdeacec..7114703168d475c50c26316da67b618637c0bf62 100644 |
--- a/src/effects/SkPerlinNoiseShader.cpp |
+++ b/src/effects/SkPerlinNoiseShader.cpp |
@@ -212,7 +212,8 @@ |
SkScalar highFrequencx = |
SkScalarCeilToScalar(tileWidth * fBaseFrequency.fX) / tileWidth; |
// BaseFrequency should be non-negative according to the standard. |
- if (fBaseFrequency.fX / lowFrequencx < highFrequencx / fBaseFrequency.fX) { |
+ if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) < |
+ SkScalarDiv(highFrequencx, fBaseFrequency.fX)) { |
fBaseFrequency.fX = lowFrequencx; |
} else { |
fBaseFrequency.fX = highFrequencx; |
@@ -223,7 +224,8 @@ |
SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; |
SkScalar highFrequency = |
SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; |
- if (fBaseFrequency.fY / lowFrequency < highFrequency / fBaseFrequency.fY) { |
+ if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) < |
+ SkScalarDiv(highFrequency, fBaseFrequency.fY)) { |
fBaseFrequency.fY = lowFrequency; |
} else { |
fBaseFrequency.fY = highFrequency; |
@@ -382,9 +384,8 @@ |
SkScalar ratio = SK_Scalar1; |
for (int octave = 0; octave < perlinNoiseShader.fNumOctaves; ++octave) { |
SkScalar noise = noise2D(channel, stitchData, noiseVector); |
- SkScalar numer = (perlinNoiseShader.fType == kFractalNoise_Type) ? |
- noise : SkScalarAbs(noise); |
- turbulenceFunctionResult += numer / ratio; |
+ turbulenceFunctionResult += SkScalarDiv( |
+ (perlinNoiseShader.fType == kFractalNoise_Type) ? noise : SkScalarAbs(noise), ratio); |
noiseVector.fX *= 2; |
noiseVector.fY *= 2; |
ratio *= 2; |
@@ -405,7 +406,8 @@ |
} |
if (channel == 3) { // Scale alpha by paint value |
- turbulenceFunctionResult *= SkIntToScalar(getPaintAlpha()) / 255; |
+ turbulenceFunctionResult = SkScalarMul(turbulenceFunctionResult, |
+ SkScalarDiv(SkIntToScalar(getPaintAlpha()), SkIntToScalar(255))); |
} |
// Clamp result |
@@ -929,7 +931,7 @@ |
const SkVector& baseFrequency = turbulence.baseFrequency(); |
pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY); |
- pdman.set1f(fAlphaUni, SkIntToScalar(turbulence.alpha()) / 255); |
+ pdman.set1f(fAlphaUni, SkScalarDiv(SkIntToScalar(turbulence.alpha()), SkIntToScalar(255))); |
if (turbulence.stitchTiles()) { |
const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchData(); |