Revert of stop calling SkScalarDiv (patchset #4 id:60001 of https://codereview.chromium.org/1135053002/)

Reason for revert:
need to wait for Blink roll (and patch android)

Original issue's description:
> stop calling SkScalarDiv
>
> BUG=skia:
> TBR=
>
> Committed: https://skia.googlesource.com/skia/+/67d71c898249a7af3523b16c6a69895a63bfae0a

TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1138263002
This commit is contained in:
reed 2015-05-12 10:28:06 -07:00 committed by Commit bot
parent 39a9a5069b
commit 2629697933
57 changed files with 167 additions and 153 deletions

View File

@ -101,8 +101,8 @@ static SkShader* MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data, static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, float scale) { SkShader::TileMode tm, float scale) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center0, radius0, return SkGradientShader::CreateTwoPointConical(center0, radius0,
@ -115,8 +115,8 @@ static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data, static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, float scale) { SkShader::TileMode tm, float scale) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center0, 0.0, return SkGradientShader::CreateTwoPointConical(center0, 0.0,

View File

@ -39,8 +39,8 @@ static IntersectionType intersection(const SkPoint& p1, const SkPoint& p2,
SkScalar pre = SkScalarMul(x1, y2) - SkScalarMul(y1, x2), SkScalar pre = SkScalarMul(x1, y2) - SkScalarMul(y1, x2),
post = SkScalarMul(x3, y4) - SkScalarMul(y3, x4); post = SkScalarMul(x3, y4) - SkScalarMul(y3, x4);
// Compute the point of intersection // Compute the point of intersection
res.set((SkScalarMul(pre, x3 - x4) - SkScalarMul(x1 - x2, post) / d, res.set(SkScalarDiv(SkScalarMul(pre, x3 - x4) - SkScalarMul(x1 - x2, post), d),
(SkScalarMul(pre, y3 - y4) - SkScalarMul(y1 - y2, post) / d); SkScalarDiv(SkScalarMul(pre, y3 - y4) - SkScalarMul(y1 - y2, post), d));
// Check if the x and y coordinates are within both lines // Check if the x and y coordinates are within both lines
return (res.x() < GrMin(x1, x2) || res.x() > GrMax(x1, x2) || return (res.x() < GrMin(x1, x2) || res.x() > GrMax(x1, x2) ||
@ -184,7 +184,9 @@ bool GrStrokePathRenderer::onDrawPath(const SkPath& origPath,
SkPoint miterPt1 = miterPt[0] - *pt1; SkPoint miterPt1 = miterPt[0] - *pt1;
SkScalar sqDist0 = miterPt0.dot(miterPt0); SkScalar sqDist0 = miterPt0.dot(miterPt0);
SkScalar sqDist1 = miterPt1.dot(miterPt1); SkScalar sqDist1 = miterPt1.dot(miterPt1);
const SkScalar rSq = radius*radius / sinHalfAngleSq; const SkScalar rSq =
SkScalarDiv(SkScalarMul(radius, radius),
sinHalfAngleSq);
const SkScalar sqRLimit = const SkScalar sqRLimit =
SkScalarMul(sqMiterLimit, rSq); SkScalarMul(sqMiterLimit, rSq);
if (sqDist0 > sqRLimit || sqDist1 > sqRLimit) { if (sqDist0 > sqRLimit || sqDist1 > sqRLimit) {

View File

@ -82,8 +82,10 @@ protected:
canvas->scale(3.0f, 3.0f); canvas->scale(3.0f, 3.0f);
SkMatrix skew; SkMatrix skew;
skew.setIdentity(); skew.setIdentity();
skew.setSkewX(8.0f / 25.0f); skew.setSkewX(SkScalarDiv(8.0f,
skew.setSkewY(2.0f / 25.0f); 25.0f));
skew.setSkewY(SkScalarDiv(2.0f,
25.0f));
canvas->concat(skew); canvas->concat(skew);
drawTestCase(canvas, 1.0f); drawTestCase(canvas, 1.0f);
canvas->restore(); canvas->restore();
@ -93,9 +95,11 @@ protected:
canvas->save(); canvas->save();
SkMatrix perspective; SkMatrix perspective;
perspective.setIdentity(); perspective.setIdentity();
perspective.setPerspX(-SkScalarInvert(340)); perspective.setPerspX(-SkScalarDiv(SK_Scalar1, 340.0f));
perspective.setSkewX(8.0f / 25.0f); perspective.setSkewX(SkScalarDiv(8.0f,
perspective.setSkewY(2.0f / 25.0f); 25.0f));
perspective.setSkewY(SkScalarDiv(2.0f,
25.0f));
canvas->concat(perspective); canvas->concat(perspective);

View File

@ -80,8 +80,8 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center1, radius1, return SkGradientShader::CreateTwoPointConical(center1, radius1,
@ -185,8 +185,10 @@ protected:
// apply an increasing y perspective as we move to the right // apply an increasing y perspective as we move to the right
SkMatrix perspective; SkMatrix perspective;
perspective.setIdentity(); perspective.setIdentity();
perspective.setPerspY(SkIntToScalar(i+1) / 500); perspective.setPerspY(SkScalarDiv(SkIntToScalar((unsigned) i+1),
perspective.setSkewX(SkIntToScalar(i+1) / 10); SkIntToScalar(500)));
perspective.setSkewX(SkScalarDiv(SkIntToScalar((unsigned) i+1),
SkIntToScalar(10)));
SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, perspective); SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, perspective);
@ -218,8 +220,8 @@ protected:
virtual void onDraw(SkCanvas* canvas) { virtual void onDraw(SkCanvas* canvas) {
SkMatrix perspective; SkMatrix perspective;
perspective.setIdentity(); perspective.setIdentity();
perspective.setPerspY(0.001f); perspective.setPerspY(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000)));
perspective.setSkewX(SkIntToScalar(8) / 25); perspective.setSkewX(SkScalarDiv(SkIntToScalar(8), SkIntToScalar(25)));
canvas->concat(perspective); canvas->concat(perspective);
INHERITED::onDraw(canvas); INHERITED::onDraw(canvas);
} }

View File

@ -40,8 +40,8 @@ static const GradData gGradData[] = {
static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center0, radius0, return SkGradientShader::CreateTwoPointConical(center0, radius0,
@ -53,8 +53,8 @@ static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center1, radius1, return SkGradientShader::CreateTwoPointConical(center1, radius1,
@ -145,7 +145,7 @@ static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = 0.f; SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center0, radius0, return SkGradientShader::CreateTwoPointConical(center0, radius0,
@ -158,7 +158,7 @@ static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const Grad
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = 0.f; SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center1, radius1, return SkGradientShader::CreateTwoPointConical(center1, radius1,
@ -170,8 +170,8 @@ static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const Grad
static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX + radius1, center1.fY); center0.set(center1.fX + radius1, center1.fY);
@ -184,8 +184,8 @@ static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1); center0.set(center1.fX, center1.fY + radius1);
@ -199,7 +199,7 @@ static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData&
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = 0.f; SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX + radius1, center1.fY); center0.set(center1.fX + radius1, center1.fY);
@ -213,7 +213,7 @@ static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData&
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = 0.f; SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1); center0.set(center1.fX, center1.fY + radius1);
@ -226,8 +226,8 @@ static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData&
static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX - radius1 + radius0, center1.fY); center0.set(center1.fX - radius1 + radius0, center1.fY);
@ -240,8 +240,8 @@ static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data, static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) { SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center1.set(SkScalarAve(pts[0].fX, pts[1].fX), center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY)); SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1 - radius0); center0.set(center1.fX, center1.fY + radius1 - radius0);

View File

@ -59,8 +59,8 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShade
static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) { static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center0, center1; SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1); center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
return SkGradientShader::CreateTwoPointConical(center1, radius1, return SkGradientShader::CreateTwoPointConical(center1, radius1,

View File

@ -115,7 +115,8 @@ protected:
canvas->scale(SkScalarInvert(RESIZE_FACTOR_X), canvas->scale(SkScalarInvert(RESIZE_FACTOR_X),
SkScalarInvert(RESIZE_FACTOR_Y)); SkScalarInvert(RESIZE_FACTOR_Y));
} }
canvas->drawCircle(r.centerX(), r.centerY(), r.width() * 2 / 5, paint); canvas->drawCircle(r.centerX(), r.centerY(),
SkScalarDiv(r.width()*2, SkIntToScalar(5)), paint);
canvas->restore(); canvas->restore();
canvas->translate(r.width() + margin, 0); canvas->translate(r.width() + margin, 0);
} }

View File

@ -134,7 +134,8 @@ protected:
canvas->scale(SkScalarInvert(RESIZE_FACTOR), canvas->scale(SkScalarInvert(RESIZE_FACTOR),
SkScalarInvert(RESIZE_FACTOR)); SkScalarInvert(RESIZE_FACTOR));
} }
canvas->drawCircle(r.centerX(), r.centerY(), r.width()*2/5, paint); canvas->drawCircle(r.centerX(), r.centerY(),
SkScalarDiv(r.width()*2, SkIntToScalar(5)), paint);
canvas->restore(); canvas->restore();
canvas->translate(r.width() * scales[j].fX + margin, 0); canvas->translate(r.width() * scales[j].fX + margin, 0);
} }

