aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts/Sk4px_none.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-08-12 10:23:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-12 10:23:37 -0700
commitb07bee3121680b53b98b780ac08d14d374dd4c6f (patch)
tree2435afdba0713eb7b7325bbb334c731abbd8fa81 /src/opts/Sk4px_none.h
parent58d890bd45a201477ec6c4ba0ae61c574b4e5aef (diff)
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 Review URL: https://codereview.chromium.org/1286093004
Diffstat (limited to 'src/opts/Sk4px_none.h')
-rw-r--r--src/opts/Sk4px_none.h50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/opts/Sk4px_none.h b/src/opts/Sk4px_none.h
index 540edb821d..d2231c9ba1 100644
--- a/src/opts/Sk4px_none.h
+++ b/src/opts/Sk4px_none.h
@@ -7,54 +7,52 @@
#include "SkUtils.h"
-namespace { // See Sk4px.h
-
static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exact size matters.");
-inline Sk4px Sk4px::DupPMColor(SkPMColor px) {
+SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) {
Sk4px px4 = Sk16b();
sk_memset32((uint32_t*)&px4, px, 4);
return px4;
}
-inline Sk4px Sk4px::Load4(const SkPMColor px[4]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) {
Sk4px px4 = Sk16b();
memcpy(&px4, px, 16);
return px4;
}
-inline Sk4px Sk4px::Load2(const SkPMColor px[2]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) {
Sk4px px2 = Sk16b();
memcpy(&px2, px, 8);
return px2;
}
-inline Sk4px Sk4px::Load1(const SkPMColor px[1]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) {
Sk4px px1 = Sk16b();
memcpy(&px1, px, 4);
return px1;
}
-inline void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); }
-inline void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); }
-inline void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); }
+SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); }
+SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); }
+SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); }
-inline Sk4px::Wide Sk4px::widenLo() const {
+SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const {
return Sk16h(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), this->kth< 3>(),
this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7>(),
this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11>(),
this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15>());
}
-inline Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; }
+SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; }
-inline Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->widenHi(); }
+SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->widenHi(); }
-inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const {
+SK_ALWAYS_INLINE Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const {
return this->widenLo() * Sk4px(other).widenLo();
}
-inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
+SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
Sk4px::Wide r = (*this + other) >> 8;
return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(),
r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(),
@@ -62,7 +60,7 @@ inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>());
}
-inline Sk4px Sk4px::alphas() const {
+SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const {
static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3>(),
this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7>(),
@@ -70,21 +68,21 @@ inline Sk4px Sk4px::alphas() const {
this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15>());
}
-inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
return Sk16b(a[0], a[0], a[0], a[0],
a[1], a[1], a[1], a[1],
a[2], a[2], a[2], a[2],
a[3], a[3], a[3], a[3]);
}
-inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) {
return Sk16b(a[0], a[0], a[0], a[0],
a[1], a[1], a[1], a[1],
0,0,0,0,
0,0,0,0);
}
-inline Sk4px Sk4px::zeroAlphas() const {
+SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const {
static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0,
this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), 0,
@@ -92,7 +90,7 @@ inline Sk4px Sk4px::zeroAlphas() const {
this->kth<12>(), this->kth<13>(), this->kth<14>(), 0);
}
-inline Sk4px Sk4px::zeroColors() const {
+SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const {
static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
return Sk16b(0,0,0, this->kth< 3>(),
0,0,0, this->kth< 7>(),
@@ -100,35 +98,33 @@ inline Sk4px Sk4px::zeroColors() const {
0,0,0, this->kth<15>());
}
-inline Sk4px Sk4px::Load4(const SkPMColor16 src[4]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor16 src[4]) {
SkPMColor src32[4];
for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
return Load4(src32);
}
-inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) {
SkPMColor src32[2];
for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
return Load2(src32);
}
-inline Sk4px Sk4px::Load1(const SkPMColor16 src[1]) {
+SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor16 src[1]) {
SkPMColor src32 = SkPixel16ToPixel32(src[0]);
return Load1(&src32);
}
-inline void Sk4px::store4(SkPMColor16 dst[4]) const {
+SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const {
SkPMColor dst32[4];
this->store4(dst32);
for (int i = 0; i < 4; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
}
-inline void Sk4px::store2(SkPMColor16 dst[2]) const {
+SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor16 dst[2]) const {
SkPMColor dst32[2];
this->store2(dst32);
for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
}
-inline void Sk4px::store1(SkPMColor16 dst[1]) const {
+SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor16 dst[1]) const {
SkPMColor dst32;
this->store1(&dst32);
dst[0] = SkPixel32ToPixel16(dst32);
}
-
-} // namespace