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