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 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
15 #include "SkArithmeticMode_gpu.h" | 15 #include "SkArithmeticMode_gpu.h" |
16 #endif | 16 #endif |
17 | 17 |
18 static const bool gUseUnpremul = false; | 18 static const bool gUseUnpremul = false; |
19 | 19 |
20 class SkArithmeticMode_scalar : public SkXfermode { | 20 class SkArithmeticMode_scalar : public SkXfermode { |
21 public: | 21 public: |
22 static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3
, SkScalar k4, | 22 static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3
, SkScalar k4, |
23 bool enforcePMColor) { | 23 bool enforcePMColor) { |
24 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4, enforcePMCol
or)); | 24 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4, enforcePMCol
or)); |
25 } | 25 } |
26 | 26 |
27 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, | 27 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, |
28 const SkAlpha aa[]) const SK_OVERRIDE; | 28 const SkAlpha aa[]) const override; |
29 | 29 |
30 SK_TO_STRING_OVERRIDE() | 30 SK_TO_STRING_OVERRIDE() |
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) | 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) |
32 | 32 |
33 #if SK_SUPPORT_GPU | 33 #if SK_SUPPORT_GPU |
34 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* background) const
SK_OVERRIDE; | 34 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* background) const
override; |
35 | 35 |
36 bool asXPFactory(GrXPFactory**) const SK_OVERRIDE; | 36 bool asXPFactory(GrXPFactory**) const override; |
37 #endif | 37 #endif |
38 | 38 |
39 private: | 39 private: |
40 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
bool enforcePMColor) { | 40 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
bool enforcePMColor) { |
41 fK[0] = k1; | 41 fK[0] = k1; |
42 fK[1] = k2; | 42 fK[1] = k2; |
43 fK[2] = k3; | 43 fK[2] = k3; |
44 fK[3] = k4; | 44 fK[3] = k4; |
45 fEnforcePMColor = enforcePMColor; | 45 fEnforcePMColor = enforcePMColor; |
46 } | 46 } |
47 | 47 |
48 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 48 void flatten(SkWriteBuffer& buffer) const override { |
49 buffer.writeScalar(fK[0]); | 49 buffer.writeScalar(fK[0]); |
50 buffer.writeScalar(fK[1]); | 50 buffer.writeScalar(fK[1]); |
51 buffer.writeScalar(fK[2]); | 51 buffer.writeScalar(fK[2]); |
52 buffer.writeScalar(fK[3]); | 52 buffer.writeScalar(fK[3]); |
53 buffer.writeBool(fEnforcePMColor); | 53 buffer.writeBool(fEnforcePMColor); |
54 } | 54 } |
55 SkScalar fK[4]; | 55 SkScalar fK[4]; |
56 bool fEnforcePMColor; | 56 bool fEnforcePMColor; |
57 | 57 |
58 friend class SkArithmeticMode; | 58 friend class SkArithmeticMode; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 fEnforcePMColor); | 256 fEnforcePMColor); |
257 } | 257 } |
258 return true; | 258 return true; |
259 } | 259 } |
260 | 260 |
261 #endif | 261 #endif |
262 | 262 |
263 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 263 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
264 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 264 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
265 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 265 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |