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

Side by Side Diff: src/effects/SkArithmeticMode.cpp

Issue 1643753002: kill SkValue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/SkXfermode_proccoeff.h ('k') | src/effects/SkPixelXorXfermode.cpp » ('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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkArithmeticMode.h" 8 #include "SkArithmeticMode.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 #include "SkUnPreMultiply.h" 13 #include "SkUnPreMultiply.h"
14 #include "SkValue.h"
15 #include "SkValueKeys.h"
16 #if SK_SUPPORT_GPU 14 #if SK_SUPPORT_GPU
17 #include "SkArithmeticMode_gpu.h" 15 #include "SkArithmeticMode_gpu.h"
18 #endif 16 #endif
19 17
20 static const bool gUseUnpremul = false; 18 static const bool gUseUnpremul = false;
21 19
22 class SkArithmeticMode_scalar : public SkXfermode { 20 class SkArithmeticMode_scalar : public SkXfermode {
23 public: 21 public:
24 static SkXfermode* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4 , 22 static SkXfermode* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4 ,
25 bool enforcePMColor) { 23 bool enforcePMColor) {
26 if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) && 24 if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) &&
27 SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) { 25 SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) {
28 return SkXfermode::Create(SkXfermode::kSrc_Mode); 26 return SkXfermode::Create(SkXfermode::kSrc_Mode);
29 } else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) && 27 } else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) &&
30 SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4) ) { 28 SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4) ) {
31 return SkXfermode::Create(SkXfermode::kDst_Mode); 29 return SkXfermode::Create(SkXfermode::kDst_Mode);
32 } 30 }
33 31
34 return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor); 32 return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor);
35 } 33 }
36 34
37 void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 35 void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
38 const SkAlpha aa[]) const override; 36 const SkAlpha aa[]) const override;
39 37
(...skipping 17 matching lines...) Expand all
57 } 55 }
58 56
59 void flatten(SkWriteBuffer& buffer) const override { 57 void flatten(SkWriteBuffer& buffer) const override {
60 buffer.writeScalar(fK[0]); 58 buffer.writeScalar(fK[0]);
61 buffer.writeScalar(fK[1]); 59 buffer.writeScalar(fK[1]);
62 buffer.writeScalar(fK[2]); 60 buffer.writeScalar(fK[2]);
63 buffer.writeScalar(fK[3]); 61 buffer.writeScalar(fK[3]);
64 buffer.writeBool(fEnforcePMColor); 62 buffer.writeBool(fEnforcePMColor);
65 } 63 }
66 64
67 SkValue asValue() const override {
68 auto value = SkValue::Object(SkValue::ArithmeticXfermode);
69 using namespace SkValueKeys::ArithmeticXfermode;
70 value.set(kK0, SkValue::FromF32(fK[0]));
71 value.set(kK1, SkValue::FromF32(fK[1]));
72 value.set(kK2, SkValue::FromF32(fK[2]));
73 value.set(kK3, SkValue::FromF32(fK[3]));
74 value.set(kEnforcePMColor, SkValue::FromS32(fEnforcePMColor ? 1 : 0));
75 return value;
76 }
77
78 SkScalar fK[4]; 65 SkScalar fK[4];
79 bool fEnforcePMColor; 66 bool fEnforcePMColor;
80 67
81 friend class SkArithmeticMode; 68 friend class SkArithmeticMode;
82 69
83 typedef SkXfermode INHERITED; 70 typedef SkXfermode INHERITED;
84 }; 71 };
85 72
86 SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) { 73 SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) {
87 const SkScalar k1 = buffer.readScalar(); 74 const SkScalar k1 = buffer.readScalar();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 fEnforcePMColor); 266 fEnforcePMColor);
280 } 267 }
281 return true; 268 return true;
282 } 269 }
283 270
284 #endif 271 #endif
285 272
286 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
287 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 274 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
288 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkXfermode_proccoeff.h ('k') | src/effects/SkPixelXorXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698