View File

@ -32,8 +32,8 @@ protected:
SkRect dstRect; SkRect dstRect;
canvas->getTotalMatrix().mapRect(&dstRect, rect); canvas->getTotalMatrix().mapRect(&dstRect, rect);
canvas->save(); canvas->save();
SkScalar deviceScaleX = deviceSize.width() / dstRect.width(); SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width());
SkScalar deviceScaleY = deviceSize.height() / dstRect.height(); SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height());
canvas->translate(rect.x(), rect.y()); canvas->translate(rect.x(), rect.y());
canvas->scale(deviceScaleX, deviceScaleY); canvas->scale(deviceScaleX, deviceScaleY);
canvas->translate(-rect.x(), -rect.y()); canvas->translate(-rect.x(), -rect.y());
@ -96,7 +96,7 @@ protected:
SkPaint paint; SkPaint paint;
paint.setColor(0xFF00FF00); paint.setColor(0xFF00FF00);
SkRect ovalRect = SkRect::MakeWH(16, 16); SkRect ovalRect = SkRect::MakeWH(16, 16);
ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); ovalRect.inset(SkScalarDiv(2.0f, 3.0f), SkScalarDiv(2.0f, 3.0f));
bitmapCanvas.drawOval(ovalRect, paint); bitmapCanvas.drawOval(ovalRect, paint);
} }
SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20);

View File

@ -80,9 +80,10 @@ protected:
if (background) { if (background) {
scale = 0.6f; scale = 0.6f;
} }
SkScalar shaderWidth = width / scale; SkScalar shaderWidth = SkScalarDiv(SkIntToScalar(width), scale);
SkScalar shaderHeight = height / scale; SkScalar shaderHeight = SkScalarDiv(SkIntToScalar(height), scale);
SkMatrix shaderScale = SkMatrix::MakeScale(scale); SkMatrix shaderScale;
shaderScale.setScale(scale, scale);
SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, shaderScale); SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, shaderScale);
return shader; return shader;
} }

View File

@ -47,7 +47,7 @@ protected:
SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX, SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX,
length*SkScalarSin(step) + center.fY); length*SkScalarSin(step) + center.fY);
path.lineTo(rp); path.lineTo(rp);
length += angle / SkScalarHalf(SK_ScalarPI); length += SkScalarDiv(angle, SkScalarHalf(SK_ScalarPI));
step += angle; step += angle;
} }
path.close(); path.close();

View File

@ -29,12 +29,6 @@ public:
return m; return m;
} }
static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar scale) {
SkMatrix m;
m.setScale(scale, scale);
return m;
}
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) { static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) {
SkMatrix m; SkMatrix m;
m.setTranslate(dx, dy); m.setTranslate(dx, dy);

View File

@ -348,16 +348,6 @@ struct SK_API SkPoint {
fY -= v.fY; fY -= v.fY;
} }
SkPoint operator*(SkScalar scale) const {
return Make(fX * scale, fY * scale);
}
SkPoint& operator*=(SkScalar scale) {
fX *= scale;
fY *= scale;
return *this;
}
/** /**
* Returns true if both X and Y are finite (not infinity or NaN) * Returns true if both X and Y are finite (not infinity or NaN)
*/ */

View File

@ -184,9 +184,7 @@ static inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
#define SkScalarMul(a, b) ((SkScalar)(a) * (b)) #define SkScalarMul(a, b) ((SkScalar)(a) * (b))
#define SkScalarMulAdd(a, b, c) ((SkScalar)(a) * (b) + (c)) #define SkScalarMulAdd(a, b, c) ((SkScalar)(a) * (b) + (c))
#ifdef SK_SUPPORT_LEGACY_SCALAR_DIV #define SkScalarDiv(a, b) ((SkScalar)(a) / (b))
#define SkScalarDiv(a, b) ((SkScalar)(a) / (b))
#endif
#define SkScalarMulDiv(a, b, c) ((SkScalar)(a) * (b) / (c)) #define SkScalarMulDiv(a, b, c) ((SkScalar)(a) * (b) / (c))
#define SkScalarInvert(x) (SK_Scalar1 / (x)) #define SkScalarInvert(x) (SK_Scalar1 / (x))
#define SkScalarFastInvert(x) (SK_Scalar1 / (x)) #define SkScalarFastInvert(x) (SK_Scalar1 / (x))

