From c39c8674c94dba8b1ffe938cd99c825320cc1475 Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Tue, 17 Apr 2012 21:46:18 +0000 Subject: [PATCH] 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 --- gm/gammatext.cpp | 12 ++++++------ gm/shaderbounds.cpp | 4 ++-- src/pdf/SkPDFShader.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp index 6f1c298c69..9a24d792c3 100644 --- a/gm/gammatext.cpp +++ b/gm/gammatext.cpp @@ -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; } diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp index ee08ce643d..9529151c5f 100644 --- a/gm/shaderbounds.cpp +++ b/gm/shaderbounds.cpp @@ -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); diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index 3a559ba3d3..2c3bfd0b56 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -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: