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

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

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo 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 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 8
9 #ifndef SkMorphologyImageFilter_DEFINED 9 #ifndef SkMorphologyImageFilter_DEFINED
10 #define SkMorphologyImageFilter_DEFINED 10 #define SkMorphologyImageFilter_DEFINED
11 11
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkImageFilter.h" 13 #include "SkImageFilter.h"
14 #include "SkSize.h" 14 #include "SkSize.h"
15 15
16 class SK_API SkMorphologyImageFilter : public SkImageFilter { 16 class SK_API SkMorphologyImageFilter : public SkImageFilter {
17 public: 17 public:
18 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, cons t CropRect* cropRect);
19 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER RIDE; 18 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER RIDE;
20 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect * dst) const SK_OVERRIDE; 19 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect * dst) const SK_OVERRIDE;
21 20
22 /** 21 /**
23 * 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
24 * 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
25 * 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
26 * 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.
27 */ 26 */
28 27
29 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, 28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius,
30 int width, int height, int srcStride, int dstStride); 29 int width, int height, int srcStride, int dstStride);
31 30
32 protected: 31 protected:
32 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, cons t CropRect* cropRect);
scroggo 2014/03/03 19:11:54 nit: line too long
Dominik Grewe 2014/03/04 10:29:00 Done.
33 bool filterImageGeneric(Proc procX, Proc procY, 33 bool filterImageGeneric(Proc procX, Proc procY,
34 Proxy*, const SkBitmap& src, const SkMatrix&, 34 Proxy*, const SkBitmap& src, const SkMatrix&,
35 SkBitmap* result, SkIPoint* offset) const; 35 SkBitmap* result, SkIPoint* offset) const;
36 SkMorphologyImageFilter(SkReadBuffer& buffer); 36 SkMorphologyImageFilter(SkReadBuffer& buffer);
37 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 37 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
38 #if SK_SUPPORT_GPU 38 #if SK_SUPPORT_GPU
39 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } 39 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
40 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, 40 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src,
41 const SkMatrix& ctm, SkBitmap* result, 41 const SkMatrix& ctm, SkBitmap* result,
42 SkIPoint* offset) const; 42 SkIPoint* offset) const;
43 #endif 43 #endif
44 44
45 SkISize radius() const { return fRadius; } 45 SkISize radius() const { return fRadius; }
46 46
47 private: 47 private:
48 SkISize fRadius; 48 SkISize fRadius;
49 typedef SkImageFilter INHERITED; 49 typedef SkImageFilter INHERITED;
50 }; 50 };
51 51
52 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { 52 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
53 public: 53 public:
54 SkDilateImageFilter(int radiusX, int radiusY, 54 static SkDilateImageFilter* Create(int radiusX, int radiusY,
55 SkImageFilter* input = NULL, 55 SkImageFilter* input = NULL,
56 const CropRect* cropRect = NULL) 56 const CropRect* cropRect = NULL) {
57 : INHERITED(radiusX, radiusY, input, cropRect) {} 57 return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRec t));
58 }
58 59
59 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, 60 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
60 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; 61 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE;
61 #if SK_SUPPORT_GPU 62 #if SK_SUPPORT_GPU
62 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm, 63 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm,
63 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE; 64 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE;
64 #endif 65 #endif
65 66
66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) 67 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
67 68
68 protected: 69 protected:
69 SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} 70 SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
70 71
72 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
73 public:
74 #endif
75 SkDilateImageFilter(int radiusX, int radiusY,
76 SkImageFilter* input = NULL,
77 const CropRect* cropRect = NULL)
78 : INHERITED(radiusX, radiusY, input, cropRect) {}
79
71 private: 80 private:
72 typedef SkMorphologyImageFilter INHERITED; 81 typedef SkMorphologyImageFilter INHERITED;
73 }; 82 };
74 83
75 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { 84 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
76 public: 85 public:
77 SkErodeImageFilter(int radiusX, int radiusY, 86 static SkErodeImageFilter* Create(int radiusX, int radiusY,
78 SkImageFilter* input = NULL, 87 SkImageFilter* input = NULL,
79 const CropRect* cropRect = NULL) 88 const CropRect* cropRect = NULL) {
80 : INHERITED(radiusX, radiusY, input, cropRect) {} 89 return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect ));
90 }
81 91
82 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, 92 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
83 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; 93 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE;
84 #if SK_SUPPORT_GPU 94 #if SK_SUPPORT_GPU
85 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm, 95 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri x& ctm,
86 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE; 96 SkBitmap* result, SkIPoint* offset) const SK_OVE RRIDE;
87 #endif 97 #endif
88 98
89 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) 99 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
90 100
91 protected: 101 protected:
92 SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} 102 SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
93 103
104 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
105 public:
106 #endif
107 SkErodeImageFilter(int radiusX, int radiusY,
108 SkImageFilter* input = NULL,
109 const CropRect* cropRect = NULL)
110 : INHERITED(radiusX, radiusY, input, cropRect) {}
111
94 private: 112 private:
95 typedef SkMorphologyImageFilter INHERITED; 113 typedef SkMorphologyImageFilter INHERITED;
96 }; 114 };
97 115
98 #endif 116 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698