Make class members that are static constexpr also be inline.
This is in prep for compiling with -std=c++14 and -Wno-c++17-extensions
when building with clang. Chrome has encountered problems with
third_party headers that are included both in Skia and other Chrome
sources that produce different code based on whether preprocessor macros
indicate a C++14 or C++17 compilation.
In C++17 they are already inline implicitly. When compiling with C++14
we can get linker errors unless they're explicitly inlined or defined
outside the class. With -Wno-c++17-extensions we can explicitly inline
them in the C++14 build because the warning that would be generated
about using a C++17 language extension is suppressed.
We cannot do this in public headers because we support compiling with
C++14 without suppressing the C++17 language extension warnings.
Bug: chromium:1257145
Change-Id: Iaf5f4c62a398f98dd4ca9b7dfb86f2d5cab21d66
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457498
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/samplecode/Sample3D.cpp b/samplecode/Sample3D.cpp
index 4ddc15d..d5c6bcf 100644
--- a/samplecode/Sample3D.cpp
+++ b/samplecode/Sample3D.cpp
@@ -176,8 +176,8 @@
SkScalar fAngleSpeed = 0,
fAngleSign = 1;
- static constexpr double kSlowDown = 4;
- static constexpr SkScalar kMaxSpeed = 16;
+ inline static constexpr double kSlowDown = 4;
+ inline static constexpr SkScalar kMaxSpeed = 16;
public:
void update(SkV3 axis, SkScalar angle) {
diff --git a/samplecode/SampleChart.cpp b/samplecode/SampleChart.cpp
index 46e4dec..37b9d06 100644
--- a/samplecode/SampleChart.cpp
+++ b/samplecode/SampleChart.cpp
@@ -79,9 +79,9 @@
// A set of scrolling line plots with the area between each plot filled. Stresses out GPU path
// filling
class ChartView : public Sample {
- static constexpr int kNumGraphs = 5;
- static constexpr int kPixelsPerTick = 3;
- static constexpr int kShiftPerFrame = 1;
+ inline static constexpr int kNumGraphs = 5;
+ inline static constexpr int kPixelsPerTick = 3;
+ inline static constexpr int kShiftPerFrame = 1;
int fShift = 0;
SkISize fSize = {-1, -1};
SkTDArray<SkScalar> fData[kNumGraphs];
diff --git a/samplecode/SampleChineseFling.cpp b/samplecode/SampleChineseFling.cpp
index 081433c..0e62725 100644
--- a/samplecode/SampleChineseFling.cpp
+++ b/samplecode/SampleChineseFling.cpp
@@ -38,8 +38,8 @@
}
class ChineseFlingView : public Sample {
- static constexpr int kNumBlobs = 200;
- static constexpr int kWordLength = 16;
+ inline static constexpr int kNumBlobs = 200;
+ inline static constexpr int kWordLength = 16;
sk_sp<SkTypeface> fTypeface;
SkFontMetrics fMetrics;
@@ -103,8 +103,8 @@
};
class ChineseZoomView : public Sample {
- static constexpr int kNumBlobs = 8;
- static constexpr int kParagraphLength = 175;
+ inline static constexpr int kNumBlobs = 8;
+ inline static constexpr int kParagraphLength = 175;
bool fAfterFirstFrame = false;
sk_sp<SkTypeface> fTypeface;
diff --git a/samplecode/SampleCowboy.cpp b/samplecode/SampleCowboy.cpp
index 9c9a20a..2ed47cb 100644
--- a/samplecode/SampleCowboy.cpp
+++ b/samplecode/SampleCowboy.cpp
@@ -22,7 +22,7 @@
namespace {
class AnimatedSVGSample : public Sample {
- static constexpr auto kAnimationIterations = 5;
+ inline static constexpr auto kAnimationIterations = 5;
enum State {
kZoomIn,
kScroll,
diff --git a/samplecode/SampleFlutterAnimate.cpp b/samplecode/SampleFlutterAnimate.cpp
index c823722..48198bf 100644
--- a/samplecode/SampleFlutterAnimate.cpp
+++ b/samplecode/SampleFlutterAnimate.cpp
@@ -74,7 +74,7 @@
}
}
- static constexpr double kDuration = 5.0;
+ inline static constexpr double kDuration = 5.0;
double fCurrTime;
double fResetTime;
SkRandom fRand;
@@ -86,7 +86,7 @@
SkScalar fEndRotation;
};
sk_sp<SkTypeface> fTypeface;
- static constexpr int kNumChars = 40;
+ inline static constexpr int kNumChars = 40;
AnimatedChar fChars[kNumChars];
using INHERITED = Sample;
diff --git a/samplecode/SampleSimpleStroker.cpp b/samplecode/SampleSimpleStroker.cpp
index 999b084..651d2ed 100644
--- a/samplecode/SampleSimpleStroker.cpp
+++ b/samplecode/SampleSimpleStroker.cpp
@@ -352,7 +352,7 @@
float fWidth = 175;
SkPaint fPtsPaint, fStrokePaint, fMirrorStrokePaint, fNewFillPaint, fHiddenPaint,
fSkeletonPaint;
- static constexpr int kN = 3;
+ inline static constexpr int kN = 3;
public:
SkPoint fPts[kN];
diff --git a/samplecode/SampleTextureUpload.cpp b/samplecode/SampleTextureUpload.cpp
index 4f0757e..933748c 100644
--- a/samplecode/SampleTextureUpload.cpp
+++ b/samplecode/SampleTextureUpload.cpp
@@ -17,9 +17,9 @@
* This sample exercises heavy texture updates and uploads.
*/
class TextureUploadSample : public Sample {
- static constexpr int kMinTileSize = 128;
- static constexpr int kMaxTileSize = 2048;
- static constexpr float kGridScale = 0.25f;
+ inline static constexpr int kMinTileSize = 128;
+ inline static constexpr int kMaxTileSize = 2048;
+ inline static constexpr float kGridScale = 0.25f;
bool fDrawTexturesToScreen = true;
int fTileSize = 256;
diff --git a/samplecode/SampleThinAA.cpp b/samplecode/SampleThinAA.cpp
index 452548d..5989deb 100644
--- a/samplecode/SampleThinAA.cpp
+++ b/samplecode/SampleThinAA.cpp
@@ -18,8 +18,8 @@
class ShapeRenderer : public SkRefCntBase {
public:
- static constexpr SkScalar kTileWidth = 20.f;
- static constexpr SkScalar kTileHeight = 20.f;
+ inline static constexpr SkScalar kTileWidth = 20.f;
+ inline static constexpr SkScalar kTileHeight = 20.f;
// Draw the shape, limited to kTileWidth x kTileHeight. It must apply the local subpixel (tx,
// ty) translation and rotation by angle. Prior to these transform adjustments, the SkCanvas
diff --git a/samplecode/SampleTiming.cpp b/samplecode/SampleTiming.cpp
index 9e237a0..d8e3216 100644
--- a/samplecode/SampleTiming.cpp
+++ b/samplecode/SampleTiming.cpp
@@ -12,8 +12,8 @@
#include <chrono>
struct TimingSample : public Sample {
- static constexpr int W = 24,
- H = 16;
+ inline static constexpr int W = 24,
+ H = 16;
sk_sp<SkImage> fImg;
SkString name() override { return SkString("Timing"); }
diff --git a/samplecode/SampleVariableWidthStroker.cpp b/samplecode/SampleVariableWidthStroker.cpp
index 7d9a352..65efa11 100644
--- a/samplecode/SampleVariableWidthStroker.cpp
+++ b/samplecode/SampleVariableWidthStroker.cpp
@@ -52,7 +52,7 @@
*/
class ScalarBezCurve {
public:
- static constexpr int kDegreeInvalid = -1;
+ inline static constexpr int kDegreeInvalid = -1;
/** Creates an empty curve with invalid degree. */
ScalarBezCurve() : fDegree(kDegreeInvalid) {}
@@ -1374,7 +1374,7 @@
float fWidth = 175;
SkPaint fPtsPaint, fStrokePaint, fNewFillPaint, fHiddenPaint, fSkeletonPaint,
fStrokePointsPaint;
- static constexpr int kNPts = 5;
+ inline static constexpr int kNPts = 5;
std::array<SkPoint, kNPts> fPathPts;
SkSize fWinSize;
SkVarWidthStroker::LengthMetric fLengthMetric;