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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, |
136 otherwise = sa * Sk4f::Min(da, (d*sa)*(sa-s).approxInvert()) + s*ida +
d*isa; | 136 otherwise = sa * Sk4f::Min(da, (d*sa)*(sa-s).invert()) + s*ida + d*isa; |
137 | 137 |
138 // Order matters here, preferring d==0 over s==sa. | 138 // Order matters here, preferring d==0 over s==sa. |
139 auto colors = (d == Sk4f(0)).thenElse(dstover, | 139 auto colors = (d == Sk4f(0)).thenElse(dstover, |
140 (s == sa).thenElse(srcover, | 140 (s == sa).thenElse(srcover, |
141 otherwise)); | 141 otherwise)); |
142 return a_rgb(srcover, colors); | 142 return a_rgb(srcover, colors); |
143 } | 143 } |
144 XFERMODE(ColorBurn) { | 144 XFERMODE(ColorBurn) { |
145 auto sa = alphas(s), | 145 auto sa = alphas(s), |
146 da = alphas(d), | 146 da = alphas(d), |
147 isa = Sk4f(1)-sa, | 147 isa = Sk4f(1)-sa, |
148 ida = Sk4f(1)-da; | 148 ida = Sk4f(1)-da; |
149 | 149 |
150 auto srcover = s + d*isa, | 150 auto srcover = s + d*isa, |
151 dstover = d + s*ida, | 151 dstover = d + s*ida, |
152 otherwise = sa*(da-Sk4f::Min(da, (da-d)*sa*s.approxInvert())) + s*ida +
d*isa; | 152 otherwise = sa*(da-Sk4f::Min(da, (da-d)*sa*s.invert())) + s*ida + d*isa
; |
153 | 153 |
154 // Order matters here, preferring d==da over s==0. | 154 // Order matters here, preferring d==da over s==0. |
155 auto colors = (d == da).thenElse(dstover, | 155 auto colors = (d == da).thenElse(dstover, |
156 (s == Sk4f(0)).thenElse(srcover, | 156 (s == Sk4f(0)).thenElse(srcover, |
157 otherwise)); | 157 otherwise)); |
158 return a_rgb(srcover, colors); | 158 return a_rgb(srcover, colors); |
159 } | 159 } |
160 XFERMODE(SoftLight) { | 160 XFERMODE(SoftLight) { |
161 auto sa = alphas(s), | 161 auto sa = alphas(s), |
162 da = alphas(d), | 162 da = alphas(d), |
(...skipping 188 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 |