SkBlurMaskFilter.h revision e396455d2d60ddf8e625b5037254f3c09fbcdcf5
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" 14e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#include "SkBlurTypes.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 168c3ff17e2cab6f7c798b9f8ff4515c4a3d3fd9d1bsalomon@google.comclass SK_API SkBlurMaskFilter { 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 18e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum BlurStyle { 20e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org kNormal_BlurStyle = kNormal_SkBlurStyle, //!< fuzzy inside and outside 21e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org kSolid_BlurStyle = kSolid_SkBlurStyle, //!< solid inside, fuzzy outside 22e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org kOuter_BlurStyle = kOuter_SkBlurStyle, //!< nothing inside, fuzzy outside 23e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org kInner_BlurStyle = kInner_SkBlurStyle, //!< fuzzy inside, nothing outside 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kBlurStyleCount 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 27e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#endif 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 29038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org enum BlurFlags { 30038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org kNone_BlurFlag = 0x00, 31038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org /** The blur layer's radius is not affected by transforms */ 324868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kIgnoreTransform_BlurFlag = 0x01, 334868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org /** Use a smother, higher qulity blur algorithm */ 344868e6b221a4a98e40f977851af5fcf09631ea15senorblanco@chromium.org kHighQuality_BlurFlag = 0x02, 35038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org /** mask for all blur flags */ 3691f489a65d436d36c7fe580af2775cd0cd13c8d2senorblanco@chromium.org kAll_BlurFlag = 0x03 37038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org }; 38038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org 39e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE 404469938e92d779dff05e745559e67907bbf21e78reed@google.com SK_ATTR_DEPRECATED("use sigma version") 417ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* Create(SkScalar radius, BlurStyle style, 427ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com uint32_t flags = kNone_BlurFlag); 437ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create a blur maskfilter. 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param style The BlurStyle to use 467ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 47038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org @param flags Flags to use - defaults to none 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The new blur maskfilter 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 507ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* Create(BlurStyle style, SkScalar sigma, 51038aff623d9fd47946cd31685f74cf473f7c84f0senorblanco@chromium.org uint32_t flags = kNone_BlurFlag); 52e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org#endif 53e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org 54e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org /** Create a blur maskfilter. 55e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org * @param style The SkBlurStyle to use 56e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org * @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 57e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org * @param flags Flags to use - defaults to none 58e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org * @return The new blur maskfilter 59e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org */ 60e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org static SkMaskFilter* Create(SkBlurStyle style, SkScalar sigma, uint32_t flags = kNone_BlurFlag); 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create an emboss maskfilter 637bd141dce43ea3405bc60c9c84e6f910b851b079skia.committer@gmail.com @param blurSigma standard deviation of the Gaussian blur to apply 647ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com before applying lighting (e.g. 3) 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param direction array of 3 scalars [x, y, z] specifying the direction of the light source 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ambient 0...1 amount of ambient light 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param specular coefficient for specular highlights (e.g. 8) 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the emboss maskfilter 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 707ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3], 717ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar ambient, SkScalar specular); 727ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 734469938e92d779dff05e745559e67907bbf21e78reed@google.com SK_ATTR_DEPRECATED("use sigma version") 747ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com static SkMaskFilter* CreateEmboss(const SkScalar direction[3], 757ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar ambient, SkScalar specular, 767ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com SkScalar blurRadius); 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 78a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 797ce661d19c5cf4484305a1b20c44bd111f129847robertphillips@google.com 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBlurMaskFilter(); // can't be instantiated 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 85