View File

@ -1320,18 +1320,18 @@ void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
static const SkScalar gAnimPeriod = 10 * SK_Scalar1; static const SkScalar gAnimPeriod = 10 * SK_Scalar1;
static const SkScalar gAnimMag = SK_Scalar1 / 1000; static const SkScalar gAnimMag = SK_Scalar1 / 1000;
SkScalar t = SkScalarMod(secs, gAnimPeriod); SkScalar t = SkScalarMod(secs, gAnimPeriod);
if (SkScalarFloorToInt(secs / gAnimPeriod) & 0x1) { if (SkScalarFloorToInt(SkScalarDiv(secs, gAnimPeriod)) & 0x1) {
t = gAnimPeriod - t; t = gAnimPeriod - t;
} }
t = 2 * t - gAnimPeriod; t = 2 * t - gAnimPeriod;
t *= gAnimMag / gAnimPeriod; t = SkScalarMul(SkScalarDiv(t, gAnimPeriod), gAnimMag);
SkMatrix m; SkMatrix m;
m.reset(); m.reset();
#if 1 #if 1
m.setPerspY(t); m.setPerspY(t);
#else #else
m.setPerspY(SK_Scalar1 / 1000); m.setPerspY(SK_Scalar1 / 1000);
m.setSkewX(8.0f / 25); m.setSkewX(SkScalarDiv(8, 25));
m.dump(); m.dump();
#endif #endif
canvas->concat(m); canvas->concat(m);

View File

@ -42,7 +42,7 @@ protected:
SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX, SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX,
length*SkScalarSin(step) + center.fY); length*SkScalarSin(step) + center.fY);
path.lineTo(rp); path.lineTo(rp);
length += angle / SkScalarHalf(SK_ScalarPI); length += SkScalarDiv(angle, SkScalarHalf(SK_ScalarPI));
step += angle; step += angle;
} }
path.close(); path.close();

View File

@ -91,7 +91,7 @@ void SkAnimateBase::dump(SkAnimateMaker* maker) {
SkDebugf("to=\"%s\" ", to.c_str()); SkDebugf("to=\"%s\" ", to.c_str());
} }
if (begin != 0) { if (begin != 0) {
SkDebugf("begin=\"%g\" ", begin * 0.001); SkDebugf("begin=\"%g\" ", SkScalarToFloat(SkScalarDiv(begin,1000)));
} }
} }
#endif #endif

View File

@ -41,7 +41,7 @@ void SkAnimate::dump(SkAnimateMaker* maker) {
SkDebugf("mirror=\"true\" "); SkDebugf("mirror=\"true\" ");
if (fReset) if (fReset)
SkDebugf("reset=\"true\" "); SkDebugf("reset=\"true\" ");
SkDebugf("dur=\"%g\" ", dur * 0.001); SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
if (repeat != SK_Scalar1) if (repeat != SK_Scalar1)
SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat)); SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat));
//if (fHasValues) //if (fHasValues)

View File

@ -39,7 +39,7 @@ SkSet::SkSet() {
void SkSet::dump(SkAnimateMaker* maker) { void SkSet::dump(SkAnimateMaker* maker) {
INHERITED::dump(maker); INHERITED::dump(maker);
if (dur != 1) { if (dur != 1) {
SkDebugf("dur=\"%g\" ", dur * 0.001); SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
} }
//don't want double />\n's //don't want double />\n's
SkDebugf("/>\n"); SkDebugf("/>\n");

View File

@ -235,7 +235,7 @@ bool SkAnimatorScript::EvalMemberCommon(SkScriptEngine* engine, const SkMemberIn
if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction)
value->fOperand.fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too value->fOperand.fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too
if (type == SkType_MSec) { if (type == SkType_MSec) {
value->fOperand.fScalar = value->fOperand.fS32 * 0.001f; value->fOperand.fScalar = SkScalarDiv((SkScalar) value->fOperand.fS32, 1000); // dividing two ints is the same as dividing two scalars
type = SkType_Float; type = SkType_Float;
} }
break; break;

View File

@ -412,7 +412,7 @@ bool SkAnimatorScript2::evalMemberCommon(const SkMemberInfo* info,
if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction)
value->fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too value->fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too
if (type == SkType_MSec) { if (type == SkType_MSec) {
value->fScalar = value->fS32 * 0.001f; value->fScalar = SkScalarDiv((SkScalar) value->fS32, 1000); // dividing two ints is the same as dividing two scalars
type = SkType_Float; type = SkType_Float;
} }
break; break;

View File

@ -76,7 +76,7 @@ void SkPost::dump(SkAnimateMaker* maker) {
delete eventType; delete eventType;
if (delay > 0) { if (delay > 0) {
SkDebugf("delay=\"%g\" ", delay * 0.001); SkDebugf("delay=\"%g\" ", SkScalarToFloat(SkScalarDiv(delay, 1000)));
} }
// if (initialized == false) // if (initialized == false)
// SkDebugf("(uninitialized) "); // SkDebugf("(uninitialized) ");

View File

@ -377,7 +377,7 @@ void SkDisplayable::dumpValues(const SkMemberInfo* info, SkDisplayTypes type, Sk
break; break;
case SkType_MSec: case SkType_MSec:
if (op.fS32 != blankOp.fS32) { if (op.fS32 != blankOp.fS32) {
SkDebugf(" %s=\"%g\" ", info->fName, op.fS32 * 0.001); SkDebugf(" %s=\"%g\" ", info->fName, SkScalarToFloat(SkScalarDiv(op.fS32, 1000)));
} }
default: default:
SkDebugf(""); SkDebugf("");

View File

@ -30,14 +30,14 @@ static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) {
if (choice == kGetValue) if (choice == kGetValue)
return value/255; return value/255;
SkScalar delta = value - min; SkScalar delta = value - min;
SkScalar saturation = value == 0 ? 0 : delta / value; SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value);
if (choice == kGetSaturation) if (choice == kGetSaturation)
return saturation; return saturation;
SkScalar hue; SkScalar hue;
if (saturation == 0) if (saturation == 0)
hue = 0; hue = 0;
else { else {
SkScalar part60 = 60 / delta; SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta);
if (red == value) { if (red == value) {
hue = SkScalarMul(green - blue, part60); hue = SkScalarMul(green - blue, part60);
if (hue < 0) if (hue < 0)

View File

@ -1387,7 +1387,7 @@ bool SkScriptEngine::processOp() {
if (operand2.fScalar == 0) if (operand2.fScalar == 0)
operand2.fScalar = operand1.fScalar == 0 ? SK_ScalarNaN : operand1.fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax; operand2.fScalar = operand1.fScalar == 0 ? SK_ScalarNaN : operand1.fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax;
else else
operand2.fScalar = operand1.fScalar / operand2.fScalar; operand2.fScalar = SkScalarDiv(operand1.fScalar, operand2.fScalar);
break; break;
case kEqualInt: case kEqualInt:
operand2.fS32 = operand1.fS32 == operand2.fS32; operand2.fS32 = operand1.fS32 == operand2.fS32;

View File

@ -249,7 +249,7 @@ bool SkScriptRuntime::executeTokens(unsigned char* opCode) {
operand[0].fScalar = operand[0].fScalar == 0 ? SK_ScalarNaN : operand[0].fScalar = operand[0].fScalar == 0 ? SK_ScalarNaN :
operand[0].fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax; operand[0].fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax;
else else
operand[0].fScalar = operand[0].fScalar / operand[1].fScalar; operand[0].fScalar = SkScalarDiv(operand[0].fScalar, operand[1].fScalar);
break; break;
case SkScriptEngine2::kEqualInt: case SkScriptEngine2::kEqualInt:
operand[0].fS32 = operand[0].fS32 == operand[1].fS32; operand[0].fS32 = operand[0].fS32 == operand[1].fS32;

View File

@ -62,7 +62,7 @@ static int valid_unit_divide(SkScalar numer, SkScalar denom, SkScalar* ratio) {
return 0; return 0;
} }
SkScalar r = numer / denom; SkScalar r = SkScalarDiv(numer, denom);
if (SkScalarIsNaN(r)) { if (SkScalarIsNaN(r)) {
return 0; return 0;
} }
@ -1149,7 +1149,7 @@ static SkScalar conic_eval_pos(const SkScalar src[], SkScalar w, SkScalar t) {
A = -B; A = -B;
SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C);
return numer / denom; return SkScalarDiv(numer, denom);
} }
// F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w) // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w)

View File

@ -2313,7 +2313,7 @@ SkTextToPathIter::SkTextToPathIter( const char text[], size_t length,
fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths));
fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths;
if (has_thick_frame(fPaint)) { if (has_thick_frame(fPaint)) {
fPaint.setStrokeWidth(fPaint.getStrokeWidth() / fScale); fPaint.setStrokeWidth(SkScalarDiv(fPaint.getStrokeWidth(), fScale));
} }
} else { } else {
fScale = SK_Scalar1; fScale = SK_Scalar1;

View File

@ -341,7 +341,8 @@ static void seg_to(const SkPoint pts[], int segType,
if (SK_Scalar1 == stopT) { if (SK_Scalar1 == stopT) {
dst->quadTo(tmp0[3], tmp0[4]); dst->quadTo(tmp0[3], tmp0[4]);
} else { } else {
SkChopQuadAt(&tmp0[2], tmp1, (stopT - startT) / (1 - startT)); SkChopQuadAt(&tmp0[2], tmp1, SkScalarDiv(stopT - startT,
SK_Scalar1 - startT));
dst->quadTo(tmp1[1], tmp1[2]); dst->quadTo(tmp1[1], tmp1[2]);
} }
} }
@ -382,7 +383,8 @@ static void seg_to(const SkPoint pts[], int segType,
if (SK_Scalar1 == stopT) { if (SK_Scalar1 == stopT) {
dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]); dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]);
} else { } else {
SkChopCubicAt(&tmp0[3], tmp1, (stopT - startT) / (1 - startT)); SkChopCubicAt(&tmp0[3], tmp1, SkScalarDiv(stopT - startT,
SK_Scalar1 - startT));
dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]); dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]);
} }
} }

