18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBlurMaskFilter_DEFINED
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBlurMaskFilter_DEFINED
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// we include this since our callers will need to at least be able to ref/unref
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h"
14e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#include "SkBlurTypes.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
168c3ff17e2cab6f7c798b9f8ff4515c4a3d3fd9d1bsalomon@google.comclass SK_API SkBlurMaskFilter {
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
18508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org    /**
19508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org     *  If radius > 0, return the corresponding sigma, else return 0. Use this to convert from the
20508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org     *  (legacy) idea of specify the blur "radius" to the standard notion of specifying its sigma.
21508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org     */
22508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org    static SkScalar ConvertRadiusToSigma(SkScalar radius);
23508022cff04c5226cfd1714ba049528f57f9f25ecommit-bot@chromium.org
24038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    enum BlurFlags {
25038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        kNone_BlurFlag = 0x00,
26038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** The blur layer's radius is not affected by transforms */
274868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        kIgnoreTransform_BlurFlag   = 0x01,
284868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        /** Use a smother, higher qulity blur algorithm */
294868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        kHighQuality_BlurFlag       = 0x02,
30038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** mask for all blur flags */
3191f489a65d436d36c7fe580af2775cd0cd13c8d2senorblanco@chromium.org        kAll_BlurFlag = 0x03
32038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    };
33038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org
34e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org    /** Create a blur maskfilter.
35e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org     *  @param style    The SkBlurStyle to use
36e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org     *  @param sigma    Standard deviation of the Gaussian blur to apply. Must be > 0.
37e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org     *  @param flags    Flags to use - defaults to none
38e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org     *  @return The new blur maskfilter
39e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org     */
40e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org    static SkMaskFilter* Create(SkBlurStyle style, SkScalar sigma, uint32_t flags = kNone_BlurFlag);
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Create an emboss maskfilter
437bd141dce43ea3405bc60c9c84e6f910b851b079skia.committer@gmail.com        @param blurSigma    standard deviation of the Gaussian blur to apply
447ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com                            before applying lighting (e.g. 3)
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param direction    array of 3 scalars [x, y, z] specifying the direction of the light source
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ambient      0...1 amount of ambient light
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param specular     coefficient for specular highlights (e.g. 8)
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the emboss maskfilter
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
507ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com    static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3],
517ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com                                      SkScalar ambient, SkScalar specular);
527ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com
534469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("use sigma version")
547ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com    static SkMaskFilter* CreateEmboss(const SkScalar direction[3],
557ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com                                      SkScalar ambient, SkScalar specular,
567ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com                                      SkScalar blurRadius);
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
58a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com    SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
597ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBlurMaskFilter(); // can't be instantiated
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
65