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

Unified Diff: gm/gradient_matrix.cpp

Issue 2300623005: Replace a lot of 'static const' with 'constexpr' or 'const'. (Closed)
Patch Set: small msvc concession Created 4 years, 3 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 | « gm/gradientDirtyLaundry.cpp ('k') | gm/gradients.cpp » ('j') | 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 816891847ddf4a521898028a27b89c9349bc74a3..3992a49d44f9c037a593c518b08727ef85ba8700 100644
--- a/gm/gradient_matrix.cpp
+++ b/gm/gradient_matrix.cpp
@@ -19,19 +19,19 @@
#include "gm.h"
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorYELLOW
};
// These annoying defines are necessary, because the only other alternative
// is to use SkIntToScalar(...) everywhere.
-static const SkScalar sZero = 0;
-static const SkScalar sHalf = SK_ScalarHalf;
-static const SkScalar sOne = SK_Scalar1;
+constexpr SkScalar sZero = 0;
+constexpr SkScalar sHalf = SK_ScalarHalf;
+constexpr 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] = {
+constexpr SkPoint linearPts[][2] = {
{{sZero, sZero}, {sOne, sZero}},
{{sZero, sZero}, {sZero, sOne}},
{{sOne, sZero}, {sZero, sZero}},
@@ -43,7 +43,7 @@ static const SkPoint linearPts[][2] = {
{{sZero, sOne}, {sOne, sZero}}
};
-static const SkPoint radialPts[][2] = {
+constexpr SkPoint radialPts[][2] = {
{{sZero, sHalf}, {sOne, sHalf}},
{{sHalf, sZero}, {sHalf, sOne}},
{{sOne, sHalf}, {sZero, sHalf}},
@@ -56,10 +56,10 @@ static const SkPoint radialPts[][2] = {
};
// These define the pixels allocated to each gradient image.
-static const SkScalar TESTGRID_X = SkIntToScalar(200);
-static const SkScalar TESTGRID_Y = SkIntToScalar(200);
+constexpr SkScalar TESTGRID_X = SkIntToScalar(200);
+constexpr SkScalar TESTGRID_Y = SkIntToScalar(200);
-static const int IMAGES_X = 4; // number of images per row
+constexpr int IMAGES_X = 4; // number of images per row
static sk_sp<SkShader> make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
return SkGradientShader::MakeLinear(pts, gColors, nullptr, SK_ARRAY_COUNT(gColors),
« no previous file with comments | « gm/gradientDirtyLaundry.cpp ('k') | gm/gradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698