Replace a lot of 'static const' with 'constexpr' or 'const'.
'static const' means, there must be at most one of these, and initialize it at
compile time if possible or runtime if necessary. This leads to unexpected
code execution, and TSAN* will complain about races on the guard variables.
Generally 'constexpr' or 'const' are better choices. Neither can cause races:
they're either intialized at compile time (constexpr) or intialized each time
independently (const).
This CL prefers constexpr where possible, and uses const where not. It even
prefers constexpr over const where they don't make a difference... I want to have
lots of examples of constexpr for people to see and mimic.
The scoped-to-class static has nothing to do with any of this, and is not changed.
* Not yet on the bots, which use an older TSAN.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2300623005
Review-Url: https://codereview.chromium.org/2300623005
diff --git a/gm/aarectmodes.cpp b/gm/aarectmodes.cpp
index 10fa15a..6e9f4bf 100644
--- a/gm/aarectmodes.cpp
+++ b/gm/aarectmodes.cpp
@@ -58,7 +58,7 @@
canvas->drawPath(path, paint);
}
-static const struct {
+constexpr struct {
SkXfermode::Mode fMode;
const char* fLabel;
} gModes[] = {
@@ -140,7 +140,7 @@
test4(canvas);
}
const SkRect bounds = SkRect::MakeWH(W, H);
- static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };
+ constexpr SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };
canvas->translate(SkIntToScalar(4), SkIntToScalar(4));
diff --git a/gm/aaxfermodes.cpp b/gm/aaxfermodes.cpp
index 2ea1844..78f7d3e 100644
--- a/gm/aaxfermodes.cpp
+++ b/gm/aaxfermodes.cpp
@@ -23,11 +23,11 @@
kSubtitleSpacing = 5 * kShapeSpacing / 8
};
-static const SkColor kBGColor = SkColorSetARGB(200, 210, 184, 135);
+constexpr SkColor kBGColor = 0xc8d2b887;
-static const SkColor kShapeColors[2] = {
- SkColorSetARGB(130, 255, 0, 128), // input color unknown
- SkColorSetARGB(255, 0, 255, 255) // input color opaque
+constexpr SkColor kShapeColors[2] = {
+ 0x82ff0080, // input color unknown
+ 0xff00ffff, // input color opaque
};
enum Shape {
@@ -73,7 +73,7 @@
fLabelPaint.setTextSize(5 * kShapeSize/8);
fLabelPaint.setSubpixelText(true);
- static const SkScalar radius = -1.4f * kShapeSize/2;
+ constexpr SkScalar radius = -1.4f * kShapeSize/2;
SkPoint pts[4] = {
{-radius, 0},
{0, -1.33f * radius},
diff --git a/gm/alphagradients.cpp b/gm/alphagradients.cpp
index 65fa0c4..fa9d3e2 100644
--- a/gm/alphagradients.cpp
+++ b/gm/alphagradients.cpp
@@ -38,7 +38,7 @@
}
void onDraw(SkCanvas* canvas) override {
- static const struct {
+ constexpr struct {
SkColor fColor0;
SkColor fColor1;
} gRec[] = {
diff --git a/gm/anisotropic.cpp b/gm/anisotropic.cpp
index 3e573c4..d8f9181 100644
--- a/gm/anisotropic.cpp
+++ b/gm/anisotropic.cpp
@@ -27,9 +27,9 @@
// Create an image consisting of lines radiating from its center
void onOnceBeforeDraw() override {
- static const int kNumLines = 100;
- static const SkScalar kAngleStep = 360.0f / kNumLines;
- static const int kInnerOffset = 10;
+ constexpr int kNumLines = 100;
+ constexpr SkScalar kAngleStep = 360.0f / kNumLines;
+ constexpr int kInnerOffset = 10;
fBM.allocN32Pixels(kImageSize, kImageSize, true);
@@ -97,9 +97,9 @@
}
private:
- static const int kImageSize = 256;
- static const int kSpacer = 10;
- static const int kNumVertImages = 5;
+ static constexpr int kImageSize = 256;
+ static constexpr int kSpacer = 10;
+ static constexpr int kNumVertImages = 5;
SkBitmap fBM;
SkFilterQuality fFilterQuality;
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index cd074d4..70661a0 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -82,8 +82,8 @@
SkBitmap src = make_src();
SkBitmap dst = make_dst();
- const SkScalar one = SK_Scalar1;
- static const SkScalar K[] = {
+ constexpr SkScalar one = SK_Scalar1;
+ constexpr SkScalar K[] = {
0, 0, 0, 0,
0, 0, 0, one,
0, one, 0, 0,
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 0c568d0..42be080 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -74,8 +74,8 @@
SkScalar fSign;
sk_sp<GrGeometryProcessor> fGeometryProcessor;
- static const int kVertsPerCubic = 4;
- static const int kIndicesPerCubic = 6;
+ static constexpr int kVertsPerCubic = 4;
+ static constexpr int kIndicesPerCubic = 6;
typedef GrTestBatch INHERITED;
};
@@ -115,7 +115,7 @@
float fKLM[4]; // The last value is ignored. The effect expects a vec4f.
};
- static const int kNumCubics = 15;
+ constexpr int kNumCubics = 15;
SkRandom rand;
// Mult by 3 for each edge effect type
@@ -125,7 +125,7 @@
SkScalar h = SkIntToScalar(drawContext->height()) / numRows;
int row = 0;
int col = 0;
- static const GrColor color = 0xff000000;
+ constexpr GrColor color = 0xff000000;
for (int i = 0; i < kNumCubics; ++i) {
SkPoint baseControlPts[] = {
@@ -247,7 +247,7 @@
float fKLM[4]; // The last value is ignored. The effect expects a vec4f.
};
- static const int kNumConics = 10;
+ constexpr int kNumConics = 10;
SkRandom rand;
// Mult by 3 for each edge effect type
@@ -257,7 +257,7 @@
SkScalar h = SkIntToScalar(drawContext->height()) / numRows;
int row = 0;
int col = 0;
- static const GrColor color = 0xff000000;
+ constexpr GrColor color = 0xff000000;
for (int i = 0; i < kNumConics; ++i) {
SkPoint baseControlPts[] = {
@@ -416,8 +416,8 @@
GrPathUtils::QuadUVMatrix fDevToUV;
sk_sp<GrGeometryProcessor> fGeometryProcessor;
- static const int kVertsPerCubic = 4;
- static const int kIndicesPerCubic = 6;
+ static constexpr int kVertsPerCubic = 4;
+ static constexpr int kIndicesPerCubic = 6;
typedef GrTestBatch INHERITED;
};
@@ -458,7 +458,7 @@
float fUV[4]; // The last two values are ignored. The effect expects a vec4f.
};
- static const int kNumQuads = 5;
+ constexpr int kNumQuads = 5;
SkRandom rand;
int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumQuads*3)));
@@ -467,7 +467,7 @@
SkScalar h = SkIntToScalar(drawContext->height()) / numRows;
int row = 0;
int col = 0;
- static const GrColor color = 0xff000000;
+ constexpr GrColor color = 0xff000000;
for (int i = 0; i < kNumQuads; ++i) {
SkPoint baseControlPts[] = {
diff --git a/gm/beziers.cpp b/gm/beziers.cpp
index 20abb03..cf65c0b 100755
--- a/gm/beziers.cpp
+++ b/gm/beziers.cpp
@@ -13,7 +13,7 @@
#define H 400
#define N 10
-static const SkScalar SH = SkIntToScalar(H);
+constexpr SkScalar SH = SkIntToScalar(H);
static void rnd_quad(SkPath* p, SkPaint* paint, SkRandom& rand) {
p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H));
diff --git a/gm/bigblurs.cpp b/gm/bigblurs.cpp
index 5c09ab9..8cad70d 100644
--- a/gm/bigblurs.cpp
+++ b/gm/bigblurs.cpp
@@ -32,8 +32,8 @@
}
void onDraw(SkCanvas* canvas) override {
- static const int kBig = 65536;
- static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
+ constexpr int kBig = 65536;
+ const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
const SkRect bigRect = SkRect::MakeWH(SkIntToScalar(kBig), SkIntToScalar(kBig));
SkRect insetRect = bigRect;
@@ -46,8 +46,8 @@
// The blur extends 3*kSigma out from the big rect.
// Offset the close-up windows so we get the entire blur
- static const SkScalar kLeftTopPad = 3*kSigma; // use on left & up of big rect
- static const SkScalar kRightBotPad = kCloseUpSize-3*kSigma; // use on right and bot sides
+ const SkScalar kLeftTopPad = 3*kSigma; // use on left & up of big rect
+ const SkScalar kRightBotPad = kCloseUpSize-3*kSigma; // use on right and bot sides
// UL hand corners of the rendered closeups
const SkPoint origins[] = {
@@ -103,9 +103,9 @@
}
private:
- static const int kCloseUpSize = 64;
- static const int kWidth = 5 * kCloseUpSize;
- static const int kHeight = 2 * (kLastEnum_SkBlurStyle + 1) * kCloseUpSize;
+ static constexpr int kCloseUpSize = 64;
+ static constexpr int kWidth = 5 * kCloseUpSize;
+ static constexpr int kHeight = 2 * (kLastEnum_SkBlurStyle + 1) * kCloseUpSize;
typedef GM INHERITED;
};
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 7f79a34..8387d5e 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -58,7 +58,7 @@
int y = kPad;
int x = kPad;
- static const GrPrimitiveEdgeType kEdgeTypes[] = {
+ constexpr GrPrimitiveEdgeType kEdgeTypes[] = {
kFillAA_GrProcessorEdgeType,
kInverseFillAA_GrProcessorEdgeType,
};
@@ -98,9 +98,9 @@
private:
// pad between test cases
- static const int kPad = 7;
+ static constexpr int kPad = 7;
// gap between rect for each case that is rendered and exterior of rrect
- static const int kGap = 3;
+ static constexpr int kGap = 3;
SkRRect fRRect;
int fWidth;
@@ -116,7 +116,7 @@
///////////////////////////////////////////////////////////////////////////////
// This value is motivated by bug chromium:477684. It has to be large to cause overflow in
// the shader
-static const int kSize = 700;
+constexpr int kSize = 700;
DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRect(SkRect::MakeIWH(kSize, kSize)), "rect"); )
DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize, kSize)), "circle"); )
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index b74f62c..429ef1e 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -94,9 +94,9 @@
}
private:
- static const int kWidth = 512;
- static const int kHeight = 512;
- static const int kBitmapSize = 64;
+ static constexpr int kWidth = 512;
+ static constexpr int kHeight = 512;
+ static constexpr int kBitmapSize = 64;
sk_sp<SkImage> fRedImage;
sk_sp<SkImage> fGreenImage;
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index b52337b..5950587 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -18,7 +18,7 @@
"Index8",
};
-static const SkColorType gColorTypes[] = {
+constexpr SkColorType gColorTypes[] = {
kRGB_565_SkColorType,
kARGB_4444_SkColorType,
kN32_SkColorType,
diff --git a/gm/bitmappremul.cpp b/gm/bitmappremul.cpp
index 172612d..31a5650 100644
--- a/gm/bitmappremul.cpp
+++ b/gm/bitmappremul.cpp
@@ -18,9 +18,9 @@
* This tests both the ARGB4444 and ARGB8888 bitmap configurations.
*/
-static const int SLIDE_SIZE = 256;
-static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
-static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
+constexpr int SLIDE_SIZE = 256;
+constexpr int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
+constexpr int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
static void init_bitmap(SkColorType ct, SkBitmap* bitmap) {
bitmap->allocPixels(SkImageInfo::Make(SLIDE_SIZE, SLIDE_SIZE, ct,
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index 4db6e2f..2a81300 100644
--- a/gm/bitmaprect.cpp
+++ b/gm/bitmaprect.cpp
@@ -153,9 +153,9 @@
//////////////////////////////////////////////////////////////////////////////
static void make_big_bitmap(SkBitmap* bitmap) {
- static const int gXSize = 4096;
- static const int gYSize = 4096;
- static const int gBorderWidth = 10;
+ constexpr int gXSize = 4096;
+ constexpr int gYSize = 4096;
+ constexpr int gBorderWidth = 10;
bitmap->allocN32Pixels(gXSize, gYSize);
for (int y = 0; y < gYSize; ++y) {
diff --git a/gm/bleed.cpp b/gm/bleed.cpp
index da261ef..8ffefc9 100644
--- a/gm/bleed.cpp
+++ b/gm/bleed.cpp
@@ -107,10 +107,10 @@
/** Create a black and white checked bitmap with 2 1-pixel rings around the outside edge.
The inner ring is red and the outer ring is blue. */
static bool make_ringed_color_bitmap(TestPixels* result, int width, int height) {
- static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE);
- static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED);
- static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK);
- static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE);
+ const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE);
+ const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED);
+ const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK);
+ const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE);
return make_ringed_bitmap<SkPMColor>(result, width, height, kN32_SkColorType,
kPremul_SkAlphaType, kBlue, kRed, kBlack, kWhite);
}
@@ -119,10 +119,10 @@
checker board of 3/4 and 1/2. The inner checkers are large enough to fill the interior with
the 2x2 checker grid. */
static bool make_ringed_alpha_bitmap(TestPixels* result, int width, int height) {
- static const uint8_t kZero = 0x00;
- static const uint8_t kHalf = 0x80;
- static const uint8_t k3Q = 0xC0;
- static const uint8_t kOne = 0xFF;
+ constexpr uint8_t kZero = 0x00;
+ constexpr uint8_t kHalf = 0x80;
+ constexpr uint8_t k3Q = 0xC0;
+ constexpr uint8_t kOne = 0xFF;
return make_ringed_bitmap<uint8_t>(result, width, height, kAlpha_8_SkColorType,
kPremul_SkAlphaType, kZero, kOne, k3Q, kHalf);
}
@@ -155,8 +155,8 @@
}
static sk_sp<SkShader> make_shader() {
- static const SkPoint pts[] = { {0, 0}, {20, 20} };
- static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW };
+ constexpr SkPoint pts[] = { {0, 0}, {20, 20} };
+ constexpr SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW };
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kMirror_TileMode);
}
@@ -322,7 +322,7 @@
// Draw with rotation and scale down in x, up in y.
SkMatrix m;
- static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlockSpacing);
+ constexpr SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlockSpacing);
m.setTranslate(0, kBottom);
m.preRotate(15.f, 0, kBottom + kBlockSpacing);
m.preScale(0.71f, 1.22f);
@@ -407,25 +407,25 @@
#endif
private:
- static const int kBlockSize = 70;
- static const int kBlockSpacing = 12;
+ static constexpr int kBlockSize = 70;
+ static constexpr int kBlockSpacing = 12;
- static const int kCol0X = kBlockSpacing;
- static const int kCol1X = 2*kBlockSpacing + kBlockSize;
- static const int kCol2X = 3*kBlockSpacing + 2*kBlockSize;
- static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize;
- static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize;
- static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize;
- static const int kWidth = 7*kBlockSpacing + 6*kBlockSize;
+ static constexpr int kCol0X = kBlockSpacing;
+ static constexpr int kCol1X = 2*kBlockSpacing + kBlockSize;
+ static constexpr int kCol2X = 3*kBlockSpacing + 2*kBlockSize;
+ static constexpr int kCol3X = 4*kBlockSpacing + 3*kBlockSize;
+ static constexpr int kCol4X = 5*kBlockSpacing + 4*kBlockSize;
+ static constexpr int kCol5X = 6*kBlockSpacing + 5*kBlockSize;
+ static constexpr int kWidth = 7*kBlockSpacing + 6*kBlockSize;
- static const int kRow0Y = kBlockSpacing;
- static const int kRow1Y = 2*kBlockSpacing + kBlockSize;
- static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize;
- static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize;
- static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize;
+ static constexpr int kRow0Y = kBlockSpacing;
+ static constexpr int kRow1Y = 2*kBlockSpacing + kBlockSize;
+ static constexpr int kRow2Y = 3*kBlockSpacing + 2*kBlockSize;
+ static constexpr int kRow3Y = 4*kBlockSpacing + 3*kBlockSize;
+ static constexpr int kRow4Y = 5*kBlockSpacing + 4*kBlockSize;
- static const int kSmallSize = 6;
- static const int kMaxTileSize = 32;
+ static constexpr int kSmallSize = 6;
+ static constexpr int kMaxTileSize = 32;
TestPixels fBigTestPixels;
TestPixels fSmallTestPixels;
diff --git a/gm/blurcircles.cpp b/gm/blurcircles.cpp
index b15901b..13cbeb8 100644
--- a/gm/blurcircles.cpp
+++ b/gm/blurcircles.cpp
@@ -58,7 +58,7 @@
}
}
private:
- static const int kNumBlurs = 4;
+ static constexpr int kNumBlurs = 4;
sk_sp<SkMaskFilter> fBlurFilters[kNumBlurs];
diff --git a/gm/blurcircles2.cpp b/gm/blurcircles2.cpp
index ad0c37d..93fcddb 100644
--- a/gm/blurcircles2.cpp
+++ b/gm/blurcircles2.cpp
@@ -44,7 +44,7 @@
}
void onDraw(SkCanvas* canvas) override {
- static constexpr SkScalar kMaxR = kMaxRadius + kMaxBlurRadius;
+ constexpr SkScalar kMaxR = kMaxRadius + kMaxBlurRadius;
auto almostCircleMaker = [] (SkScalar radius, SkPath* dst) {
dst->reset();
@@ -76,13 +76,13 @@
} else {
bool benchMode = this->getMode() == kBench_Mode;
canvas->save();
- static constexpr SkScalar kPad = 5;
- static constexpr SkScalar kRadiusSteps = 5;
- static constexpr SkScalar kBlurRadiusSteps = 5;
+ constexpr SkScalar kPad = 5;
+ constexpr SkScalar kRadiusSteps = 5;
+ constexpr SkScalar kBlurRadiusSteps = 5;
canvas->translate(kPad + kMinRadius + kMaxBlurRadius,
kPad + kMinRadius + kMaxBlurRadius);
- static constexpr SkScalar kDeltaRadius = (kMaxRadius - kMinRadius) / kRadiusSteps;
- static constexpr SkScalar kDeltaBlurRadius = (kMaxBlurRadius - kMinBlurRadius) /
+ constexpr SkScalar kDeltaRadius = (kMaxRadius - kMinRadius) / kRadiusSteps;
+ constexpr SkScalar kDeltaBlurRadius = (kMaxBlurRadius - kMinBlurRadius) /
kBlurRadiusSteps;
SkScalar lineWidth = 0;
if (!benchMode) {
diff --git a/gm/blurquickreject.cpp b/gm/blurquickreject.cpp
index c970458..452cdf7 100644
--- a/gm/blurquickreject.cpp
+++ b/gm/blurquickreject.cpp
@@ -31,8 +31,8 @@
}
void onDraw(SkCanvas* canvas) override {
- static const SkScalar kBlurRadius = SkIntToScalar(20);
- static const SkScalar kBoxSize = SkIntToScalar(100);
+ constexpr SkScalar kBlurRadius = SkIntToScalar(20);
+ constexpr SkScalar kBoxSize = SkIntToScalar(100);
SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize);
SkRect blurRects[] = {
@@ -73,8 +73,8 @@
}
private:
- static const int kWidth = 300;
- static const int kHeight = 300;
+ static constexpr int kWidth = 300;
+ static constexpr int kHeight = 300;
typedef GM INHERITED;
};
diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp
index 8aae04a..1e24571 100644
--- a/gm/blurrect.cpp
+++ b/gm/blurrect.cpp
@@ -125,7 +125,7 @@
SkPaint paintWithRadial = paint;
paintWithRadial.setShader(MakeRadial());
- static const Proc procs[] = {
+ constexpr Proc procs[] = {
fill_rect, draw_donut, draw_donut_skewed
};
diff --git a/gm/blurredclippedcircle.cpp b/gm/blurredclippedcircle.cpp
index 495d16a..bf49cd6 100644
--- a/gm/blurredclippedcircle.cpp
+++ b/gm/blurredclippedcircle.cpp
@@ -38,7 +38,7 @@
whitePaint.setAntiAlias(true);
// This scale exercises precision limits in the circle blur effect (crbug.com/560651)
- static const float kScale = 2.0f;
+ constexpr float kScale = 2.0f;
canvas->scale(kScale, kScale);
canvas->save();
@@ -80,8 +80,8 @@
}
private:
- static const int kWidth = 1164;
- static const int kHeight = 802;
+ static constexpr int kWidth = 1164;
+ static constexpr int kHeight = 802;
typedef GM INHERITED;
};
diff --git a/gm/blurs.cpp b/gm/blurs.cpp
index 8fa97b8..16e6249 100644
--- a/gm/blurs.cpp
+++ b/gm/blurs.cpp
@@ -12,7 +12,7 @@
DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, sk_tool_utils::color_to_565(0xFFDDDDDD)) {
SkBlurStyle NONE = SkBlurStyle(-999);
- static const struct {
+ const struct {
SkBlurStyle fStyle;
int fCx, fCy;
} gRecs[] = {
diff --git a/gm/bmpfilterqualityrepeat.cpp b/gm/bmpfilterqualityrepeat.cpp
index 6264d74..c55626f 100644
--- a/gm/bmpfilterqualityrepeat.cpp
+++ b/gm/bmpfilterqualityrepeat.cpp
@@ -39,7 +39,7 @@
void onDraw(SkCanvas* canvas) override {
- static const struct {
+ constexpr struct {
SkFilterQuality fQuality;
const char* fName;
} kQualities[] = {
@@ -59,7 +59,7 @@
lm.setTranslateX(423);
lm.setTranslateY(330);
- static const SkShader::TileMode kTM = SkShader::kRepeat_TileMode;
+ constexpr SkShader::TileMode kTM = SkShader::kRepeat_TileMode;
bmpPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTM, kTM, &lm));
SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210);
canvas->drawRect(rect, bmpPaint);
diff --git a/gm/circulararcs.cpp b/gm/circulararcs.cpp
index 5888f05..3d6a56d 100644
--- a/gm/circulararcs.cpp
+++ b/gm/circulararcs.cpp
@@ -10,13 +10,13 @@
#include "SkDashPathEffect.h"
#include "gm.h"
-static constexpr SkScalar kStarts[] = {0.f, 10.f, 30.f, 45.f, 90.f, 165.f, 180.f, 270.f};
-static constexpr SkScalar kSweeps[] = {1.f, 45.f, 90.f, 130.f, 180.f, 184.f, 300.f, 355.f};
-static constexpr SkScalar kDiameter = 40.f;
-static constexpr SkRect kRect = {0.f, 0.f, kDiameter, kDiameter};
-static constexpr int kW = 1000;
-static constexpr int kH = 1000;
-static constexpr SkScalar kPad = 20.f;
+constexpr SkScalar kStarts[] = {0.f, 10.f, 30.f, 45.f, 90.f, 165.f, 180.f, 270.f};
+constexpr SkScalar kSweeps[] = {1.f, 45.f, 90.f, 130.f, 180.f, 184.f, 300.f, 355.f};
+constexpr SkScalar kDiameter = 40.f;
+constexpr SkRect kRect = {0.f, 0.f, kDiameter, kDiameter};
+constexpr int kW = 1000;
+constexpr int kH = 1000;
+constexpr SkScalar kPad = 20.f;
void draw_arcs(SkCanvas* canvas, std::function<void(SkPaint*)> configureStyle) {
// Draws grid of arcs with different start/sweep angles in red and their complement arcs in
@@ -50,8 +50,8 @@
canvas->restore();
};
// Draw a grids for combo of enabling/disabling aa and using center.
- static constexpr SkScalar kGridW = kW / 2.f;
- static constexpr SkScalar kGridH = kH / 2.f;
+ constexpr SkScalar kGridW = kW / 2.f;
+ constexpr SkScalar kGridH = kH / 2.f;
drawGrid(0.f , 0.f , false, false);
drawGrid(kGridW, 0.f , true , false);
drawGrid(0.f , kGridH, false, true );
@@ -128,13 +128,13 @@
}
DEF_SIMPLE_GM(circular_arcs_weird, canvas, 1000, 400) {
- static constexpr SkScalar kS = 50;
+ constexpr SkScalar kS = 50;
struct Arc {
SkRect fOval;
SkScalar fStart;
SkScalar fSweep;
};
- static const Arc noDrawArcs[] = {
+ const Arc noDrawArcs[] = {
// no sweep
{SkRect::MakeWH(kS, kS), 0, 0},
// empty rect in x
@@ -144,7 +144,7 @@
// empty rect in x and y
{SkRect::MakeWH( 0, 0), 0, 90},
};
- static const Arc arcs[] = {
+ const Arc arcs[] = {
// large start
{SkRect::MakeWH(kS, kS), 810.f, 90.f},
// large negative start
@@ -175,7 +175,7 @@
// dash effect
paints.push_back().setStyle(SkPaint::kStroke_Style);
paints.back().setStrokeWidth(kS / 6.f);
- static constexpr SkScalar kDashIntervals[] = {kS / 15, 2 * kS / 15};
+ constexpr SkScalar kDashIntervals[] = {kS / 15, 2 * kS / 15};
paints.back().setPathEffect(SkDashPathEffect::Make(kDashIntervals, 2, 0.f));
canvas->translate(kPad, kPad);
diff --git a/gm/clippedbitmapshaders.cpp b/gm/clippedbitmapshaders.cpp
index 4b77aba..b421800 100644
--- a/gm/clippedbitmapshaders.cpp
+++ b/gm/clippedbitmapshaders.cpp
@@ -37,8 +37,8 @@
return bmp;
}
-static const SkScalar RECT_SIZE = 64;
-static const SkScalar SLIDE_SIZE = 300;
+constexpr SkScalar RECT_SIZE = 64;
+constexpr SkScalar SLIDE_SIZE = 300;
class ClippedBitmapShadersGM : public GM {
public:
diff --git a/gm/colorcube.cpp b/gm/colorcube.cpp
index 54e0688..dc183bc 100644
--- a/gm/colorcube.cpp
+++ b/gm/colorcube.cpp
@@ -14,11 +14,11 @@
namespace skiagm {
static sk_sp<SkShader> MakeLinear() {
- static const SkPoint pts[2] = {
+ constexpr SkPoint pts[2] = {
{ 0, 0 },
{ SkIntToScalar(80), SkIntToScalar(80) }
};
- static const SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE };
+ constexpr SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE };
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kRepeat_TileMode, 0,
&SkMatrix::I());
}
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp
index f4de3e5..371768c 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -20,9 +20,9 @@
* Spits out a dummy gradient to test blur with shader on paint
*/
static sk_sp<SkShader> MakeLinear() {
- static const SkPoint kPts[] = { { 0, 0 }, { 32, 32 } };
- static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
- static const SkColor kColors[] = {0x80F00080, 0xF0F08000, 0x800080F0 };
+ constexpr SkPoint kPts[] = { { 0, 0 }, { 32, 32 } };
+ constexpr SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
+ constexpr SkColor kColors[] = {0x80F00080, 0xF0F08000, 0x800080F0 };
return SkGradientShader::MakeLinear(kPts, kColors, kPos, SK_ARRAY_COUNT(kColors),
SkShader::kClamp_TileMode);
}
@@ -77,7 +77,7 @@
const char* text = emojiFont.text;
// draw text at different point sizes
- static constexpr SkScalar textSizes[] = { 10, 30, 50, };
+ constexpr SkScalar textSizes[] = { 10, 30, 50, };
SkPaint::FontMetrics metrics;
SkScalar y = 0;
for (const SkScalar& textSize : textSizes) {
@@ -137,7 +137,7 @@
SkRect interiorClip = bounds;
interiorClip.inset(boundsQuarterWidth, boundsQuarterHeight);
- static const SkRect clipRects[] = { bounds, upperLeftClip, lowerRightClip, interiorClip };
+ const SkRect clipRects[] = { bounds, upperLeftClip, lowerRightClip, interiorClip };
SkPaint clipHairline;
clipHairline.setColor(SK_ColorWHITE);
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 7708efe..ec22204 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -12,9 +12,9 @@
namespace skiagm {
-static const SkColor gPathColor = SK_ColorBLACK;
-static const SkColor gClipAColor = SK_ColorBLUE;
-static const SkColor gClipBColor = SK_ColorRED;
+constexpr SkColor gPathColor = SK_ColorBLACK;
+constexpr SkColor gClipAColor = SK_ColorBLUE;
+constexpr SkColor gClipBColor = SK_ColorRED;
class ComplexClipGM : public GM {
public:
@@ -85,7 +85,7 @@
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(SkIntToScalar(20));
- static const struct {
+ constexpr struct {
SkRegion::Op fOp;
const char* fName;
} gOps[] = { //extra spaces in names for measureText
diff --git a/gm/complexclip2.cpp b/gm/complexclip2.cpp
index 4314619..2994e68 100644
--- a/gm/complexclip2.cpp
+++ b/gm/complexclip2.cpp
@@ -102,10 +102,10 @@
}
}
- static const int kRows = 5;
- static const int kCols = 5;
- static const int kPadX = 20;
- static const int kPadY = 20;
+ static constexpr int kRows = 5;
+ static constexpr int kCols = 5;
+ static constexpr int kPadX = 20;
+ static constexpr int kPadY = 20;
static const char* ClipStr(Clip clip) {
switch (clip) {
diff --git a/gm/complexclip3.cpp b/gm/complexclip3.cpp
index 67916ca..1deb446 100644
--- a/gm/complexclip3.cpp
+++ b/gm/complexclip3.cpp
@@ -10,7 +10,7 @@
namespace skiagm {
-static const SkColor gPathColor = SK_ColorYELLOW;
+constexpr SkColor gPathColor = SK_ColorYELLOW;
class ComplexClip3GM : public GM {
public:
@@ -51,7 +51,7 @@
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(SkIntToScalar(20));
- static const struct {
+ constexpr struct {
SkRegion::Op fOp;
const char* fName;
} gOps[] = {
diff --git a/gm/composeshader.cpp b/gm/composeshader.cpp
index c029c98..b58f91f 100644
--- a/gm/composeshader.cpp
+++ b/gm/composeshader.cpp
@@ -210,7 +210,7 @@
* work in a release build. You can change this parameter and then compile a release build
* to have this GM draw larger bitmaps for easier visual inspection.
*/
- static const int squareLength = 20;
+ static constexpr int squareLength = 20;
SkBitmap fColorBitmap;
SkBitmap fAlpha8Bitmap;
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index d9b5f6c..166014d 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -57,21 +57,21 @@
return;
}
- static const GrColor kColors[] = {
+ constexpr GrColor kColors[] = {
0xFFFFFFFF,
0xFFFF00FF,
0x80000000,
0x00000000,
};
- static const SkColor kPaintColors[] = {
+ constexpr SkColor kPaintColors[] = {
0xFFFFFFFF,
0xFFFF0000,
0x80FF0000,
0x00000000,
};
- static const char* kModeStrs[] {
+ const char* kModeStrs[] {
"kIgnore",
"kModulateRGBA",
"kModulateA",
@@ -175,17 +175,14 @@
// Use this as a way of generating and input FP
sk_sp<SkShader> fShader;
- static const SkScalar kPad;
- static const SkScalar kRectSize;
- static const int kWidth = 820;
- static const int kHeight = 500;
+ static constexpr SkScalar kPad = 10.f;
+ static constexpr SkScalar kRectSize = 20.f;
+ static constexpr int kWidth = 820;
+ static constexpr int kHeight = 500;
typedef GM INHERITED;
};
-const SkScalar ConstColorProcessor::kPad = 10.f;
-const SkScalar ConstColorProcessor::kRectSize = 20.f;
-
DEF_GM(return new ConstColorProcessor;)
}
diff --git a/gm/convex_all_line_paths.cpp b/gm/convex_all_line_paths.cpp
index a54c0e4..aba1ef2 100644
--- a/gm/convex_all_line_paths.cpp
+++ b/gm/convex_all_line_paths.cpp
@@ -278,7 +278,7 @@
const SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE };
const SkPath::Direction dirs[2] = { SkPath::kCW_Direction, SkPath::kCCW_Direction };
const float scales[] = { 1.0f, 0.75f, 0.5f, 0.25f, 0.1f, 0.01f, 0.001f };
- const SkPaint::Join joins[3] = { SkPaint::kRound_Join,
+ const SkPaint::Join joins[3] = { SkPaint::kRound_Join,
SkPaint::kBevel_Join,
SkPaint::kMiter_Join };
@@ -336,11 +336,11 @@
}
private:
- static const int kStrokeWidth = 10;
- static const int kNumPaths = 20;
- static const int kMaxPathHeight = 100;
- static const int kGMWidth = 512;
- static const int kGMHeight = 512;
+ static constexpr int kStrokeWidth = 10;
+ static constexpr int kNumPaths = 20;
+ static constexpr int kMaxPathHeight = 100;
+ static constexpr int kGMWidth = 512;
+ static constexpr int kGMHeight = 512;
bool fDoStrokeAndFill;
diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp
index 0c8e291..9681faa 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -60,7 +60,7 @@
paint.setTextSize(wScalar / 2.2f);
paint.setShader(0);
paint.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY));
- static const char kTxt[] = "Skia";
+ constexpr char kTxt[] = "Skia";
SkPoint texPos = { wScalar / 17, hScalar / 2 + paint.getTextSize() / 2.5f };
canvas.drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1, texPos.fX, texPos.fY, paint);
paint.setColor(SK_ColorBLACK);
@@ -103,7 +103,7 @@
fClips.addToTail()->setPath(tri);
SkPath hexagon;
- static const SkScalar kRadius = 45.f;
+ constexpr SkScalar kRadius = 45.f;
const SkPoint center = { kRadius, kRadius };
for (int i = 0; i < 6; ++i) {
SkScalar angle = 2 * SK_ScalarPI * i / 6;
@@ -139,14 +139,14 @@
void onDraw(SkCanvas* canvas) override {
SkScalar y = 0;
- static const SkScalar kMargin = 10.f;
+ constexpr SkScalar kMargin = 10.f;
SkPaint bgPaint;
bgPaint.setAlpha(0x15);
SkISize size = canvas->getDeviceSize();
canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint);
- static const char kTxt[] = "Clip Me!";
+ constexpr char kTxt[] = "Clip Me!";
SkPaint txtPaint;
txtPaint.setTextSize(23.f);
txtPaint.setAntiAlias(true);
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index a5c2904..44471e5 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -110,7 +110,7 @@
fPaths.addToTail(tri);
SkPath ngon;
- static const SkScalar kRadius = 50.f;
+ constexpr SkScalar kRadius = 50.f;
const SkPoint center = { kRadius, kRadius };
for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) {
SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges;
@@ -160,7 +160,7 @@
}
SkScalar y = 0;
- static const SkScalar kDX = 12.f;
+ constexpr SkScalar kDX = 12.f;
for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
iter.get();
iter.next()) {
diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp
index 819dac2..abac5b2 100644
--- a/gm/cubicpaths.cpp
+++ b/gm/cubicpaths.cpp
@@ -158,7 +158,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -168,7 +168,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
@@ -178,7 +178,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
@@ -302,7 +302,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -312,7 +312,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
@@ -322,7 +322,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp
index f631c40..fbe08b7 100644
--- a/gm/dashcircle.cpp
+++ b/gm/dashcircle.cpp
@@ -95,7 +95,7 @@
}
bool onAnimate(const SkAnimTimer& timer) override {
- static const SkScalar kDesiredDurationSecs = 100.0f;
+ constexpr SkScalar kDesiredDurationSecs = 100.0f;
fRotation = timer.scaled(360.0f/kDesiredDurationSecs, 360.0f);
return true;
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index 82e6eb3..e23c24e 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -57,7 +57,7 @@
SkISize onISize() { return SkISize::Make(640, 340); }
virtual void onDraw(SkCanvas* canvas) {
- static const struct {
+ constexpr struct {
int fOnInterval;
int fOffInterval;
} gData[] = {
@@ -145,7 +145,7 @@
SkISize onISize() { return SkISize::Make(640, 480); }
virtual void onDraw(SkCanvas* canvas) {
- static const int gIntervals[] = {
+ constexpr int gIntervals[] = {
3, // 3 dashes: each count [0] followed by intervals [1..count]
2, 10, 10,
4, 20, 5, 5, 5,
@@ -334,7 +334,7 @@
SkISize onISize() { return SkISize::Make(640, 950); }
virtual void onDraw(SkCanvas* canvas) {
- static const struct {
+ constexpr struct {
int fOnInterval;
int fOffInterval;
} gData[] = {
@@ -420,11 +420,11 @@
SkISize onISize() override { return SkISize::Make(400, 200); }
void onDraw(SkCanvas* canvas) override {
- static const int kOn = 4;
- static const int kOff = 4;
- static const int kIntervalLength = kOn + kOff;
+ constexpr int kOn = 4;
+ constexpr int kOff = 4;
+ constexpr int kIntervalLength = kOn + kOff;
- static const SkColor gColors[kIntervalLength] = {
+ constexpr SkColor gColors[kIntervalLength] = {
SK_ColorRED,
SK_ColorGREEN,
SK_ColorBLUE,
diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp
index e97ab47..25d114f 100644
--- a/gm/dcshader.cpp
+++ b/gm/dcshader.cpp
@@ -132,7 +132,7 @@
struct Circle : public Prim {
SkRect draw(SkCanvas* canvas, const SkPaint& paint) override {
- static const SkScalar radius = 25;
+ constexpr SkScalar radius = 25;
canvas->drawCircle(radius, radius, radius, paint);
return SkRect::MakeXYWH(0, 0, 2 * radius, 2 * radius);
}
@@ -195,7 +195,7 @@
paint.setTextSize(30.f);
this->setFont(&paint);
const char* text = this->text();
- static const SkVector offset = SkVector::Make(10, 10);
+ const SkVector offset = SkVector::Make(10, 10);
canvas->drawText(text, strlen(text), offset.fX, offset.fY, paint);
SkRect bounds;
paint.measureText(text, strlen(text), &bounds);
@@ -245,7 +245,7 @@
canvas->translate(10, 20);
canvas->save();
SkScalar tx = 0, maxTy = 0;
- static const SkScalar kW = 900;
+ constexpr SkScalar kW = 900;
for (int aa = 0; aa < 2; ++aa) {
for (int i = 0; i < fPrims.count(); ++i) {
diff --git a/gm/degeneratesegments.cpp b/gm/degeneratesegments.cpp
index d516490..c7254f2 100644
--- a/gm/degeneratesegments.cpp
+++ b/gm/degeneratesegments.cpp
@@ -208,7 +208,7 @@
}
virtual void onDraw(SkCanvas* canvas) {
- static const AddSegmentFunc gSegmentFunctions[] = {
+ constexpr AddSegmentFunc gSegmentFunctions[] = {
AddMove,
AddMoveClose,
AddDegenLine,
@@ -231,7 +231,7 @@
AddMoveCubic,
AddMoveCubicClose
};
- static const char* gSegmentNames[] = {
+ const char* gSegmentNames[] = {
"Move",
"MoveClose",
"DegenLine",
@@ -259,7 +259,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -269,7 +269,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke 10"},
{SkPaint::kStrokeAndFill_Style, "Stroke 10 And Fill"}
@@ -279,7 +279,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
diff --git a/gm/distantclip.cpp b/gm/distantclip.cpp
index 9276dad..07594e7 100644
--- a/gm/distantclip.cpp
+++ b/gm/distantclip.cpp
@@ -26,8 +26,8 @@
SkISize onISize() { return SkISize::Make(100, 100); }
virtual void onDraw(SkCanvas* canvas) {
- static const SkScalar kOffset = 35000.0f;
- static const SkScalar kExtents = 1000.0f;
+ constexpr SkScalar kOffset = 35000.0f;
+ constexpr SkScalar kExtents = 1000.0f;
SkPictureRecorder recorder;
// We record a picture of huge vertical extents in which we clear the canvas to red, create
diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp
index 3331482..b5dba99 100644
--- a/gm/drawatlascolor.cpp
+++ b/gm/drawatlascolor.cpp
@@ -162,11 +162,11 @@
}
private:
- static const int kNumXferModes = 29;
- static const int kNumColors = 4;
- static const int kAtlasSize = 30;
- static const int kPad = 2;
- static const int kTextPad = 8;
+ static constexpr int kNumXferModes = 29;
+ static constexpr int kNumColors = 4;
+ static constexpr int kAtlasSize = 30;
+ static constexpr int kPad = 2;
+ static constexpr int kTextPad = 8;
sk_sp<SkImage> fAtlas;
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index ea9a09f..3c873e2 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -131,8 +131,8 @@
typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRect&, const SkRect&,
const SkPaint*);
-static const int gSize = 1024;
-static const int gBmpSize = 2048;
+constexpr int gSize = 1024;
+constexpr int gBmpSize = 2048;
class DrawBitmapRectGM : public skiagm::GM {
public:
@@ -163,10 +163,10 @@
}
SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};
- static const int kMaxSrcRectSize = 1 << (SkNextLog2(gBmpSize) + 2);
+ const int kMaxSrcRectSize = 1 << (SkNextLog2(gBmpSize) + 2);
- static const int kPadX = 30;
- static const int kPadY = 40;
+ const int kPadX = 30;
+ const int kPadY = 40;
SkPaint paint;
paint.setAlpha(0x20);
canvas->drawImageRect(fImage, SkRect::MakeIWH(gSize, gSize), &paint);
diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp
index 019566e..df8256f 100644
--- a/gm/drawlooper.cpp
+++ b/gm/drawlooper.cpp
@@ -56,7 +56,7 @@
void init() {
if (fLooper) return;
- static const struct {
+ constexpr struct {
SkColor fColor;
SkPaint::Style fStyle;
SkScalar fWidth;
diff --git a/gm/drawminibitmaprect.cpp b/gm/drawminibitmaprect.cpp
index d539f26..eccf04c 100644
--- a/gm/drawminibitmaprect.cpp
+++ b/gm/drawminibitmaprect.cpp
@@ -29,12 +29,12 @@
const SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar);
- static const SkColor colors[] = { SK_ColorRED, SK_ColorYELLOW,
+ constexpr SkColor colors[] = { SK_ColorRED, SK_ColorYELLOW,
SK_ColorGREEN, SK_ColorMAGENTA,
SK_ColorBLUE, SK_ColorCYAN,
SK_ColorRED};
- static const SkScalar pos[] = {0,
+ constexpr SkScalar pos[] = {0,
SK_Scalar1 / 6,
2 * SK_Scalar1 / 6,
3 * SK_Scalar1 / 6,
@@ -60,8 +60,8 @@
return surface->makeImageSnapshot();
}
-static const int gSize = 1024;
-static const int gSurfaceSize = 2048;
+constexpr int gSize = 1024;
+constexpr int gSurfaceSize = 2048;
// This GM calls drawImageRect several times using the same texture. This is
// intended to exercise batching of these calls.
@@ -85,10 +85,10 @@
}
const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};
- static const int kMaxSrcRectSize = 1 << (SkNextLog2(gSurfaceSize) + 2);
+ const int kMaxSrcRectSize = 1 << (SkNextLog2(gSurfaceSize) + 2);
- static const int kPadX = 30;
- static const int kPadY = 40;
+ constexpr int kPadX = 30;
+ constexpr int kPadY = 40;
int rowCount = 0;
canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY));
diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp
index 4f0f071..47c7056 100644
--- a/gm/dstreadshuffle.cpp
+++ b/gm/dstreadshuffle.cpp
@@ -44,8 +44,8 @@
void drawShape(SkCanvas* canvas,
SkPaint* paint,
ShapeType type) {
- static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntToScalar(-50),
- SkIntToScalar(75), SkIntToScalar(105));
+ const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntToScalar(-50),
+ SkIntToScalar(75), SkIntToScalar(105));
switch (type) {
case kCircle_ShapeType:
canvas->drawCircle(0, 0, 50, *paint);
@@ -183,8 +183,8 @@
SkAutoTUnref<SkShader> fBG;
SkPath fConcavePath;
SkPath fConvexPath;
- static const int kWidth = 900;
- static const int kHeight = 400;
+ static constexpr int kWidth = 900;
+ static constexpr int kHeight = 400;
typedef GM INHERITED;
};
diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp
index aadb94d..260f0a0 100644
--- a/gm/emptypath.cpp
+++ b/gm/emptypath.cpp
@@ -44,7 +44,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -54,7 +54,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index 408a4e8..812c666 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -78,7 +78,7 @@
canvas->drawBitmapRect(bm, r, &p);
}
-static const drawMth gDrawMthds[] = {
+constexpr drawMth gDrawMthds[] = {
draw_rect, draw_oval, draw_rrect, draw_drrect, draw_path, draw_points, draw_bitmap
};
@@ -119,7 +119,7 @@
}
{
- static const SkDropShadowImageFilter::ShadowMode kBoth =
+ constexpr SkDropShadowImageFilter::ShadowMode kBoth =
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode;
sk_sp<SkImageFilter> dsif(SkDropShadowImageFilter::Make(10.0f, 10.0f,
@@ -154,10 +154,10 @@
}
protected:
- static const int kTileWidth = 100;
- static const int kTileHeight = 100;
- static const int kNumVertTiles = 7;
- static const int kNumXtraCols = 2;
+ static constexpr int kTileWidth = 100;
+ static constexpr int kTileHeight = 100;
+ static constexpr int kNumVertTiles = 7;
+ static constexpr int kNumXtraCols = 2;
SkString onShortName() override{ return SkString("filterfastbounds"); }
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp
index a4dc263..50b8383 100644
--- a/gm/fontmgr.cpp
+++ b/gm/fontmgr.cpp
@@ -188,7 +188,7 @@
paint.setSubpixelText(true);
paint.setTextSize(17);
- static const char* gNames[] = {
+ const char* gNames[] = {
"Helvetica Neue", "Arial"
};
diff --git a/gm/gammacolorfilter.cpp b/gm/gammacolorfilter.cpp
index ecb2daa..f5e6542 100644
--- a/gm/gammacolorfilter.cpp
+++ b/gm/gammacolorfilter.cpp
@@ -88,9 +88,9 @@
}
private:
- static const int kCellWidth = 64;
- static const int kCellHeight = 64;
- static const int kNumGreySteps = 16;
+ static constexpr int kCellWidth = 64;
+ static constexpr int kCellHeight = 64;
+ static constexpr int kNumGreySteps = 16;
typedef GM INHERITED;
};
diff --git a/gm/glyph_pos.cpp b/gm/glyph_pos.cpp
index ed61c76..7628fbe 100644
--- a/gm/glyph_pos.cpp
+++ b/gm/glyph_pos.cpp
@@ -14,8 +14,8 @@
* glyph_pos_(h/n)_(s/f/b)
* -> test hairline/non-hairline stroke/fill/stroke+fill.
*/
-static const SkScalar kTextHeight = 14.0f;
-static const char kText[] = "Proportional Hamburgefons #% fi";
+constexpr SkScalar kTextHeight = 14.0f;
+constexpr char kText[] = "Proportional Hamburgefons #% fi";
static void drawTestCase(SkCanvas* canvas,
SkScalar textScale,
diff --git a/gm/glyph_pos_align.cpp b/gm/glyph_pos_align.cpp
index 0ac877d..e0bf83e 100644
--- a/gm/glyph_pos_align.cpp
+++ b/gm/glyph_pos_align.cpp
@@ -12,10 +12,10 @@
/**
* This test exercises drawPosTextH and drawPosText with every text align.
*/
-static const int kWidth = 480;
-static const int kHeight = 600;
-static const SkScalar kTextHeight = 64.0f;
-static const int kMaxStringLength = 12;
+constexpr int kWidth = 480;
+constexpr int kHeight = 600;
+constexpr SkScalar kTextHeight = 64.0f;
+constexpr int kMaxStringLength = 12;
static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&);
diff --git a/gm/gm.cpp b/gm/gm.cpp
index e0cb8b8..b6cac0c 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -80,7 +80,7 @@
paint.setTextSize(20);
paint.setColor(SK_ColorRED);
sk_tool_utils::set_portable_typeface(&paint);
- static const char kTxt[] = "GPU Only";
+ constexpr char kTxt[] = "GPU Only";
bmpCanvas.drawText(kTxt, strlen(kTxt), 20, 40, paint);
SkMatrix localM;
localM.setRotate(35.f);
diff --git a/gm/gradientDirtyLaundry.cpp b/gm/gradientDirtyLaundry.cpp
index 6b16be9..dc52d9e 100644
--- a/gm/gradientDirtyLaundry.cpp
+++ b/gm/gradientDirtyLaundry.cpp
@@ -15,7 +15,7 @@
const SkScalar* fPos;
};
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
@@ -26,9 +26,9 @@
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
};
-//static const SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 };
+//constexpr SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 };
-static const GradData gGradData[] = {
+constexpr GradData gGradData[] = {
{ 40, gColors, nullptr },
// { 2, gColors, gPos },
// { 2, gCol2, nullptr },
@@ -51,7 +51,7 @@
typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkShader::TileMode);
-static const GradMaker gGradMakers[] = {
+constexpr GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep,
};
diff --git a/gm/gradient_matrix.cpp b/gm/gradient_matrix.cpp
index 8168918..3992a49 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 @@
{{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 @@
};
// 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),
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 11c27ba..4a68702 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -17,21 +17,21 @@
const SkScalar* fPos;
};
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
};
-static const SkScalar gPos0[] = { 0, SK_Scalar1 };
-static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
-static const SkScalar gPos2[] = {
+constexpr SkScalar gPos0[] = { 0, SK_Scalar1 };
+constexpr SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
+constexpr SkScalar gPos2[] = {
0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
};
-static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
-static const SkColor gColorClamp[] = {
+constexpr SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
+constexpr SkColor gColorClamp[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE
};
-static const GradData gGradData[] = {
+constexpr GradData gGradData[] = {
{ 2, gColors, nullptr },
{ 2, gColors, gPos0 },
{ 2, gColors, gPos1 },
@@ -91,7 +91,7 @@
typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix);
-static const GradMaker gGradMakers[] = {
+constexpr GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical
};
diff --git a/gm/gradients_2pt_conical.cpp b/gm/gradients_2pt_conical.cpp
index 28ed8bb..ee1aee9 100644
--- a/gm/gradients_2pt_conical.cpp
+++ b/gm/gradients_2pt_conical.cpp
@@ -16,21 +16,21 @@
const SkScalar* fPos;
};
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
};
-static const SkScalar gPos0[] = { 0, SK_Scalar1 };
-static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
-static const SkScalar gPos2[] = {
+constexpr SkScalar gPos0[] = { 0, SK_Scalar1 };
+constexpr SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
+constexpr SkScalar gPos2[] = {
0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
};
-static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
-static const SkColor gColorClamp[] = {
+constexpr SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
+constexpr SkColor gColorClamp[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE
};
-static const GradData gGradData[] = {
+constexpr GradData gGradData[] = {
{ 2, gColors, gPos0 },
{ 2, gColors, gPos1 },
{ 5, gColors, gPos2 },
@@ -250,17 +250,17 @@
typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix);
-static const GradMaker gGradMakersOutside[] = {
+constexpr GradMaker gGradMakersOutside[] = {
Make2ConicalOutside, Make2ConicalOutsideFlip,
Make2ConicalZeroRadOutside, Make2ConicalZeroRadFlipOutside
};
-static const GradMaker gGradMakersInside[] = {
+constexpr GradMaker gGradMakersInside[] = {
Make2ConicalInside, Make2ConicalInsideFlip, Make2ConicalInsideCenter,
Make2ConicalZeroRad, Make2ConicalZeroRadFlip, Make2ConicalZeroRadCenter,
};
-static const GradMaker gGradMakersEdgeCases[] = {
+constexpr GradMaker gGradMakersEdgeCases[] = {
Make2ConicalEdgeX, Make2ConicalEdgeY,
Make2ConicalZeroRadEdgeX, Make2ConicalZeroRadEdgeY,
Make2ConicalTouchX, Make2ConicalTouchY,
@@ -268,7 +268,7 @@
};
-static const struct {
+constexpr struct {
const GradMaker* fMaker;
const int fCount;
const char* fName;
diff --git a/gm/gradients_no_texture.cpp b/gm/gradients_no_texture.cpp
index b688aab..5d0d4c9 100644
--- a/gm/gradients_no_texture.cpp
+++ b/gm/gradients_no_texture.cpp
@@ -15,11 +15,11 @@
const SkScalar* fPos;
};
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE,
};
-static const GradData gGradData[] = {
+constexpr GradData gGradData[] = {
{ 1, gColors, nullptr },
{ 2, gColors, nullptr },
{ 3, gColors, nullptr },
@@ -71,7 +71,7 @@
typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
-static const GradMaker gGradMakers[] = {
+constexpr GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical,
};
@@ -92,16 +92,16 @@
SkISize onISize() override { return SkISize::Make(640, 615); }
void onDraw(SkCanvas* canvas) override {
- static const SkPoint kPts[2] = { { 0, 0 },
+ constexpr SkPoint kPts[2] = { { 0, 0 },
{ SkIntToScalar(50), SkIntToScalar(50) } };
- static const SkShader::TileMode kTM = SkShader::kClamp_TileMode;
+ constexpr SkShader::TileMode kTM = SkShader::kClamp_TileMode;
SkRect kRect = { 0, 0, SkIntToScalar(50), SkIntToScalar(50) };
SkPaint paint;
paint.setAntiAlias(true);
paint.setDither(fDither);
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
- static const uint8_t kAlphas[] = { 0xff, 0x40 };
+ constexpr uint8_t kAlphas[] = { 0xff, 0x40 };
for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphas); ++a) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); ++i) {
canvas->save();
diff --git a/gm/hairlines.cpp b/gm/hairlines.cpp
index 89c5cd3..6ec5bde 100644
--- a/gm/hairlines.cpp
+++ b/gm/hairlines.cpp
@@ -138,9 +138,9 @@
{
// Arc example to test imperfect truncation bug (crbug.com/295626)
- static const SkScalar kRad = SkIntToScalar(2000);
- static const SkScalar kStartAngle = 262.59717f;
- static const SkScalar kSweepAngle = SkScalarHalf(17.188717f);
+ constexpr SkScalar kRad = SkIntToScalar(2000);
+ constexpr SkScalar kStartAngle = 262.59717f;
+ constexpr SkScalar kSweepAngle = SkScalarHalf(17.188717f);
SkPath* bug = &fPaths.push_back();
@@ -163,8 +163,8 @@
}
void onDraw(SkCanvas* canvas) override {
- static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
- static const SkScalar kWidths[] = { 0, 0.5f, 1.5f };
+ constexpr SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
+ constexpr SkScalar kWidths[] = { 0, 0.5f, 1.5f };
enum {
kMargin = 5,
diff --git a/gm/hairmodes.cpp b/gm/hairmodes.cpp
index 2651d04..de937c4 100644
--- a/gm/hairmodes.cpp
+++ b/gm/hairmodes.cpp
@@ -10,7 +10,7 @@
#include "SkColorPriv.h"
#include "SkShader.h"
-static const struct {
+constexpr struct {
SkXfermode::Mode fMode;
const char* fLabel;
} gModes[] = {
@@ -88,7 +88,7 @@
void onDraw(SkCanvas* canvas) override {
const SkRect bounds = SkRect::MakeWH(W, H);
- static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };
+ constexpr SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };
canvas->translate(SkIntToScalar(4), SkIntToScalar(4));
diff --git a/gm/image.cpp b/gm/image.cpp
index 400d421..f1bb5a4 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -132,17 +132,17 @@
canvas->scale(2, 2);
- static const char* kLabel1 = "Original Img";
- static const char* kLabel2 = "Modified Img";
- static const char* kLabel3 = "Cur Surface";
- static const char* kLabel4 = "Full Crop";
- static const char* kLabel5 = "Over-crop";
- static const char* kLabel6 = "Upper-left";
- static const char* kLabel7 = "No Crop";
+ const char* kLabel1 = "Original Img";
+ const char* kLabel2 = "Modified Img";
+ const char* kLabel3 = "Cur Surface";
+ const char* kLabel4 = "Full Crop";
+ const char* kLabel5 = "Over-crop";
+ const char* kLabel6 = "Upper-left";
+ const char* kLabel7 = "No Crop";
- static const char* kLabel8 = "Pre-Alloc Img";
- static const char* kLabel9 = "New Alloc Img";
- static const char* kLabel10 = "GPU";
+ const char* kLabel8 = "Pre-Alloc Img";
+ const char* kLabel9 = "New Alloc Img";
+ const char* kLabel10 = "GPU";
SkPaint textPaint;
textPaint.setAntiAlias(true);
@@ -453,7 +453,7 @@
canvas->drawRect(SkRect::MakeXYWH(30.f,30.f,10.f,10.f), paint);
};
- static const int kSize = 50;
+ static constexpr int kSize = 50;
SkBitmap bmp;
bmp.allocN32Pixels(kSize, kSize);
SkCanvas bmpCanvas(bmp);
@@ -491,7 +491,7 @@
}
};
- static const SkScalar kPad = 5.f;
+ constexpr SkScalar kPad = 5.f;
canvas->translate(kPad, kPad);
for (auto factory : imageFactories) {
auto image(factory());
diff --git a/gm/imageblur2.cpp b/gm/imageblur2.cpp
index c6835d8..7431ded 100644
--- a/gm/imageblur2.cpp
+++ b/gm/imageblur2.cpp
@@ -14,7 +14,7 @@
#define WIDTH 500
#define HEIGHT 500
-static const float kBlurSigmas[] = {
+constexpr float kBlurSigmas[] = {
0.0, 0.3f, 0.5f, 2.0f, 32.0f, 80.0f };
const char* kTestStrings[] = {
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index e523d22..13e0300 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -38,7 +38,7 @@
// We create an RGB bitmap and then extract YUV bmps where the U and V bitmaps are
// subsampled by 2 in both dimensions.
SkPaint paint;
- static const SkColor kColors[] =
+ constexpr SkColor kColors[] =
{ SK_ColorBLUE, SK_ColorYELLOW, SK_ColorGREEN, SK_ColorWHITE };
paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(0,0), kBmpSize / 2.f, kColors,
nullptr, SK_ARRAY_COUNT(kColors),
@@ -131,7 +131,7 @@
}
- static const SkScalar kPad = 10.f;
+ constexpr SkScalar kPad = 10.f;
SkISize sizes[] = {
{ fYUVBmps[0].width(), fYUVBmps[0].height()},
@@ -161,7 +161,7 @@
sk_sp<SkImage> fRGBImage;
SkBitmap fYUVBmps[3];
- static const int kBmpSize = 32;
+ static constexpr int kBmpSize = 32;
typedef GM INHERITED;
};
diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp
index a012a9e..88a6d10 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagemagnifier.cpp
@@ -72,7 +72,7 @@
SkIntToScalar(WIDTH_HEIGHT-32));
srcRect.inset(64.0f, 64.0f);
- static const SkScalar kInset = 64.0f;
+ constexpr SkScalar kInset = 64.0f;
// Crop out a 16 pixel ring around the result
const SkRect rect = SkRect::MakeXYWH(16, 16, WIDTH_HEIGHT-32, WIDTH_HEIGHT-32);
diff --git a/gm/imagescalealigned.cpp b/gm/imagescalealigned.cpp
index 474490f..9498d32 100644
--- a/gm/imagescalealigned.cpp
+++ b/gm/imagescalealigned.cpp
@@ -138,8 +138,8 @@
return pt;
}
- static const unsigned kSegLen = 15;
- static const unsigned kStretchFactor = 4;
+ static constexpr unsigned kSegLen = 15;
+ static constexpr unsigned kStretchFactor = 4;
SkSTArray<2, ImageSet> fSets;
typedef GM INHERITED;
diff --git a/gm/imagesource2.cpp b/gm/imagesource2.cpp
index ba6af46..70a91da 100644
--- a/gm/imagesource2.cpp
+++ b/gm/imagesource2.cpp
@@ -31,7 +31,7 @@
// Create an image with high frequency vertical stripes
void onOnceBeforeDraw() override {
- static const SkPMColor gColors[] = {
+ constexpr SkPMColor gColors[] = {
SK_ColorRED, SK_ColorGRAY,
SK_ColorGREEN, SK_ColorGRAY,
SK_ColorBLUE, SK_ColorGRAY,
@@ -73,7 +73,7 @@
}
private:
- static const int kImageSize = 503;
+ static constexpr int kImageSize = 503;
SkString fSuffix;
SkFilterQuality fFilter;
diff --git a/gm/imagetoyuvplanes.cpp b/gm/imagetoyuvplanes.cpp
index 63d3fa9..d082572 100644
--- a/gm/imagetoyuvplanes.cpp
+++ b/gm/imagetoyuvplanes.cpp
@@ -25,7 +25,7 @@
}
// Create an RGB image from which we will extract planes
SkPaint paint;
- static const SkColor kColors[] =
+ constexpr SkColor kColors[] =
{ SK_ColorBLUE, SK_ColorYELLOW, SK_ColorGREEN, SK_ColorWHITE };
SkScalar r = (width + height) / 4.f;
paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(0,0), r, kColors,
@@ -37,8 +37,8 @@
}
DEF_SIMPLE_GM(image_to_yuv_planes, canvas, 120, 525) {
- static const SkScalar kPad = 5.f;
- static const int kImageSize = 32;
+ constexpr SkScalar kPad = 5.f;
+ constexpr int kImageSize = 32;
GrContext *context = canvas->getGrContext();
sk_sp<SkImage> rgbImage(create_image(context, kImageSize, kImageSize));
@@ -49,14 +49,14 @@
canvas->drawImage(rgbImage.get(), kPad, kPad);
// Test cases where all three planes are the same size, where just u and v are the same size,
// and where all differ.
- static const SkISize kSizes[][3] = {
+ constexpr SkISize kSizes[][3] = {
{{kImageSize, kImageSize}, {kImageSize , kImageSize }, {kImageSize, kImageSize }},
{{kImageSize, kImageSize}, {kImageSize/2, kImageSize/2}, {kImageSize/2, kImageSize/2}},
{{kImageSize, kImageSize}, {kImageSize/2, kImageSize/2}, {kImageSize/3, kImageSize/3}}
};
// A mix of rowbytes triples to go with the above sizes.
- static const size_t kRowBytes[][3] {
+ constexpr size_t kRowBytes[][3] {
{0, 0, 0},
{kImageSize, kImageSize/2 + 1, kImageSize},
{kImageSize + 13, kImageSize, kImageSize/3 + 8}
diff --git a/gm/inversepaths.cpp b/gm/inversepaths.cpp
index 6eb054e..9a247e8 100644
--- a/gm/inversepaths.cpp
+++ b/gm/inversepaths.cpp
@@ -47,7 +47,7 @@
};
sk_sp<SkPathEffect> make_dash() {
- static constexpr SkScalar kIntervals[] = { 4.f, 3.f };
+ constexpr SkScalar kIntervals[] = { 4.f, 3.f };
return SkDashPathEffect::Make(kIntervals, SK_ARRAY_COUNT(kIntervals), 0);
}
diff --git a/gm/largeglyphblur.cpp b/gm/largeglyphblur.cpp
index 6ffe953..235c7cc 100644
--- a/gm/largeglyphblur.cpp
+++ b/gm/largeglyphblur.cpp
@@ -23,7 +23,7 @@
paint.setAntiAlias(true);
// setup up maskfilter
- static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
+ const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
SkPaint blurPaint(paint);
blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index 42359e3..537c4cb 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -17,10 +17,10 @@
namespace skiagm {
-static const int kColWidth = 180;
-static const int kNumCols = 4;
-static const int kWidth = kColWidth * kNumCols;
-static const int kHeight = 750;
+constexpr int kColWidth = 180;
+constexpr int kNumCols = 4;
+constexpr int kWidth = kColWidth * kNumCols;
+constexpr int kHeight = 750;
static sk_sp<SkShader> make_shader(const SkRect& bounds) {
const SkPoint pts[] = {
diff --git a/gm/lcdoverlap.cpp b/gm/lcdoverlap.cpp
index aae27d8..de159e1 100644
--- a/gm/lcdoverlap.cpp
+++ b/gm/lcdoverlap.cpp
@@ -17,8 +17,8 @@
namespace skiagm {
-static const int kWidth = 750;
-static const int kHeight = 750;
+constexpr int kWidth = 750;
+constexpr int kHeight = 750;
class LcdOverlapGM : public skiagm::GM {
public:
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index 7915c33..cd4132e 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -158,14 +158,14 @@
}
bool onAnimate(const SkAnimTimer& timer) override {
- static const SkScalar kDesiredDurationSecs = 15.0f;
+ constexpr SkScalar kDesiredDurationSecs = 15.0f;
fAzimuth = kStartAzimuth + timer.scaled(360.0f/kDesiredDurationSecs, 360.0f);
return true;
}
private:
- static const int kStartAzimuth = 225;
+ static constexpr int kStartAzimuth = 225;
SkBitmap fBitmap;
SkScalar fAzimuth;
diff --git a/gm/lightingshader.cpp b/gm/lightingshader.cpp
index 137fd64..8576dd7 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -66,7 +66,7 @@
kLast_NormalMap = kTetra_NormalMap
};
- static const int kNormalMapCount = kLast_NormalMap+1;
+ static constexpr int kNormalMapCount = kLast_NormalMap+1;
SkString onShortName() override {
return SkString("lightingshader");
@@ -164,8 +164,8 @@
}
private:
- static const int kTexSize = 128;
- static const int kGMSize = 512;
+ static constexpr int kTexSize = 128;
+ static constexpr int kGMSize = 512;
SkBitmap fDiffuse;
SkBitmap fNormalMaps[kNormalMapCount];
diff --git a/gm/lightingshader2.cpp b/gm/lightingshader2.cpp
index 886c647..2efcebb 100644
--- a/gm/lightingshader2.cpp
+++ b/gm/lightingshader2.cpp
@@ -254,7 +254,7 @@
}
private:
- static const int kTexSize = 96;
+ static constexpr int kTexSize = 96;
sk_sp<SkShader> fOpaqueDiffuse;
sk_sp<SkShader> fTranslucentDiffuse;
diff --git a/gm/linepaths.cpp b/gm/linepaths.cpp
index 51df788..e7a0c93 100644
--- a/gm/linepaths.cpp
+++ b/gm/linepaths.cpp
@@ -33,7 +33,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -43,7 +43,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
@@ -53,7 +53,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp
index 385c60e..6f071cb 100644
--- a/gm/megalooper.cpp
+++ b/gm/megalooper.cpp
@@ -68,11 +68,11 @@
}
private:
- static const int kWidth = 800;
- static const int kHeight = 800;
- static const int kHalfOuterClipSize = 100;
- static const int kHalfSquareSize = 50;
- static const int kOffsetToOutsideClip = kHalfSquareSize + kHalfOuterClipSize + 1;
+ static constexpr int kWidth = 800;
+ static constexpr int kHeight = 800;
+ static constexpr int kHalfOuterClipSize = 100;
+ static constexpr int kHalfSquareSize = 50;
+ static constexpr int kOffsetToOutsideClip = kHalfSquareSize + kHalfOuterClipSize + 1;
static const SkPoint gBlurOffsets[4];
static const SkColor gColors[4];
@@ -111,7 +111,7 @@
}
static sk_sp<SkMaskFilter> MakeBlur() {
- static const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25));
+ const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25));
return SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma,
SkBlurMaskFilter::kHighQuality_BlurFlag);
diff --git a/gm/mixedtextblobs.cpp b/gm/mixedtextblobs.cpp
index 9a9bded..66e2379 100644
--- a/gm/mixedtextblobs.cpp
+++ b/gm/mixedtextblobs.cpp
@@ -155,8 +155,8 @@
const char* fEmojiText;
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 1250;
- static const int kHeight = 700;
+ static constexpr int kWidth = 1250;
+ static constexpr int kHeight = 700;
typedef GM INHERITED;
};
diff --git a/gm/modecolorfilters.cpp b/gm/modecolorfilters.cpp
index 4e5d45c..50bb27f 100644
--- a/gm/modecolorfilters.cpp
+++ b/gm/modecolorfilters.cpp
@@ -16,7 +16,7 @@
// Using gradients because GPU doesn't currently have an implementation of SkColorShader (duh!)
static sk_sp<SkShader> make_color_shader(SkColor color) {
- static const SkPoint kPts[] = {{0, 0}, {1, 1}};
+ constexpr SkPoint kPts[] = {{0, 0}, {1, 1}};
SkColor colors[] = {color, color};
return SkGradientShader::MakeLinear(kPts, colors, nullptr, 2, SkShader::kClamp_TileMode);
@@ -68,10 +68,10 @@
void onDraw(SkCanvas* canvas) override {
// size of rect for each test case
- static const int kRectWidth = 20;
- static const int kRectHeight = 20;
+ constexpr int kRectWidth = 20;
+ constexpr int kRectHeight = 20;
- static const int kCheckSize = 10;
+ constexpr int kCheckSize = 10;
if (!fBmpShader) {
fBmpShader = make_bg_shader(kCheckSize);
@@ -118,7 +118,7 @@
SkPaint paint;
int idx = 0;
- static const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectWidth, 1);
+ const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectWidth, 1);
for (size_t cfm = 0; cfm < SK_ARRAY_COUNT(modes); ++cfm) {
for (size_t cfc = 0; cfc < SK_ARRAY_COUNT(colors); ++cfc) {
paint.setColorFilter(SkColorFilter::MakeModeFilter(colors[cfc], modes[cfm]));
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
index 83b0d5b..d7d81f2 100644
--- a/gm/multipicturedraw.cpp
+++ b/gm/multipicturedraw.cpp
@@ -12,18 +12,18 @@
#include "SkPictureRecorder.h"
#include "SkSurface.h"
-static const SkScalar kRoot3Over2 = 0.86602545f; // sin(60)
-static const SkScalar kRoot3 = 1.73205081f;
+constexpr SkScalar kRoot3Over2 = 0.86602545f; // sin(60)
+constexpr SkScalar kRoot3 = 1.73205081f;
-static const int kHexSide = 30;
-static const int kNumHexX = 6;
-static const int kNumHexY = 6;
-static const int kPicWidth = kNumHexX * kHexSide;
-static const int kPicHeight = SkScalarCeilToInt((kNumHexY - 0.5f) * 2 * kHexSide * kRoot3Over2);
-static const SkScalar kInset = 20.0f;
-static const int kNumPictures = 4;
+constexpr int kHexSide = 30;
+constexpr int kNumHexX = 6;
+constexpr int kNumHexY = 6;
+constexpr int kPicWidth = kNumHexX * kHexSide;
+constexpr int kPicHeight = (int)((kNumHexY - 0.5f) * 2 * kHexSide * kRoot3Over2 + 0.5f);
+constexpr SkScalar kInset = 20.0f;
+constexpr int kNumPictures = 4;
-static const int kTriSide = 40;
+constexpr int kTriSide = 40;
// Create a hexagon centered at (originX, originY)
static SkPath make_hex_path(SkScalar originX, SkScalar originY) {
@@ -106,7 +106,7 @@
SkPictureRecorder recorder;
SkRTreeFactory bbhFactory;
- static const SkScalar kBig = 10000.0f;
+ constexpr SkScalar kBig = 10000.0f;
SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory);
canvas->saveLayer(nullptr, nullptr);
@@ -218,7 +218,7 @@
SkIntToScalar(kPicHeight),
&bbhFactory);
- static const int kNumLevels = 4;
+ constexpr int kNumLevels = 4;
for (int i = 0; i < kNumLevels; ++i) {
canvas->save();
canvas->translate(kPicWidth/2 - (i+1) * (kTriSide/2.0f), 0.0f);
@@ -336,7 +336,7 @@
canvas->drawPicture(pictures[3]);
}
-static const PFContentMtd gContentMthds[] = {
+constexpr PFContentMtd gContentMthds[] = {
no_clip,
rect_clip,
rrect_clip,
@@ -391,15 +391,15 @@
PFContentMtd pfGen,
const SkPicture* pictures[kNumPictures],
SkTArray<ComposeStep> *composeSteps) {
- static const int kNumTilesX = 2;
- static const int kNumTilesY = 2;
- static const int kTileWidth = kPicWidth / kNumTilesX;
- static const int kTileHeight = kPicHeight / kNumTilesY;
+ const int kNumTilesX = 2;
+ const int kNumTilesY = 2;
+ const int kTileWidth = kPicWidth / kNumTilesX;
+ const int kTileHeight = kPicHeight / kNumTilesY;
SkASSERT(kPicWidth == kNumTilesX * kTileWidth);
SkASSERT(kPicHeight == kNumTilesY * kTileHeight);
- static const SkColor colors[kNumTilesX][kNumTilesY] = {
+ const SkColor colors[kNumTilesX][kNumTilesY] = {
{ SK_ColorCYAN, SK_ColorMAGENTA },
{ SK_ColorYELLOW, SK_ColorGREEN }
};
@@ -426,7 +426,7 @@
}
}
-static const PFLayoutMtd gLayoutMthds[] = { simple, tiled };
+constexpr PFLayoutMtd gLayoutMthds[] = { simple, tiled };
namespace skiagm {
/**
@@ -450,7 +450,7 @@
kLast_Content = kBigLayer_Content
};
- static const int kContentCnt = kLast_Content + 1;
+ const int kContentCnt = kLast_Content + 1;
enum Layout {
kSimple_Layout,
@@ -459,7 +459,7 @@
kLast_Layout = kTiled_Layout
};
- static const int kLayoutCnt = kLast_Layout + 1;
+ const int kLayoutCnt = kLast_Layout + 1;
MultiPictureDraw(Content content, Layout layout) : fContent(content), fLayout(layout) {
SkASSERT(SK_ARRAY_COUNT(gLayoutMthds) == kLayoutCnt);
@@ -511,11 +511,11 @@
SkISize onISize() override { return SkISize::Make(kPicWidth, kPicHeight); }
SkString onShortName() override {
- static const char* gContentNames[] = {
+ const char* gContentNames[] = {
"noclip", "rectclip", "rrectclip", "pathclip",
"invpathclip", "sierpinski", "biglayer"
};
- static const char* gLayoutNames[] = { "simple", "tiled" };
+ const char* gLayoutNames[] = { "simple", "tiled" };
SkASSERT(SK_ARRAY_COUNT(gLayoutNames) == kLayoutCnt);
SkASSERT(SK_ARRAY_COUNT(gContentNames) == kContentCnt);
diff --git a/gm/nested.cpp b/gm/nested.cpp
index d3b75b3..0b3cf19 100644
--- a/gm/nested.cpp
+++ b/gm/nested.cpp
@@ -123,8 +123,8 @@
}
private:
- static const int kImageWidth = 269;
- static const int kImageHeight = 134;
+ static constexpr int kImageWidth = 269;
+ static constexpr int kImageHeight = 134;
bool fDoAA;
bool fFlipped;
diff --git a/gm/nonclosedpaths.cpp b/gm/nonclosedpaths.cpp
index a3d91b5..dc806f3 100644
--- a/gm/nonclosedpaths.cpp
+++ b/gm/nonclosedpaths.cpp
@@ -71,22 +71,22 @@
// Stroke widths are:
// 0(may use hairline rendering), 10(common case for stroke-style)
// 40 and 50(>= geometry width/height, make the contour filled in fact)
- static const int kStrokeWidth[] = {0, 10, 40, 50};
+ constexpr int kStrokeWidth[] = {0, 10, 40, 50};
int numWidths = SK_ARRAY_COUNT(kStrokeWidth);
- static const SkPaint::Style kStyle[] = {
+ constexpr SkPaint::Style kStyle[] = {
SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style
};
- static const SkPaint::Cap kCap[] = {
+ constexpr SkPaint::Cap kCap[] = {
SkPaint::kButt_Cap, SkPaint::kRound_Cap, SkPaint::kSquare_Cap
};
- static const SkPaint::Join kJoin[] = {
+ constexpr SkPaint::Join kJoin[] = {
SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join
};
- static const ClosureType kType[] = {
+ constexpr ClosureType kType[] = {
TotallyNonClosed, FakeCloseCorner, FakeCloseMiddle
};
diff --git a/gm/occludedrrectblur.cpp b/gm/occludedrrectblur.cpp
index e21a014..059b473 100644
--- a/gm/occludedrrectblur.cpp
+++ b/gm/occludedrrectblur.cpp
@@ -65,7 +65,7 @@
SkRRect::Corner left = SkRRect::kUpperLeft_Corner, right = SkRRect::kUpperLeft_Corner;
SkVector dir = { 0, 0 };
- static const SkScalar kSize = 64.0f / SK_ScalarSqrt2;
+ constexpr SkScalar kSize = 64.0f / SK_ScalarSqrt2;
switch (corner) {
case SkRRect::kUpperLeft_Corner:
@@ -88,11 +88,11 @@
left = SkRRect::kLowerRight_Corner;
right = SkRRect::kUpperLeft_Corner;
dir.set(-SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
- break;
+ break;
default:
SkFAIL("Invalid shape.");
}
-
+
SkRect r = SkRect::MakeWH(kSize, kSize);
// UL, UR, LR, LL
SkVector radii[4] = { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } };
@@ -110,9 +110,9 @@
radii);
draw_rrect(canvas, rr, occRR);
-}
+}
-static void draw_45_simple(SkCanvas* canvas, const SkVector& v,
+static void draw_45_simple(SkCanvas* canvas, const SkVector& v,
SkScalar dist, const SkPoint& center) {
SkIRect r = SkIRect::MakeWH(64, 64);
SkRRect rr = SkRRect::MakeRectXY(
@@ -121,14 +121,14 @@
dist -= 10.0f;
SkRRect occRR = SkRRect::MakeRectXY(
- offset_center_to(r, center.fX + dist*v.fX, center.fY + dist*v.fY),
+ offset_center_to(r, center.fX + dist*v.fX, center.fY + dist*v.fY),
8, 8);
draw_rrect(canvas, rr, occRR);
}
static void draw_90(SkCanvas* canvas, const SkVector& v, SkScalar dist, const SkPoint& center) {
- static const int kWidth = 25;
+ constexpr int kWidth = 25;
SkIRect r;
if (fabs(v.fX) < fabs(v.fY)) {
@@ -148,10 +148,10 @@
static void draw_90_simple(SkCanvas* canvas, const SkVector& v,
SkScalar dist, const SkPoint& center) {
- static const int kLength = 128;
+ constexpr int kLength = 128;
// The width needs to be larger than 2*3*blurRadii+2*cornerRadius for the analytic
// RRect blur to kick in
- static const int kWidth = 47;
+ constexpr int kWidth = 47;
SkIRect r;
if (fabs(v.fX) < fabs(v.fY)) {
@@ -175,8 +175,8 @@
SkScalar dist, const SkPoint& center) {
SkRRect::Corner left = SkRRect::kUpperLeft_Corner, right = SkRRect::kUpperLeft_Corner;
- static const int kLength = 64;
- static const int kWidth = 30;
+ constexpr int kLength = 64;
+ constexpr int kWidth = 30;
switch (corner) {
case SkRRect::kUpperLeft_Corner:
@@ -194,7 +194,7 @@
case SkRRect::kLowerLeft_Corner:
left = SkRRect::kLowerRight_Corner;
right = SkRRect::kUpperLeft_Corner;
- break;
+ break;
default:
SkFAIL("Invalid shape.");
}
@@ -215,7 +215,7 @@
dist -= 10.0f;
SkRRect occRR;
occRR.setRectRadii(offset_center_to(r, center.fX + dist*v.fX, center.fY + dist*v.fY), radii);
- draw_rrect(canvas, rr, occRR);
+ draw_rrect(canvas, rr, occRR);
}
namespace skiagm {
@@ -272,7 +272,7 @@
draw_90(canvas, SkVector::Make(1.0f, 0.0f), 64, center);
draw_90(canvas, SkVector::Make(0.0f, 1.0f), 64, center);
- static const SkScalar kRoot3Over2 = 0.8660254037844386f;
+ constexpr SkScalar kRoot3Over2 = 0.8660254037844386f;
draw_30_60(canvas, SkRRect::kLowerLeft_Corner,
SkVector::Make(0.5f, kRoot3Over2), 120, center);
@@ -310,8 +310,8 @@
}
private:
- static const int kWidth = 440;
- static const int kHeight = 440;
+ static constexpr int kWidth = 440;
+ static constexpr int kHeight = 440;
typedef GM INHERITED;
};
diff --git a/gm/patchgrid.cpp b/gm/patchgrid.cpp
index 962c1a9..a36e58f 100644
--- a/gm/patchgrid.cpp
+++ b/gm/patchgrid.cpp
@@ -105,8 +105,8 @@
{{50,325},{150,325},{250,325},{350,325},{450,325}}
};
- static const int kRows = 3;
- static const int kCols = 4;
+ constexpr int kRows = 3;
+ constexpr int kCols = 4;
canvas->scale(3, 3);
SkPatchGrid grid(kRows, kCols, SkPatchGrid::kColors_VertexType, nullptr);
diff --git a/gm/pathcontourstart.cpp b/gm/pathcontourstart.cpp
index 56f6492..0e85e38 100644
--- a/gm/pathcontourstart.cpp
+++ b/gm/pathcontourstart.cpp
@@ -90,8 +90,8 @@
}
private:
- static const int kImageWidth = 1200;
- static const int kImageHeight = 600;
+ static constexpr int kImageWidth = 1200;
+ static constexpr int kImageHeight = 600;
SkPaint fDashPaint, fPointsPaint;
SkRect fRect;
diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp
index 9821b3a..9a1f62d 100644
--- a/gm/patheffects.cpp
+++ b/gm/patheffects.cpp
@@ -48,7 +48,7 @@
compose_pe(paint);
}
-static const int gXY[] = {
+constexpr int gXY[] = {
4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
};
@@ -73,7 +73,7 @@
}
typedef void (*PE_Proc)(SkPaint*);
-static const PE_Proc gPE[] = { hair_pe, hair2_pe, stroke_pe, dash_pe, one_d_pe };
+constexpr PE_Proc gPE[] = { hair_pe, hair2_pe, stroke_pe, dash_pe, one_d_pe };
static void fill_pe(SkPaint* paint) {
paint->setStyle(SkPaint::kFill_Style);
@@ -98,7 +98,7 @@
paint->setPathEffect(MakeTileEffect());
}
-static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };
+constexpr PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };
class PathEffectGM : public GM {
public:
diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp
index b4010ce..3496cfd 100644
--- a/gm/pathfill.cpp
+++ b/gm/pathfill.cpp
@@ -23,7 +23,7 @@
}
static SkScalar make_triangle(SkPath* path) {
- static const int gCoord[] = {
+ constexpr int gCoord[] = {
10, 20, 15, 5, 30, 30
};
path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1]));
@@ -102,7 +102,7 @@
return SkIntToScalar(40);
}
-static const MakePathProc gProcs[] = {
+constexpr MakePathProc gProcs[] = {
make_frame,
make_triangle,
make_rect,
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index 2b09cc6..b231291 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -56,10 +56,10 @@
{ 0, 0 },
{ 0, SkIntToScalar(kCellSize) }
};
- static const SkColor colors[] = {
+ constexpr SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN, SK_ColorRED
};
- static const SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
+ constexpr SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
fLinearGrad1 = SkGradientShader::MakeLinear(pts1, colors, pos, SK_ARRAY_COUNT(colors),
SkShader::kClamp_TileMode);
@@ -151,9 +151,9 @@
canvas->translate(0, SkIntToScalar(kCellSize));
}
private:
- static const int kCellSize = 50;
- static const int kNumRows = 4;
- static const int kNumCols = 6;
+ static constexpr int kCellSize = 50;
+ static constexpr int kNumRows = 4;
+ static constexpr int kNumCols = 6;
bool fDoAA;
SkPath fPath;
diff --git a/gm/pictureimagegenerator.cpp b/gm/pictureimagegenerator.cpp
index 60e979f..95efbb2 100644
--- a/gm/pictureimagegenerator.cpp
+++ b/gm/pictureimagegenerator.cpp
@@ -16,10 +16,10 @@
#include "SkPictureRecorder.h"
static void draw_vector_logo(SkCanvas* canvas, const SkRect& viewBox) {
- static const char kSkiaStr[] = "SKIA";
- static const SkScalar kGradientPad = .1f;
- static const SkScalar kVerticalSpacing = 0.25f;
- static const SkScalar kAccentScale = 1.20f;
+ constexpr char kSkiaStr[] = "SKIA";
+ constexpr SkScalar kGradientPad = .1f;
+ constexpr SkScalar kVerticalSpacing = 0.25f;
+ constexpr SkScalar kAccentScale = 1.20f;
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/pictureshadertile.cpp b/gm/pictureshadertile.cpp
index 8774318..10d5e5d 100644
--- a/gm/pictureshadertile.cpp
+++ b/gm/pictureshadertile.cpp
@@ -12,11 +12,11 @@
#include "SkPictureRecorder.h"
#include "SkShader.h"
-static const SkScalar kPictureSize = SK_Scalar1;
-static const SkScalar kFillSize = 100;
-static const unsigned kRowSize = 6;
+constexpr SkScalar kPictureSize = SK_Scalar1;
+constexpr SkScalar kFillSize = 100;
+constexpr unsigned kRowSize = 6;
-static const struct {
+constexpr struct {
SkScalar x, y, w, h;
SkScalar offsetX, offsetY;
} tiles[] = {
diff --git a/gm/pixelsnap.cpp b/gm/pixelsnap.cpp
index 1711f5e..18fb7b2 100644
--- a/gm/pixelsnap.cpp
+++ b/gm/pixelsnap.cpp
@@ -17,15 +17,15 @@
protected:
// kTrans should be even or checkboards wont agree in different test cases.
- static const int kTrans = 14;
- static const int kLabelPad = 4;
+ static constexpr int kTrans = 14;
+ static constexpr int kLabelPad = 4;
// The inverse of this value should be a perfect SkScalar.
- static const int kSubPixelSteps = 8;
- static const int kLabelTextSize = 9;
+ static constexpr int kSubPixelSteps = 8;
+ static constexpr int kLabelTextSize = 9;
static_assert(kSubPixelSteps < 99, "label_offset_too_small");
- static const int kLabelOffsetX = 2 * kLabelTextSize + kLabelPad;
- static const int kLabelOffsetY = kLabelTextSize + kLabelPad;
+ static constexpr int kLabelOffsetX = 2 * kLabelTextSize + kLabelPad;
+ static constexpr int kLabelOffsetY = kLabelTextSize + kLabelPad;
SkISize onISize() override {
return SkISize::Make((kSubPixelSteps + 1) * kTrans + kLabelOffsetX + kLabelPad,
diff --git a/gm/polygons.cpp b/gm/polygons.cpp
index a5756bb..00fe336 100644
--- a/gm/polygons.cpp
+++ b/gm/polygons.cpp
@@ -98,10 +98,10 @@
// Stroke widths are:
// 0(may use hairline rendering), 10(common case for stroke-style)
// 40(>= geometry width/height, make the contour filled in fact)
- static const int kStrokeWidths[] = {0, 10, 40};
+ constexpr int kStrokeWidths[] = {0, 10, 40};
SkASSERT(kNumStrokeWidths == SK_ARRAY_COUNT(kStrokeWidths));
- static const SkPaint::Join kJoins[] = {
+ constexpr SkPaint::Join kJoins[] = {
SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join
};
SkASSERT(kNumJoins == SK_ARRAY_COUNT(kJoins));
@@ -131,7 +131,7 @@
}
// For stroke-and-fill style painter and fill style painter
- static const SkPaint::Style kStyles[] = {
+ constexpr SkPaint::Style kStyles[] = {
SkPaint::kStrokeAndFill_Style, SkPaint::kFill_Style
};
SkASSERT(kNumExtraStyles == SK_ARRAY_COUNT(kStyles));
@@ -152,11 +152,11 @@
}
private:
- static const int kNumPolygons = 8;
- static const int kCellSize = 100;
- static const int kNumExtraStyles = 2;
- static const int kNumStrokeWidths = 3;
- static const int kNumJoins = 3;
+ static constexpr int kNumPolygons = 8;
+ static constexpr int kCellSize = 100;
+ static constexpr int kNumExtraStyles = 2;
+ static constexpr int kNumStrokeWidths = 3;
+ static constexpr int kNumJoins = 3;
SkTArray<SkPath> fPolygons;
typedef GM INHERITED;
diff --git a/gm/quadpaths.cpp b/gm/quadpaths.cpp
index 359f62d..0578d2e 100644
--- a/gm/quadpaths.cpp
+++ b/gm/quadpaths.cpp
@@ -47,7 +47,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -57,7 +57,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
@@ -67,7 +67,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
@@ -190,7 +190,7 @@
SkPath::FillType fFill;
const char* fName;
};
- static const FillAndName gFills[] = {
+ constexpr FillAndName gFills[] = {
{SkPath::kWinding_FillType, "Winding"},
{SkPath::kEvenOdd_FillType, "Even / Odd"},
{SkPath::kInverseWinding_FillType, "Inverse Winding"},
@@ -200,7 +200,7 @@
SkPaint::Style fStyle;
const char* fName;
};
- static const StyleAndName gStyles[] = {
+ constexpr StyleAndName gStyles[] = {
{SkPaint::kFill_Style, "Fill"},
{SkPaint::kStroke_Style, "Stroke"},
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
@@ -210,7 +210,7 @@
SkPaint::Join fJoin;
const char* fName;
};
- static const CapAndName gCaps[] = {
+ constexpr CapAndName gCaps[] = {
{SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
{SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
{SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
diff --git a/gm/recordopts.cpp b/gm/recordopts.cpp
index 4a5248d..b98d2cc 100644
--- a/gm/recordopts.cpp
+++ b/gm/recordopts.cpp
@@ -13,8 +13,8 @@
#include "SkColorFilterImageFilter.h"
#include "SkPictureImageFilter.h"
-static const int kTestRectSize = 50;
-static const int kDetectorGreenValue = 50;
+constexpr int kTestRectSize = 50;
+constexpr int kDetectorGreenValue = 50;
// Below are few functions to install "detector" color filters. The filter is there to assert that
// the color value it sees is the expected. It will trigger only with kDetectorGreenValue, and
diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp
index 3208c0d..1359d34 100644
--- a/gm/rectangletexture.cpp
+++ b/gm/rectangletexture.cpp
@@ -127,9 +127,9 @@
return;
}
- static const int kWidth = 50;
- static const int kHeight = 50;
- static const SkScalar kPad = 5.f;
+ constexpr int kWidth = 50;
+ constexpr int kHeight = 50;
+ constexpr SkScalar kPad = 5.f;
SkPMColor pixels[kWidth * kHeight];
this->fillPixels(kWidth, kHeight, pixels);
@@ -138,19 +138,19 @@
if (!rectImg) {
SkPaint paint;
paint.setAntiAlias(true);
- static const char* kMsg = "Could not create rectangle texture image.";
+ const char* kMsg = "Could not create rectangle texture image.";
canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint);
return;
}
- static const SkFilterQuality kQualities[] = {
+ constexpr SkFilterQuality kQualities[] = {
kNone_SkFilterQuality,
kLow_SkFilterQuality,
kMedium_SkFilterQuality,
kHigh_SkFilterQuality,
};
- static const SkScalar kScales[] = { 1.0f, 1.2f, 0.75f };
+ constexpr SkScalar kScales[] = { 1.0f, 1.2f, 0.75f };
canvas->translate(kPad, kPad);
for (auto s : kScales) {
diff --git a/gm/rrect.cpp b/gm/rrect.cpp
index 5106634..660e72a 100644
--- a/gm/rrect.cpp
+++ b/gm/rrect.cpp
@@ -136,7 +136,7 @@
}
void onDraw(SkCanvas* canvas) override {
- static const InsetProc insetProcs[] = {
+ constexpr InsetProc insetProcs[] = {
inset0, inset1, inset2, inset3
};
diff --git a/gm/rrectclipdrawpaint.cpp b/gm/rrectclipdrawpaint.cpp
index 3f5ded2..172facc 100644
--- a/gm/rrectclipdrawpaint.cpp
+++ b/gm/rrectclipdrawpaint.cpp
@@ -32,8 +32,8 @@
canvas->drawPaint(p);
canvas->restore();
- static constexpr SkPoint kPts[] = {{0.f, 0.f}, {256.f, 256.f}};
- static constexpr SkColor kColors1[] = {SK_ColorCYAN, SK_ColorGREEN};
+ constexpr SkPoint kPts[] = {{0.f, 0.f}, {256.f, 256.f}};
+ constexpr SkColor kColors1[] = {SK_ColorCYAN, SK_ColorGREEN};
p.setShader(SkGradientShader::MakeLinear(kPts, kColors1, nullptr, 2,
SkShader::kClamp_TileMode));
canvas->concat(zoomOut);
@@ -42,7 +42,7 @@
canvas->drawPaint(p);
canvas->restore();
- static constexpr SkColor kColors2[] = {SK_ColorMAGENTA, SK_ColorGRAY};
+ constexpr SkColor kColors2[] = {SK_ColorMAGENTA, SK_ColorGRAY};
p.setShader(SkGradientShader::MakeRadial({128.f, 128.f}, 128.f, kColors2, nullptr, 2,
SkShader::kClamp_TileMode));
canvas->concat(zoomOut);
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 0f3ac56..63b6dbc 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -73,11 +73,11 @@
paint.setAntiAlias(true);
}
- static const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX),
- SkIntToScalar(kTileY));
+ const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX),
+ SkIntToScalar(kTileY));
#ifdef SK_DEBUG
- static const SkRect kMaxImageBound = SkRect::MakeWH(SkIntToScalar(kImageWidth),
- SkIntToScalar(kImageHeight));
+ const SkRect kMaxImageBound = SkRect::MakeWH(SkIntToScalar(kImageWidth),
+ SkIntToScalar(kImageHeight));
#endif
#if SK_SUPPORT_GPU
@@ -168,17 +168,17 @@
private:
Type fType;
- static const int kImageWidth = 640;
- static const int kImageHeight = 480;
+ static constexpr int kImageWidth = 640;
+ static constexpr int kImageHeight = 480;
- static const int kTileX = 80;
- static const int kTileY = 40;
+ static constexpr int kTileX = 80;
+ static constexpr int kTileY = 40;
- static const int kNumSimpleCases = 7;
- static const int kNumComplexCases = 35;
+ static constexpr int kNumSimpleCases = 7;
+ static constexpr int kNumComplexCases = 35;
static const SkVector gRadii[kNumComplexCases][4];
- static const int kNumRRects = kNumSimpleCases + kNumComplexCases;
+ static constexpr int kNumRRects = kNumSimpleCases + kNumComplexCases;
SkRRect fRRects[kNumRRects];
typedef GM INHERITED;
diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp
index ee87f09..64a42b9 100644
--- a/gm/samplerstress.cpp
+++ b/gm/samplerstress.cpp
@@ -42,8 +42,8 @@
return;
}
- static const int xSize = 16;
- static const int ySize = 16;
+ constexpr int xSize = 16;
+ constexpr int ySize = 16;
fTexture.allocN32Pixels(xSize, ySize);
SkPMColor* addr = fTexture.getAddr32(0, 0);
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index f794481..7d54e77 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -37,11 +37,11 @@
const SkScalar* fPos;
};
-static const SkColor gColors[] = {
+constexpr SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
};
-static const GradData gGradData[] = {
+constexpr GradData gGradData[] = {
{ 2, gColors, nullptr },
{ 5, gColors, nullptr },
};
@@ -79,7 +79,7 @@
typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
-static const GradMaker gGradMakers[] = {
+constexpr GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Conical
};
@@ -119,9 +119,9 @@
SkShader::kMirror_TileMode
};
- static const int gradCount = SK_ARRAY_COUNT(gGradData) *
+ constexpr int gradCount = SK_ARRAY_COUNT(gGradData) *
SK_ARRAY_COUNT(gGradMakers);
- static const int bmpCount = SK_ARRAY_COUNT(tileModes) *
+ constexpr int bmpCount = SK_ARRAY_COUNT(tileModes) *
SK_ARRAY_COUNT(tileModes);
sk_sp<SkShader> shaders[gradCount + bmpCount];
@@ -158,9 +158,9 @@
false);
path.close();
- static const int testsPerCol = 8;
- static const int rowHeight = 60;
- static const int colWidth = 300;
+ constexpr int testsPerCol = 8;
+ constexpr int rowHeight = 60;
+ constexpr int colWidth = 300;
canvas->save();
for (int s = 0; s < static_cast<int>(SK_ARRAY_COUNT(shaders)); s++) {
canvas->save();
diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp
index 2ec1952..6fd784a 100644
--- a/gm/shadertext2.cpp
+++ b/gm/shadertext2.cpp
@@ -15,11 +15,11 @@
SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(SkMin32(w, h));
- static const SkPoint kPts0[] = { { 0, 0 }, { s, s } };
- static const SkPoint kPts1[] = { { s, 0 }, { 0, s } };
- static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
- static const SkColor kColors0[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF };
- static const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF };
+ const SkPoint kPts0[] = { { 0, 0 }, { s, s } };
+ const SkPoint kPts1[] = { { s, 0 }, { 0, s } };
+ const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
+ const SkColor kColors0[] = {0x40FF00FF, 0xF0FFFF00, 0x4000FFFF };
+ const SkColor kColors1[] = {0xF0FF00FF, 0x80FFFF00, 0xF000FFFF };
SkPaint paint;
@@ -41,9 +41,9 @@
DEF_SIMPLE_GM_BG(shadertext2, canvas, 1800, 900,
sk_tool_utils::color_to_565(0xFFDDDDDD)) {
- static const char kText[] = "SKIA";
- static const int kTextLen = SK_ARRAY_COUNT(kText) - 1;
- static const int kPointSize = 55;
+ constexpr char kText[] = "SKIA";
+ constexpr int kTextLen = SK_ARRAY_COUNT(kText) - 1;
+ constexpr int kPointSize = 55;
SkTDArray<LabeledMatrix> matrices;
matrices.append()->fMatrix.reset();
@@ -105,7 +105,7 @@
canvas->drawBitmap(bmp, 0, 0);
canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f);
- static const char kLabelLabel[] = "localM / canvasM";
+ constexpr char kLabelLabel[] = "localM / canvasM";
canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint);
canvas->translate(0, 15.f);
@@ -172,8 +172,8 @@
if (0 == s) {
canvas->drawLine(0.f, -kPadY, 0.f, columnH + kPadY, outlinePaint);
canvas->translate(kPadX / 2, 0.f);
- static const char kFillLabel[] = "Filled";
- static const char kStrokeLabel[] = "Stroked";
+ constexpr char kFillLabel[] = "Filled";
+ constexpr char kStrokeLabel[] = "Stroked";
SkScalar y = columnH + kPadY / 2;
SkScalar fillX = -outlinePaint.measureText(kFillLabel, strlen(kFillLabel)) - kPadX;
SkScalar strokeX = kPadX;
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp
index 9f3301e..b811ac9 100644
--- a/gm/shadertext3.cpp
+++ b/gm/shadertext3.cpp
@@ -17,11 +17,11 @@
SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(SkMin32(w, h));
- static const SkPoint kPts0[] = { { 0, 0 }, { s, s } };
- static const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } };
- static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
- static const SkColor kColors0[] = {0x80F00080, 0xF0F08000, 0x800080F0 };
- static const SkColor kColors1[] = {0xF08000F0, 0x8080F000, 0xF000F080 };
+ const SkPoint kPts0[] = { { 0, 0 }, { s, s } };
+ const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } };
+ const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
+ const SkColor kColors0[] = {0x80F00080, 0xF0F08000, 0x800080F0 };
+ const SkColor kColors1[] = {0xF08000F0, 0x8080F000, 0xF000F080 };
SkPaint paint;
@@ -41,9 +41,9 @@
const char* fLabel;
};
-static const char kText[] = "B";
-static const int kTextLen = SK_ARRAY_COUNT(kText) - 1;
-static const int kPointSize = 300;
+constexpr char kText[] = "B";
+constexpr int kTextLen = SK_ARRAY_COUNT(kText) - 1;
+constexpr int kPointSize = 300;
class ShaderText3GM : public GM {
public:
@@ -83,7 +83,7 @@
// draw glyphs scaled up
canvas->scale(2.f, 2.f);
- static const SkShader::TileMode kTileModes[] = {
+ constexpr SkShader::TileMode kTileModes[] = {
SkShader::kRepeat_TileMode,
SkShader::kMirror_TileMode,
};
diff --git a/gm/shadowmaps.cpp b/gm/shadowmaps.cpp
index d8682ce..acbf275 100644
--- a/gm/shadowmaps.cpp
+++ b/gm/shadowmaps.cpp
@@ -84,8 +84,8 @@
}
protected:
- static const int kWidth = 400;
- static const int kHeight = 400;
+ constexpr int kWidth = 400;
+ constexpr int kHeight = 400;
SkString onShortName() override {
return SkString("shadowmaps");
diff --git a/gm/shadows.cpp b/gm/shadows.cpp
index fcaeeb7..e642070 100644
--- a/gm/shadows.cpp
+++ b/gm/shadows.cpp
@@ -87,7 +87,7 @@
SkBlurDrawLooper::kHighQuality_BlurFlag),
};
- static const struct {
+ constexpr struct {
SkColor fColor;
SkScalar fStrokeWidth;
} gRec[] = {
diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp
index 3b10c47..b5aa3ae 100644
--- a/gm/simpleaaclip.cpp
+++ b/gm/simpleaaclip.cpp
@@ -141,7 +141,7 @@
void onDraw(SkCanvas* canvas) override {
- static const struct {
+ const struct {
SkColor fColor;
const char* fName;
SkRegion::Op fOp;
diff --git a/gm/smallpaths.cpp b/gm/smallpaths.cpp
index 926b2a2..ddbb60d 100644
--- a/gm/smallpaths.cpp
+++ b/gm/smallpaths.cpp
@@ -11,7 +11,7 @@
typedef SkScalar (*MakePathProc)(SkPath*);
static SkScalar make_triangle(SkPath* path) {
- static const int gCoord[] = {
+ constexpr int gCoord[] = {
10, 20, 15, 5, 30, 30
};
path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1]));
@@ -154,7 +154,7 @@
return SkIntToScalar(70);
}
-static const MakePathProc gProcs[] = {
+constexpr MakePathProc gProcs[] = {
make_triangle,
make_rect,
make_oval,
@@ -167,7 +167,7 @@
make_battery2
};
-static const SkScalar gWidths[] = {
+constexpr SkScalar gWidths[] = {
2.0f,
3.0f,
4.0f,
@@ -180,7 +180,7 @@
0.0f,
};
-static const SkScalar gMiters[] = {
+constexpr SkScalar gMiters[] = {
2.0f,
3.0f,
3.0f,
diff --git a/gm/stringart.cpp b/gm/stringart.cpp
index 1da8757..e21e8f2 100644
--- a/gm/stringart.cpp
+++ b/gm/stringart.cpp
@@ -12,10 +12,10 @@
// Reproduces https://code.google.com/p/chromium/issues/detail?id=279014
-static const int kWidth = 440;
-static const int kHeight = 440;
-static const SkScalar kAngle = 0.305f;
-static const int kMaxNumSteps = 140;
+constexpr int kWidth = 440;
+constexpr int kHeight = 440;
+constexpr SkScalar kAngle = 0.305f;
+constexpr int kMaxNumSteps = 140;
// Renders a string art shape.
// The particular shape rendered can be controlled by adjusting kAngle, from 0 to 1
@@ -61,7 +61,7 @@
}
bool onAnimate(const SkAnimTimer& timer) override {
- static const SkScalar kDesiredDurationSecs = 3.0f;
+ constexpr SkScalar kDesiredDurationSecs = 3.0f;
// Make the animation ping-pong back and forth but start in the fully drawn state
SkScalar fraction = 1.0f - timer.scaled(2.0f/kDesiredDurationSecs, 2.0f);
diff --git a/gm/stroke_rect_shader.cpp b/gm/stroke_rect_shader.cpp
index 0eb09e9..1826f62 100644
--- a/gm/stroke_rect_shader.cpp
+++ b/gm/stroke_rect_shader.cpp
@@ -14,9 +14,9 @@
// bevel, miter, miter-limited-to-bevel, round
// and as a hairline.
DEF_SIMPLE_GM(stroke_rect_shader, canvas, 690, 300) {
- static constexpr SkRect kRect {0, 0, 100, 100};
- static constexpr SkPoint kPts[] {{kRect.fLeft, kRect.fTop}, {kRect.fRight, kRect.fBottom}};
- static constexpr SkColor kColors[] {SK_ColorRED, SK_ColorBLUE};
+ constexpr SkRect kRect {0, 0, 100, 100};
+ constexpr SkPoint kPts[] {{kRect.fLeft, kRect.fTop}, {kRect.fRight, kRect.fBottom}};
+ constexpr SkColor kColors[] {SK_ColorRED, SK_ColorBLUE};
SkPaint paint;
sk_sp<SkShader> shader = SkGradientShader::MakeLinear(kPts, kColors, nullptr, 2,
SkShader::kClamp_TileMode);
@@ -25,12 +25,12 @@
// Do a large initial translate so that local coords disagree with device coords significantly
// for the first rect drawn.
canvas->translate(kRect.centerX(), kRect.centerY());
- static constexpr SkScalar kPad = 20;
+ constexpr SkScalar kPad = 20;
for (auto aa : {false, true}) {
paint.setAntiAlias(aa);
canvas->save();
- static constexpr SkScalar kStrokeWidth = 10;
+ constexpr SkScalar kStrokeWidth = 10;
paint.setStrokeWidth(kStrokeWidth);
paint.setStrokeJoin(SkPaint::kBevel_Join);
diff --git a/gm/strokedlines.cpp b/gm/strokedlines.cpp
index f0eb6b4..7bcb3fb 100644
--- a/gm/strokedlines.cpp
+++ b/gm/strokedlines.cpp
@@ -13,12 +13,12 @@
#include "SkPath.h"
#include "SkPoint3.h"
-static const int kNumColumns = 6;
-static const int kNumRows = 8;
-static const int kRadius = 40; // radius of the snowflake
-static const int kPad = 5; // padding on both sides of the snowflake
-static const int kNumSpokes = 6;
-static const SkScalar kStrokeWidth = 5.0f;
+constexpr int kNumColumns = 6;
+constexpr int kNumRows = 8;
+constexpr int kRadius = 40; // radius of the snowflake
+constexpr int kPad = 5; // padding on both sides of the snowflake
+constexpr int kNumSpokes = 6;
+constexpr SkScalar kStrokeWidth = 5.0f;
static void draw_fins(SkCanvas* canvas, const SkPoint& offset, float angle, const SkPaint& paint) {
SkScalar cos, sin;
diff --git a/gm/strokerect.cpp b/gm/strokerect.cpp
index 7b14854..1d5d803 100644
--- a/gm/strokerect.cpp
+++ b/gm/strokerect.cpp
@@ -63,13 +63,13 @@
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(STROKE_WIDTH);
- static const SkPaint::Join gJoins[] = {
+ constexpr SkPaint::Join gJoins[] = {
SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join
};
- static const SkScalar W = 80;
- static const SkScalar H = 80;
- static const SkRect gRects[] = {
+ constexpr SkScalar W = 80;
+ constexpr SkScalar H = 80;
+ constexpr SkRect gRects[] = {
{ 0, 0, W, H },
{ W, 0, 0, H },
{ 0, H, W, 0 },
diff --git a/gm/strokerects.cpp b/gm/strokerects.cpp
index afd41b2..fc5743e 100644
--- a/gm/strokerects.cpp
+++ b/gm/strokerects.cpp
@@ -16,8 +16,8 @@
#define H 400
#define N 100
-static const SkScalar SW = SkIntToScalar(W);
-static const SkScalar SH = SkIntToScalar(H);
+constexpr SkScalar SW = SkIntToScalar(W);
+constexpr SkScalar SH = SkIntToScalar(H);
class StrokeRectsGM : public GM {
public:
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index afbe5ee..218f845 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -15,8 +15,8 @@
#define H 400
#define N 50
-static const SkScalar SW = SkIntToScalar(W);
-static const SkScalar SH = SkIntToScalar(H);
+constexpr SkScalar SW = SkIntToScalar(W);
+constexpr SkScalar SH = SkIntToScalar(H);
static void rnd_rect(SkRect* r, SkPaint* paint, SkRandom& rand) {
SkScalar x = rand.nextUScalar1() * W;
diff --git a/gm/tallstretchedbitmaps.cpp b/gm/tallstretchedbitmaps.cpp
index f22f2d2..b70ae3d 100644
--- a/gm/tallstretchedbitmaps.cpp
+++ b/gm/tallstretchedbitmaps.cpp
@@ -12,12 +12,12 @@
#include "SkRandom.h"
int make_bm(SkBitmap* bm, int height) {
- static const int kRadius = 22;
- static const int kMargin = 8;
- static const SkScalar kStartAngle = 0;
- static const SkScalar kDAngle = 25;
- static const SkScalar kSweep = 320;
- static const SkScalar kThickness = 8;
+ constexpr int kRadius = 22;
+ constexpr int kMargin = 8;
+ constexpr SkScalar kStartAngle = 0;
+ constexpr SkScalar kDAngle = 25;
+ constexpr SkScalar kSweep = 320;
+ constexpr SkScalar kThickness = 8;
int count = (height / (2 * kRadius + kMargin));
height = count * (2 * kRadius + kMargin);
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 0c23749..5fb9083 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -17,7 +17,7 @@
#include "effects/GrPorterDuffXferProcessor.h"
#include "effects/GrSimpleTextureEffect.h"
-static const int S = 200;
+constexpr int S = 200;
DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDrawContext();
@@ -32,13 +32,13 @@
}
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
- static const int stride = 2 * S;
- static const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40);
- static const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff);
- static const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00);
- static const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80);
- static const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00);
- static const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00);
+ constexpr int stride = 2 * S;
+ const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40);
+ const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff);
+ const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00);
+ const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80);
+ const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00);
+ const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00);
for (int i = 0; i < 2; ++i) {
int offset = 0;
// fill upper-left
diff --git a/gm/textblobblockreordering.cpp b/gm/textblobblockreordering.cpp
index 31ba3c7..ea90308 100644
--- a/gm/textblobblockreordering.cpp
+++ b/gm/textblobblockreordering.cpp
@@ -79,8 +79,8 @@
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 275;
- static const int kHeight = 200;
+ static constexpr int kWidth = 275;
+ static constexpr int kHeight = 200;
typedef GM INHERITED;
};
diff --git a/gm/textblobcolortrans.cpp b/gm/textblobcolortrans.cpp
index 0e4e0ff..1e7a666 100644
--- a/gm/textblobcolortrans.cpp
+++ b/gm/textblobcolortrans.cpp
@@ -89,8 +89,8 @@
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 675;
- static const int kHeight = 1600;
+ static constexpr int kWidth = 675;
+ static constexpr int kHeight = 1600;
typedef GM INHERITED;
};
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
index 5e3f0d1..9e33e95 100644
--- a/gm/textblobgeometrychange.cpp
+++ b/gm/textblobgeometrychange.cpp
@@ -65,8 +65,8 @@
}
private:
- static const int kWidth = 200;
- static const int kHeight = 200;
+ static constexpr int kWidth = 200;
+ static constexpr int kHeight = 200;
typedef GM INHERITED;
};
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index 066546e..752fd54 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -20,8 +20,8 @@
namespace skiagm {
-static const int kWidth = 1250;
-static const int kHeight = 700;
+constexpr int kWidth = 1250;
+constexpr int kHeight = 700;
// Unlike the variant in sk_tool_utils, this version positions the glyphs on a diagonal
static void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint,
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index 4e3f0ea..6ce0eaf 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -118,8 +118,8 @@
SkRect bounds = fBlob->bounds();
- static const int kPadX = SkScalarFloorToInt(bounds.width() / 3);
- static const int kPadY = SkScalarFloorToInt(bounds.height() / 3);
+ const int kPadX = SkScalarFloorToInt(bounds.width() / 3);
+ const int kPadY = SkScalarFloorToInt(bounds.height() / 3);
int rowCount = 0;
canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY));
@@ -132,13 +132,13 @@
}
paint.setAntiAlias(false);
- static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(8));
+ const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(8));
// setup blur paint
SkPaint blurPaint(paint);
blurPaint.setColor(sk_tool_utils::color_to_565(SK_ColorBLACK));
blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
-
+
for (int i = 0; i < 4; i++) {
canvas->save();
switch (i % 2) {
@@ -179,8 +179,8 @@
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 2100;
- static const int kHeight = 1900;
+ static constexpr int kWidth = 2100;
+ static constexpr int kHeight = 1900;
bool fUseDFT;
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index 2e8249f..583f4fc 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -138,8 +138,8 @@
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 2000;
- static const int kHeight = 1600;
+ static constexpr int kWidth = 2000;
+ static constexpr int kHeight = 1600;
typedef GM INHERITED;
};
diff --git a/gm/textblobshader.cpp b/gm/textblobshader.cpp
index 6a8fa49..bb0e03c 100644
--- a/gm/textblobshader.cpp
+++ b/gm/textblobshader.cpp
@@ -89,8 +89,8 @@
p.setShader(fShader);
SkISize sz = this->onISize();
- static const int kXCount = 4;
- static const int kYCount = 3;
+ constexpr int kXCount = 4;
+ constexpr int kYCount = 3;
for (int i = 0; i < kXCount; ++i) {
for (int j = 0; j < kYCount; ++j) {
canvas->drawTextBlob(fBlob,
diff --git a/gm/textblobtransforms.cpp b/gm/textblobtransforms.cpp
index eed1809..537ddb1 100644
--- a/gm/textblobtransforms.cpp
+++ b/gm/textblobtransforms.cpp
@@ -160,8 +160,8 @@
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 1000;
- static const int kHeight = 1200;
+ static constexpr int kWidth = 1000;
+ static constexpr int kHeight = 1200;
typedef GM INHERITED;
};
diff --git a/gm/textblobuseaftergpufree.cpp b/gm/textblobuseaftergpufree.cpp
index 61df533..c104e9b 100644
--- a/gm/textblobuseaftergpufree.cpp
+++ b/gm/textblobuseaftergpufree.cpp
@@ -62,8 +62,8 @@
}
private:
- static const int kWidth = 200;
- static const int kHeight = 200;
+ static constexpr int kWidth = 200;
+ static constexpr int kHeight = 200;
typedef GM INHERITED;
};
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index f0d2752..c89b4e0 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -146,7 +146,7 @@
typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
-static const raster_proc gRastProcs[] = {
+constexpr raster_proc gRastProcs[] = {
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
};
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index ba574b6..2dd340e 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -138,19 +138,15 @@
}
private:
- static const SkScalar kDrawPad;
- static const SkScalar kTestPad;
- static const int kTargetWidth = 100;
- static const int kTargetHeight = 100;
+ static constexpr SkScalar kDrawPad = 10.f;
+ static constexpr SkScalar kTestPad = 10.f;;
+ static constexpr int kTargetWidth = 100;
+ static constexpr int kTargetHeight = 100;
SkBitmap fBmp;
typedef GM INHERITED;
};
-// Windows builds did not like SkScalar initialization in class :(
-const SkScalar TextureDomainEffect::kDrawPad = 10.f;
-const SkScalar TextureDomainEffect::kTestPad = 10.f;
-
DEF_GM(return new TextureDomainEffect;)
}
diff --git a/gm/thinrects.cpp b/gm/thinrects.cpp
index a25176c..999028c 100644
--- a/gm/thinrects.cpp
+++ b/gm/thinrects.cpp
@@ -65,7 +65,7 @@
private:
static void DrawVertRects(SkCanvas* canvas, const SkPaint& p) {
- static const SkRect vertRects[] = {
+ constexpr SkRect vertRects[] = {
{ 1, 1, 5.0f, 21 }, // 4 pix wide
{ 8, 1, 10.0f, 21 }, // 2 pix wide
{ 13, 1, 14.0f, 21 }, // 1 pix wide
@@ -81,7 +81,7 @@
}
static void DrawHorizRects(SkCanvas* canvas, const SkPaint& p) {
- static const SkRect horizRects[] = {
+ constexpr SkRect horizRects[] = {
{ 1, 1, 21, 5.0f }, // 4 pix high
{ 1, 8, 21, 10.0f }, // 2 pix high
{ 1, 13, 21, 14.0f }, // 1 pix high
@@ -97,7 +97,7 @@
}
static void DrawSquares(SkCanvas* canvas, const SkPaint& p) {
- static const SkRect squares[] = {
+ constexpr SkRect squares[] = {
{ 1, 1, 5.0f, 5.0f }, // 4 pix
{ 8, 8, 10.0f, 10.0f }, // 2 pix
{ 13, 13, 14.0f, 14.0f }, // 1 pix
diff --git a/gm/thinstrokedrects.cpp b/gm/thinstrokedrects.cpp
index 73e1f529..a4f2f13 100644
--- a/gm/thinstrokedrects.cpp
+++ b/gm/thinstrokedrects.cpp
@@ -32,10 +32,10 @@
paint.setStyle(SkPaint::kStroke_Style);
paint.setAntiAlias(true);
- static const SkRect rect = { 0, 0, 10, 10 };
- static const SkRect rect2 = { 0, 0, 20, 20 };
+ constexpr SkRect rect = { 0, 0, 10, 10 };
+ constexpr SkRect rect2 = { 0, 0, 20, 20 };
- static const SkScalar gStrokeWidths[] = {
+ constexpr SkScalar gStrokeWidths[] = {
4, 2, 1, 0.5f, 0.25f, 0.125f, 0
};
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index c944fe7..b1f6d14 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -39,7 +39,7 @@
paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
}
-static const SkColorType gColorTypes[] = {
+constexpr SkColorType gColorTypes[] = {
kN32_SkColorType,
kRGB_565_SkColorType,
};
@@ -82,13 +82,14 @@
SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
- static const char* gConfigNames[] = { "8888", "565", "4444" };
+ const char* gConfigNames[] = { "8888", "565", "4444" };
- static const bool gFilters[] = { false, true };
- static const char* gFilterNames[] = { "point", "bilinear" };
+ constexpr bool gFilters[] = { false, true };
+ static const char* gFilterNames[] = { "point", "bilinear" };
- static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
- static const char* gModeNames[] = { "C", "R", "M" };
+ constexpr SkShader::TileMode gModes[] = {
+ SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
+ static const char* gModeNames[] = { "C", "R", "M" };
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(10);
@@ -153,8 +154,8 @@
typedef skiagm::GM INHERITED;
};
-static const int gWidth = 32;
-static const int gHeight = 32;
+constexpr int gWidth = 32;
+constexpr int gHeight = 32;
static sk_sp<SkShader> make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm;
@@ -205,10 +206,10 @@
const SkScalar h = SkIntToScalar(gHeight);
SkRect r = { -w, -h, w*2, h*2 };
- static const SkShader::TileMode gModes[] = {
+ constexpr SkShader::TileMode gModes[] = {
SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode
};
- static const char* gModeNames[] = {
+ const char* gModeNames[] = {
"Clamp", "Repeat", "Mirror"
};
diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp
index 897c829..580931f 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -38,7 +38,7 @@
paint->setFilterQuality(filter_level);
}
-static const SkColorType gColorTypes[] = {
+constexpr SkColorType gColorTypes[] = {
kN32_SkColorType,
kRGB_565_SkColorType,
};
@@ -81,17 +81,18 @@
SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
- static const char* gColorTypeNames[] = { "8888" , "565", "4444" };
+ const char* gColorTypeNames[] = { "8888" , "565", "4444" };
- static const SkFilterQuality gFilterQualitys[] =
+ constexpr SkFilterQuality gFilterQualitys[] =
{ kNone_SkFilterQuality,
kLow_SkFilterQuality,
kMedium_SkFilterQuality,
kHigh_SkFilterQuality };
- static const char* gFilterNames[] = { "None", "Low", "Medium", "High" };
+ const char* gFilterNames[] = { "None", "Low", "Medium", "High" };
- static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
- static const char* gModeNames[] = { "C", "R", "M" };
+ constexpr SkShader::TileMode gModes[] = {
+ SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode };
+ const char* gModeNames[] = { "C", "R", "M" };
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(10)/scale;
@@ -156,8 +157,8 @@
typedef skiagm::GM INHERITED;
};
-static const int gWidth = 32;
-static const int gHeight = 32;
+constexpr int gWidth = 32;
+constexpr int gHeight = 32;
static sk_sp<SkShader> make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm;
@@ -209,10 +210,10 @@
const SkScalar h = SkIntToScalar(gHeight);
SkRect r = { -w, -h, w*2, h*2 };
- static const SkShader::TileMode gModes[] = {
+ constexpr SkShader::TileMode gModes[] = {
SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode
};
- static const char* gModeNames[] = {
+ const char* gModeNames[] = {
"Clamp", "Repeat", "Mirror"
};
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index d22a276..8303b37 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -71,7 +71,7 @@
canvas->drawPosText(glyphs, glyphCount * sizeof(uint16_t), pos, glyphPaint);
}
-static const struct {
+constexpr struct {
const char* fName;
SkTypeface::Style fStyle;
} gFaceStyles[] = {
@@ -89,7 +89,7 @@
{ "monospace", SkTypeface::kBoldItalic },
};
-static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
+constexpr int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
class TypefaceStylesGM : public skiagm::GM {
sk_sp<SkTypeface> fFaces[gFaceStylesCount];
diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp
index e33c40b..b17bb70 100644
--- a/gm/variedtext.cpp
+++ b/gm/variedtext.cpp
@@ -72,8 +72,8 @@
fColors[i] |= 0xFF000000;
fColors[i] = sk_tool_utils::color_to_565(fColors[i]);
- static const SkScalar kMinPtSize = 8.f;
- static const SkScalar kMaxPtSize = 32.f;
+ constexpr SkScalar kMinPtSize = 8.f;
+ constexpr SkScalar kMaxPtSize = 32.f;
fPtSizes[i] = random.nextRangeScalar(kMinPtSize, kMaxPtSize);
@@ -134,9 +134,9 @@
bool runAsBench() const override { return true; }
private:
- static const int kCnt = 30;
- static const int kMinLength = 15;
- static const int kMaxLength = 40;
+ static constexpr int kCnt = 30;
+ static constexpr int kMinLength = 15;
+ static constexpr int kMaxLength = 40;
bool fEffectiveClip;
bool fLCD;
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 978d9e6..2d6e37d 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -79,7 +79,7 @@
void onDraw(SkCanvas* canvas) override {
// start with the center of a 3x3 grid
- static const uint16_t fan[] = {
+ constexpr uint16_t fan[] = {
4,
0, 1, 2, 5, 8, 7, 6, 3, 0
};
diff --git a/gm/verttext.cpp b/gm/verttext.cpp
index 37cf37c..700fb25 100644
--- a/gm/verttext.cpp
+++ b/gm/verttext.cpp
@@ -13,17 +13,17 @@
namespace skiagm {
#define TEXT_SIZE 48
-static const char gText[] = "Hello";
+constexpr char gText[] = "Hello";
//Before shaping
-//static const char gText[] = "「テスト。」";
-//static const char gText[] = {0xE3,0x80,0x8C, 0xE3,0x83,0x86, 0xE3,0x82,0xB9, 0xE3,0x83,0x88, 0xE3,0x80,0x82, 0xE3,0x80,0x8D, 0x0};
+//constexpr char gText[] = "「テスト。」";
+//constexpr char gText[] = {0xE3,0x80,0x8C, 0xE3,0x83,0x86, 0xE3,0x82,0xB9, 0xE3,0x83,0x88, 0xE3,0x80,0x82, 0xE3,0x80,0x8D, 0x0};
//After shaping
-//static const char gText[] = "﹁テスト︒﹂";
-//static const char gText[] = {0xEF,0xB9,0x81, 0xE3,0x83,0x86, 0xE3,0x82,0xB9, 0xE3,0x83,0x88, 0xEF,0xB8,0x92, 0xEF,0xB9,0x82, 0x0};
+//constexpr char gText[] = "﹁テスト︒﹂";
+//constexpr char gText[] = {0xEF,0xB9,0x81, 0xE3,0x83,0x86, 0xE3,0x82,0xB9, 0xE3,0x83,0x88, 0xEF,0xB8,0x92, 0xEF,0xB9,0x82, 0x0};
-static const size_t gLen = sizeof(gText) - sizeof(gText[0]);
+constexpr size_t gLen = sizeof(gText) - sizeof(gText[0]);
class VertTextGM : public GM {
public:
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index ee6822a..0ff0ea9 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -148,7 +148,7 @@
y += fBitmap.height() + MARGIN;
}
// Test cropping
- static const size_t nbSamples = 3;
+ constexpr size_t nbSamples = 3;
SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode,
SkXfermode::kSrcOver_Mode,
SkXfermode::kPlus_Mode};
diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp
index b0d6ca3..6f7d054 100644
--- a/gm/xfermodes2.cpp
+++ b/gm/xfermodes2.cpp
@@ -84,7 +84,7 @@
private:
void onOnceBeforeDraw() override {
- static const uint32_t kCheckData[] = {
+ const uint32_t kCheckData[] = {
SkPackARGB32(0xFF, 0x42, 0x41, 0x42),
SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp
index 642175e..300b78f 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -48,13 +48,13 @@
labelP.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&labelP);
- static const SkColor kSolidColors[] = {
+ constexpr SkColor kSolidColors[] = {
SK_ColorTRANSPARENT,
SK_ColorBLUE,
0x80808000
};
- static const SkColor kBmpAlphas[] = {
+ constexpr SkColor kBmpAlphas[] = {
0xff,
0x80,
};
@@ -63,7 +63,7 @@
int test = 0;
int x = 0, y = 0;
- static const struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes[] = {
+ constexpr struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes[] = {
{SkPaint::kFill_Style, 0},
{SkPaint::kStroke_Style, SkIntToScalar(kSize) / 2},
};
@@ -173,7 +173,7 @@
}
void onOnceBeforeDraw() override {
- static const uint32_t kCheckData[] = {
+ const uint32_t kCheckData[] = {
SkPackARGB32(0xFF, 0x42, 0x41, 0x42),
SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 0be3008..d064cf3 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -94,9 +94,9 @@
return;
}
- static const SkScalar kDrawPad = 10.f;
- static const SkScalar kTestPad = 10.f;
- static const SkScalar kColorSpaceOffset = 36.f;
+ constexpr SkScalar kDrawPad = 10.f;
+ constexpr SkScalar kTestPad = 10.f;
+ constexpr SkScalar kColorSpaceOffset = 36.f;
SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}};
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace;
@@ -211,9 +211,9 @@
return;
}
- static const SkScalar kDrawPad = 10.f;
- static const SkScalar kTestPad = 10.f;
- static const SkScalar kColorSpaceOffset = 36.f;
+ constexpr SkScalar kDrawPad = 10.f;
+ constexpr SkScalar kTestPad = 10.f;
+ constexpr SkScalar kColorSpaceOffset = 36.f;
SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}};
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {