Add Load2/store2 to Sk4x (dumb impl for now)
authorreed <reed@google.com>
Wed, 18 Mar 2015 19:56:46 +0000 (12:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 18 Mar 2015 19:56:46 +0000 (12:56 -0700)
patch from issue 1001003002 at patchset 1 (http://crrev.com/1001003002#ps1)

BUG=skia:

Review URL: https://codereview.chromium.org/1001453006

src/core/Sk4x.h
tests/Sk4xTest.cpp

index 0b9796d..401bbd8 100644 (file)
@@ -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 <typename Dst> Dst reinterpret() const;
     template <typename Dst> Dst        cast() const;
 
index 1cecd4f..05863ff 100644 (file)
@@ -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) {