Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/core/SkXfermode.cpp

Issue 1585813004: SkValue: SkXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-01-14 (Thursday) 16:27:56 EST Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkValueKeys.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
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 SkValue SkProcCoeffXfermode::represent() const {
768 auto value = SkValue::Object(SkValue::ProcCoeffXfermode);
769 value.set(SkValueKeys::ProcCoeffXfermode_Mode,
770 SkValue::FromU32(static_cast<uint32_t>(fMode)));
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698