Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 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 | |
Mike Reed | 37387c8 | 2017-10-09 13:48:09 -0400 | [diff] [blame] | 8 | #ifndef SkMaskBlurFilter_DEFINED |
| 9 | #define SkMaskBlurFilter_DEFINED |
Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 10 | |
| 11 | #include <algorithm> |
| 12 | #include <memory> |
Herb Derby | 56ffafe | 2017-08-31 10:10:01 -0400 | [diff] [blame] | 13 | #include <tuple> |
Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 14 | |
| 15 | #include "SkMask.h" |
| 16 | #include "SkTypes.h" |
| 17 | |
| 18 | // Implement a single channel Gaussian blur. The specifics for implementation are taken from: |
| 19 | // https://drafts.fxtf.org/filters/#feGaussianBlurElement |
| 20 | class SkMaskBlurFilter { |
| 21 | public: |
Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 22 | // Create an object suitable for filtering an SkMask using a filter with width sigmaW and |
| 23 | // height sigmaH. |
| 24 | SkMaskBlurFilter(double sigmaW, double sigmaH); |
| 25 | |
Mike Reed | a7ba6e7 | 2017-07-21 12:23:12 -0400 | [diff] [blame] | 26 | // returns true iff the sigmas will result in an identity mask (no blurring) |
| 27 | bool hasNoBlur() const; |
| 28 | |
Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 29 | // Given a src SkMask, generate dst SkMask returning the border width and height. |
| 30 | SkIPoint blur(const SkMask& src, SkMask* dst) const; |
| 31 | |
| 32 | private: |
Herb Derby | 2c75957 | 2017-09-06 14:40:48 -0400 | [diff] [blame] | 33 | const double fSigmaW; |
| 34 | const double fSigmaH; |
Mike Reed | 771ae96 | 2017-07-13 17:16:34 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | #endif // SkBlurMaskFilter_DEFINED |