OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkPM4fPriv.h" | 8 #include "SkPM4fPriv.h" |
9 #include "SkUtils.h" | 9 #include "SkUtils.h" |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 template <DstType D> void src_1(const SkXfermode::PM4fState& state, uint32_t dst
[], | 196 template <DstType D> void src_1(const SkXfermode::PM4fState& state, uint32_t dst
[], |
197 const SkPM4f& src, int count, const SkAlpha aa[]
) { | 197 const SkPM4f& src, int count, const SkAlpha aa[]
) { |
198 const Sk4f s4 = Sk4f::Load(src.fVec); | 198 const Sk4f s4 = Sk4f::Load(src.fVec); |
199 | 199 |
200 if (aa) { | 200 if (aa) { |
201 if (D == kLinear_Dst) { | 201 if (D == kLinear_Dst) { |
202 // operate in bias-255 space for src and dst | 202 // operate in bias-255 space for src and dst |
203 const Sk4f& s4_255 = s4 * Sk4f(255); | 203 const Sk4f& s4_255 = s4 * Sk4f(255); |
204 while (count >= 4) { | 204 while (count >= 4) { |
205 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.f); | 205 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.f); |
206 Sk4f r0 = lerp(s4_255, to_4f(dst[0]), Sk4f(aa4.kth<0>())) + Sk4f
(0.5f); | 206 Sk4f r0 = lerp(s4_255, to_4f(dst[0]), Sk4f(aa4[0])) + Sk4f(0.5f)
; |
207 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4.kth<1>())) + Sk4f
(0.5f); | 207 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4[1])) + Sk4f(0.5f)
; |
208 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4.kth<2>())) + Sk4f
(0.5f); | 208 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4[2])) + Sk4f(0.5f)
; |
209 Sk4f r3 = lerp(s4_255, to_4f(dst[3]), Sk4f(aa4.kth<3>())) + Sk4f
(0.5f); | 209 Sk4f r3 = lerp(s4_255, to_4f(dst[3]), Sk4f(aa4[3])) + Sk4f(0.5f)
; |
210 Sk4f_ToBytes((uint8_t*)dst, r0, r1, r2, r3); | 210 Sk4f_ToBytes((uint8_t*)dst, r0, r1, r2, r3); |
211 | 211 |
212 dst += 4; | 212 dst += 4; |
213 aa += 4; | 213 aa += 4; |
214 count -= 4; | 214 count -= 4; |
215 } | 215 } |
216 } else { // kSRGB | 216 } else { // kSRGB |
217 while (count >= 4) { | 217 while (count >= 4) { |
218 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.0f); | 218 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.0f); |
219 | 219 |
220 /* If we ever natively support convert 255_linear -> 255_srgb,
then perhaps | 220 /* If we ever natively support convert 255_linear -> 255_srgb,
then perhaps |
221 * it would be faster (and possibly allow more code sharing wit
h kLinear) to | 221 * it would be faster (and possibly allow more code sharing wit
h kLinear) to |
222 * stay in that space. | 222 * stay in that space. |
223 */ | 223 */ |
224 Sk4f r0 = lerp(s4, load_dst<D>(dst[0]), Sk4f(aa4.kth<0>())); | 224 Sk4f r0 = lerp(s4, load_dst<D>(dst[0]), Sk4f(aa4[0])); |
225 Sk4f r1 = lerp(s4, load_dst<D>(dst[1]), Sk4f(aa4.kth<1>())); | 225 Sk4f r1 = lerp(s4, load_dst<D>(dst[1]), Sk4f(aa4[1])); |
226 Sk4f r2 = lerp(s4, load_dst<D>(dst[2]), Sk4f(aa4.kth<2>())); | 226 Sk4f r2 = lerp(s4, load_dst<D>(dst[2]), Sk4f(aa4[2])); |
227 Sk4f r3 = lerp(s4, load_dst<D>(dst[3]), Sk4f(aa4.kth<3>())); | 227 Sk4f r3 = lerp(s4, load_dst<D>(dst[3]), Sk4f(aa4[3])); |
228 Sk4f_ToBytes((uint8_t*)dst, | 228 Sk4f_ToBytes((uint8_t*)dst, |
229 linear_unit_to_srgb_255f(r0), | 229 linear_unit_to_srgb_255f(r0), |
230 linear_unit_to_srgb_255f(r1), | 230 linear_unit_to_srgb_255f(r1), |
231 linear_unit_to_srgb_255f(r2), | 231 linear_unit_to_srgb_255f(r2), |
232 linear_unit_to_srgb_255f(r3)); | 232 linear_unit_to_srgb_255f(r3)); |
233 | 233 |
234 dst += 4; | 234 dst += 4; |
235 aa += 4; | 235 aa += 4; |
236 count -= 4; | 236 count -= 4; |
237 } | 237 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 514 |
515 const LCD32Proc procs[] = { | 515 const LCD32Proc procs[] = { |
516 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, | 516 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, |
517 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, | 517 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, |
518 | 518 |
519 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, | 519 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, |
520 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, | 520 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, |
521 }; | 521 }; |
522 return procs[flags]; | 522 return procs[flags]; |
523 } | 523 } |
OLD | NEW |