View File

@ -168,7 +168,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
static const SkScalar kMaxTileArea = 2048 * 2048; static const SkScalar kMaxTileArea = 2048 * 2048;
SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height());
if (tileArea > kMaxTileArea) { if (tileArea > kMaxTileArea) {
SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea); SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea));
scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
SkScalarMul(scaledSize.height(), clampScale)); SkScalarMul(scaledSize.height(), clampScale));
} }
@ -176,7 +176,8 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
// Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture
if (maxTextureSize) { if (maxTextureSize) {
if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) { if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) {
SkScalar downScale = maxTextureSize / SkMax32(scaledSize.width(), scaledSize.height()); SkScalar downScale = SkScalarDiv(maxTextureSize,
SkMax32(scaledSize.width(), scaledSize.height()));
scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)), scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)),
SkScalarFloorToScalar(SkScalarMul(scaledSize.height(), downScale))); SkScalarFloorToScalar(SkScalarMul(scaledSize.height(), downScale)));
} }

View File

@ -26,7 +26,8 @@ void SkRRect::setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
} }
if (rect.width() < xRad+xRad || rect.height() < yRad+yRad) { if (rect.width() < xRad+xRad || rect.height() < yRad+yRad) {
SkScalar scale = SkMinScalar(rect.width() / (xRad + xRad), rect.height() / (yRad + yRad)); SkScalar scale = SkMinScalar(SkScalarDiv(rect.width(), xRad + xRad),
SkScalarDiv(rect.height(), yRad + yRad));
SkASSERT(scale < SK_Scalar1); SkASSERT(scale < SK_Scalar1);
xRad = SkScalarMul(xRad, scale); xRad = SkScalarMul(xRad, scale);
yRad = SkScalarMul(yRad, scale); yRad = SkScalarMul(yRad, scale);
@ -65,10 +66,10 @@ void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad
SkScalar scale = SK_Scalar1; SkScalar scale = SK_Scalar1;
if (leftRad + rightRad > rect.width()) { if (leftRad + rightRad > rect.width()) {
scale = rect.width() / (leftRad + rightRad); scale = SkScalarDiv(rect.width(), leftRad + rightRad);
} }
if (topRad + bottomRad > rect.height()) { if (topRad + bottomRad > rect.height()) {
scale = SkMinScalar(scale, rect.height() / (topRad + bottomRad)); scale = SkMinScalar(scale, SkScalarDiv(rect.height(), topRad + bottomRad));
} }
if (scale < SK_Scalar1) { if (scale < SK_Scalar1) {

View File

@ -31,6 +31,6 @@ SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
// Otherwise, interpolate between right - 1 and right. // Otherwise, interpolate between right - 1 and right.
SkScalar rightKey = keys[right]; SkScalar rightKey = keys[right];
SkScalar leftKey = keys[right-1]; SkScalar leftKey = keys[right-1];
SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey); SkScalar fract = SkScalarDiv(searchKey-leftKey,rightKey-leftKey);
return SkScalarInterp(values[right-1], values[right], fract); return SkScalarInterp(values[right-1], values[right], fract);
} }

View File

@ -454,7 +454,8 @@ void SkPathStroker::quad_to(const SkPoint pts[3],
normalB = pts[2] - pts[0]; normalB = pts[2] - pts[0];
normalB.rotateCCW(); normalB.rotateCCW();
SkScalar dot = SkPoint::DotProduct(unitNormalAB, *unitNormalBC); SkScalar dot = SkPoint::DotProduct(unitNormalAB, *unitNormalBC);
SkAssertResult(normalB.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); SkAssertResult(normalB.setLength(SkScalarDiv(fRadius,
SkScalarSqrt((SK_Scalar1 + dot)/2))));
fOuter.quadTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY, fOuter.quadTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
pts[2].fX + normalBC->fX, pts[2].fY + normalBC->fY); pts[2].fX + normalBC->fX, pts[2].fY + normalBC->fY);
@ -760,9 +761,11 @@ DRAW_LINE:
normalC = *unitNormalCD + unitBC; normalC = *unitNormalCD + unitBC;
SkScalar dot = SkPoint::DotProduct(unitNormalAB, unitBC); SkScalar dot = SkPoint::DotProduct(unitNormalAB, unitBC);
SkAssertResult(normalB.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); SkAssertResult(normalB.setLength(SkScalarDiv(fRadius,
SkScalarSqrt((SK_Scalar1 + dot)/2))));
dot = SkPoint::DotProduct(*unitNormalCD, unitBC); dot = SkPoint::DotProduct(*unitNormalCD, unitBC);
SkAssertResult(normalC.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); SkAssertResult(normalC.setLength(SkScalarDiv(fRadius,
SkScalarSqrt((SK_Scalar1 + dot)/2))));
fOuter.cubicTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY, fOuter.cubicTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
pts[2].fX + normalC.fX, pts[2].fY + normalC.fY, pts[2].fX + normalC.fX, pts[2].fY + normalC.fY,

