SkBlurMaskFilter.h revision a2ca41e3afdd8fad5e0e924dec029f33918e0a67
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBlurMaskFilter_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBlurMaskFilter_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// we include this since our callers will need to at least be able to ref/unref
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178c3ff17e2cab6f7c798b9f8ff4515c4a3d3fd9d1bsalomon@google.comclass SK_API SkBlurMaskFilter {
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum BlurStyle {
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kNormal_BlurStyle,  //!< fuzzy inside and outside
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kSolid_BlurStyle,   //!< solid inside, fuzzy outside
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kOuter_BlurStyle,   //!< nothing inside, fuzzy outside
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInner_BlurStyle,   //!< fuzzy inside, nothing outside
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kBlurStyleCount
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
28038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    enum BlurFlags {
29038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        kNone_BlurFlag = 0x00,
30038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** The blur layer's radius is not affected by transforms */
314868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        kIgnoreTransform_BlurFlag   = 0x01,
324868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        /** Use a smother, higher qulity blur algorithm */
334868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        kHighQuality_BlurFlag       = 0x02,
34038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** mask for all blur flags */
354868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org        kAll_BlurFlag = 0x03
36038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    };
37038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Create a blur maskfilter.
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius to extend the blur from the original mask. Must be > 0.
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param style    The BlurStyle to use
41038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        @param flags    Flags to use - defaults to none
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return The new blur maskfilter
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
44038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    static SkMaskFilter* Create(SkScalar radius, BlurStyle style,
45038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org                                uint32_t flags = kNone_BlurFlag);
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Create an emboss maskfilter
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param direction    array of 3 scalars [x, y, z] specifying the direction of the light source
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ambient      0...1 amount of ambient light
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param specular     coefficient for specular highlights (e.g. 8)
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param blurRadius   amount to blur before applying lighting (e.g. 3)
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the emboss maskfilter
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static SkMaskFilter* CreateEmboss(  const SkScalar direction[3],
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                        SkScalar ambient, SkScalar specular,
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                        SkScalar blurRadius);
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
58a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com    SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBlurMaskFilter(); // can't be instantiated
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
65