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

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

Issue 2198263002: Image filters: force near-zero floating point parameters to zero. Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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
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 "SkNx.h" 10 #include "SkNx.h"
11 #include "SkRasterPipeline.h" 11 #include "SkRasterPipeline.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "SkUnPreMultiply.h" 14 #include "SkUnPreMultiply.h"
15 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
16 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
17 #include "SkArithmeticMode_gpu.h" 17 #include "SkArithmeticMode_gpu.h"
18 #endif 18 #endif
19 19
20 class SkArithmeticMode_scalar : public SkXfermode { 20 class SkArithmeticMode_scalar : public SkXfermode {
21 public: 21 public:
22 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, 22 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
23 bool enforcePMColor) { 23 bool enforcePMColor) {
24 fK[0] = k1; 24 fK[0] = SkScalarNormalize(k1);
25 fK[1] = k2; 25 fK[1] = SkScalarNormalize(k2);
26 fK[2] = k3; 26 fK[2] = SkScalarNormalize(k3);
27 fK[3] = k4; 27 fK[3] = SkScalarNormalize(k4);
28 fEnforcePMColor = enforcePMColor; 28 fEnforcePMColor = enforcePMColor;
29 } 29 }
30 30
31 void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) cons t override; 31 void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) cons t override;
32 32
33 bool onAppendStages(SkRasterPipeline* p) const override { 33 bool onAppendStages(SkRasterPipeline* p) const override {
34 p->append(&Stage, this); 34 p->append(&Stage, this);
35 return true; 35 return true;
36 } 36 }
37 37
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 SkScalarToFloat(fK[2]), 173 SkScalarToFloat(fK[2]),
174 SkScalarToFloat(fK[3]), 174 SkScalarToFloat(fK[3]),
175 fEnforcePMColor); 175 fEnforcePMColor);
176 } 176 }
177 177
178 #endif 178 #endif
179 179
180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
181 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 181 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
182 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 182 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698