aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/Sk4px.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-05-22 17:18:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-22 17:18:21 -0700
commitaa999cb952753d373c03befa7fce8c4700ef9308 (patch)
tree187820613cb390da6f4ce7aca7e4da08eab31f69 /src/core/Sk4px.h
parentd23a395d519835f78630aaea3f2a2c30ecdffe87 (diff)
Everyone gets a namespace {}.
If we include Sk4px.h, SkPMFloat.h, or SkNx.h into files with different SIMD flags, that could cause different definitions of the same method. Normally that's moot, because all the code inlines, but in Debug it tends not to. So in Debug, the linker picks one definition for us. That breaks _someone_. Wrapping everything in a namespace {} keeps the definitions separate. Tested locally, it fixes this bug. BUG=skia:3861 This code is not yet enabled in Chrome, so shouldn't affect the roll. NOTREECHECKS=true Review URL: https://codereview.chromium.org/1154523004
Diffstat (limited to 'src/core/Sk4px.h')
-rw-r--r--src/core/Sk4px.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h
index 48e09e1c92..8fb546a406 100644
--- a/src/core/Sk4px.h
+++ b/src/core/Sk4px.h
@@ -11,6 +11,13 @@
#include "SkNx.h"
#include "SkColor.h"
+// This file may be included multiple times by .cpp files with different flags, leading
+// to different definitions. Usually that doesn't matter because it's all inlined, but
+// in Debug modes the compilers may not inline everything. So wrap everything in an
+// anonymous namespace to give each includer their own silo of this code (or the linker
+// will probably pick one randomly for us, which is rarely correct).
+namespace {
+
// 1, 2 or 4 SkPMColors, generally vectorized.
class Sk4px : public Sk16b {
public:
@@ -171,6 +178,8 @@ private:
typedef Sk16b INHERITED;
};
+} // namespace
+
#ifdef SKNX_NO_SIMD
#include "../opts/Sk4px_none.h"
#else