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
This commit is contained in:
parent
83aaf88b99
commit
8015cdd8fa
@ -108,15 +108,6 @@ inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
|
|||||||
/** Returns the product of two SkScalars plus a third SkScalar
|
/** Returns the product of two SkScalars plus a third SkScalar
|
||||||
*/
|
*/
|
||||||
#define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
|
#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)
|
/** Returns the quotient of two SkScalars (a/b)
|
||||||
*/
|
*/
|
||||||
#define SkScalarDiv(a, b) ((float)(a) / (b))
|
#define SkScalarDiv(a, b) ((float)(a) / (b))
|
||||||
|
@ -112,7 +112,7 @@ protected:
|
|||||||
SkApply* apply = (SkApply*) fDraw->addPath;
|
SkApply* apply = (SkApply*) fDraw->addPath;
|
||||||
apply->refresh(*fMaker);
|
apply->refresh(*fMaker);
|
||||||
apply->activate(*fMaker);
|
apply->activate(*fMaker);
|
||||||
apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
|
apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
|
||||||
drawPath = (SkDrawPath*) apply->getScope();
|
drawPath = (SkDrawPath*) apply->getScope();
|
||||||
}
|
}
|
||||||
SkMatrix m;
|
SkMatrix m;
|
||||||
@ -125,7 +125,7 @@ protected:
|
|||||||
SkApply* apply = (SkApply*) fDraw->addMatrix;
|
SkApply* apply = (SkApply*) fDraw->addMatrix;
|
||||||
apply->refresh(*fMaker);
|
apply->refresh(*fMaker);
|
||||||
apply->activate(*fMaker);
|
apply->activate(*fMaker);
|
||||||
apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
|
apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000));
|
||||||
matrix = (SkDrawMatrix*) apply->getScope();
|
matrix = (SkDrawMatrix*) apply->getScope();
|
||||||
}
|
}
|
||||||
if (matrix) {
|
if (matrix) {
|
||||||
|
@ -303,7 +303,7 @@ scriptCommon: {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (type == SkType_MSec)
|
if (type == SkType_MSec)
|
||||||
scriptValue.fOperand.fMSec = SkScalarMulRound(scriptValue.fOperand.fScalar, 1000);
|
scriptValue.fOperand.fMSec = SkScalarRoundToInt(scriptValue.fOperand.fScalar * 1000);
|
||||||
scriptValue.fType = type;
|
scriptValue.fType = type;
|
||||||
break;
|
break;
|
||||||
noScriptString:
|
noScriptString:
|
||||||
|
@ -203,10 +203,10 @@ public:
|
|||||||
// When stitching tiled turbulence, the frequencies must be adjusted
|
// When stitching tiled turbulence, the frequencies must be adjusted
|
||||||
// so that the tile borders will be continuous.
|
// so that the tile borders will be continuous.
|
||||||
if (fBaseFrequency.fX) {
|
if (fBaseFrequency.fX) {
|
||||||
SkScalar lowFrequencx = SkScalarDiv(
|
SkScalar lowFrequencx =
|
||||||
SkScalarMulFloor(tileWidth, fBaseFrequency.fX), tileWidth);
|
SkScalarFloorToScalar(tileWidth * fBaseFrequency.fX) / tileWidth;
|
||||||
SkScalar highFrequencx = SkScalarDiv(
|
SkScalar highFrequencx =
|
||||||
SkScalarMulCeil(tileWidth, fBaseFrequency.fX), tileWidth);
|
SkScalarCeilToScalar(tileWidth * fBaseFrequency.fX) / tileWidth;
|
||||||
// BaseFrequency should be non-negative according to the standard.
|
// BaseFrequency should be non-negative according to the standard.
|
||||||
if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) <
|
if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) <
|
||||||
SkScalarDiv(highFrequencx, fBaseFrequency.fX)) {
|
SkScalarDiv(highFrequencx, fBaseFrequency.fX)) {
|
||||||
@ -216,10 +216,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fBaseFrequency.fY) {
|
if (fBaseFrequency.fY) {
|
||||||
SkScalar lowFrequency = SkScalarDiv(
|
SkScalar lowFrequency =
|
||||||
SkScalarMulFloor(tileHeight, fBaseFrequency.fY), tileHeight);
|
SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
|
||||||
SkScalar highFrequency = SkScalarDiv(
|
SkScalar highFrequency =
|
||||||
SkScalarMulCeil(tileHeight, fBaseFrequency.fY), tileHeight);
|
SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
|
||||||
if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
|
if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
|
||||||
SkScalarDiv(highFrequency, fBaseFrequency.fY)) {
|
SkScalarDiv(highFrequency, fBaseFrequency.fY)) {
|
||||||
fBaseFrequency.fY = lowFrequency;
|
fBaseFrequency.fY = lowFrequency;
|
||||||
@ -229,10 +229,10 @@ public:
|
|||||||
}
|
}
|
||||||
// Set up TurbulenceInitial stitch values.
|
// Set up TurbulenceInitial stitch values.
|
||||||
fStitchDataInit.fWidth =
|
fStitchDataInit.fWidth =
|
||||||
SkScalarMulRound(tileWidth, fBaseFrequency.fX);
|
SkScalarRoundToInt(tileWidth * fBaseFrequency.fX);
|
||||||
fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
|
fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
|
||||||
fStitchDataInit.fHeight =
|
fStitchDataInit.fHeight =
|
||||||
SkScalarMulRound(tileHeight, fBaseFrequency.fY);
|
SkScalarRoundToInt(tileHeight * fBaseFrequency.fY);
|
||||||
fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
|
fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,11 @@ SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T,
|
|||||||
this->getDuration(&startTime, &endTime);
|
this->getDuration(&startTime, &endTime);
|
||||||
SkMSec totalTime = endTime - startTime;
|
SkMSec totalTime = endTime - startTime;
|
||||||
SkMSec offsetTime = time - startTime;
|
SkMSec offsetTime = time - startTime;
|
||||||
endTime = SkScalarMulFloor(fRepeat, totalTime);
|
endTime = SkScalarFloorToInt(fRepeat * totalTime);
|
||||||
if (offsetTime >= endTime) {
|
if (offsetTime >= endTime) {
|
||||||
SkScalar fraction = SkScalarFraction(fRepeat);
|
SkScalar fraction = SkScalarFraction(fRepeat);
|
||||||
offsetTime = fraction == 0 && fRepeat > 0 ? totalTime :
|
offsetTime = fraction == 0 && fRepeat > 0 ? totalTime :
|
||||||
(SkMSec) SkScalarMulFloor(fraction, totalTime);
|
(SkMSec) SkScalarFloorToInt(fraction * totalTime);
|
||||||
result = kFreezeEnd_Result;
|
result = kFreezeEnd_Result;
|
||||||
} else {
|
} else {
|
||||||
int mirror = fFlags & kMirror;
|
int mirror = fFlags & kMirror;
|
||||||
|
Loading…
Reference in New Issue
Block a user