View File

@ -214,7 +214,7 @@ static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
else else
mid.set(before.fX + after.fX, before.fY + after.fY); mid.set(before.fX + after.fX, before.fY + after.fY);
mid.setLength(radius / sinHalfAngle); mid.setLength(SkScalarDiv(radius, sinHalfAngle));
DO_MITER: DO_MITER:
if (prevIsLine) if (prevIsLine)
outer->setLastPt(pivot.fX + mid.fX, pivot.fY + mid.fY); outer->setLastPt(pivot.fX + mid.fX, pivot.fY + mid.fY);

View File

@ -512,7 +512,7 @@ static void transform_offsets(SkScalar* stopOffsets, const int numOffsets,
SkScalar startToStop = (stopTransformed.fX - startTransformed.fX) SkScalar startToStop = (stopTransformed.fX - startTransformed.fX)
+ (stopTransformed.fY - startTransformed.fY); + (stopTransformed.fY - startTransformed.fY);
//Percentage along transformed line. //Percentage along transformed line.
stopOffsets[i] = startToStop / startToEnd; stopOffsets[i] = SkScalarDiv(startToStop, startToEnd);
} }
} }
@ -1396,8 +1396,10 @@ void SkXPSDevice::convertToPpm(const SkMaskFilter* filter,
SkVector* ppuScale, SkVector* ppuScale,
const SkIRect& clip, SkIRect* clipIRect) { const SkIRect& clip, SkIRect* clipIRect) {
//This action is in unit space, but the ppm is specified in physical space. //This action is in unit space, but the ppm is specified in physical space.
ppuScale->set(fCurrentPixelsPerMeter.fX / fCurrentUnitsPerMeter.fX, ppuScale->fX = SkScalarDiv(this->fCurrentPixelsPerMeter.fX,
fCurrentPixelsPerMeter.fY / fCurrentUnitsPerMeter.fY); this->fCurrentUnitsPerMeter.fX);
ppuScale->fY = SkScalarDiv(this->fCurrentPixelsPerMeter.fY,
this->fCurrentUnitsPerMeter.fY);
matrix->postScale(ppuScale->fX, ppuScale->fY); matrix->postScale(ppuScale->fX, ppuScale->fY);

View File

@ -20,12 +20,13 @@ static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius,
SkPoint* step) { SkPoint* step) {
SkScalar dist = SkPoint::Distance(a, b); SkScalar dist = SkPoint::Distance(a, b);
*step = b - a; step->set(b.fX - a.fX, b.fY - a.fY);
if (dist <= radius * 2) { if (dist <= radius * 2) {
*step *= SK_ScalarHalf; step->scale(SK_ScalarHalf);
return false; return false;
} else { } else {
*step *= radius / dist; step->scale(SkScalarDiv(radius, dist));
return true; return true;
} }
} }
@ -46,7 +47,6 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
bool prevIsValid = true; bool prevIsValid = true;
// to avoid warnings // to avoid warnings
step.set(0, 0);
moveTo.set(0, 0); moveTo.set(0, 0);
firstStep.set(0, 0); firstStep.set(0, 0);
lastCorner.set(0, 0); lastCorner.set(0, 0);

View File

@ -248,7 +248,7 @@ bool SkDashPathEffect::asPoints(PointData* results,
len2 -= clampedInitialDashLength; // skip initial partial empty len2 -= clampedInitialDashLength; // skip initial partial empty
} }
} }
int numMidPoints = SkScalarFloorToInt(len2 / fIntervalLength); int numMidPoints = SkScalarFloorToInt(SkScalarDiv(len2, fIntervalLength));
results->fNumPoints += numMidPoints; results->fNumPoints += numMidPoints;
len2 -= numMidPoints * fIntervalLength; len2 -= numMidPoints * fIntervalLength;
bool partialLast = false; bool partialLast = false;

View File

@ -56,7 +56,7 @@ void computeDisplacement(const SkVector& scale, SkBitmap* dst,
SkBitmap* src, SkBitmap* src,
const SkIRect& bounds) const SkIRect& bounds)
{ {
static const SkScalar Inv8bit = SkScalarInvert(255); static const SkScalar Inv8bit = SkScalarDiv(SK_Scalar1, 255.0f);
const int srcW = src->width(); const int srcW = src->width();
const int srcH = src->height(); const int srcH = src->height();
const SkVector scaleForColor = SkVector::Make(SkScalarMul(scale.fX, Inv8bit), const SkVector scaleForColor = SkVector::Make(SkScalarMul(scale.fX, Inv8bit),
@ -625,8 +625,8 @@ void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>(); const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
GrTexture* colorTex = displacementMap.texture(1); GrTexture* colorTex = displacementMap.texture(1);
SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colorTex->width()));
SkScalar scaleY = displacementMap.scale().fY / colorTex->height(); SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colorTex->height()));
pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
colorTex->origin() == kTopLeft_GrSurfaceOrigin ? colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));

View File

