OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkUtils.h" | 8 #include "SkUtils.h" |
9 | 9 |
10 namespace { // See Sk4px.h | 10 namespace { // See Sk4px.h |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { | 57 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { |
58 Sk4px::Wide r = (*this + other) >> 8; | 58 Sk4px::Wide r = (*this + other) >> 8; |
59 return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(), | 59 return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(), |
60 r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(), | 60 r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(), |
61 r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(), | 61 r.kth< 8>(), r.kth< 9>(), r.kth<10>(), r.kth<11>(), |
62 r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>()); | 62 r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>()); |
63 } | 63 } |
64 | 64 |
| 65 inline Sk4px Sk4px::Wide::div255() const { |
| 66 // Calculated as ((x+128) + ((x+128)>>8)) >> 8. |
| 67 auto v = *this + Sk16h(128); |
| 68 return v.addNarrowHi(v>>8); |
| 69 } |
| 70 |
65 inline Sk4px Sk4px::alphas() const { | 71 inline Sk4px Sk4px::alphas() const { |
66 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); | 72 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); |
67 return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3
>(), | 73 return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3
>(), |
68 this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7
>(), | 74 this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7
>(), |
69 this->kth<11>(), this->kth<11>(), this->kth<11>(), this->kth<11
>(), | 75 this->kth<11>(), this->kth<11>(), this->kth<11>(), this->kth<11
>(), |
70 this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15
>()); | 76 this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15
>()); |
71 } | 77 } |
72 | 78 |
73 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { | 79 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { |
74 return Sk16b(a[0], a[0], a[0], a[0], | 80 return Sk16b(a[0], a[0], a[0], a[0], |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 this->store2(dst32); | 131 this->store2(dst32); |
126 for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } | 132 for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } |
127 } | 133 } |
128 inline void Sk4px::store1(SkPMColor16 dst[1]) const { | 134 inline void Sk4px::store1(SkPMColor16 dst[1]) const { |
129 SkPMColor dst32; | 135 SkPMColor dst32; |
130 this->store1(&dst32); | 136 this->store1(&dst32); |
131 dst[0] = SkPixel32ToPixel16(dst32); | 137 dst[0] = SkPixel32ToPixel16(dst32); |
132 } | 138 } |
133 | 139 |
134 } // namespace | 140 } // namespace |
OLD | NEW |