SkBlurMaskFilter.h revision 4868e6b221a4a98e40f977851af5fcf09631ea15
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 */ 384868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kIgnoreTransform_BlurFlag = 0x01, 394868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org /** Use a smother, higher qulity blur algorithm */ 404868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kHighQuality_BlurFlag = 0x02, 41038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org /** mask for all blur flags */ 424868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kAll_BlurFlag = 0x03 43038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org }; 44038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create a blur maskfilter. 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param radius The radius to extend the blur from the original mask. Must be > 0. 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param style The BlurStyle to use 48038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org @param flags Flags to use - defaults to none 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The new blur maskfilter 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 51038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org static SkMaskFilter* Create(SkScalar radius, BlurStyle style, 52038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org uint32_t flags = kNone_BlurFlag); 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create an emboss maskfilter 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param direction array of 3 scalars [x, y, z] specifying the direction of the light source 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ambient 0...1 amount of ambient light 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param specular coefficient for specular highlights (e.g. 8) 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param blurRadius amount to blur before applying lighting (e.g. 3) 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the emboss maskfilter 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static SkMaskFilter* CreateEmboss( const SkScalar direction[3], 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar ambient, SkScalar specular, 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar blurRadius); 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBlurMaskFilter(); // can't be instantiated 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 71