| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkXfermode.h" | 9 #include "SkXfermode.h" |
| 10 #include "SkXfermode_proccoeff.h" | 10 #include "SkXfermode_proccoeff.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkMathPriv.h" | 12 #include "SkMathPriv.h" |
| 13 #include "SkOncePtr.h" | 13 #include "SkOncePtr.h" |
| 14 #include "SkOpts.h" | 14 #include "SkOpts.h" |
| 15 #include "SkReadBuffer.h" | 15 #include "SkReadBuffer.h" |
| 16 #include "SkString.h" | 16 #include "SkString.h" |
| 17 #include "SkWriteBuffer.h" | 17 #include "SkWriteBuffer.h" |
| 18 #include "SkValue.h" | |
| 19 #include "SkValueKeys.h" | |
| 20 | 18 |
| 21 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) | 19 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) |
| 22 | 20 |
| 23 static inline unsigned saturated_add(unsigned a, unsigned b) { | 21 static inline unsigned saturated_add(unsigned a, unsigned b) { |
| 24 SkASSERT(a <= 255); | 22 SkASSERT(a <= 255); |
| 25 SkASSERT(b <= 255); | 23 SkASSERT(b <= 255); |
| 26 unsigned sum = a + b; | 24 unsigned sum = a + b; |
| 27 if (sum > 255) { | 25 if (sum > 255) { |
| 28 sum = 255; | 26 sum = 255; |
| 29 } | 27 } |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { | 756 if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { |
| 759 return nullptr; | 757 return nullptr; |
| 760 } | 758 } |
| 761 return SkXfermode::Create((SkXfermode::Mode)mode32); | 759 return SkXfermode::Create((SkXfermode::Mode)mode32); |
| 762 } | 760 } |
| 763 | 761 |
| 764 void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const { | 762 void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const { |
| 765 buffer.write32(fMode); | 763 buffer.write32(fMode); |
| 766 } | 764 } |
| 767 | 765 |
| 768 SkValue SkProcCoeffXfermode::asValue() const { | |
| 769 auto value = SkValue::Object(SkValue::ProcCoeffXfermode); | |
| 770 value.set(SkValueKeys::ProcCoeffXfermode::kMode, SkValue::FromU32(SkToU32(fM
ode))); | |
| 771 return value; | |
| 772 } | |
| 773 | |
| 774 bool SkProcCoeffXfermode::asMode(Mode* mode) const { | 766 bool SkProcCoeffXfermode::asMode(Mode* mode) const { |
| 775 if (mode) { | 767 if (mode) { |
| 776 *mode = fMode; | 768 *mode = fMode; |
| 777 } | 769 } |
| 778 return true; | 770 return true; |
| 779 } | 771 } |
| 780 | 772 |
| 781 bool SkProcCoeffXfermode::supportsCoverageAsAlpha() const { | 773 bool SkProcCoeffXfermode::supportsCoverageAsAlpha() const { |
| 782 if (CANNOT_USE_COEFF == fSrcCoeff) { | 774 if (CANNOT_USE_COEFF == fSrcCoeff) { |
| 783 return false; | 775 return false; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 if (!xfer) { | 1064 if (!xfer) { |
| 1073 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; | 1065 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; |
| 1074 } | 1066 } |
| 1075 | 1067 |
| 1076 return xfer->isOpaque(opacityType); | 1068 return xfer->isOpaque(opacityType); |
| 1077 } | 1069 } |
| 1078 | 1070 |
| 1079 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1071 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
| 1080 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1072 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
| 1081 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1073 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 1082 | |
| 1083 SkValue SkXfermode::asValue() const { return SkValue(); } | |
| OLD | NEW |