Chromium Code Reviews| Index: src/core/SkXfermode4f.cpp |
| diff --git a/src/core/SkXfermode4f.cpp b/src/core/SkXfermode4f.cpp |
| index 0485a5e6edd4c0c65f884eae88b27beb8c9cd637..98b73b527aae5952c7e52ee8b6e472a139b2eeee 100644 |
| --- a/src/core/SkXfermode4f.cpp |
| +++ b/src/core/SkXfermode4f.cpp |
| @@ -35,6 +35,16 @@ template <DstType D> uint32_t store_dst(const Sk4f& x4) { |
| return (D == kSRGB_Dst) ? Sk4f_toS32(x4) : Sk4f_toL32(x4); |
| } |
| +template <DstType D> Sk4f linear_to_dst_255(const Sk4f& l4) { |
|
mtklein
2016/02/01 21:55:32
Seems odd to template this on DstType if we're onl
reed1
2016/02/02 14:04:39
I had a bool, but it made reading profiles harder.
mtklein
2016/02/02 14:26:06
No no, I mean, it's weird to template at all. Onl
reed1
2016/02/02 14:45:58
Ah. It *was* being used more generically, until I
|
| + Sk4f x4; |
| + if (D == kSRGB_Dst) { |
| + x4 = linear_to_srgb(l4); |
| + } else { |
| + x4 = l4; |
| + } |
| + return x4 * Sk4f(255) + Sk4f(0.5f); |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////////////////////////// |
| static Sk4f scale_255_round(const SkPM4f& pm4) { |
| @@ -276,10 +286,35 @@ template <DstType D> void srcover_1(const SkXfermode::PM4fState& state, uint32_t |
| dst[i] = store_dst<D>(r4); |
| } |
| } else { |
| + if (D == kLinear_Dst) { |
| + s4 = s4 * Sk4f(255) + Sk4f(0.5f); |
|
mtklein
2016/02/01 21:55:32
I find it really confusing to mutate values condit
reed1
2016/02/02 14:04:39
Agreed. I will give them meaningful names
|
| + scale = scale * Sk4f(255); |
| + } |
|
mtklein
2016/02/01 21:58:44
I'm also curious to see if this hoisting can be do
|
| + while (count >= 4) { |
| + Sk4f d0 = load_dst<D>(dst[0]); |
| + Sk4f d1 = load_dst<D>(dst[1]); |
| + Sk4f d2 = load_dst<D>(dst[2]); |
| + Sk4f d3 = load_dst<D>(dst[3]); |
| + if (D == kLinear_Dst) { |
| + Sk4f_ToBytes((uint8_t*)dst, |
| + s4 + d0 * scale, s4 + d1 * scale, s4 + d2 * scale, s4 + d3 * scale); |
|
mtklein
2016/02/01 21:55:32
Might be nice to line-break after each comma here
reed1
2016/02/02 14:04:39
Agreed.
|
| + } else { |
| + Sk4f_ToBytes((uint8_t*)dst, |
| + linear_to_dst_255<D>(s4 + d0 * scale), |
| + linear_to_dst_255<D>(s4 + d1 * scale), |
| + linear_to_dst_255<D>(s4 + d2 * scale), |
| + linear_to_dst_255<D>(s4 + d3 * scale)); |
| + } |
| + dst += 4; |
| + count -= 4; |
| + } |
| for (int i = 0; i < count; ++i) { |
| - Sk4f d4 = load_dst<D>(dst[i]); |
| - Sk4f r4 = s4 + d4 * scale; |
| - dst[i] = store_dst<D>(r4); |
| + Sk4f r4 = s4 + load_dst<D>(dst[i]) * scale; |
| + if (D == kLinear_Dst) { |
| + dst[i] = to_4b(r4); |
| + } else { |
| + dst[i] = store_dst<D>(r4); |
| + } |
| } |
| } |
| } |