blob: f2b86f80fd04b80f2140897f9819900a2a75c36f [file] [log] [blame]
Mike Reed771ae962017-07-13 17:16:34 +00001/*
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 Reed37387c82017-10-09 13:48:09 -04008#ifndef SkMaskBlurFilter_DEFINED
9#define SkMaskBlurFilter_DEFINED
Mike Reed771ae962017-07-13 17:16:34 +000010
11#include <algorithm>
12#include <memory>
Herb Derby56ffafe2017-08-31 10:10:01 -040013#include <tuple>
Mike Reed771ae962017-07-13 17:16:34 +000014
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
20class SkMaskBlurFilter {
21public:
Mike Reed771ae962017-07-13 17:16:34 +000022 // 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 Reeda7ba6e72017-07-21 12:23:12 -040026 // returns true iff the sigmas will result in an identity mask (no blurring)
27 bool hasNoBlur() const;
28
Mike Reed771ae962017-07-13 17:16:34 +000029 // Given a src SkMask, generate dst SkMask returning the border width and height.
30 SkIPoint blur(const SkMask& src, SkMask* dst) const;
31
32private:
Herb Derby2c759572017-09-06 14:40:48 -040033 const double fSigmaW;
34 const double fSigmaH;
Mike Reed771ae962017-07-13 17:16:34 +000035};
36
37#endif // SkBlurMaskFilter_DEFINED