Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
SkTableMaskFilterImpl Class Reference
Inheritance diagram for SkTableMaskFilterImpl:
SkMaskFilterBase SkMaskFilter SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkTableMaskFilterImpl (const uint8_t table[256])
 
SkMask::Format getFormat () const override
 
bool filterMask (SkMaskBuilder *, const SkMask &, const SkMatrix &, SkIPoint *) const override
 
SkMaskFilterBase::Type type () const override
 
- Public Member Functions inherited from SkMaskFilterBase
virtual SkMask::Format getFormat () const =0
 
virtual bool filterMask (SkMaskBuilder *dst, const SkMask &src, const SkMatrix &, SkIPoint *margin) const =0
 
virtual Type type () const =0
 
virtual void computeFastBounds (const SkRect &src, SkRect *dest) const
 
virtual bool asABlur (BlurRec *) const
 
virtual sk_sp< SkImageFilterasImageFilter (const SkMatrix &ctm) const
 
SkFlattenable::Type getFlattenableType () const override
 
- Public Member Functions inherited from SkMaskFilter
SkRect approximateFilteredBounds (const SkRect &src) const
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
virtual Factory getFactory () const =0
 
virtual const char * getTypeName () const =0
 
virtual void flatten (SkWriteBuffer &) const
 
virtual Type getFlattenableType () const =0
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

 ~SkTableMaskFilterImpl () override
 
void flatten (SkWriteBuffer &) const override
 
- Protected Member Functions inherited from SkMaskFilterBase
 SkMaskFilterBase ()
 
virtual FilterReturn filterRectsToNine (const SkRect[], int count, const SkMatrix &, const SkIRect &clipBounds, SkTLazy< NinePatch > *) const
 
virtual FilterReturn filterRRectToNine (const SkRRect &, const SkMatrix &, const SkIRect &clipBounds, SkTLazy< NinePatch > *) const
 

Additional Inherited Members

- Public Types inherited from SkMaskFilterBase
enum class  Type {
  kBlur , kEmboss , kSDF , kShader ,
  kTable
}
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 
- Static Public Member Functions inherited from SkMaskFilterBase
static SkFlattenable::Type GetFlattenableType ()
 
- Static Public Member Functions inherited from SkMaskFilter
static sk_sp< SkMaskFilterMakeBlur (SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
 
static sk_sp< SkMaskFilterDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 
- Protected Types inherited from SkMaskFilterBase
enum  FilterReturn { kFalse_FilterReturn , kTrue_FilterReturn , kUnimplemented_FilterReturn }
 

Detailed Description

Definition at line 32 of file SkTableMaskFilter.cpp.

Constructor & Destructor Documentation

◆ SkTableMaskFilterImpl()

SkTableMaskFilterImpl::SkTableMaskFilterImpl ( const uint8_t  table[256])
explicit

Definition at line 61 of file SkTableMaskFilter.cpp.

61 {
62 memcpy(fTable, table, sizeof(fTable));
63}
SI F table(const skcms_Curve *curve, F v)

◆ ~SkTableMaskFilterImpl()

SkTableMaskFilterImpl::~SkTableMaskFilterImpl ( )
overrideprotected

Definition at line 65 of file SkTableMaskFilter.cpp.

65{}

Member Function Documentation

◆ filterMask()

bool SkTableMaskFilterImpl::filterMask ( SkMaskBuilder dst,
const SkMask src,
const SkMatrix ,
SkIPoint margin 
) const
overridevirtual

Create a new mask by filter the src mask. If src.fImage == null, then do not allocate or create the dst image but do fill out the other fields in dstMask. If you do allocate a dst image, use SkMask::AllocImage() If this returns false, dst mask is ignored.

Parameters
dstthe result of the filter. If src.fImage == null, dst should not allocate its image
srcthe original image to be filtered.
matrixthe CTM
marginif not null, return the buffer dx/dy need when calculating the effect. Used when drawing a clipped object to know how much larger to allocate the src before applying the filter. If returning false, ignore this parameter.
Returns
true if the dst mask was correctly created.

Implements SkMaskFilterBase.

Definition at line 67 of file SkTableMaskFilter.cpp.

68 {
69 if (src.fFormat != SkMask::kA8_Format) {
70 return false;
71 }
72
73 dst->bounds() = src.fBounds;
74 dst->rowBytes() = SkAlign4(dst->fBounds.width());
75 dst->format() = SkMask::kA8_Format;
76 dst->image() = nullptr;
77
78 if (src.fImage) {
79 dst->image() = SkMaskBuilder::AllocImage(dst->computeImageSize());
80
81 const uint8_t* srcP = src.fImage;
82 uint8_t* dstP = dst->image();
83 const uint8_t* table = fTable;
84 int dstWidth = dst->fBounds.width();
85 int extraZeros = dst->fRowBytes - dstWidth;
86
87 for (int y = dst->fBounds.height() - 1; y >= 0; --y) {
88 for (int x = dstWidth - 1; x >= 0; --x) {
89 dstP[x] = table[srcP[x]];
90 }
91 srcP += src.fRowBytes;
92 // we can't just inc dstP by rowbytes, because if it has any
93 // padding between its width and its rowbytes, we need to zero those
94 // so that the bitters can read those safely if that is faster for
95 // them
96 dstP += dstWidth;
97 for (int i = extraZeros - 1; i >= 0; --i) {
98 *dstP++ = 0;
99 }
100 }
101 }
102
103 if (margin) {
104 margin->set(0, 0);
105 }
106 return true;
107}
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
double y
double x
dst
Definition: cp.py:12
void set(int32_t x, int32_t y)
Definition: SkPoint_impl.h:65
static uint8_t * AllocImage(size_t bytes, AllocType=kUninit_Alloc)
Definition: SkMask.cpp:45
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28

◆ flatten()

void SkTableMaskFilterImpl::flatten ( SkWriteBuffer ) const
overrideprotectedvirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Definition at line 113 of file SkTableMaskFilter.cpp.

113 {
114 wb.writeByteArray(fTable, 256);
115}

◆ getFormat()

SkMask::Format SkTableMaskFilterImpl::getFormat ( ) const
overridevirtual

Returns the format of the resulting mask that this subclass will return when its filterMask() method is called.

Implements SkMaskFilterBase.

Definition at line 109 of file SkTableMaskFilter.cpp.

109 {
110 return SkMask::kA8_Format;
111}

◆ type()

SkMaskFilterBase::Type SkTableMaskFilterImpl::type ( ) const
inlineoverridevirtual

Implements SkMaskFilterBase.

Definition at line 38 of file SkTableMaskFilter.cpp.


The documentation for this class was generated from the following file: