diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-10-29 17:37:56 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-10-29 17:37:56 +0000 |
commit | 3f2025fdb5fc0bd8b1edc92174f0df5226942f8a (patch) | |
tree | a1968bdcfcf1920890b059ba37ea8736daa4f44f /include | |
parent | 3cfda413a2eadedc1ef9db3c980e78f4d415d6dc (diff) |
rename gamma to table, since it is more general than just gamma
git-svn-id: http://skia.googlecode.com/svn/trunk@412 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/effects/SkTableMaskFilter.h (renamed from include/effects/SkGammaMaskFilter.h) | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/include/effects/SkGammaMaskFilter.h b/include/effects/SkTableMaskFilter.h index fdff43d1e8..a57053d6f3 100644 --- a/include/effects/SkGammaMaskFilter.h +++ b/include/effects/SkTableMaskFilter.h @@ -14,27 +14,45 @@ * limitations under the License. */ -#ifndef SkGammaMaskFilter_DEFINED -#define SkGammaMaskFilter_DEFINED +#ifndef SkTableMaskFilter_DEFINED +#define SkTableMaskFilter_DEFINED #include "SkMaskFilter.h" #include "SkScalar.h" -/** \class SkGammaMaskFilter +/** \class SkTableMaskFilter 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. + Helper methods create some common tables (e.g. gamma, clipping) */ -class SkGammaMaskFilter : public SkMaskFilter { +class SkTableMaskFilter : public SkMaskFilter { public: - SkGammaMaskFilter(); - SkGammaMaskFilter(SkScalar gamma); - SkGammaMaskFilter(const uint8_t table[256]); - virtual ~SkGammaMaskFilter(); + SkTableMaskFilter(); + SkTableMaskFilter(const uint8_t table[256]); + virtual ~SkTableMaskFilter(); - void setGamma(SkScalar gamma); - void setGammaTable(const uint8_t table[256]); + void setTable(const uint8_t table[256]); + + /** Utility that sets the gamma table + */ + static void MakeGammaTable(uint8_t table[256], SkScalar gamma); + + /** Utility that creates a clipping table: clamps values below min to 0 + and above max to 255, and rescales the remaining into 0..255 + */ + static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); + + static SkTableMaskFilter* CreateGamma(SkScalar gamma) { + uint8_t table[256]; + MakeGammaTable(table, gamma); + return SkNEW_ARGS(SkTableMaskFilter, (table)); + } + + static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) { + uint8_t table[256]; + MakeClipTable(table, min, max); + return SkNEW_ARGS(SkTableMaskFilter, (table)); + } // overrides from SkMaskFilter virtual SkMask::Format getFormat(); @@ -45,7 +63,7 @@ public: virtual Factory getFactory(); protected: - SkGammaMaskFilter(SkFlattenableReadBuffer& rb); + SkTableMaskFilter(SkFlattenableReadBuffer& rb); static SkFlattenable* Factory(SkFlattenableReadBuffer&); private: |