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" |
18 | 20 |
19 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) | 21 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) |
20 | 22 |
21 static inline unsigned saturated_add(unsigned a, unsigned b) { | 23 static inline unsigned saturated_add(unsigned a, unsigned b) { |
22 SkASSERT(a <= 255); | 24 SkASSERT(a <= 255); |
23 SkASSERT(b <= 255); | 25 SkASSERT(b <= 255); |
24 unsigned sum = a + b; | 26 unsigned sum = a + b; |
25 if (sum > 255) { | 27 if (sum > 255) { |
26 sum = 255; | 28 sum = 255; |
27 } | 29 } |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { | 758 if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { |
757 return nullptr; | 759 return nullptr; |
758 } | 760 } |
759 return SkXfermode::Create((SkXfermode::Mode)mode32); | 761 return SkXfermode::Create((SkXfermode::Mode)mode32); |
760 } | 762 } |
761 | 763 |
762 void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const { | 764 void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const { |
763 buffer.write32(fMode); | 765 buffer.write32(fMode); |
764 } | 766 } |
765 | 767 |
| 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 |
766 bool SkProcCoeffXfermode::asMode(Mode* mode) const { | 774 bool SkProcCoeffXfermode::asMode(Mode* mode) const { |
767 if (mode) { | 775 if (mode) { |
768 *mode = fMode; | 776 *mode = fMode; |
769 } | 777 } |
770 return true; | 778 return true; |
771 } | 779 } |
772 | 780 |
773 bool SkProcCoeffXfermode::supportsCoverageAsAlpha() const { | 781 bool SkProcCoeffXfermode::supportsCoverageAsAlpha() const { |
774 if (CANNOT_USE_COEFF == fSrcCoeff) { | 782 if (CANNOT_USE_COEFF == fSrcCoeff) { |
775 return false; | 783 return false; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 if (!xfer) { | 1072 if (!xfer) { |
1065 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; | 1073 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; |
1066 } | 1074 } |
1067 | 1075 |
1068 return xfer->isOpaque(opacityType); | 1076 return xfer->isOpaque(opacityType); |
1069 } | 1077 } |
1070 | 1078 |
1071 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1079 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1072 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1080 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1073 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1081 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 1082 |
| 1083 SkValue SkXfermode::asValue() const { return SkValue(); } |
OLD | NEW |