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

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

Issue 1585813004: SkValue: SkXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: space 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
« no previous file with comments | « src/core/SkValueKeys.h ('k') | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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(); }
OLDNEW
« no previous file with comments | « src/core/SkValueKeys.h ('k') | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698