OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef Sk4pxXfermode_DEFINED | 8 #ifndef Sk4pxXfermode_DEFINED |
9 #define Sk4pxXfermode_DEFINED | 9 #define Sk4pxXfermode_DEFINED |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #undef XFERMODE | 110 #undef XFERMODE |
111 | 111 |
112 // Some xfermodes use math like divide or sqrt that's best done in floats 1 pixe
l at a time. | 112 // Some xfermodes use math like divide or sqrt that's best done in floats 1 pixe
l at a time. |
113 #define XFERMODE(Name) static Sk4f SK_VECTORCALL Name(Sk4f d, Sk4f s) | 113 #define XFERMODE(Name) static Sk4f SK_VECTORCALL Name(Sk4f d, Sk4f s) |
114 | 114 |
115 static inline Sk4f a_rgb(const Sk4f& a, const Sk4f& rgb) { | 115 static inline Sk4f a_rgb(const Sk4f& a, const Sk4f& rgb) { |
116 static_assert(SK_A32_SHIFT == 24, ""); | 116 static_assert(SK_A32_SHIFT == 24, ""); |
117 return a * Sk4f(0,0,0,1) + rgb * Sk4f(1,1,1,0); | 117 return a * Sk4f(0,0,0,1) + rgb * Sk4f(1,1,1,0); |
118 } | 118 } |
119 static inline Sk4f alphas(const Sk4f& f) { | 119 static inline Sk4f alphas(const Sk4f& f) { |
120 return Sk4f(f.kth<SK_A32_SHIFT/8>()); | 120 return SkNx_dup<SK_A32_SHIFT/8>(f); |
121 } | 121 } |
122 | 122 |
123 XFERMODE(ColorDodge) { | 123 XFERMODE(ColorDodge) { |
124 auto sa = alphas(s), | 124 auto sa = alphas(s), |
125 da = alphas(d), | 125 da = alphas(d), |
126 isa = Sk4f(1)-sa, | 126 isa = Sk4f(1)-sa, |
127 ida = Sk4f(1)-da; | 127 ida = Sk4f(1)-da; |
128 | 128 |
129 auto srcover = s + d*isa, | 129 auto srcover = s + d*isa, |
130 dstover = d + s*ida, | 130 dstover = d + s*ida, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 #undef CASE | 330 #undef CASE |
331 | 331 |
332 default: break; | 332 default: break; |
333 } | 333 } |
334 return nullptr; | 334 return nullptr; |
335 } | 335 } |
336 | 336 |
337 } // namespace SK_OPTS_NS | 337 } // namespace SK_OPTS_NS |
338 | 338 |
339 #endif//Sk4pxXfermode_DEFINED | 339 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |