diff options
author | mtklein <mtklein@google.com> | 2015-08-12 11:56:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 11:56:43 -0700 |
commit | 082e329887a8f1efe4e1020f0a0a6ea09961712d (patch) | |
tree | ef1018c577771f493bc499c341c701becb12b617 /src/core | |
parent | 147dc06f3bda762f948cfdcc3fc43cecbf32e826 (diff) |
Revert of Refactor to put SkXfermode_opts inside SK_OPTS_NS. (patchset #1 id:1 of https://codereview.chromium.org/1286093004/ )
Reason for revert:
Maybe causing test / gold problems?
Original issue's description:
> Refactor to put SkXfermode_opts inside SK_OPTS_NS.
>
> Without this refactor I was getting warnings previously about having code
> inside namespace SK_OPTS_NS (e.g. namespace sse2, namespace neon) referring to
> code inside an anonymous namespace (Sk4px, SkPMFloat, Sk4f, etc) [1].
>
> That low-level code was in an anonymous namespace to allow multiple independent
> copies of its methods to be instantiated without the linker getting confused /
> offended about violating the One Definition Rule. This was only happening in
> Debug mode where the methods were not being inlined.
>
> To fix this all, I've force-inlined the methods of the low-level code and
> removed the anonymous namespace.
>
> BUG=skia:4117
>
>
> [1] Here is what those errors looked like:
>
> In file included from ../../../../src/core/SkOpts.cpp:18:0:
> ../../../../src/opts/SkXfermode_opts.h:193:7: error: 'portable::Sk4pxXfermode' has a field 'portable::Sk4pxXfermode::fProc4' whose type uses the anonymous namespace [-Werror]
> class Sk4pxXfermode : public SkProcCoeffXfermode {
> ^
> ../../../../src/opts/SkXfermode_opts.h:193:7: error: 'portable::Sk4pxXfermode' has a field 'portable::Sk4pxXfermode::fAAProc4' whose type uses the anonymous namespace [-Werror]
> ../../../../src/opts/SkXfermode_opts.h:235:7: error: 'portable::SkPMFloatXfermode' has a field 'portable::SkPMFloatXfermode::fProcF' whose type uses the anonymous namespace [-Werror]
> class SkPMFloatXfermode : public SkProcCoeffXfermode {
> ^
> cc1plus: all warnings being treated as errors
>
> Committed: https://skia.googlesource.com/skia/+/b07bee3121680b53b98b780ac08d14d374dd4c6f
TBR=djsollen@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4117
Review URL: https://codereview.chromium.org/1284333002
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Sk4px.h | 9 | ||||
-rw-r--r-- | src/core/SkNx.h | 9 | ||||
-rw-r--r-- | src/core/SkOpts.cpp | 2 | ||||
-rw-r--r-- | src/core/SkPMFloat.h | 9 |
4 files changed, 28 insertions, 1 deletions
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h index 1c8ed0df71..ffde1af504 100644 --- a/src/core/Sk4px.h +++ b/src/core/Sk4px.h @@ -12,6 +12,13 @@ #include "SkColor.h" #include "SkColorPriv.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: @@ -219,6 +226,8 @@ private: typedef Sk16b INHERITED; }; +} // namespace + #ifdef SKNX_NO_SIMD #include "../opts/Sk4px_none.h" #else diff --git a/src/core/SkNx.h b/src/core/SkNx.h index 728e450ebb..84f9b69353 100644 --- a/src/core/SkNx.h +++ b/src/core/SkNx.h @@ -17,6 +17,13 @@ #include <math.h> #define REQUIRE(x) static_assert(x, #x) +// 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 { + // The default implementations just fall back on a pair of size N/2. template <int N, typename T> @@ -245,6 +252,8 @@ protected: T fVal; }; +} // namespace + // Include platform specific specializations if available. #ifndef SKNX_NO_SIMD #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp index 986c7cf6a8..2bfc1af899 100644 --- a/src/core/SkOpts.cpp +++ b/src/core/SkOpts.cpp @@ -37,7 +37,7 @@ namespace SkOpts { decltype(rsqrt) rsqrt = portable::rsqrt; decltype(memset16) memset16 = portable::memset16; decltype(memset32) memset32 = portable::memset32; - decltype(create_xfermode) create_xfermode = portable::create_xfermode; + decltype(create_xfermode) create_xfermode = SkCreate4pxXfermode; decltype(box_blur_xx) box_blur_xx = portable::box_blur_xx; decltype(box_blur_xy) box_blur_xy = portable::box_blur_xy; diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h index 7db689917e..f97f25c9c6 100644 --- a/src/core/SkPMFloat.h +++ b/src/core/SkPMFloat.h @@ -13,6 +13,13 @@ #include "SkColorPriv.h" #include "SkNx.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 { + // A pre-multiplied color storing each component in the same order as SkPMColor, // but as a float in the range [0, 1]. class SkPMFloat : public Sk4f { @@ -52,6 +59,8 @@ private: typedef Sk4f INHERITED; }; +} // namespace + #ifdef SKNX_NO_SIMD // Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _none is generic. #include "../opts/SkPMFloat_none.h" |