@ -61,7 +61,7 @@ static void normalize(SkScalar v[3]) {
mag = SkScalarSqrt(mag); mag = SkScalarSqrt(mag);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
v[i] /= mag; v[i] = SkScalarDiv(v[i], mag);
} }
} }

View File

@ -30,8 +30,8 @@ typedef GrGLProgramDataManager::UniformHandle UniformHandle;
namespace { namespace {
const SkScalar gOneThird = SkIntToScalar(1) / 3; const SkScalar gOneThird = SkScalarInvert(SkIntToScalar(3));
const SkScalar gTwoThirds = SkIntToScalar(2) / 3; const SkScalar gTwoThirds = SkScalarDiv(SkIntToScalar(2), SkIntToScalar(3));
const SkScalar gOneHalf = 0.5f; const SkScalar gOneHalf = 0.5f;
const SkScalar gOneQuarter = 0.25f; const SkScalar gOneQuarter = 0.25f;

View File

@ -212,7 +212,8 @@ private:
SkScalar highFrequencx = SkScalar highFrequencx =
SkScalarCeilToScalar(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 (fBaseFrequency.fX / lowFrequencx < highFrequencx / fBaseFrequency.fX) { if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) <
SkScalarDiv(highFrequencx, fBaseFrequency.fX)) {
fBaseFrequency.fX = lowFrequencx; fBaseFrequency.fX = lowFrequencx;
} else { } else {
fBaseFrequency.fX = highFrequencx; fBaseFrequency.fX = highFrequencx;
@ -223,7 +224,8 @@ private:
SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
SkScalar highFrequency = SkScalar highFrequency =
SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
if (fBaseFrequency.fY / lowFrequency < highFrequency / fBaseFrequency.fY) { if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
SkScalarDiv(highFrequency, fBaseFrequency.fY)) {
fBaseFrequency.fY = lowFrequency; fBaseFrequency.fY = lowFrequency;
} else { } else {
fBaseFrequency.fY = highFrequency; fBaseFrequency.fY = highFrequency;
@ -382,9 +384,8 @@ SkScalar SkPerlinNoiseShader::PerlinNoiseShaderContext::calculateTurbulenceValue
SkScalar ratio = SK_Scalar1; SkScalar ratio = SK_Scalar1;
for (int octave = 0; octave < perlinNoiseShader.fNumOctaves; ++octave) { for (int octave = 0; octave < perlinNoiseShader.fNumOctaves; ++octave) {
SkScalar noise = noise2D(channel, stitchData, noiseVector); SkScalar noise = noise2D(channel, stitchData, noiseVector);
SkScalar numer = (perlinNoiseShader.fType == kFractalNoise_Type) ? turbulenceFunctionResult += SkScalarDiv(
noise : SkScalarAbs(noise); (perlinNoiseShader.fType == kFractalNoise_Type) ? noise : SkScalarAbs(noise), ratio);
turbulenceFunctionResult += numer / ratio;
noiseVector.fX *= 2; noiseVector.fX *= 2;
noiseVector.fY *= 2; noiseVector.fY *= 2;
ratio *= 2; ratio *= 2;
@ -405,7 +406,8 @@ SkScalar SkPerlinNoiseShader::PerlinNoiseShaderContext::calculateTurbulenceValue
} }
if (channel == 3) { // Scale alpha by paint value if (channel == 3) { // Scale alpha by paint value
turbulenceFunctionResult *= SkIntToScalar(getPaintAlpha()) / 255; turbulenceFunctionResult = SkScalarMul(turbulenceFunctionResult,
SkScalarDiv(SkIntToScalar(getPaintAlpha()), SkIntToScalar(255)));
} }
// Clamp result // Clamp result
@ -929,7 +931,7 @@ void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrProce
const SkVector& baseFrequency = turbulence.baseFrequency(); const SkVector& baseFrequency = turbulence.baseFrequency();
pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY); 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()) { if (turbulence.stitchTiles()) {
const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchData(); const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchData();

View File

@ -357,7 +357,7 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
// Scale factor 1 / (1 - focalX * focalX) // Scale factor 1 / (1 - focalX * focalX)
SkScalar oneMinusF2 = 1.f - SkScalarMul(*focalX, *focalX); SkScalar oneMinusF2 = 1.f - SkScalarMul(*focalX, *focalX);
SkScalar s = SkScalarInvert(oneMinusF2); SkScalar s = SkScalarDiv(1.f, oneMinusF2);
if (s >= 0.f) { if (s >= 0.f) {
@ -1115,7 +1115,8 @@ private:
: INHERITED(ctx, shader, matrix, tm), fInfo(info) { : INHERITED(ctx, shader, matrix, tm), fInfo(info) {
this->initClassID<CircleOutside2PtConicalEffect>(); this->initClassID<CircleOutside2PtConicalEffect>();
if (shader.getStartRadius() != shader.getEndRadius()) { if (shader.getStartRadius() != shader.getEndRadius()) {
fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shader.getEndRadius()); fTLimit = SkScalarDiv(shader.getStartRadius(),
(shader.getStartRadius() - shader.getEndRadius()));
} else { } else {
fTLimit = SK_ScalarMin; fTLimit = SK_ScalarMin;
} }

View File

@ -105,7 +105,7 @@ static void center_of_mass(const SegmentArray& segments, SkPoint* c) {
*c = avg; *c = avg;
} else { } else {
area *= 3; area *= 3;
area = SkScalarInvert(area); area = SkScalarDiv(SK_Scalar1, area);
center.fX = SkScalarMul(center.fX, area); center.fX = SkScalarMul(center.fX, area);
center.fY = SkScalarMul(center.fY, area); center.fY = SkScalarMul(center.fY, area);
// undo the translate of p0 to the origin. // undo the translate of p0 to the origin.

View File

@ -1253,11 +1253,11 @@ public:
const SkRect& bounds = geom.fBounds; const SkRect& bounds = geom.fBounds;
// This adjusts the "radius" to include the half-pixel border // This adjusts the "radius" to include the half-pixel border
SkScalar offsetDx = geom.fGeoDx / xRadius; SkScalar offsetDx = SkScalarDiv(geom.fGeoDx, xRadius);
SkScalar offsetDy = geom.fGeoDy / yRadius; SkScalar offsetDy = SkScalarDiv(geom.fGeoDy, yRadius);
SkScalar innerRatioX = xRadius / geom.fInnerXRadius; SkScalar innerRatioX = SkScalarDiv(xRadius, geom.fInnerXRadius);
SkScalar innerRatioY = yRadius / geom.fInnerYRadius; SkScalar innerRatioY = SkScalarDiv(yRadius, geom.fInnerYRadius);
verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop);
verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy); verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy);
@ -1386,8 +1386,8 @@ static GrBatch* create_diellipse_batch(GrColor color,
SkScalar b = viewMatrix[SkMatrix::kMSkewX]; SkScalar b = viewMatrix[SkMatrix::kMSkewX];
SkScalar c = viewMatrix[SkMatrix::kMSkewY]; SkScalar c = viewMatrix[SkMatrix::kMSkewY];
SkScalar d = viewMatrix[SkMatrix::kMScaleY]; SkScalar d = viewMatrix[SkMatrix::kMScaleY];
SkScalar geoDx = SK_ScalarHalf / SkScalarSqrt(a*a + c*c); SkScalar geoDx = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(a*a + c*c));
SkScalar geoDy = SK_ScalarHalf / SkScalarSqrt(b*b + d*d); SkScalar geoDy = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(b*b + d*d));
DIEllipseBatch::Geometry geometry; DIEllipseBatch::Geometry geometry;
geometry.fViewMatrix = viewMatrix; geometry.fViewMatrix = viewMatrix;

View File

@ -29,7 +29,8 @@ SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1)); stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1));
} }
} }
return srcTol / stretch; srcTol = SkScalarDiv(srcTol, stretch);
return srcTol;
} }
static const int MAX_POINTS_PER_CURVE = 1 << 10; static const int MAX_POINTS_PER_CURVE = 1 << 10;
@ -50,7 +51,7 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[],
// subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x)
// points. // points.
// 2^(log4(x)) = sqrt(x); // 2^(log4(x)) = sqrt(x);
SkScalar divSqrt = SkScalarSqrt(d / tol); SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol));
if (((SkScalar)SK_MaxS32) <= divSqrt) { if (((SkScalar)SK_MaxS32) <= divSqrt) {
return MAX_POINTS_PER_CURVE; return MAX_POINTS_PER_CURVE;
} else { } else {
@ -106,11 +107,11 @@ uint32_t GrPathUtils::cubicPointCount(const SkPoint points[],
if (d <= tol) { if (d <= tol) {
return 1; return 1;
} else { } else {
SkScalar divSqrt = SkScalarSqrt(d / tol); SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol));
if (((SkScalar)SK_MaxS32) <= divSqrt) { if (((SkScalar)SK_MaxS32) <= divSqrt) {
return MAX_POINTS_PER_CURVE; return MAX_POINTS_PER_CURVE;
} else { } else {
int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol)));
int pow2 = GrNextPow2(temp); int pow2 = GrNextPow2(temp);
// Because of NaNs & INFs we can wind up with a degenerate temp // Because of NaNs & INFs we can wind up with a degenerate temp
// such that pow2 comes out negative. Also, our point generator // such that pow2 comes out negative. Also, our point generator

View File

@ -135,10 +135,10 @@ static SkScalar calc_end_adjustment(const SkScalar intervals[2], const SkPoint p
} }
SkScalar srcIntervalLen = intervals[0] + intervals[1]; SkScalar srcIntervalLen = intervals[0] + intervals[1];
SkScalar totalLen = pts[1].fX - pts[0].fX; SkScalar totalLen = pts[1].fX - pts[0].fX;
SkScalar temp = totalLen / srcIntervalLen; SkScalar temp = SkScalarDiv(totalLen, srcIntervalLen);
SkScalar numFullIntervals = SkScalarFloorToScalar(temp); SkScalar numFullIntervals = SkScalarFloorToScalar(temp);
*endingInt = totalLen - numFullIntervals * srcIntervalLen + phase; *endingInt = totalLen - numFullIntervals * srcIntervalLen + phase;
temp = *endingInt / srcIntervalLen; temp = SkScalarDiv(*endingInt, srcIntervalLen);
*endingInt = *endingInt - SkScalarFloorToScalar(temp) * srcIntervalLen; *endingInt = *endingInt - SkScalarFloorToScalar(temp) * srcIntervalLen;
if (0 == *endingInt) { if (0 == *endingInt) {
*endingInt = srcIntervalLen; *endingInt = srcIntervalLen;

View File

@ -39,12 +39,15 @@
static void emit_pdf_color(SkColor color, SkWStream* result) { static void emit_pdf_color(SkColor color, SkWStream* result) {
SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere.
SkScalar colorScale = SkScalarInvert(0xFF); SkScalar colorMax = SkIntToScalar(0xFF);
SkPDFUtils::AppendScalar(SkColorGetR(color) * colorScale, result); SkPDFUtils::AppendScalar(
SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result);
result->writeText(" "); result->writeText(" ");
SkPDFUtils::AppendScalar(SkColorGetG(color) * colorScale, result); SkPDFUtils::AppendScalar(
SkScalarDiv(SkIntToScalar(SkColorGetG(color)), colorMax), result);
result->writeText(" "); result->writeText(" ");
SkPDFUtils::AppendScalar(SkColorGetB(color) * colorScale, result); SkPDFUtils::AppendScalar(
SkScalarDiv(SkIntToScalar(SkColorGetB(color)), colorMax), result);
result->writeText(" "); result->writeText(" ");
} }

View File

@ -201,7 +201,7 @@ void SkPDFGraphicState::emitObject(SkWStream* stream,
SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState"))); SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState")));
dict->insertName("Type", "ExtGState"); dict->insertName("Type", "ExtGState");
SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; SkScalar alpha = SkScalarDiv(fAlpha, 0xFF);
dict->insertScalar("CA", alpha); dict->insertScalar("CA", alpha);
dict->insertScalar("ca", alpha); dict->insertScalar("ca", alpha);

View File

@ -58,7 +58,7 @@ static void interpolateColorCode(SkScalar range, SkScalar* curColor,
// Figure out how to scale each color component. // Figure out how to scale each color component.
SkScalar multiplier[kColorComponents]; SkScalar multiplier[kColorComponents];
for (int i = 0; i < kColorComponents; i++) { for (int i = 0; i < kColorComponents; i++) {
multiplier[i] = (curColor[i] - prevColor[i]) / range; multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range);
} }
// Calculate when we no longer need to keep a copy of the input parameter t. // Calculate when we no longer need to keep a copy of the input parameter t.
@ -1132,7 +1132,7 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor
static const SkScalar kMaxBitmapArea = 1024 * 1024; static const SkScalar kMaxBitmapArea = 1024 * 1024;
SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbox.height(); SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbox.height();
if (bitmapArea > kMaxBitmapArea) { if (bitmapArea > kMaxBitmapArea) {
rasterScale *= SkScalarSqrt(kMaxBitmapArea / bitmapArea); rasterScale *= SkScalarSqrt(SkScalarDiv(kMaxBitmapArea, bitmapArea));
} }
SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.width()), SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.width()),

