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

Unified Diff: src/effects/SkPerlinNoiseShader.cpp

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