aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMaskBlurFilter.h
blob: f2b86f80fd04b80f2140897f9819900a2a75c36f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkMaskBlurFilter_DEFINED
#define SkMaskBlurFilter_DEFINED

#include <algorithm>
#include <memory>
#include <tuple>

#include "SkMask.h"
#include "SkTypes.h"

// Implement a single channel Gaussian blur. The specifics for implementation are taken from:
// https://drafts.fxtf.org/filters/#feGaussianBlurElement
class SkMaskBlurFilter {
public:
    // Create an object suitable for filtering an SkMask using a filter with width sigmaW and
    // height sigmaH.
    SkMaskBlurFilter(double sigmaW, double sigmaH);

    // returns true iff the sigmas will result in an identity mask (no blurring)
    bool hasNoBlur() const;

    // Given a src SkMask, generate dst SkMask returning the border width and height.
    SkIPoint blur(const SkMask& src, SkMask* dst) const;

private:
    const double fSigmaW;
    const double fSigmaH;
};

#endif  // SkBlurMaskFilter_DEFINED