View File

@ -1198,7 +1198,8 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
// This means do not try to scale embedded bitmaps; only scale bitmaps in bitmap only fonts. // This means do not try to scale embedded bitmaps; only scale bitmaps in bitmap only fonts.
if (!FT_IS_SCALABLE(fFace) && fScaleY && fFace->size->metrics.y_ppem) { if (!FT_IS_SCALABLE(fFace) && fScaleY && fFace->size->metrics.y_ppem) {
// NOTE: both dimensions are scaled by y_ppem. this is WAI. // NOTE: both dimensions are scaled by y_ppem. this is WAI.
scaleGlyphMetrics(*glyph, SkFixedToScalar(fScaleY) / fFace->size->metrics.y_ppem); scaleGlyphMetrics(*glyph, SkScalarDiv(SkFixedToScalar(fScaleY),
SkIntToScalar(fFace->size->metrics.y_ppem)));
} }
#ifdef ENABLE_GLYPH_SPEW #ifdef ENABLE_GLYPH_SPEW

View File

@ -43,8 +43,11 @@ void SkSVGSVG::translate(SkSVGParser& parser, bool defState) {
if (strcmp(wSuffix, "pt") == 0) if (strcmp(wSuffix, "pt") == 0)
width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96); width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96);
SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4); SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4);
SkRect box = SkRect::MakeLTRB(viewBox[0] / width, viewBox[1] / height, SkRect box;
viewBox[2] / width, viewBox[3] / height); box.fLeft = SkScalarDiv(viewBox[0], width);
box.fTop = SkScalarDiv(viewBox[1], height);
box.fRight = SkScalarDiv(viewBox[2], width);
box.fBottom = SkScalarDiv(viewBox[3], height);
if (box.fLeft == 0 && box.fTop == 0 && if (box.fLeft == 0 && box.fTop == 0 &&
box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1) box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1)
return; return;

