aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
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: