SkBlurMaskFilter.h revision 038aff623d9fd47946cd31685f74cf473f7c84f0
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkBlurMaskFilter_DEFINED
18#define SkBlurMaskFilter_DEFINED
19
20// we include this since our callers will need to at least be able to ref/unref
21#include "SkMaskFilter.h"
22#include "SkScalar.h"
23
24class SkBlurMaskFilter {
25public:
26    enum BlurStyle {
27        kNormal_BlurStyle,  //!< fuzzy inside and outside
28        kSolid_BlurStyle,   //!< solid inside, fuzzy outside
29        kOuter_BlurStyle,   //!< nothing inside, fuzzy outside
30        kInner_BlurStyle,   //!< fuzzy inside, nothing outside
31
32        kBlurStyleCount
33    };
34
35    enum BlurFlags {
36        kNone_BlurFlag = 0x00,
37        /** The blur layer's radius is not affected by transforms */
38        kIgnoreTransform_BlurFlag = 0x01,
39        /** mask for all blur flags */
40        kAll_BlurFlag = 0x01
41    };
42
43    /** Create a blur maskfilter.
44        @param radius   The radius to extend the blur from the original mask. Must be > 0.
45        @param style    The BlurStyle to use
46        @param flags    Flags to use - defaults to none
47        @return The new blur maskfilter
48    */
49    static SkMaskFilter* Create(SkScalar radius, BlurStyle style,
50                                uint32_t flags = kNone_BlurFlag);
51
52    /** Create an emboss maskfilter
53        @param direction    array of 3 scalars [x, y, z] specifying the direction of the light source
54        @param ambient      0...1 amount of ambient light
55        @param specular     coefficient for specular highlights (e.g. 8)
56        @param blurRadius   amount to blur before applying lighting (e.g. 3)
57        @return the emboss maskfilter
58    */
59    static SkMaskFilter* CreateEmboss(  const SkScalar direction[3],
60                                        SkScalar ambient, SkScalar specular,
61                                        SkScalar blurRadius);
62
63private:
64    SkBlurMaskFilter(); // can't be instantiated
65};
66
67#endif
68
69