| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 #include "SkXfermode.h" | 8 #include "SkXfermode.h" |
| 9 #include "SkXfermode_proccoeff.h" | 9 #include "SkXfermode_proccoeff.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 static Sk4f multiply_4f(const Sk4f& s, const Sk4f& d) { | 88 static Sk4f multiply_4f(const Sk4f& s, const Sk4f& d) { |
| 89 return s * inv_alpha(d) + d * inv_alpha(s) + s * d; | 89 return s * inv_alpha(d) + d * inv_alpha(s) + s * d; |
| 90 } | 90 } |
| 91 | 91 |
| 92 static Sk4f overlay_4f(const Sk4f& s, const Sk4f& d) { | 92 static Sk4f overlay_4f(const Sk4f& s, const Sk4f& d) { |
| 93 Sk4f sa = alpha(s); | 93 Sk4f sa = alpha(s); |
| 94 Sk4f da = alpha(d); | 94 Sk4f da = alpha(d); |
| 95 Sk4f two = Sk4f(2); | 95 Sk4f two = Sk4f(2); |
| 96 Sk4f rc = (two * d <= da).thenElse(two * s * d, | 96 Sk4f rc = (two * d <= da).thenElse(two * s * d, |
| 97 sa * da - two * (da - d) * (sa - s)); | 97 sa * da - two * (da - d) * (sa - s)); |
| 98 return s + d - s * da + color_alpha(rc - d * sa, 0); | 98 return pin_1(s + d - s * da + color_alpha(rc - d * sa, 0)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 static Sk4f hardlight_4f(const Sk4f& s, const Sk4f& d) { | 101 static Sk4f hardlight_4f(const Sk4f& s, const Sk4f& d) { |
| 102 return overlay_4f(d, s); | 102 return overlay_4f(d, s); |
| 103 } | 103 } |
| 104 | 104 |
| 105 static Sk4f darken_4f(const Sk4f& s, const Sk4f& d) { | 105 static Sk4f darken_4f(const Sk4f& s, const Sk4f& d) { |
| 106 Sk4f sa = alpha(s); | 106 Sk4f sa = alpha(s); |
| 107 Sk4f da = alpha(d); | 107 Sk4f da = alpha(d); |
| 108 return s + d - Sk4f::Max(s * da, d * sa); | 108 return s + d - Sk4f::Max(s * da, d * sa); |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 SkXfermodeProc4f SkXfermode::GetProc4f(Mode mode) { | 1338 SkXfermodeProc4f SkXfermode::GetProc4f(Mode mode) { |
| 1339 SkXfermodeProc4f proc = nullptr; | 1339 SkXfermodeProc4f proc = nullptr; |
| 1340 if ((unsigned)mode < kModeCount) { | 1340 if ((unsigned)mode < kModeCount) { |
| 1341 proc = gProcCoeffs[mode].fProc4f; | 1341 proc = gProcCoeffs[mode].fProc4f; |
| 1342 } | 1342 } |
| 1343 return proc; | 1343 return proc; |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 static SkPM4f missing_proc4f(const SkPM4f& src, const SkPM4f& dst) { |
| 1347 return src; |
| 1348 } |
| 1349 |
| 1350 SkXfermodeProc4f SkXfermode::getProc4f() const { |
| 1351 Mode mode; |
| 1352 return this->asMode(&mode) ? GetProc4f(mode) : missing_proc4f; |
| 1353 } |
| 1354 |
| 1346 bool SkXfermode::ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst) { | 1355 bool SkXfermode::ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst) { |
| 1347 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); | 1356 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); |
| 1348 | 1357 |
| 1349 if ((unsigned)mode >= (unsigned)kModeCount) { | 1358 if ((unsigned)mode >= (unsigned)kModeCount) { |
| 1350 // illegal mode parameter | 1359 // illegal mode parameter |
| 1351 return false; | 1360 return false; |
| 1352 } | 1361 } |
| 1353 | 1362 |
| 1354 const ProcCoeff& rec = gProcCoeffs[mode]; | 1363 const ProcCoeff& rec = gProcCoeffs[mode]; |
| 1355 | 1364 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 if (!xfer) { | 1409 if (!xfer) { |
| 1401 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; | 1410 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; |
| 1402 } | 1411 } |
| 1403 | 1412 |
| 1404 return xfer->isOpaque(opacityType); | 1413 return xfer->isOpaque(opacityType); |
| 1405 } | 1414 } |
| 1406 | 1415 |
| 1407 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1416 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
| 1408 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1417 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
| 1409 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1418 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |