Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: src/opts/Sk4px_none.h

Issue 1132273004: Sk4px (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: a smidge faster Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/opts/Sk4px_SSE2.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/Sk4px_none.h
diff --git a/src/opts/Sk4px_none.h b/src/opts/Sk4px_none.h
new file mode 100644
index 0000000000000000000000000000000000000000..c8c33a0d16fa1ef779230b481d7fdb76cc4d6950
--- /dev/null
+++ b/src/opts/Sk4px_none.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkUtils.h"
+
+static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exact size matters.");
+
+inline Sk4px::Sk4px(SkPMColor px) {
+ sk_memset32((uint32_t*)this, px, 4);
+}
+
+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]) {
+ Sk4px px2 = Sk16b();
+ memcpy(&px2, px, 8);
+ return px2;
+}
+
+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); }
+
+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; }
+
+inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const {
+ return this->widenLo() * Sk4px(other).widenLo();
+}
+
+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>(),
+ r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(),
+ r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>());
+}
« no previous file with comments | « src/opts/Sk4px_SSE2.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698