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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Some xfermodes use math like divide or sqrt that's best done in floats 1 pixe
l at a time. | 115 // Some xfermodes use math like divide or sqrt that's best done in floats 1 pixe
l at a time. |
116 #define XFERMODE(Xfermode) \ | 116 #define XFERMODE(Xfermode) \ |
117 struct Xfermode { Sk4f operator()(const Sk4f&, const Sk4f&) const; }; \ | 117 struct Xfermode { Sk4f operator()(const Sk4f&, const Sk4f&) const; }; \ |
118 inline Sk4f Xfermode::operator()(const Sk4f& d, const Sk4f& s) const | 118 inline Sk4f Xfermode::operator()(const Sk4f& d, const Sk4f& s) const |
119 | 119 |
120 static inline Sk4f a_rgb(const Sk4f& a, const Sk4f& rgb) { | 120 static inline Sk4f a_rgb(const Sk4f& a, const Sk4f& rgb) { |
121 static_assert(SK_A32_SHIFT == 24, ""); | 121 static_assert(SK_A32_SHIFT == 24, ""); |
122 return a * Sk4f(0,0,0,1) + rgb * Sk4f(1,1,1,0); | 122 return a * Sk4f(0,0,0,1) + rgb * Sk4f(1,1,1,0); |
123 } | 123 } |
124 static inline Sk4f alphas(const Sk4f& f) { | 124 static inline Sk4f alphas(const Sk4f& f) { |
125 return f.kth<SK_A32_SHIFT/8>(); | 125 return f[SK_A32_SHIFT/8]; |
126 } | 126 } |
127 | 127 |
128 XFERMODE(ColorDodge) { | 128 XFERMODE(ColorDodge) { |
129 auto sa = alphas(s), | 129 auto sa = alphas(s), |
130 da = alphas(d), | 130 da = alphas(d), |
131 isa = Sk4f(1)-sa, | 131 isa = Sk4f(1)-sa, |
132 ida = Sk4f(1)-da; | 132 ida = Sk4f(1)-da; |
133 | 133 |
134 auto srcover = s + d*isa, | 134 auto srcover = s + d*isa, |
135 dstover = d + s*ida, | 135 dstover = d + s*ida, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 #undef CASE | 351 #undef CASE |
352 | 352 |
353 default: break; | 353 default: break; |
354 } | 354 } |
355 return nullptr; | 355 return nullptr; |
356 } | 356 } |
357 | 357 |
358 } // namespace SK_OPTS_NS | 358 } // namespace SK_OPTS_NS |
359 | 359 |
360 #endif//Sk4pxXfermode_DEFINED | 360 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |