Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkTableMaskFilter.h
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkTableMaskFilter_DEFINED
9 #define SkTableMaskFilter_DEFINED
10 
11 #include "SkMaskFilter.h"
12 #include "SkScalar.h"
13 
19 class SK_API SkTableMaskFilter : public SkMaskFilter {
20 public:
23  static void MakeGammaTable(uint8_t table[256], SkScalar gamma);
24 
28  static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max);
29 
30  static SkMaskFilter* Create(const uint8_t table[256]) {
31  return new SkTableMaskFilter(table);
32  }
33 
34  static SkMaskFilter* CreateGamma(SkScalar gamma) {
35  uint8_t table[256];
36  MakeGammaTable(table, gamma);
37  return new SkTableMaskFilter(table);
38  }
39 
40  static SkMaskFilter* CreateClip(uint8_t min, uint8_t max) {
41  uint8_t table[256];
42  MakeClipTable(table, min, max);
43  return new SkTableMaskFilter(table);
44  }
45 
46  SkMask::Format getFormat() const override;
47  bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override;
48 
49  SK_TO_STRING_OVERRIDE()
50  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter)
51 
52 protected:
53  ~SkTableMaskFilter() override;
54 
55  void flatten(SkWriteBuffer&) const override;
56 
57 private:
59  explicit SkTableMaskFilter(const uint8_t table[256]);
60 
61  uint8_t fTable[256];
62 
63  typedef SkMaskFilter INHERITED;
64 };
65 
66 #endif
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Definition: SkRefCnt.h:125
SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or the 3-channel 3D format.
Definition: SkMask.h:19
virtual bool filterMask(SkMask *dst, const SkMask &src, const SkMatrix &, SkIPoint *margin) const
Create a new mask by filter the src mask.
SkMaskFilter is the base class for object that perform transformations on an alpha-channel mask befor...
Definition: SkMaskFilter.h:47
virtual SkMask::Format getFormat() const =0
Returns the format of the resulting mask that this subclass will return when its filterMask() method ...
Applies a table lookup on each of the alpha values in the mask.
Definition: SkTableMaskFilter.h:19
Format
Definition: SkMask.h:22
Definition: SkWriteBuffer.h:27
virtual void flatten(SkWriteBuffer &) const
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Definition: SkFlattenable.h:117
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40