Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkMatrixConvolutionImageFilter.h
1 /*
2  * Copyright 2012 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkMatrixConvolutionImageFilter_DEFINED
9 #define SkMatrixConvolutionImageFilter_DEFINED
10 
11 #include "SkImageFilter.h"
12 #include "SkScalar.h"
13 #include "SkSize.h"
14 #include "SkPoint.h"
15 
16 class SkBitmap;
17 
25 public:
27  enum TileMode {
28  kClamp_TileMode = 0,
31  kMax_TileMode = kClampToBlack_TileMode
32  };
33 
35 
57  static sk_sp<SkImageFilter> Make(const SkISize& kernelSize,
58  const SkScalar* kernel,
59  SkScalar gain,
60  SkScalar bias,
61  const SkIPoint& kernelOffset,
62  TileMode tileMode,
63  bool convolveAlpha,
65  const CropRect* cropRect = nullptr);
66 
67  SK_TO_STRING_OVERRIDE()
68  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
69 
70 protected:
71  SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
72  const SkScalar* kernel,
73  SkScalar gain,
74  SkScalar bias,
75  const SkIPoint& kernelOffset,
76  TileMode tileMode,
77  bool convolveAlpha,
78  sk_sp<SkImageFilter> input,
79  const CropRect* cropRect);
80  void flatten(SkWriteBuffer&) const override;
81 
82  sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
83  SkIPoint* offset) const override;
84  sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
85  SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
86  bool affectsTransparentBlack() const override;
87 
88 private:
89  SkISize fKernelSize;
90  SkScalar* fKernel;
91  SkScalar fGain;
92  SkScalar fBias;
93  SkIPoint fKernelOffset;
94  TileMode fTileMode;
95  bool fConvolveAlpha;
96 
97  template <class PixelFetcher, bool convolveAlpha>
98  void filterPixels(const SkBitmap& src,
99  SkBitmap* result,
100  const SkIRect& rect,
101  const SkIRect& bounds) const;
102  template <class PixelFetcher>
103  void filterPixels(const SkBitmap& src,
104  SkBitmap* result,
105  const SkIRect& rect,
106  const SkIRect& bounds) const;
107  void filterInteriorPixels(const SkBitmap& src,
108  SkBitmap* result,
109  const SkIRect& rect,
110  const SkIRect& bounds) const;
111  void filterBorderPixels(const SkBitmap& src,
112  SkBitmap* result,
113  const SkIRect& rect,
114  const SkIRect& bounds) const;
115 
116  typedef SkImageFilter INHERITED;
117 };
118 
119 #endif
TileMode
Definition: SkMatrixConvolutionImageFilter.h:27
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Definition: SkMatrixConvolutionImageFilter.h:24
The SkBitmap class specifies a raster bitmap.
Definition: SkBitmap.h:37
Base class for image filters.
Definition: SkImageFilter.h:36
Definition: SkSize.h:13
Definition: SkWriteBuffer.h:27
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
Definition: SkMatrixConvolutionImageFilter.h:30
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40
Definition: SkMatrixConvolutionImageFilter.h:29