Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: gm/gradient_matrix.cpp

Issue 16871004: add SkIntToScalar and SkFloatToScalar to stop build errors on Mac10.6 (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use ALL the SkIntToScalar! Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gradient_matrix.cpp
diff --git a/gm/gradient_matrix.cpp b/gm/gradient_matrix.cpp
index a0679bd4acc7cbed1f76fbbf55ac1e00cb68c008..508b3eb919d44a302a89255fc7506fa84ea690bb 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());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698