blob: daca68da0689da8ff5195cd528d5363c27994dea [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
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
bsalomon@google.com8c3ff172011-04-15 15:42:24 +000024class SK_API SkBlurMaskFilter {
reed@android.com8a1c16f2008-12-17 15:59:43 +000025public:
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
senorblanco@chromium.org038aff62010-12-06 23:45:58 +000035 enum BlurFlags {
36 kNone_BlurFlag = 0x00,
37 /** The blur layer's radius is not affected by transforms */
senorblanco@chromium.org4868e6b2011-02-18 19:03:01 +000038 kIgnoreTransform_BlurFlag = 0x01,
39 /** Use a smother, higher qulity blur algorithm */
40 kHighQuality_BlurFlag = 0x02,
senorblanco@chromium.org038aff62010-12-06 23:45:58 +000041 /** mask for all blur flags */
senorblanco@chromium.org4868e6b2011-02-18 19:03:01 +000042 kAll_BlurFlag = 0x03
senorblanco@chromium.org038aff62010-12-06 23:45:58 +000043 };
44
reed@android.com8a1c16f2008-12-17 15:59:43 +000045 /** Create a blur maskfilter.
46 @param radius The radius to extend the blur from the original mask. Must be > 0.
47 @param style The BlurStyle to use
senorblanco@chromium.org038aff62010-12-06 23:45:58 +000048 @param flags Flags to use - defaults to none
reed@android.com8a1c16f2008-12-17 15:59:43 +000049 @return The new blur maskfilter
50 */
senorblanco@chromium.org038aff62010-12-06 23:45:58 +000051 static SkMaskFilter* Create(SkScalar radius, BlurStyle style,
52 uint32_t flags = kNone_BlurFlag);
reed@android.com8a1c16f2008-12-17 15:59:43 +000053
54 /** Create an emboss maskfilter
55 @param direction array of 3 scalars [x, y, z] specifying the direction of the light source
56 @param ambient 0...1 amount of ambient light
57 @param specular coefficient for specular highlights (e.g. 8)
58 @param blurRadius amount to blur before applying lighting (e.g. 3)
59 @return the emboss maskfilter
60 */
61 static SkMaskFilter* CreateEmboss( const SkScalar direction[3],
62 SkScalar ambient, SkScalar specular,
63 SkScalar blurRadius);
64
65private:
66 SkBlurMaskFilter(); // can't be instantiated
67};
68
69#endif
70