aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-18 15:49:32 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-18 15:49:32 +0000
commit8015cdd8fa5694e52b70e728bcdc6b35d739b819 (patch)
tree1e698fc094a2228a438e4a8e6c0ae21964c7aef5
parent83aaf88b999306b2361ee01b0c6a7c345f2242a2 (diff)
replace SkScalarMulRound(a,b) with SkScalarRountToInt(a*b)
BUG= R=sugoi@google.com Review URL: https://codereview.chromium.org/111393010 git-svn-id: http://skia.googlecode.com/svn/trunk@12740 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkScalar.h9
-rw-r--r--src/animator/SkDrawExtraPathEffect.cpp4
-rw-r--r--src/animator/SkMemberInfo.cpp2
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp20
-rw-r--r--src/utils/SkInterpolator.cpp4
5 files changed, 15 insertions, 24 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 10bfa7297c..70509e493c 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -108,15 +108,6 @@ inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
/** Returns the product of two SkScalars plus a third SkScalar
*/
#define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
-/** Returns the product of a SkScalar and an int rounded to the nearest integer value
-*/
-#define SkScalarMulRound(a, b) SkScalarRoundToInt((float)(a) * (b))
-/** Returns the product of a SkScalar and an int promoted to the next larger int
-*/
-#define SkScalarMulCeil(a, b) SkScalarCeilToInt((float)(a) * (b))
-/** Returns the product of a SkScalar and an int truncated to the next smaller int
-*/
-#define SkScalarMulFloor(a, b) SkScalarFloorToInt((float)(a) * (b))
/** Returns the quotient of two SkScalars (a/b)
*/
#define SkScalarDiv(a, b) ((float)(a) / (b))
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index e973dbf795..7b991d251e 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -112,7 +112,7 @@ protected:
SkApply* apply = (SkApply*) fDraw->addPath;
apply->refresh(*fMaker);
apply->activate(*fMaker);
- apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
+ apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
drawPath = (SkDrawPath*) apply->getScope();
}
SkMatrix m;
@@ -125,7 +125,7 @@ protected:
SkApply* apply = (SkApply*) fDraw->addMatrix;
apply->refresh(*fMaker);
apply->activate(*fMaker);
- apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
+ apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
matrix = (SkDrawMatrix*) apply->getScope();
}
if (matrix) {
diff --git a/src/animator/SkMemberInfo.cpp b/src/animator/SkMemberInfo.cpp
index 5e54b53aed..5cdc8d0de6 100644
--- a/src/animator/SkMemberInfo.cpp
+++ b/src/animator/SkMemberInfo.cpp
@@ -303,7 +303,7 @@ scriptCommon: {
return false;
}
if (type == SkType_MSec)
- scriptValue.fOperand.fMSec = SkScalarMulRound(scriptValue.fOperand.fScalar, 1000);
+ scriptValue.fOperand.fMSec = SkScalarRoundToInt(scriptValue.fOperand.fScalar * 1000);
scriptValue.fType = type;
break;
noScriptString:
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 26771c5db7..5f858303c5 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -203,10 +203,10 @@ public:
// When stitching tiled turbulence, the frequencies must be adjusted
// so that the tile borders will be continuous.
if (fBaseFrequency.fX) {
- SkScalar lowFrequencx = SkScalarDiv(
- SkScalarMulFloor(tileWidth, fBaseFrequency.fX), tileWidth);
- SkScalar highFrequencx = SkScalarDiv(
- SkScalarMulCeil(tileWidth, fBaseFrequency.fX), tileWidth);
+ SkScalar lowFrequencx =
+ SkScalarFloorToScalar(tileWidth * fBaseFrequency.fX) / tileWidth;
+ 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)) {
@@ -216,10 +216,10 @@ public:
}
}
if (fBaseFrequency.fY) {
- SkScalar lowFrequency = SkScalarDiv(
- SkScalarMulFloor(tileHeight, fBaseFrequency.fY), tileHeight);
- SkScalar highFrequency = SkScalarDiv(
- SkScalarMulCeil(tileHeight, fBaseFrequency.fY), tileHeight);
+ SkScalar lowFrequency =
+ SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
+ SkScalar highFrequency =
+ SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
SkScalarDiv(highFrequency, fBaseFrequency.fY)) {
fBaseFrequency.fY = lowFrequency;
@@ -229,10 +229,10 @@ public:
}
// Set up TurbulenceInitial stitch values.
fStitchDataInit.fWidth =
- SkScalarMulRound(tileWidth, fBaseFrequency.fX);
+ SkScalarRoundToInt(tileWidth * fBaseFrequency.fX);
fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
fStitchDataInit.fHeight =
- SkScalarMulRound(tileHeight, fBaseFrequency.fY);
+ SkScalarRoundToInt(tileHeight * fBaseFrequency.fY);
fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
}
diff --git a/src/utils/SkInterpolator.cpp b/src/utils/SkInterpolator.cpp
index 595e46402d..dd884b881c 100644
--- a/src/utils/SkInterpolator.cpp
+++ b/src/utils/SkInterpolator.cpp
@@ -77,11 +77,11 @@ SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T,
this->getDuration(&startTime, &endTime);
SkMSec totalTime = endTime - startTime;
SkMSec offsetTime = time - startTime;
- endTime = SkScalarMulFloor(fRepeat, totalTime);
+ endTime = SkScalarFloorToInt(fRepeat * totalTime);
if (offsetTime >= endTime) {
SkScalar fraction = SkScalarFraction(fRepeat);
offsetTime = fraction == 0 && fRepeat > 0 ? totalTime :
- (SkMSec) SkScalarMulFloor(fraction, totalTime);
+ (SkMSec) SkScalarFloorToInt(fraction * totalTime);
result = kFreezeEnd_Result;
} else {
int mirror = fFlags & kMirror;