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 new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor); |
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 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**, GrProcessorDataManager*, | 34 bool asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataManager*, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 bool enforcePMColor) { | 210 bool enforcePMColor) { |
211 if (fitsInBits(k1, 8) && fitsInBits(k2, 16) && | 211 if (fitsInBits(k1, 8) && fitsInBits(k2, 16) && |
212 fitsInBits(k2, 16) && fitsInBits(k2, 24)) { | 212 fitsInBits(k2, 16) && fitsInBits(k2, 24)) { |
213 | 213 |
214 #if 0 // UNUSED | 214 #if 0 // UNUSED |
215 int32_t i1 = toDot8(k1); | 215 int32_t i1 = toDot8(k1); |
216 int32_t i2 = toDot8(k2); | 216 int32_t i2 = toDot8(k2); |
217 int32_t i3 = toDot8(k3); | 217 int32_t i3 = toDot8(k3); |
218 int32_t i4 = toDot8(k4); | 218 int32_t i4 = toDot8(k4); |
219 if (i1) { | 219 if (i1) { |
220 return SkNEW_ARGS(SkArithmeticMode_quad, (i1, i2, i3, i4)); | 220 return new SkArithmeticMode_quad (i1, i2, i3, i4); |
221 } | 221 } |
222 if (0 == i2) { | 222 if (0 == i2) { |
223 return SkNEW_ARGS(SkArithmeticMode_dst, (i3, i4)); | 223 return new SkArithmeticMode_dst (i3, i4); |
224 } | 224 } |
225 if (0 == i3) { | 225 if (0 == i3) { |
226 return SkNEW_ARGS(SkArithmeticMode_src, (i2, i4)); | 226 return new SkArithmeticMode_src (i2, i4); |
227 } | 227 } |
228 return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4)); | 228 return new SkArithmeticMode_linear (i2, i3, i4); |
229 #endif | 229 #endif |
230 } | 230 } |
231 return SkArithmeticMode_scalar::Create(k1, k2, k3, k4, enforcePMColor); | 231 return SkArithmeticMode_scalar::Create(k1, k2, k3, k4, enforcePMColor); |
232 } | 232 } |
233 | 233 |
234 | 234 |
235 ////////////////////////////////////////////////////////////////////////////// | 235 ////////////////////////////////////////////////////////////////////////////// |
236 | 236 |
237 #if SK_SUPPORT_GPU | 237 #if SK_SUPPORT_GPU |
238 bool SkArithmeticMode_scalar::asFragmentProcessor(GrFragmentProcessor** fp, | 238 bool SkArithmeticMode_scalar::asFragmentProcessor(GrFragmentProcessor** fp, |
(...skipping 20 matching lines...) Expand all Loading... |
259 fEnforcePMColor); | 259 fEnforcePMColor); |
260 } | 260 } |
261 return true; | 261 return true; |
262 } | 262 } |
263 | 263 |
264 #endif | 264 #endif |
265 | 265 |
266 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 266 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
267 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 267 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
268 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 268 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |