| 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 // This file is possibly included into multiple .cpp files. | 15 // This file is possibly included into multiple .cpp files. |
| 16 // Each gets its own independent instantiation by wrapping in an anonymous names
pace. | 16 // Each gets its own independent instantiation by wrapping in an anonymous names
pace. |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 #if defined(SK_CPU_ARM32) && !defined(SK_ARM_HAS_NEON) | |
| 20 // Signals SkXfermode.cpp to look for runtime-detected NEON. | |
| 21 static SkProcCoeffXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfer
mode::Mode mode) { | |
| 22 return nullptr; | |
| 23 } | |
| 24 #else | |
| 25 | |
| 26 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit
fixed point. | 19 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit
fixed point. |
| 27 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) | 20 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) |
| 28 | 21 |
| 29 XFERMODE(Clear) { return Sk4px::DupPMColor(0); } | 22 XFERMODE(Clear) { return Sk4px::DupPMColor(0); } |
| 30 XFERMODE(Src) { return s; } | 23 XFERMODE(Src) { return s; } |
| 31 XFERMODE(Dst) { return d; } | 24 XFERMODE(Dst) { return d; } |
| 32 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } | 25 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } |
| 33 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } | 26 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } |
| 34 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } | 27 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } |
| 35 XFERMODE(DstIn) { return SrcIn (d,s); } | 28 XFERMODE(DstIn) { return SrcIn (d,s); } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // We do aa in full float precision before going back down to bytes, bec
ause we can! | 269 // We do aa in full float precision before going back down to bytes, bec
ause we can! |
| 277 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); | 270 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); |
| 278 b = b*a + d*(Sk4f(1)-a); | 271 b = b*a + d*(Sk4f(1)-a); |
| 279 return b.round(); | 272 return b.round(); |
| 280 } | 273 } |
| 281 | 274 |
| 282 ProcF fProcF; | 275 ProcF fProcF; |
| 283 typedef SkProcCoeffXfermode INHERITED; | 276 typedef SkProcCoeffXfermode INHERITED; |
| 284 }; | 277 }; |
| 285 | 278 |
| 286 static SkProcCoeffXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode
::Mode mode) { | 279 static SkXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode::Mode mo
de) { |
| 287 switch (mode) { | 280 switch (mode) { |
| 288 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ | 281 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ |
| 289 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) | 282 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) |
| 290 CASE(Clear); | 283 CASE(Clear); |
| 291 CASE(Src); | 284 CASE(Src); |
| 292 CASE(Dst); | 285 CASE(Dst); |
| 293 CASE(SrcOver); | 286 CASE(SrcOver); |
| 294 CASE(DstOver); | 287 CASE(DstOver); |
| 295 CASE(SrcIn); | 288 CASE(SrcIn); |
| 296 CASE(DstIn); | 289 CASE(DstIn); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 316 CASE(ColorDodge); | 309 CASE(ColorDodge); |
| 317 CASE(ColorBurn); | 310 CASE(ColorBurn); |
| 318 CASE(SoftLight); | 311 CASE(SoftLight); |
| 319 #undef CASE | 312 #undef CASE |
| 320 | 313 |
| 321 default: break; | 314 default: break; |
| 322 } | 315 } |
| 323 return nullptr; | 316 return nullptr; |
| 324 } | 317 } |
| 325 | 318 |
| 326 #endif | |
| 327 | |
| 328 } // namespace | 319 } // namespace |
| 329 | 320 |
| 330 #endif//Sk4pxXfermode_DEFINED | 321 #endif//Sk4pxXfermode_DEFINED |
| OLD | NEW |