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 |
11 #include "Sk4px.h" | 11 #include "Sk4px.h" |
12 #include "SkPMFloat.h" | 12 #include "SkPMFloat.h" |
13 #include "SkXfermode_proccoeff.h" | 13 #include "SkXfermode_proccoeff.h" |
14 | 14 |
15 namespace /* TODO: SK_OPTS_NS */ { | 15 namespace SK_OPTS_NS { |
16 | 16 |
17 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit
fixed point. | 17 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit
fixed point. |
18 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) | 18 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) |
19 | 19 |
20 XFERMODE(Clear) { return Sk4px::DupPMColor(0); } | 20 XFERMODE(Clear) { return Sk4px::DupPMColor(0); } |
21 XFERMODE(Src) { return s; } | 21 XFERMODE(Src) { return s; } |
22 XFERMODE(Dst) { return d; } | 22 XFERMODE(Dst) { return d; } |
23 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } | 23 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } |
24 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } | 24 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } |
25 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } | 25 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // We do aa in full float precision before going back down to bytes, bec
ause we can! | 267 // We do aa in full float precision before going back down to bytes, bec
ause we can! |
268 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); | 268 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); |
269 b = b*a + d*(Sk4f(1)-a); | 269 b = b*a + d*(Sk4f(1)-a); |
270 return b.round(); | 270 return b.round(); |
271 } | 271 } |
272 | 272 |
273 ProcF fProcF; | 273 ProcF fProcF; |
274 typedef SkProcCoeffXfermode INHERITED; | 274 typedef SkProcCoeffXfermode INHERITED; |
275 }; | 275 }; |
276 | 276 |
277 static SkXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode::Mode mo
de) { | 277 static SkXfermode* create_xfermode(const ProcCoeff& rec, SkXfermode::Mode mode)
{ |
278 switch (mode) { | 278 switch (mode) { |
279 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ | 279 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ |
280 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) | 280 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) |
281 CASE(Clear); | 281 CASE(Clear); |
282 CASE(Src); | 282 CASE(Src); |
283 CASE(Dst); | 283 CASE(Dst); |
284 CASE(SrcOver); | 284 CASE(SrcOver); |
285 CASE(DstOver); | 285 CASE(DstOver); |
286 CASE(SrcIn); | 286 CASE(SrcIn); |
287 CASE(DstIn); | 287 CASE(DstIn); |
(...skipping 22 matching lines...) Expand all Loading... |
310 #undef CASE | 310 #undef CASE |
311 | 311 |
312 default: break; | 312 default: break; |
313 } | 313 } |
314 return nullptr; | 314 return nullptr; |
315 } | 315 } |
316 | 316 |
317 } // namespace SK_NS_OPTS | 317 } // namespace SK_NS_OPTS |
318 | 318 |
319 #endif//Sk4pxXfermode_DEFINED | 319 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |