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 const Sk4f s4 = Sk4f::Load(src[i].fVec); | 137 Sk4f s = Sk4f::Load(src+i), |
138 const Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); | 138 d = SkHalfToFloat_01(dst+i), |
139 const Sk4f d4 = SkHalfToFloat_01(dst[i]); | 139 r = s + d*(1.0f - SkNx_shuffle<3,3,3,3>(s)); |
140 const Sk4f r4 = s4 + d4 * dst_scale; | |
141 if (aa) { | 140 if (aa) { |
142 dst[i] = SkFloatToHalf_01(lerp_by_coverage(r4, d4, aa[i])); | 141 r = lerp_by_coverage(r, d, aa[i]); |
143 } else { | |
144 dst[i] = SkFloatToHalf_01(r4); | |
145 } | 142 } |
| 143 SkFloatToHalf_01(r, dst+i); |
146 } | 144 } |
147 } | 145 } |
148 | 146 |
149 const SkXfermode::F16Proc gProcs_SrcOver[] = { srcover_n, src_n, srcover_1, src_
1 }; | 147 const SkXfermode::F16Proc gProcs_SrcOver[] = { srcover_n, src_n, srcover_1, src_
1 }; |
150 | 148 |
151 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 149 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
152 | 150 |
153 static SkXfermode::F16Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { | 151 static SkXfermode::F16Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { |
154 SkASSERT(0 == (flags & ~3)); | 152 SkASSERT(0 == (flags & ~3)); |
155 flags &= 3; | 153 flags &= 3; |
(...skipping 13 matching lines...) Expand all Loading... |
169 SkASSERT(0 == (flags & ~3)); | 167 SkASSERT(0 == (flags & ~3)); |
170 flags &= 3; | 168 flags &= 3; |
171 | 169 |
172 Mode mode; | 170 Mode mode; |
173 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; | 171 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; |
174 } | 172 } |
175 | 173 |
176 SkXfermode::F16Proc SkXfermode::GetF16Proc(SkXfermode* xfer, uint32_t flags) { | 174 SkXfermode::F16Proc SkXfermode::GetF16Proc(SkXfermode* xfer, uint32_t flags) { |
177 return xfer ? xfer->onGetF16Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod
e, flags); | 175 return xfer ? xfer->onGetF16Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod
e, flags); |
178 } | 176 } |
OLD | NEW |