diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-10-29 15:19:10 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-10-29 15:19:10 +0000 |
commit | 3cfda413a2eadedc1ef9db3c980e78f4d415d6dc (patch) | |
tree | 7999c4f978f93d2312a8b86d19c2e92d47c01247 /include | |
parent | a563162780d589938aef8a4d8b63d2957139313b (diff) |
add gamma maskfilter, especially nice when applied after a blur
git-svn-id: http://skia.googlecode.com/svn/trunk@411 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/effects/SkGammaMaskFilter.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/effects/SkGammaMaskFilter.h b/include/effects/SkGammaMaskFilter.h new file mode 100644 index 0000000000..fdff43d1e8 --- /dev/null +++ b/include/effects/SkGammaMaskFilter.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SkGammaMaskFilter_DEFINED +#define SkGammaMaskFilter_DEFINED + +#include "SkMaskFilter.h" +#include "SkScalar.h" + +/** \class SkGammaMaskFilter + + Applies a table lookup on each of the alpha values in the mask. + An arbitrary table can be assigned, or a gamma (pow) table is computed + based on the specified exponent. + */ +class SkGammaMaskFilter : public SkMaskFilter { +public: + SkGammaMaskFilter(); + SkGammaMaskFilter(SkScalar gamma); + SkGammaMaskFilter(const uint8_t table[256]); + virtual ~SkGammaMaskFilter(); + + void setGamma(SkScalar gamma); + void setGammaTable(const uint8_t table[256]); + + // overrides from SkMaskFilter + virtual SkMask::Format getFormat(); + virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*); + + // overrides from SkFlattenable + virtual void flatten(SkFlattenableWriteBuffer& wb); + virtual Factory getFactory(); + +protected: + SkGammaMaskFilter(SkFlattenableReadBuffer& rb); + static SkFlattenable* Factory(SkFlattenableReadBuffer&); + +private: + uint8_t fTable[256]; + + typedef SkMaskFilter INHERITED; +}; + +#endif + |