SkBlurMaskFilter.h revision 038aff623d9fd47946cd31685f74cf473f7c84f0
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Copyright (C) 2006 The Android Open Source Project
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Licensed under the Apache License, Version 2.0 (the "License");
58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * you may not use this file except in compliance with the License.
68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * You may obtain a copy of the License at
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *      http://www.apache.org/licenses/LICENSE-2.0
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Unless required by applicable law or agreed to in writing, software
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * distributed under the License is distributed on an "AS IS" BASIS,
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * See the License for the specific language governing permissions and
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * limitations under the License.
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBlurMaskFilter_DEFINED
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBlurMaskFilter_DEFINED
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// we include this since our callers will need to at least be able to ref/unref
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h"
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBlurMaskFilter {
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum BlurStyle {
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kNormal_BlurStyle,  //!< fuzzy inside and outside
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kSolid_BlurStyle,   //!< solid inside, fuzzy outside
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kOuter_BlurStyle,   //!< nothing inside, fuzzy outside
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kInner_BlurStyle,   //!< fuzzy inside, nothing outside
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kBlurStyleCount
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
35038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    enum BlurFlags {
36038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        kNone_BlurFlag = 0x00,
37038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** The blur layer's radius is not affected by transforms */
38038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        kIgnoreTransform_BlurFlag = 0x01,
39038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        /** mask for all blur flags */
40038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        kAll_BlurFlag = 0x01
41038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    };
42038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Create a blur maskfilter.
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param radius   The radius to extend the blur from the original mask. Must be > 0.
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param style    The BlurStyle to use
46038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org        @param flags    Flags to use - defaults to none
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return The new blur maskfilter
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
49038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org    static SkMaskFilter* Create(SkScalar radius, BlurStyle style,
50038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org                                uint32_t flags = kNone_BlurFlag);
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Create an emboss maskfilter
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param direction    array of 3 scalars [x, y, z] specifying the direction of the light source
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param ambient      0...1 amount of ambient light
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param specular     coefficient for specular highlights (e.g. 8)
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param blurRadius   amount to blur before applying lighting (e.g. 3)
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the emboss maskfilter
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static SkMaskFilter* CreateEmboss(  const SkScalar direction[3],
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                        SkScalar ambient, SkScalar specular,
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                        SkScalar blurRadius);
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBlurMaskFilter(); // can't be instantiated
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
69