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
This commit is contained in:
vandebo@chromium.org 2012-04-17 21:46:18 +00:00
parent 99b300ed9d
commit c39c8674c9
3 changed files with 9 additions and 9 deletions

View File

@ -124,7 +124,7 @@ protected:
}
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 @@ protected:
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 @@ protected:
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;
}

View File

@ -78,8 +78,8 @@ protected:
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);

View File

@ -452,7 +452,7 @@ SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state)
}
case SkShader::kSweep_GradientType:
transformPoints[1] = transformPoints[0];
transformPoints[1].fX += 1;
transformPoints[1].fX += SK_Scalar1;
codeFunction = &sweepCode;
break;
case SkShader::kColor_GradientType: