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

Side by Side Diff: src/opts/SkBlend_opts.h

Issue 1939783003: Add a hook for CPU-optimized sRGB-sRGB srcover. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 7 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
« no previous file with comments | « 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
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkBlend_opts_DEFINED
9 #define SkBlend_opts_DEFINED
10
11 namespace SK_OPTS_NS {
12
13 #if 0
14
15 #else
16
17 static inline void srcover_srgb_srgb_1(uint32_t* dst, uint32_t src) {
18 switch (src >> 24) {
f(malita) 2016/05/02 18:19:27 Should dst/src be SkPMColor to make the swizzle ex
19 case 0x00: return;
20 case 0xff: *dst = src; return;
21 }
22
23 Sk4f d = SkNx_cast<float>(Sk4b::Load( dst)),
24 s = SkNx_cast<float>(Sk4b::Load(&src));
25
26 // Approximate sRGB gamma as 2.0.
27 Sk4f d_sq = d*d,
28 s_sq = s*s;
29 d = Sk4f{d_sq[0], d_sq[1], d_sq[2], d[3]};
30 s = Sk4f{s_sq[0], s_sq[1], s_sq[2], s[3]};
31
32 // SrcOver.
33 Sk4f invA = 1.0f - s[3]*(1/255.0f);
34 d = s + d * invA;
35
36 // Re-apply approximate sRGB gamma.
37 Sk4f d_sqrt = d.sqrt();
38 d = Sk4f{d_sqrt[0], d_sqrt[1], d_sqrt[2], d[3]};
39
40 SkNx_cast<uint8_t>(d).store(dst);
41 }
42
43 static inline void srcover_srgb_srgb(uint32_t* dst, const uint32_t* const sr c, int ndst, const int nsrc) {
44 while (ndst > 0) {
45 int n = SkTMin(ndst, nsrc);
46
47 for (int i = 0; i < n; i++) {
48 srcover_srgb_srgb_1(dst++, src[i]);
49 }
50 ndst -= n;
51 }
52 }
53
54 #endif
55
56 } // namespace SK_OPTS_NS
57
58 #endif//SkBlend_opts_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698