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

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

Issue 1819393002: Switch SkMorphologyImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 4 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
« no previous file with comments | « gm/morphology.cpp ('k') | src/effects/SkMorphologyImageFilter.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
9 #ifndef SkMorphologyImageFilter_DEFINED 8 #ifndef SkMorphologyImageFilter_DEFINED
10 #define SkMorphologyImageFilter_DEFINED 9 #define SkMorphologyImageFilter_DEFINED
11 10
12 #include "SkColor.h" 11 #include "SkColor.h"
13 #include "SkImageFilter.h" 12 #include "SkImageFilter.h"
14 #include "SkSize.h" 13 #include "SkSize.h"
15 14
15 ///////////////////////////////////////////////////////////////////////////////
16 class SK_API SkMorphologyImageFilter : public SkImageFilter { 16 class SK_API SkMorphologyImageFilter : public SkImageFilter {
17 public: 17 public:
18 SkRect computeFastBounds(const SkRect& src) const override; 18 SkRect computeFastBounds(const SkRect& src) const override;
19 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection ) const override; 19 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection ) const override;
20 20
21 /** 21 /**
22 * All morphology procs have the same signature: src is the source buffer, d st the 22 * All morphology procs have the same signature: src is the source buffer, d st the
23 * destination buffer, radius is the morphology radius, width and height are the bounds 23 * destination buffer, radius is the morphology radius, width and height are the bounds
24 * of the destination buffer (in pixels), and srcStride and dstStride are th e 24 * of the destination buffer (in pixels), and srcStride and dstStride are th e
25 * number of pixels per row in each buffer. All buffers are 8888. 25 * number of pixels per row in each buffer. All buffers are 8888.
26 */ 26 */
27 27
28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, 28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius,
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 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, 32 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
33 const CropRect* cropRect); 33 const CropRect* cropRect);
34 bool filterImageGeneric(Proc procX, Proc procY, 34 sk_sp<SkSpecialImage> filterImageGeneric(bool dilate,
35 Proxy*, const SkBitmap& src, const Context&, 35 SkSpecialImage* source,
36 SkBitmap* result, SkIPoint* offset) const; 36 const Context&,
37 SkIPoint* offset) const;
37 void flatten(SkWriteBuffer&) const override; 38 void flatten(SkWriteBuffer&) const override;
38 #if SK_SUPPORT_GPU
39 bool canFilterImageGPU() const override { return true; }
40 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src,
41 const Context& ctm, SkBitmap* result,
42 SkIPoint* offset) const;
43 #endif
44 39
45 SkISize radius() const { return fRadius; } 40 SkISize radius() const { return fRadius; }
46 41
47 private: 42 private:
48 SkISize fRadius; 43 SkISize fRadius;
49 typedef SkImageFilter INHERITED; 44 typedef SkImageFilter INHERITED;
50 }; 45 };
51 46
47 ///////////////////////////////////////////////////////////////////////////////
52 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { 48 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
53 public: 49 public:
54 static SkImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL, 50 static SkImageFilter* Create(int radiusX, int radiusY,
55 const CropRect* cropRect = NULL) { 51 SkImageFilter* input = nullptr,
52 const CropRect* cropRect = nullptr) {
56 if (radiusX < 0 || radiusY < 0) { 53 if (radiusX < 0 || radiusY < 0) {
57 return NULL; 54 return nullptr;
58 } 55 }
59 return new SkDilateImageFilter(radiusX, radiusY, input, cropRect); 56 return new SkDilateImageFilter(radiusX, radiusY, input, cropRect);
60 } 57 }
61 58
62 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
63 SkBitmap* result, SkIPoint* offset) const overr ide;
64
65 #if SK_SUPPORT_GPU
66 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Conte xt&,
67 SkBitmap* result, SkIPoint* offset) const over ride;
68 #endif
69
70 SK_TO_STRING_OVERRIDE() 59 SK_TO_STRING_OVERRIDE()
71 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) 60 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
72 61
62 protected:
63 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
64 SkIPoint* offset) const override;
65
73 private: 66 private:
74 SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cr opRect* cropRect) 67 SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cr opRect* cropRect)
75 : INHERITED(radiusX, radiusY, input, cropRect) {} 68 : INHERITED(radiusX, radiusY, input, cropRect) {}
76 69
77 typedef SkMorphologyImageFilter INHERITED; 70 typedef SkMorphologyImageFilter INHERITED;
78 }; 71 };
79 72
73 ///////////////////////////////////////////////////////////////////////////////
80 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { 74 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
81 public: 75 public:
82 static SkImageFilter* Create(int radiusX, int radiusY, 76 static SkImageFilter* Create(int radiusX, int radiusY,
83 SkImageFilter* input = NULL, 77 SkImageFilter* input = nullptr,
84 const CropRect* cropRect = NULL) { 78 const CropRect* cropRect = nullptr) {
85 if (radiusX < 0 || radiusY < 0) { 79 if (radiusX < 0 || radiusY < 0) {
86 return NULL; 80 return nullptr;
87 } 81 }
88 return new SkErodeImageFilter(radiusX, radiusY, input, cropRect); 82 return new SkErodeImageFilter(radiusX, radiusY, input, cropRect);
89 } 83 }
90 84
91 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
92 SkBitmap* result, SkIPoint* offset) const overr ide;
93
94 #if SK_SUPPORT_GPU
95 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Conte xt&,
96 SkBitmap* result, SkIPoint* offset) const over ride;
97 #endif
98
99 SK_TO_STRING_OVERRIDE() 85 SK_TO_STRING_OVERRIDE()
100 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) 86 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
101 87
88 protected:
89 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
90 SkIPoint* offset) const override;
91
102 private: 92 private:
103 SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cro pRect* cropRect) 93 SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cro pRect* cropRect)
104 : INHERITED(radiusX, radiusY, input, cropRect) {} 94 : INHERITED(radiusX, radiusY, input, cropRect) {}
105 95
106 typedef SkMorphologyImageFilter INHERITED; 96 typedef SkMorphologyImageFilter INHERITED;
107 }; 97 };
108 98
109 #endif 99 #endif
OLDNEW
« no previous file with comments | « gm/morphology.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698