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

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

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer Created 6 years, 10 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
« no previous file with comments | « src/core/SkXfermode_proccoeff.h ('k') | src/utils/debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "GrContext.h" 15 #include "GrContext.h"
16 #include "GrCoordTransform.h" 16 #include "GrCoordTransform.h"
17 #include "gl/GrGLEffect.h" 17 #include "gl/GrGLEffect.h"
18 #include "GrTBackendEffectFactory.h" 18 #include "GrTBackendEffectFactory.h"
19 #include "SkImageFilterUtils.h" 19 #include "SkImageFilterUtils.h"
20 #endif 20 #endif
21 21
22 static const bool gUseUnpremul = false; 22 static const bool gUseUnpremul = false;
23 23
24 class SkArithmeticMode_scalar : public SkXfermode { 24 class SkArithmeticMode_scalar : public SkXfermode {
25 public: 25 public:
26 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) { 26 static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3 , SkScalar k4) {
27 fK[0] = k1; 27 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4));
28 fK[1] = k2;
29 fK[2] = k3;
30 fK[3] = k4;
31 } 28 }
32 29
33 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 30 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
34 const SkAlpha aa[]) const SK_OVERRIDE; 31 const SkAlpha aa[]) const SK_OVERRIDE;
35 32
36 SK_DEVELOPER_TO_STRING() 33 SK_DEVELOPER_TO_STRING()
37 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
38 35
39 #if SK_SUPPORT_GPU 36 #if SK_SUPPORT_GPU
40 virtual bool asNewEffect(GrEffectRef** effect, GrTexture* background) const SK_OVERRIDE; 37 virtual bool asNewEffect(GrEffectRef** effect, GrTexture* background) const SK_OVERRIDE;
41 #endif 38 #endif
42 39
43 private: 40 private:
41 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
42 fK[0] = k1;
43 fK[1] = k2;
44 fK[2] = k3;
45 fK[3] = k4;
46 }
47
44 SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) { 48 SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) {
45 fK[0] = buffer.readScalar(); 49 fK[0] = buffer.readScalar();
46 fK[1] = buffer.readScalar(); 50 fK[1] = buffer.readScalar();
47 fK[2] = buffer.readScalar(); 51 fK[2] = buffer.readScalar();
48 fK[3] = buffer.readScalar(); 52 fK[3] = buffer.readScalar();
49 } 53 }
50 54
51 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 55 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
52 INHERITED::flatten(buffer); 56 INHERITED::flatten(buffer);
53 buffer.writeScalar(fK[0]); 57 buffer.writeScalar(fK[0]);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 213 }
210 if (0 == i2) { 214 if (0 == i2) {
211 return SkNEW_ARGS(SkArithmeticMode_dst, (i3, i4)); 215 return SkNEW_ARGS(SkArithmeticMode_dst, (i3, i4));
212 } 216 }
213 if (0 == i3) { 217 if (0 == i3) {
214 return SkNEW_ARGS(SkArithmeticMode_src, (i2, i4)); 218 return SkNEW_ARGS(SkArithmeticMode_src, (i2, i4));
215 } 219 }
216 return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4)); 220 return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4));
217 #endif 221 #endif
218 } 222 }
219 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4)); 223 return SkArithmeticMode_scalar::Create(k1, k2, k3, k4);
220 } 224 }
221 225
222 226
223 ////////////////////////////////////////////////////////////////////////////// 227 //////////////////////////////////////////////////////////////////////////////
224 228
225 #if SK_SUPPORT_GPU 229 #if SK_SUPPORT_GPU
226 230
227 class GrGLArithmeticEffect : public GrGLEffect { 231 class GrGLArithmeticEffect : public GrGLEffect {
228 public: 232 public:
229 GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 233 GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 background); 409 background);
406 } 410 }
407 return true; 411 return true;
408 } 412 }
409 413
410 #endif 414 #endif
411 415
412 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 416 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
413 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 417 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
414 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 418 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkXfermode_proccoeff.h ('k') | src/utils/debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698