OLD | NEW |
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" |
14 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
15 #include "SkArithmeticMode_gpu.h" | 17 #include "SkArithmeticMode_gpu.h" |
16 #endif | 18 #endif |
17 | 19 |
18 static const bool gUseUnpremul = false; | 20 static const bool gUseUnpremul = false; |
19 | 21 |
20 class SkArithmeticMode_scalar : public SkXfermode { | 22 class SkArithmeticMode_scalar : public SkXfermode { |
21 public: | 23 public: |
22 static SkXfermode* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4
, | 24 static SkXfermode* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4
, |
23 bool enforcePMColor) { | 25 bool enforcePMColor) { |
(...skipping 22 matching lines...) Expand all Loading... |
46 fEnforcePMColor = enforcePMColor; | 48 fEnforcePMColor = enforcePMColor; |
47 } | 49 } |
48 | 50 |
49 void flatten(SkWriteBuffer& buffer) const override { | 51 void flatten(SkWriteBuffer& buffer) const override { |
50 buffer.writeScalar(fK[0]); | 52 buffer.writeScalar(fK[0]); |
51 buffer.writeScalar(fK[1]); | 53 buffer.writeScalar(fK[1]); |
52 buffer.writeScalar(fK[2]); | 54 buffer.writeScalar(fK[2]); |
53 buffer.writeScalar(fK[3]); | 55 buffer.writeScalar(fK[3]); |
54 buffer.writeBool(fEnforcePMColor); | 56 buffer.writeBool(fEnforcePMColor); |
55 } | 57 } |
| 58 |
| 59 SkValue asValue() const override { |
| 60 auto value = SkValue::Object(SkValue::ArithmeticXfermode); |
| 61 using namespace SkValueKeys::ArithmeticXfermode; |
| 62 value.set(kK0, SkValue::FromF32(fK[0])); |
| 63 value.set(kK1, SkValue::FromF32(fK[1])); |
| 64 value.set(kK2, SkValue::FromF32(fK[2])); |
| 65 value.set(kK3, SkValue::FromF32(fK[3])); |
| 66 value.set(kEnforcePMColor, SkValue::FromS32(fEnforcePMColor ? 1 : 0)); |
| 67 return value; |
| 68 } |
| 69 |
56 SkScalar fK[4]; | 70 SkScalar fK[4]; |
57 bool fEnforcePMColor; | 71 bool fEnforcePMColor; |
58 | 72 |
59 friend class SkArithmeticMode; | 73 friend class SkArithmeticMode; |
60 | 74 |
61 typedef SkXfermode INHERITED; | 75 typedef SkXfermode INHERITED; |
62 }; | 76 }; |
63 | 77 |
64 SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) { | 78 SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) { |
65 const SkScalar k1 = buffer.readScalar(); | 79 const SkScalar k1 = buffer.readScalar(); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 fEnforcePMColor); | 271 fEnforcePMColor); |
258 } | 272 } |
259 return true; | 273 return true; |
260 } | 274 } |
261 | 275 |
262 #endif | 276 #endif |
263 | 277 |
264 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 278 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
265 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 279 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
266 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 280 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |