reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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 | |
| 24 | class SkBlurMaskFilter { |
| 25 | public: |
| 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.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 35 | enum BlurFlags { |
| 36 | kNone_BlurFlag = 0x00, |
| 37 | /** The blur layer's radius is not affected by transforms */ |
senorblanco@chromium.org | 4868e6b | 2011-02-18 19:03:01 +0000 | [diff] [blame^] | 38 | kIgnoreTransform_BlurFlag = 0x01, |
| 39 | /** Use a smother, higher qulity blur algorithm */ |
| 40 | kHighQuality_BlurFlag = 0x02, |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 41 | /** mask for all blur flags */ |
senorblanco@chromium.org | 4868e6b | 2011-02-18 19:03:01 +0000 | [diff] [blame^] | 42 | kAll_BlurFlag = 0x03 |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | /** 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.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 48 | @param flags Flags to use - defaults to none |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | @return The new blur maskfilter |
| 50 | */ |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 51 | static SkMaskFilter* Create(SkScalar radius, BlurStyle style, |
| 52 | uint32_t flags = kNone_BlurFlag); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | |
| 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 | |
| 65 | private: |
| 66 | SkBlurMaskFilter(); // can't be instantiated |
| 67 | }; |
| 68 | |
| 69 | #endif |
| 70 | |