diff --git a/src/core/Sk4x.h b/src/core/Sk4x.h index 0b9796db9b..401bbd857b 100644 --- a/src/core/Sk4x.h +++ b/src/core/Sk4x.h @@ -37,6 +37,18 @@ public: void store (T[4]) const; void storeAligned(T[4]) const; + // Experimental! + static Sk4x Load2(const T src[2]) { + const T padded[4] = { src[0], src[1], 0, 0 }; + return Load(padded); + } + void store2(T dst[2]) const { + T padded[4]; + this->store(padded); + dst[0] = padded[0]; + dst[1] = padded[1]; + } + template Dst reinterpret() const; template Dst cast() const; diff --git a/tests/Sk4xTest.cpp b/tests/Sk4xTest.cpp index 1cecd4f1fc..05863ffaf7 100644 --- a/tests/Sk4xTest.cpp +++ b/tests/Sk4xTest.cpp @@ -42,6 +42,15 @@ DEF_TEST(Sk4x_LoadStore, r) { fs[2] == 6 && fs[3] == 7 && fs[4] == 8); + + // Load2 and store2(). + float two[2] = { 1.0f, 2.0f }; + Sk4f twoIn4f = Sk4f::Load2(two); + twoIn4f = twoIn4f.multiply(Sk4f(2.0f)); + twoIn4f.store2(two); + + REPORTER_ASSERT(r, two[0] == 2.0f); + REPORTER_ASSERT(r, two[1] == 4.0f); } DEF_TEST(Sk4x_Conversions, r) {