OLD | NEW |
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 SkMatrixConvolutionImageFilter_DEFINED | 8 #ifndef SkMatrixConvolutionImageFilter_DEFINED |
9 #define SkMatrixConvolutionImageFilter_DEFINED | 9 #define SkMatrixConvolutionImageFilter_DEFINED |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 offset of {1, 1}). | 45 offset of {1, 1}). |
46 @param tileMode How accesses outside the image are treated. (@see | 46 @param tileMode How accesses outside the image are treated. (@see |
47 TileMode). | 47 TileMode). |
48 @param convolveAlpha If true, all channels are convolved. If false, | 48 @param convolveAlpha If true, all channels are convolved. If false, |
49 only the RGB channels are convolved, and | 49 only the RGB channels are convolved, and |
50 alpha is copied from the source image. | 50 alpha is copied from the source image. |
51 @param input The input image filter. If NULL, the src bitmap | 51 @param input The input image filter. If NULL, the src bitmap |
52 passed to filterImage() is used instead. | 52 passed to filterImage() is used instead. |
53 @param cropRect The rectangle to which the output processing will
be limited. | 53 @param cropRect The rectangle to which the output processing will
be limited. |
54 */ | 54 */ |
| 55 static sk_sp<SkImageFilter> Make(const SkISize& kernelSize, |
| 56 const SkScalar* kernel, |
| 57 SkScalar gain, |
| 58 SkScalar bias, |
| 59 const SkIPoint& kernelOffset, |
| 60 TileMode tileMode, |
| 61 bool convolveAlpha, |
| 62 sk_sp<SkImageFilter> input, |
| 63 const CropRect* cropRect = nullptr); |
| 64 |
| 65 SK_TO_STRING_OVERRIDE() |
| 66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImage
Filter) |
| 67 |
| 68 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
55 static SkImageFilter* Create(const SkISize& kernelSize, | 69 static SkImageFilter* Create(const SkISize& kernelSize, |
56 const SkScalar* kernel, | 70 const SkScalar* kernel, |
57 SkScalar gain, | 71 SkScalar gain, |
58 SkScalar bias, | 72 SkScalar bias, |
59 const SkIPoint& kernelOffset, | 73 const SkIPoint& kernelOffset, |
60 TileMode tileMode, | 74 TileMode tileMode, |
61 bool convolveAlpha, | 75 bool convolveAlpha, |
62 SkImageFilter* input = NULL, | 76 SkImageFilter* input = NULL, |
63 const CropRect* cropRect = NULL); | 77 const CropRect* cropRect = NULL) { |
64 | 78 return Make(kernelSize, kernel, gain, bias, kernelOffset, tileMode, conv
olveAlpha, |
65 SK_TO_STRING_OVERRIDE() | 79 sk_ref_sp<SkImageFilter>(input), cropRect).release(); |
66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImage
Filter) | 80 } |
| 81 #endif |
67 | 82 |
68 protected: | 83 protected: |
69 SkMatrixConvolutionImageFilter(const SkISize& kernelSize, | 84 SkMatrixConvolutionImageFilter(const SkISize& kernelSize, |
70 const SkScalar* kernel, | 85 const SkScalar* kernel, |
71 SkScalar gain, | 86 SkScalar gain, |
72 SkScalar bias, | 87 SkScalar bias, |
73 const SkIPoint& kernelOffset, | 88 const SkIPoint& kernelOffset, |
74 TileMode tileMode, | 89 TileMode tileMode, |
75 bool convolveAlpha, | 90 bool convolveAlpha, |
76 SkImageFilter* input, | 91 sk_sp<SkImageFilter> input, |
77 const CropRect* cropRect); | 92 const CropRect* cropRect); |
78 void flatten(SkWriteBuffer&) const override; | 93 void flatten(SkWriteBuffer&) const override; |
79 | 94 |
80 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, | 95 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, |
81 SkBitmap* result, SkIPoint* loc) const override
; | 96 SkBitmap* result, SkIPoint* loc) const override
; |
82 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; | 97 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; |
83 bool affectsTransparentBlack() const override; | 98 bool affectsTransparentBlack() const override; |
84 | 99 |
85 #if SK_SUPPORT_GPU | 100 #if SK_SUPPORT_GPU |
86 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, | 101 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, |
87 const SkIRect& bounds) const override; | 102 const SkIRect& bounds) const override; |
88 #endif | 103 #endif |
89 | 104 |
90 private: | 105 private: |
91 SkISize fKernelSize; | 106 SkISize fKernelSize; |
92 SkScalar* fKernel; | 107 SkScalar* fKernel; |
93 SkScalar fGain; | 108 SkScalar fGain; |
94 SkScalar fBias; | 109 SkScalar fBias; |
95 SkIPoint fKernelOffset; | 110 SkIPoint fKernelOffset; |
96 TileMode fTileMode; | 111 TileMode fTileMode; |
97 bool fConvolveAlpha; | 112 bool fConvolveAlpha; |
98 typedef SkImageFilter INHERITED; | |
99 | 113 |
100 template <class PixelFetcher, bool convolveAlpha> | 114 template <class PixelFetcher, bool convolveAlpha> |
101 void filterPixels(const SkBitmap& src, | 115 void filterPixels(const SkBitmap& src, |
102 SkBitmap* result, | 116 SkBitmap* result, |
103 const SkIRect& rect, | 117 const SkIRect& rect, |
104 const SkIRect& bounds) const; | 118 const SkIRect& bounds) const; |
105 template <class PixelFetcher> | 119 template <class PixelFetcher> |
106 void filterPixels(const SkBitmap& src, | 120 void filterPixels(const SkBitmap& src, |
107 SkBitmap* result, | 121 SkBitmap* result, |
108 const SkIRect& rect, | 122 const SkIRect& rect, |
109 const SkIRect& bounds) const; | 123 const SkIRect& bounds) const; |
110 void filterInteriorPixels(const SkBitmap& src, | 124 void filterInteriorPixels(const SkBitmap& src, |
111 SkBitmap* result, | 125 SkBitmap* result, |
112 const SkIRect& rect, | 126 const SkIRect& rect, |
113 const SkIRect& bounds) const; | 127 const SkIRect& bounds) const; |
114 void filterBorderPixels(const SkBitmap& src, | 128 void filterBorderPixels(const SkBitmap& src, |
115 SkBitmap* result, | 129 SkBitmap* result, |
116 const SkIRect& rect, | 130 const SkIRect& rect, |
117 const SkIRect& bounds) const; | 131 const SkIRect& bounds) const; |
| 132 |
| 133 typedef SkImageFilter INHERITED; |
118 }; | 134 }; |
119 | 135 |
120 #endif | 136 #endif |
OLD | NEW |