SkBlurMaskFilter.h revision 7ce661d19c5cf4484305a1b20c44bd111f129847
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBlurMaskFilter_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBlurMaskFilter_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// we include this since our callers will need to at least be able to ref/unref 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMaskFilter.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158c3ff17e2cab6f7c798b9f8ff4515c4a3d3fd9d1bsalomon@google.comclass SK_API SkBlurMaskFilter { 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum BlurStyle { 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kNormal_BlurStyle, //!< fuzzy inside and outside 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kSolid_BlurStyle, //!< solid inside, fuzzy outside 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kOuter_BlurStyle, //!< nothing inside, fuzzy outside 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kInner_BlurStyle, //!< fuzzy inside, nothing outside 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kBlurStyleCount 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 26038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org enum BlurFlags { 27038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org kNone_BlurFlag = 0x00, 28038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org /** The blur layer's radius is not affected by transforms */ 294868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kIgnoreTransform_BlurFlag = 0x01, 304868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org /** Use a smother, higher qulity blur algorithm */ 314868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kHighQuality_BlurFlag = 0x02, 32038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org /** mask for all blur flags */ 3391f489a65d436d36c7fe580af2775cd0cd13c8d2senorblanco@chromium.org kAll_BlurFlag = 0x03 34038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org }; 35038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org 367ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com /** 377ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com * DEPRECATED - radius-based 387ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com */ 397ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* Create(SkScalar radius, BlurStyle style, 407ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com uint32_t flags = kNone_BlurFlag); 417ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create a blur maskfilter. 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param style The BlurStyle to use 447ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 45038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org @param flags Flags to use - defaults to none 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The new blur maskfilter 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 487ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* Create(BlurStyle style, SkScalar sigma, 49038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org uint32_t flags = kNone_BlurFlag); 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create an emboss maskfilter 527ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com @param blurSigma standard deviation of the Gaussian blur to apply 537ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com before applying lighting (e.g. 3) 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param direction array of 3 scalars [x, y, z] specifying the direction of the light source 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ambient 0...1 amount of ambient light 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param specular coefficient for specular highlights (e.g. 8) 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the emboss maskfilter 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 597ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3], 607ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar ambient, SkScalar specular); 617ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 627ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com // DEPRECATED - radius-based 637ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* CreateEmboss(const SkScalar direction[3], 647ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar ambient, SkScalar specular, 657ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar blurRadius); 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 67a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 687ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBlurMaskFilter(); // can't be instantiated 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 74