Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: src/core/SkXfermodeU64.cpp

Issue 1884683002: SkFloatConvert (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/core/SkOpts.h ('K') | « src/core/SkOpts.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const Sk4f d4bias = load_from_dst<D>(dst[i]); 204 const Sk4f d4bias = load_from_dst<D>(dst[i]);
205 const Sk4f r4bias = s4bias + d4bias * dst_scale; 205 const Sk4f r4bias = s4bias + d4bias * dst_scale;
206 if (aa) { 206 if (aa) {
207 dst[i] = store_to_dst<D>(lerp_by_coverage(r4bias, d4bias, aa[i])); 207 dst[i] = store_to_dst<D>(lerp_by_coverage(r4bias, d4bias, aa[i]));
208 } else { 208 } else {
209 dst[i] = store_to_dst<D>(r4bias); 209 dst[i] = store_to_dst<D>(r4bias);
210 } 210 }
211 } 211 }
212 } 212 }
213 213
214 template <> void srcover_n<kF16_Dst>(const SkXfermode*, uint64_t dst[],
215 const SkPM4f src[], int count, const SkAlph a aa[]) {
216 SkFloatConvert fc;
217 for (int i = 0; i < count; ++i) {
218 Sk4f s = Sk4f::Load(src+i),
219 d = fc.halfToFloat(dst[i]),
220 r = s + d * (1.0f - SkNx_shuffle<3,3,3,3>(s));
221 if (aa) {
222 r = lerp_by_coverage(r, d, aa[i]);
223 }
224 dst[i] = fc.floatToHalf(r);
225 }
226 }
227
214 const SkXfermode::D64Proc gProcs_SrcOver[] = { 228 const SkXfermode::D64Proc gProcs_SrcOver[] = {
215 srcover_n<kU16_Dst>, src_n<kU16_Dst>, 229 srcover_n<kU16_Dst>, src_n<kU16_Dst>,
216 srcover_1<kU16_Dst>, src_1<kU16_Dst>, 230 srcover_1<kU16_Dst>, src_1<kU16_Dst>,
217 srcover_n<kF16_Dst>, src_n<kF16_Dst>, 231 srcover_n<kF16_Dst>, src_n<kF16_Dst>,
218 srcover_1<kF16_Dst>, src_1<kF16_Dst>, 232 srcover_1<kF16_Dst>, src_1<kF16_Dst>,
219 }; 233 };
220 234
221 //////////////////////////////////////////////////////////////////////////////// /////////////////// 235 //////////////////////////////////////////////////////////////////////////////// ///////////////////
222 236
223 static SkXfermode::D64Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { 237 static SkXfermode::D64Proc find_proc(SkXfermode::Mode mode, uint32_t flags) {
(...skipping 15 matching lines...) Expand all
239 SkASSERT(0 == (flags & ~7)); 253 SkASSERT(0 == (flags & ~7));
240 flags &= 7; 254 flags &= 7;
241 255
242 Mode mode; 256 Mode mode;
243 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; 257 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags];
244 } 258 }
245 259
246 SkXfermode::D64Proc SkXfermode::GetD64Proc(SkXfermode* xfer, uint32_t flags) { 260 SkXfermode::D64Proc SkXfermode::GetD64Proc(SkXfermode* xfer, uint32_t flags) {
247 return xfer ? xfer->onGetD64Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod e, flags); 261 return xfer ? xfer->onGetD64Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod e, flags);
248 } 262 }
OLDNEW
« src/core/SkOpts.h ('K') | « src/core/SkOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698