Fix some fixed-point bugs.
Review URL: https://codereview.appspot.com/6047046
git-svn-id: http://skia.googlecode.com/svn/trunk@3714 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp
index 6f1c298..9a24d79 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -124,7 +124,7 @@
}
static void drawGrad(SkCanvas* canvas) {
- SkPoint pts[] = { { 0, 0 }, { 0, HEIGHT } };
+ SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } };
#if 0
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
@@ -135,7 +135,7 @@
canvas->clear(SK_ColorRED);
SkPaint paint;
paint.setShader(s)->unref();
- SkRect r = { 0, 0, 1024, HEIGHT };
+ SkRect r = { 0, 0, SkIntToScalar(1024), SkIntToScalar(HEIGHT) };
canvas->drawRect(r, paint);
}
@@ -162,17 +162,17 @@
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
- SkScalar x = 10;
+ SkScalar x = SkIntToScalar(10);
for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
paint.setColor(fg[i]);
- SkScalar y = 40;
- SkScalar stopy = HEIGHT;
+ SkScalar y = SkIntToScalar(40);
+ SkScalar stopy = SkIntToScalar(HEIGHT);
while (y < stopy) {
#if 1
canvas->drawText(text, len, x, y, paint);
#else
- cgDrawText(cg, text, len, x, HEIGHT - y, paint);
+ cgDrawText(cg, text, len, x, SkIntToScalar(HEIGHT) - y, paint);
#endif
y += paint.getTextSize() * 2;
}
diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp
index ee08ce6..9529151 100644
--- a/gm/shaderbounds.cpp
+++ b/gm/shaderbounds.cpp
@@ -78,8 +78,8 @@
if (background) {
scale = SkFloatToScalar(0.6f);
}
- SkScalar shaderWidth = SkIntToScalar(width)/scale;
- SkScalar shaderHeight = SkIntToScalar(height)/scale;
+ SkScalar shaderWidth = SkScalarDiv(SkIntToScalar(width), scale);
+ SkScalar shaderHeight = SkScalarDiv(SkIntToScalar(height), scale);
SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background);
SkMatrix shaderScale;
shaderScale.setScale(scale, scale);
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 3a559ba..2c3bfd0 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -452,7 +452,7 @@
}
case SkShader::kSweep_GradientType:
transformPoints[1] = transformPoints[0];
- transformPoints[1].fX += 1;
+ transformPoints[1].fX += SK_Scalar1;
codeFunction = &sweepCode;
break;
case SkShader::kColor_GradientType: