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 "SkHalf.h" | 8 #include "SkHalf.h" |
9 #include "SkPM4fPriv.h" | 9 #include "SkPM4fPriv.h" |
10 #include "SkUtils.h" | 10 #include "SkUtils.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 dst[i] = SkFloatToHalf_01(lerp_by_coverage(r4, d4, aa[i])); | 127 dst[i] = SkFloatToHalf_01(lerp_by_coverage(r4, d4, aa[i])); |
128 } else { | 128 } else { |
129 dst[i] = SkFloatToHalf_01(r4); | 129 dst[i] = SkFloatToHalf_01(r4); |
130 } | 130 } |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 static void srcover_n(const SkXfermode*, uint64_t dst[], const SkPM4f src[], int
count, | 134 static void srcover_n(const SkXfermode*, uint64_t dst[], const SkPM4f src[], int
count, |
135 const SkAlpha aa[]) { | 135 const SkAlpha aa[]) { |
136 for (int i = 0; i < count; ++i) { | 136 for (int i = 0; i < count; ++i) { |
137 Sk4f s = Sk4f::Load(src+i), | 137 const Sk4f s4 = Sk4f::Load(src[i].fVec); |
138 d = SkHalfToFloat_01(dst+i), | 138 const Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); |
139 r = s + d*(1.0f - SkNx_shuffle<3,3,3,3>(s)); | 139 const Sk4f d4 = SkHalfToFloat_01(dst[i]); |
| 140 const Sk4f r4 = s4 + d4 * dst_scale; |
140 if (aa) { | 141 if (aa) { |
141 r = lerp_by_coverage(r, d, aa[i]); | 142 dst[i] = SkFloatToHalf_01(lerp_by_coverage(r4, d4, aa[i])); |
| 143 } else { |
| 144 dst[i] = SkFloatToHalf_01(r4); |
142 } | 145 } |
143 SkFloatToHalf_01(r, dst+i); | |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 const SkXfermode::F16Proc gProcs_SrcOver[] = { srcover_n, src_n, srcover_1, src_
1 }; | 149 const SkXfermode::F16Proc gProcs_SrcOver[] = { srcover_n, src_n, srcover_1, src_
1 }; |
148 | 150 |
149 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 151 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
150 | 152 |
151 static SkXfermode::F16Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { | 153 static SkXfermode::F16Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { |
152 SkASSERT(0 == (flags & ~3)); | 154 SkASSERT(0 == (flags & ~3)); |
153 flags &= 3; | 155 flags &= 3; |
(...skipping 13 matching lines...) Expand all Loading... |
167 SkASSERT(0 == (flags & ~3)); | 169 SkASSERT(0 == (flags & ~3)); |
168 flags &= 3; | 170 flags &= 3; |
169 | 171 |
170 Mode mode; | 172 Mode mode; |
171 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; | 173 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; |
172 } | 174 } |
173 | 175 |
174 SkXfermode::F16Proc SkXfermode::GetF16Proc(SkXfermode* xfer, uint32_t flags) { | 176 SkXfermode::F16Proc SkXfermode::GetF16Proc(SkXfermode* xfer, uint32_t flags) { |
175 return xfer ? xfer->onGetF16Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod
e, flags); | 177 return xfer ? xfer->onGetF16Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod
e, flags); |
176 } | 178 } |
OLD | NEW |