View File

@ -62,7 +62,8 @@ SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime,
SkMSec nextTime, const SkScalar blend[4]) { SkMSec nextTime, const SkScalar blend[4]) {
SkASSERT(time > prevTime && time < nextTime); SkASSERT(time > prevTime && time < nextTime);
SkScalar t = (SkScalar)(time - prevTime) / (SkScalar)(nextTime - prevTime); SkScalar t = SkScalarDiv((SkScalar)(time - prevTime),
(SkScalar)(nextTime - prevTime));
return blend ? return blend ?
SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t;
} }

View File

@ -161,7 +161,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds,
if (bounds.width() >= fixed) if (bounds.width() >= fixed)
stretchX = (bounds.width() - fixed) / stretchSize; stretchX = (bounds.width() - fixed) / stretchSize;
else // reuse stretchX, but keep it negative as a signal else // reuse stretchX, but keep it negative as a signal
stretchX = -bounds.width() / fixed; stretchX = SkScalarDiv(-bounds.width(), fixed);
} }
if (numYStretch > 0) { if (numYStretch > 0) {
@ -173,7 +173,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds,
if (bounds.height() >= fixed) if (bounds.height() >= fixed)
stretchY = (bounds.height() - fixed) / stretchSize; stretchY = (bounds.height() - fixed) / stretchSize;
else // reuse stretchX, but keep it negative as a signal else // reuse stretchX, but keep it negative as a signal
stretchY = -bounds.height() / fixed; stretchY = SkScalarDiv(-bounds.height(), fixed);
} }
#if 0 #if 0

View File

@ -124,19 +124,19 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
const SkScalar twoThirds = SK_Scalar1 * 2 / 3; const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
const SkScalar bigScale = (size.width() + twoThirds) / size.width(); const SkScalar bigScale = SkScalarDiv(size.width() + twoThirds, size.width());
mat.setScale(bigScale, bigScale); mat.setScale(bigScale, bigScale);
REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false));
REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
const SkScalar oneThird = SK_Scalar1 / 3; const SkScalar oneThird = SK_Scalar1 / 3;
const SkScalar smallScale = (size.width() + oneThird) / size.width(); const SkScalar smallScale = SkScalarDiv(size.width() + oneThird, size.width());
mat.setScale(smallScale, smallScale); mat.setScale(smallScale, smallScale);
REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
const SkScalar oneFortyth = SK_Scalar1 / 40; const SkScalar oneFortyth = SK_Scalar1 / 40;
const SkScalar tinyScale = (size.width() + oneFortyth) / size.width(); const SkScalar tinyScale = SkScalarDiv(size.width() + oneFortyth, size.width());
mat.setScale(tinyScale, tinyScale); mat.setScale(tinyScale, tinyScale);
REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));

View File

@ -270,8 +270,8 @@ static void test_matrix_min_max_scale(skiatest::Reporter* reporter) {
mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors)); mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors));
for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) { for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) {
SkScalar d = vectors[i].length(); SkScalar d = vectors[i].length();
REPORTER_ASSERT(reporter, d / maxScale < gVectorScaleTol); REPORTER_ASSERT(reporter, SkScalarDiv(d, maxScale) < gVectorScaleTol);
REPORTER_ASSERT(reporter, minScale / d < gVectorScaleTol); REPORTER_ASSERT(reporter, SkScalarDiv(minScale, d) < gVectorScaleTol);
if (max < d) { if (max < d) {
max = d; max = d;
} }
@ -279,8 +279,8 @@ static void test_matrix_min_max_scale(skiatest::Reporter* reporter) {
min = d; min = d;
} }
} }
REPORTER_ASSERT(reporter, max / maxScale >= gCloseScaleTol); REPORTER_ASSERT(reporter, SkScalarDiv(max, maxScale) >= gCloseScaleTol);
REPORTER_ASSERT(reporter, minScale / min >= gCloseScaleTol); REPORTER_ASSERT(reporter, SkScalarDiv(minScale, min) >= gCloseScaleTol);
} }
} }

View File

@ -60,7 +60,7 @@ static inline uint32_t compute_pointCount(SkScalar d, SkScalar tol) {
if (d < tol) { if (d < tol) {
return 1; return 1;
} else { } else {
int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol)));
uint32_t count = SkMin32(SkNextPow2(temp), MAX_POINTS_PER_CURVE); uint32_t count = SkMin32(SkNextPow2(temp), MAX_POINTS_PER_CURVE);
return count; return count;
} }

View File

@ -40,7 +40,7 @@
#include "sk_tool_utils.h" #include "sk_tool_utils.h"
static inline SkScalar scalar_log2(SkScalar x) { static inline SkScalar scalar_log2(SkScalar x) {
static const SkScalar log2_conversion_factor = SkScalarInvert(SkScalarLog(2)); static const SkScalar log2_conversion_factor = SkScalarDiv(1, SkScalarLog(2));
return SkScalarLog(x) * log2_conversion_factor; return SkScalarLog(x) * log2_conversion_factor;
} }