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

Unified Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 1138263002: Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698