diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-12 23:36:50 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-12 23:36:50 +0000 |
commit | 45672099ea3006cde5b8a97b52fcd0b8ac69d4e1 (patch) | |
tree | a685a3523a098a0aecd5b8ac61934a32082261d1 | |
parent | 4f77c8827715adb6ad9e9bab92094b1cd03b50e0 (diff) |
add SkIntToScalar and SkFloatToScalar to stop build errors on Mac10.6
BUG=
R=vandebo@chromium.org
Author: richardlin@chromium.org
Review URL: https://chromiumcodereview.appspot.com/16871004
git-svn-id: http://skia.googlecode.com/svn/trunk@9562 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/gradient_matrix.cpp | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/gm/gradient_matrix.cpp b/gm/gradient_matrix.cpp index a0679bd4ac..508b3eb919 100644 --- a/gm/gradient_matrix.cpp +++ b/gm/gradient_matrix.cpp @@ -23,35 +23,41 @@ static const SkColor gColors[] = { SK_ColorRED, SK_ColorYELLOW }; -// these arrays define the gradient stop points -// as x1, y1, x2, y2 per gradient to draw +// These annoying defines are necessary, because the only other alternative +// is to use SkIntToScalar(...) or SkFloatToScalar(...) everywhere. +static const SkScalar sZero = 0; +static const SkScalar sHalf = SK_ScalarHalf; +static const SkScalar sOne = SK_Scalar1; + +// These arrays define the gradient stop points +// as x1, y1, x2, y2 per gradient to draw. static const SkPoint linearPts[][2] = { - {{0, 0}, {1, 0}}, - {{0, 0}, {0, 1}}, - {{1, 0}, {0, 0}}, - {{0, 1}, {0, 0}}, - - {{0, 0}, {1, 1}}, - {{1, 1}, {0, 0}}, - {{1, 0}, {0, 1}}, - {{0, 1}, {1, 0}} + {{sZero, sZero}, {sOne, sZero}}, + {{sZero, sZero}, {sZero, sOne}}, + {{sOne, sZero}, {sZero, sZero}}, + {{sZero, sOne}, {sZero, sZero}}, + + {{sZero, sZero}, {sOne, sOne}}, + {{sOne, sOne}, {sZero, sZero}}, + {{sOne, sZero}, {sZero, sOne}}, + {{sZero, sOne}, {sOne, sZero}} }; static const SkPoint radialPts[][2] = { - {{0, 0.5f}, {1, 0.5f}}, - {{0.5f, 0 }, {0.5f, 1 }}, - {{1, 0.5f}, {0, 0.5f}}, - {{0.5f, 1 }, {0.5f, 0 }}, - - {{0, 0}, {1, 1}}, - {{1, 1}, {0, 0}}, - {{1, 0}, {0, 1}}, - {{0, 1}, {1, 0}} + {{sZero, sHalf}, {sOne, sHalf}}, + {{sHalf, sZero}, {sHalf, sOne}}, + {{sOne, sHalf}, {sZero, sHalf}}, + {{sHalf, sOne}, {sHalf, sZero}}, + + {{sZero, sZero}, {sOne, sOne}}, + {{sOne, sOne}, {sZero, sZero}}, + {{sOne, sZero}, {sZero, sOne}}, + {{sZero, sOne}, {sOne, sZero}} }; - -static const SkScalar TESTGRID_X = 200; // pixels allocated to each image in x dimension -static const SkScalar TESTGRID_Y = 200; // pixels allocated to each image in y dimension +// These define the pixels allocated to each gradient image. +static const SkScalar TESTGRID_X = SkIntToScalar(200); +static const SkScalar TESTGRID_Y = SkIntToScalar(200); static const int IMAGES_X = 4; // number of images per row @@ -74,7 +80,9 @@ static void draw_gradients(SkCanvas* canvas, SkShader* (*makeShader)(const SkPoi // Use some nice prime numbers for the rectangle and matrix with // different scaling along the x and y axes (which is the bug this // test addresses, where incorrect order of operations mixed up the axes) - SkRect rectGrad = { 43, 61, 181, 167 }; + SkRect rectGrad = { + SkIntToScalar(43), SkIntToScalar(61), + SkIntToScalar(181), SkIntToScalar(167) }; SkMatrix shaderMat; shaderMat.setScale(rectGrad.width(), rectGrad.height()); shaderMat.postTranslate(rectGrad.left(), rectGrad.top()); |