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

Side by Side Diff: include/effects/SkDisplacementMapEffect.h

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 6 years, 9 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 #ifndef SkDisplacementMapEffect_DEFINED 8 #ifndef SkDisplacementMapEffect_DEFINED
9 #define SkDisplacementMapEffect_DEFINED 9 #define SkDisplacementMapEffect_DEFINED
10 10
11 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 13
14 class SK_API SkDisplacementMapEffect : public SkImageFilter { 14 class SK_API SkDisplacementMapEffect : public SkImageFilter {
15 public: 15 public:
16 enum ChannelSelectorType { 16 enum ChannelSelectorType {
17 kUnknown_ChannelSelectorType, 17 kUnknown_ChannelSelectorType,
18 kR_ChannelSelectorType, 18 kR_ChannelSelectorType,
19 kG_ChannelSelectorType, 19 kG_ChannelSelectorType,
20 kB_ChannelSelectorType, 20 kB_ChannelSelectorType,
21 kA_ChannelSelectorType, 21 kA_ChannelSelectorType,
22 kKeyBits = 3 // Max value is 4, so 3 bits are required at most 22 kKeyBits = 3 // Max value is 4, so 3 bits are required at most
reed1 2014/03/04 16:56:42 I know its not part of this CL, but why is this en
Stephen White 2014/03/04 18:18:00 It's not a dupe of that value; it's the number of
Dominik Grewe 2014/03/07 16:43:38 I've replaced it with a #define inside the .cpp fi
23 }; 23 };
24 24
25 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, 25 ~SkDisplacementMapEffect();
26 ChannelSelectorType yChannelSelector,
27 SkScalar scale, SkImageFilter* displacement,
28 SkImageFilter* color = NULL,
29 const CropRect* cropRect = NULL);
30 26
31 ~SkDisplacementMapEffect(); 27 static SkDisplacementMapEffect* Create(ChannelSelectorType xChannelSelector,
28 ChannelSelectorType yChannelSelector,
29 SkScalar scale, SkImageFilter* displa cement,
30 SkImageFilter* color = NULL,
31 const CropRect* cropRect = NULL) {
32 return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSe lector, scale,
33 displacement, color, cropRec t));
34 }
32 35
33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) 36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
34 37
35 virtual bool onFilterImage(Proxy* proxy, 38 virtual bool onFilterImage(Proxy* proxy,
36 const SkBitmap& src, 39 const SkBitmap& src,
37 const SkMatrix& ctm, 40 const SkMatrix& ctm,
38 SkBitmap* dst, 41 SkBitmap* dst,
39 SkIPoint* offset) const SK_OVERRIDE; 42 SkIPoint* offset) const SK_OVERRIDE;
40 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER RIDE; 43 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER RIDE;
41 44
42 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, 45 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
43 SkIRect* dst) const SK_OVERRIDE; 46 SkIRect* dst) const SK_OVERRIDE;
44 47
45 #if SK_SUPPORT_GPU 48 #if SK_SUPPORT_GPU
46 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } 49 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
47 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm, 50 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm,
48 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE; 51 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE;
49 #endif 52 #endif
50 53
51 protected: 54 protected:
52 explicit SkDisplacementMapEffect(SkReadBuffer& buffer); 55 explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
53 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
54 57
58 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
59 public:
60 #endif
61 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
62 ChannelSelectorType yChannelSelector,
63 SkScalar scale, SkImageFilter* displacement,
64 SkImageFilter* color = NULL,
65 const CropRect* cropRect = NULL);
66
55 private: 67 private:
56 ChannelSelectorType fXChannelSelector; 68 ChannelSelectorType fXChannelSelector;
57 ChannelSelectorType fYChannelSelector; 69 ChannelSelectorType fYChannelSelector;
58 SkScalar fScale; 70 SkScalar fScale;
59 typedef SkImageFilter INHERITED; 71 typedef SkImageFilter INHERITED;
60 const SkImageFilter* getDisplacementInput() const { return getInput(0); } 72 const SkImageFilter* getDisplacementInput() const { return getInput(0); }
61 const SkImageFilter* getColorInput() const { return getInput(1); } 73 const SkImageFilter* getColorInput() const { return getInput(1); }
62 }; 74 };
63 75
64 #endif 76 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698