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

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

Issue 1860573002: Update SkMorphology ImageFilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 8 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 | « gm/morphology.cpp ('k') | samplecode/SampleFilterFuzz.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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 SkMorphologyImageFilter_DEFINED 8 #ifndef SkMorphologyImageFilter_DEFINED
9 #define SkMorphologyImageFilter_DEFINED 9 #define SkMorphologyImageFilter_DEFINED
10 10
(...skipping 18 matching lines...) Expand all
29 int width, int height, int srcStride, int dstStride); 29 int width, int height, int srcStride, int dstStride);
30 30
31 protected: 31 protected:
32 enum Op { 32 enum Op {
33 kErode_Op, 33 kErode_Op,
34 kDilate_Op, 34 kDilate_Op,
35 }; 35 };
36 36
37 virtual Op op() const = 0; 37 virtual Op op() const = 0;
38 38
39 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, 39 SkMorphologyImageFilter(int radiusX, int radiusY,
40 sk_sp<SkImageFilter> input,
40 const CropRect* cropRect); 41 const CropRect* cropRect);
41 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, 42 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source,
42 const Context&, 43 const Context&,
43 SkIPoint* offset) const override; 44 SkIPoint* offset) const override;
44 void flatten(SkWriteBuffer&) const override; 45 void flatten(SkWriteBuffer&) const override;
45 46
46 SkISize radius() const { return fRadius; } 47 SkISize radius() const { return fRadius; }
47 48
48 private: 49 private:
49 SkISize fRadius; 50 SkISize fRadius;
50 51
51 typedef SkImageFilter INHERITED; 52 typedef SkImageFilter INHERITED;
52 }; 53 };
53 54
54 /////////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////////
55 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { 56 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
56 public: 57 public:
57 static SkImageFilter* Create(int radiusX, int radiusY, 58 static sk_sp<SkImageFilter> Make(int radiusX, int radiusY,
58 SkImageFilter* input = nullptr, 59 sk_sp<SkImageFilter> input,
59 const CropRect* cropRect = nullptr) { 60 const CropRect* cropRect = nullptr) {
60 if (radiusX < 0 || radiusY < 0) { 61 if (radiusX < 0 || radiusY < 0) {
61 return nullptr; 62 return nullptr;
62 } 63 }
63 return new SkDilateImageFilter(radiusX, radiusY, input, cropRect); 64 return sk_sp<SkImageFilter>(new SkDilateImageFilter(radiusX, radiusY,
65 std::move(input),
66 cropRect));
64 } 67 }
65 68
66 SK_TO_STRING_OVERRIDE() 69 SK_TO_STRING_OVERRIDE()
67 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) 70 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
68 71
72 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
73 static SkImageFilter* Create(int radiusX, int radiusY,
74 SkImageFilter* input = nullptr,
75 const CropRect* cropRect = nullptr) {
76 return Make(radiusX, radiusY,
77 sk_ref_sp<SkImageFilter>(input),
78 cropRect).release();
79 }
80 #endif
81
69 protected: 82 protected:
70 Op op() const override { return kDilate_Op; } 83 Op op() const override { return kDilate_Op; }
71 84
72 private: 85 private:
73 SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cr opRect* cropRect) 86 SkDilateImageFilter(int radiusX, int radiusY,
87 sk_sp<SkImageFilter> input,
88 const CropRect* cropRect)
74 : INHERITED(radiusX, radiusY, input, cropRect) {} 89 : INHERITED(radiusX, radiusY, input, cropRect) {}
75 90
76 typedef SkMorphologyImageFilter INHERITED; 91 typedef SkMorphologyImageFilter INHERITED;
77 }; 92 };
78 93
79 /////////////////////////////////////////////////////////////////////////////// 94 ///////////////////////////////////////////////////////////////////////////////
80 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { 95 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
81 public: 96 public:
82 static SkImageFilter* Create(int radiusX, int radiusY, 97 static sk_sp<SkImageFilter> Make(int radiusX, int radiusY,
83 SkImageFilter* input = nullptr, 98 sk_sp<SkImageFilter> input,
84 const CropRect* cropRect = nullptr) { 99 const CropRect* cropRect = nullptr) {
85 if (radiusX < 0 || radiusY < 0) { 100 if (radiusX < 0 || radiusY < 0) {
86 return nullptr; 101 return nullptr;
87 } 102 }
88 return new SkErodeImageFilter(radiusX, radiusY, input, cropRect); 103 return sk_sp<SkImageFilter>(new SkErodeImageFilter(radiusX, radiusY,
104 std::move(input),
105 cropRect));
89 } 106 }
90 107
91 SK_TO_STRING_OVERRIDE() 108 SK_TO_STRING_OVERRIDE()
92 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) 109 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
93 110
111 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
112 static SkImageFilter* Create(int radiusX, int radiusY,
113 SkImageFilter* input = nullptr,
114 const CropRect* cropRect = nullptr) {
115 return Make(radiusX, radiusY,
116 sk_ref_sp<SkImageFilter>(input),
117 cropRect).release();
118 }
119 #endif
120
94 protected: 121 protected:
95 Op op() const override { return kErode_Op; } 122 Op op() const override { return kErode_Op; }
96 123
97 private: 124 private:
98 SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cro pRect* cropRect) 125 SkErodeImageFilter(int radiusX, int radiusY,
126 sk_sp<SkImageFilter> input, const CropRect* cropRect)
99 : INHERITED(radiusX, radiusY, input, cropRect) {} 127 : INHERITED(radiusX, radiusY, input, cropRect) {}
100 128
101 typedef SkMorphologyImageFilter INHERITED; 129 typedef SkMorphologyImageFilter INHERITED;
102 }; 130 };
103 131
104 #endif 132 #endif
OLDNEW
« no previous file with comments | « gm/morphology.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698