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 class SkArithmeticMode_scalar : public SkXfermode { | 18 class SkArithmeticMode_scalar : public SkXfermode { |
19 public: | 19 public: |
20 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, | 20 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, |
21 bool enforcePMColor) { | 21 bool enforcePMColor) { |
22 fK[0] = k1; | 22 fK[0] = k1; |
23 fK[1] = k2; | 23 fK[1] = k2; |
24 fK[2] = k3; | 24 fK[2] = k3; |
25 fK[3] = k4; | 25 fK[3] = k4; |
26 fEnforcePMColor = enforcePMColor; | 26 fEnforcePMColor = enforcePMColor; |
27 } | 27 } |
28 | 28 |
29 void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) cons
t override; | 29 void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) cons
t override; |
30 | 30 |
31 SK_TO_STRING_OVERRIDE() | 31 SK_TO_STRING_OVERRIDE() |
32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) |
33 | 33 |
34 #if SK_SUPPORT_GPU | 34 #if SK_SUPPORT_GPU |
35 const GrFragmentProcessor* getFragmentProcessorForImageFilter( | 35 const GrFragmentProcessor* getFragmentProcessorForImageFilter( |
36 const GrFragmentProcessor* dst)
const override; | 36 const GrFragmentProcessor* dst)
const override; |
37 GrXPFactory* asXPFactory() const override; | 37 GrXPFactory* asXPFactory() const override; |
38 #endif | 38 #endif |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2, | 140 SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2, |
141 SkScalar k3, SkScalar k4, | 141 SkScalar k3, SkScalar k4, |
142 bool enforcePMColor) { | 142 bool enforcePMColor) { |
143 if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) && | 143 if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) && |
144 SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) { | 144 SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) { |
145 return SkXfermode::Create(SkXfermode::kSrc_Mode); | 145 return SkXfermode::Create(SkXfermode::kSrc_Mode); |
146 } else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) && | 146 } else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) && |
147 SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4)) { | 147 SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4)) { |
148 return SkXfermode::Create(SkXfermode::kDst_Mode); | 148 return SkXfermode::Create(SkXfermode::kDst_Mode); |
149 } | 149 } |
150 | 150 |
151 return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor); | 151 return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor); |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 ////////////////////////////////////////////////////////////////////////////// | 155 ////////////////////////////////////////////////////////////////////////////// |
156 | 156 |
157 #if SK_SUPPORT_GPU | 157 #if SK_SUPPORT_GPU |
158 const GrFragmentProcessor* SkArithmeticMode_scalar::getFragmentProcessorForImage
Filter( | 158 const GrFragmentProcessor* SkArithmeticMode_scalar::getFragmentProcessorForImage
Filter( |
159 const GrFragmentProc
essor* dst) const { | 159 const GrFragmentProc
essor* dst) const { |
160 return GrArithmeticFP::Create(SkScalarToFloat(fK[0]), | 160 return GrArithmeticFP::Create(SkScalarToFloat(fK[0]), |
(...skipping 10 matching lines...) Expand all Loading... |
171 SkScalarToFloat(fK[2]), | 171 SkScalarToFloat(fK[2]), |
172 SkScalarToFloat(fK[3]), | 172 SkScalarToFloat(fK[3]), |
173 fEnforcePMColor); | 173 fEnforcePMColor); |
174 } | 174 } |
175 | 175 |
176 #endif | 176 #endif |
177 | 177 |
178 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 178 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |