OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFixed.h" | 10 #include "SkFixed.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 SkColor4f SkColor4f::Pin(float a, float r, float g, float b) { | 163 SkColor4f SkColor4f::Pin(float a, float r, float g, float b) { |
164 SkColor4f c4; | 164 SkColor4f c4; |
165 Sk4f::Min(Sk4f::Max(Sk4f(a, r, g, b), Sk4f(0)), Sk4f(1)).store(c4.vec()); | 165 Sk4f::Min(Sk4f::Max(Sk4f(a, r, g, b), Sk4f(0)), Sk4f(1)).store(c4.vec()); |
166 return c4; | 166 return c4; |
167 } | 167 } |
168 | 168 |
169 SkPM4f SkColor4f::premul() const { | 169 SkPM4f SkColor4f::premul() const { |
170 auto src = Sk4f::Load(this->pin().vec()); | 170 auto src = Sk4f::Load(this->pin().vec()); |
171 float srcAlpha = src.kth<0>(); // need the pinned version of our alpha | 171 float srcAlpha = src[0]; // need the pinned version of our alpha |
172 src = src * Sk4f(1, srcAlpha, srcAlpha, srcAlpha); | 172 src = src * Sk4f(1, srcAlpha, srcAlpha, srcAlpha); |
173 | 173 |
174 #ifdef SK_PMCOLOR_IS_BGRA | 174 #ifdef SK_PMCOLOR_IS_BGRA |
175 // ARGB -> BGRA | 175 // ARGB -> BGRA |
176 Sk4f dst = SkNx_shuffle<3,2,1,0>(src); | 176 Sk4f dst = SkNx_shuffle<3,2,1,0>(src); |
177 #else | 177 #else |
178 // ARGB -> RGBA | 178 // ARGB -> RGBA |
179 Sk4f dst = SkNx_shuffle<1,2,3,0>(src); | 179 Sk4f dst = SkNx_shuffle<1,2,3,0>(src); |
180 #endif | 180 #endif |
181 | 181 |
182 SkPM4f pm4; | 182 SkPM4f pm4; |
183 dst.store(&pm4); | 183 dst.store(&pm4); |
184 return pm4; | 184 return pm4; |
185 } | 185 } |
OLD | NEW |