OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkUtils.h" |
| 9 |
| 10 static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exac
t size matters."); |
| 11 |
| 12 inline Sk4px::Sk4px(SkPMColor px) { |
| 13 sk_memset32((uint32_t*)this, px, 4); |
| 14 } |
| 15 |
| 16 inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { |
| 17 Sk4px px4 = Sk16b(); |
| 18 memcpy(&px4, px, 16); |
| 19 return px4; |
| 20 } |
| 21 |
| 22 inline Sk4px Sk4px::Load2(const SkPMColor px[2]) { |
| 23 Sk4px px2 = Sk16b(); |
| 24 memcpy(&px2, px, 8); |
| 25 return px2; |
| 26 } |
| 27 |
| 28 inline Sk4px Sk4px::Load1(const SkPMColor px[1]) { |
| 29 Sk4px px1 = Sk16b(); |
| 30 memcpy(&px1, px, 4); |
| 31 return px1; |
| 32 } |
| 33 |
| 34 inline void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); } |
| 35 inline void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); } |
| 36 inline void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); } |
| 37 |
| 38 inline Sk4px::Wide Sk4px::widenLo() const { |
| 39 return Sk16h(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), this->kth< 3
>(), |
| 40 this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7
>(), |
| 41 this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11
>(), |
| 42 this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15
>()); |
| 43 } |
| 44 |
| 45 inline Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; } |
| 46 |
| 47 inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { |
| 48 return this->widenLo() * Sk4px(other).widenLo(); |
| 49 } |
| 50 |
| 51 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { |
| 52 Sk4px::Wide r = (*this + other) >> 8; |
| 53 return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(), |
| 54 r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(), |
| 55 r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(), |
| 56 r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>()); |
| 57 } |
OLD | NEW |