Chromium Code Reviews| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4[1])) + Sk4f(0.5f) ; | 206 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4[1])) + Sk4f(0.5f) ; |
| 207 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4[2])) + Sk4f(0.5f) ; | 207 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4[2])) + Sk4f(0.5f) ; |
| 208 Sk4f r3 = lerp(s4_255, to_4f(dst[3]), Sk4f(aa4[3])) + Sk4f(0.5f) ; | 208 Sk4f r3 = lerp(s4_255, to_4f(dst[3]), Sk4f(aa4[3])) + Sk4f(0.5f) ; |
| 209 Sk4f_ToBytes((uint8_t*)dst, r0, r1, r2, r3); | 209 Sk4f_ToBytes((uint8_t*)dst, r0, r1, r2, r3); |
| 210 | 210 |
| 211 dst += 4; | 211 dst += 4; |
| 212 aa += 4; | 212 aa += 4; |
| 213 count -= 4; | 213 count -= 4; |
| 214 } | 214 } |
| 215 } else { // kSRGB | 215 } else { // kSRGB |
| 216 while (count >= 4) { | 216 SkPMColor srcColor = store_dst<D>(s4); |
| 217 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.0f); | 217 while (count-- > 0) { |
| 218 | 218 SkAlpha cover = *aa++; |
| 219 /* If we ever natively support convert 255_linear -> 255_srgb, then perhaps | 219 switch (cover) { |
| 220 * it would be faster (and possibly allow more code sharing wit h kLinear) to | 220 case 0xFF: { |
| 221 * stay in that space. | 221 *dst++ = srcColor; |
| 222 */ | 222 break; |
| 223 Sk4f r0 = lerp(s4, load_dst<D>(dst[0]), Sk4f(aa4[0])); | 223 } |
| 224 Sk4f r1 = lerp(s4, load_dst<D>(dst[1]), Sk4f(aa4[1])); | 224 case 0x00: { |
| 225 Sk4f r2 = lerp(s4, load_dst<D>(dst[2]), Sk4f(aa4[2])); | 225 dst++; |
| 226 Sk4f r3 = lerp(s4, load_dst<D>(dst[3]), Sk4f(aa4[3])); | 226 break; |
| 227 Sk4f_ToBytes((uint8_t*)dst, | 227 } |
| 228 linear_unit_to_srgb_255f(r0), | 228 default: { |
| 229 linear_unit_to_srgb_255f(r1), | 229 Sk4f d4 = load_dst<D>(*dst); |
| 230 linear_unit_to_srgb_255f(r2), | 230 *dst++ = store_dst<D>(lerp(s4, d4, cover)); |
|
mtklein
2016/05/27 15:58:49
lerp() takes 3 Sk4f arguments in range [0,1]. I t
mtklein_C
2016/05/27 16:57:59
Nevermind, it's the other lerp!
herb_g
2016/05/27 16:59:18
There are two lerp calls:
static Sk4f lerp(const S
| |
| 231 linear_unit_to_srgb_255f(r3)); | 231 } |
| 232 | 232 } |
| 233 dst += 4; | |
| 234 aa += 4; | |
| 235 count -= 4; | |
| 236 } | 233 } |
| 237 } | 234 } // kSRGB |
| 238 for (int i = 0; i < count; ++i) { | |
| 239 unsigned a = aa[i]; | |
| 240 Sk4f d4 = load_dst<D>(dst[i]); | |
| 241 dst[i] = store_dst<D>(lerp(s4, d4, a)); | |
| 242 } | |
| 243 } else { | 235 } else { |
| 244 sk_memset32(dst, store_dst<D>(s4), count); | 236 sk_memset32(dst, store_dst<D>(s4), count); |
| 245 } | 237 } |
| 246 } | 238 } |
| 247 | 239 |
| 248 const SkXfermode::D32Proc gProcs_Src[] = { | 240 const SkXfermode::D32Proc gProcs_Src[] = { |
| 249 src_n<kLinear_Dst>, src_n<kLinear_Dst>, | 241 src_n<kLinear_Dst>, src_n<kLinear_Dst>, |
| 250 src_1<kLinear_Dst>, src_1<kLinear_Dst>, | 242 src_1<kLinear_Dst>, src_1<kLinear_Dst>, |
| 251 src_n<kSRGB_Dst>, src_n<kSRGB_Dst>, | 243 src_n<kSRGB_Dst>, src_n<kSRGB_Dst>, |
| 252 src_1<kSRGB_Dst>, src_1<kSRGB_Dst>, | 244 src_1<kSRGB_Dst>, src_1<kSRGB_Dst>, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 | 518 |
| 527 const LCD32Proc procs[] = { | 519 const LCD32Proc procs[] = { |
| 528 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, | 520 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, |
| 529 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, | 521 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, |
| 530 | 522 |
| 531 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, | 523 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, |
| 532 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, | 524 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, |
| 533 }; | 525 }; |
| 534 return procs[flags]; | 526 return procs[flags]; |
| 535 } | 527 } |
| OLD | NEW |