blob: e0b8d54ce1e11f94b821e166709457e9147da87b [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkBlurMask_DEFINED
11#define SkBlurMask_DEFINED
12
13#include "SkShader.h"
humper@google.com7c5d7b72013-03-11 20:16:28 +000014#include "SkMask.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000015
16class SkBlurMask {
17public:
18 enum Style {
19 kNormal_Style, //!< fuzzy inside and outside
20 kSolid_Style, //!< solid inside, fuzzy outside
21 kOuter_Style, //!< nothing inside, fuzzy outside
22 kInner_Style, //!< fuzzy inside, nothing outside
23
24 kStyleCount
25 };
26
senorblanco@chromium.org4868e6b2011-02-18 19:03:01 +000027 enum Quality {
28 kLow_Quality, //!< box blur
29 kHigh_Quality //!< three pass box blur (similar to gaussian)
30 };
31
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000032 static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src,
33 Style style,
skia.committer@gmail.com2e71f162013-03-12 07:12:32 +000034 SkIPoint *margin = NULL,
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000035 SkMask::CreateMode createMode =
36 SkMask::kComputeBoundsAndRenderImage_CreateMode);
37 static bool BoxBlur(SkMask* dst, const SkMask& src,
38 SkScalar sigma, Style style, Quality quality,
39 SkIPoint* margin = NULL);
humper@google.coma99a92c2013-02-20 16:42:06 +000040
41 // the "ground truth" blur does a gaussian convolution; it's slow
42 // but useful for comparison purposes.
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000043 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
44 Style style,
45 SkIPoint* margin = NULL);
humper@google.coma99a92c2013-02-20 16:42:06 +000046
reed@google.com081560e2013-10-31 16:24:08 +000047 SK_ATTR_DEPRECATED("use sigma version")
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000048 static bool BlurRect(SkMask *dst, const SkRect &src,
49 SkScalar radius, Style style,
50 SkIPoint *margin = NULL,
skia.committer@gmail.com7bd141d2013-08-28 07:01:18 +000051 SkMask::CreateMode createMode =
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000052 SkMask::kComputeBoundsAndRenderImage_CreateMode);
reed@google.com081560e2013-10-31 16:24:08 +000053
54 SK_ATTR_DEPRECATED("use sigma version")
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000055 static bool Blur(SkMask* dst, const SkMask& src,
56 SkScalar radius, Style style, Quality quality,
57 SkIPoint* margin = NULL);
reed@google.com081560e2013-10-31 16:24:08 +000058
59 SK_ATTR_DEPRECATED("use sigma version")
skia.committer@gmail.comd454ec12013-02-21 07:15:03 +000060 static bool BlurGroundTruth(SkMask* dst, const SkMask& src,
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000061 SkScalar radius, Style style,
62 SkIPoint* margin = NULL);
robertphillips@google.com17ad2bd2013-07-30 12:15:19 +000063
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000064 static SkScalar ConvertRadiusToSigma(SkScalar radius);
reed@android.com8a1c16f2008-12-17 15:59:43 +000065};
66
67#endif