Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sktext::gpu::SDFMaskFilterImpl Class Reference
Inheritance diagram for sktext::gpu::SDFMaskFilterImpl:
SkMaskFilterBase SkMaskFilter SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SDFMaskFilterImpl ()
 
SkMask::Format getFormat () const override
 
bool filterMask (SkMaskBuilder *dst, const SkMask &src, const SkMatrix &, SkIPoint *margin) const override
 
SkMaskFilterBase::Type type () const override
 
void computeFastBounds (const SkRect &, SkRect *) const override
 
- Public Member Functions inherited from SkMaskFilterBase
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
 
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
 

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 }
 
- 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
 

Detailed Description

Definition at line 24 of file SDFMaskFilter.cpp.

Constructor & Destructor Documentation

◆ SDFMaskFilterImpl()

sktext::gpu::SDFMaskFilterImpl::SDFMaskFilterImpl ( )

Definition at line 43 of file SDFMaskFilter.cpp.

43{}

Member Function Documentation

◆ computeFastBounds()

void sktext::gpu::SDFMaskFilterImpl::computeFastBounds ( const SkRect src,
SkRect dest 
) const
overridevirtual

The fast bounds function is used to enable the paint to be culled early in the drawing pipeline. This function accepts the current bounds of the paint as its src param and the filter adjust those bounds using its current mask and returns the result using the dest param. Callers are allowed to provide the same struct for both src and dest so each implementation must accommodate that behavior.

The default impl calls filterMask with the src mask having no image, but subclasses may override this if they can compute the rect faster.

Reimplemented from SkMaskFilterBase.

Definition at line 87 of file SDFMaskFilter.cpp.

88 {
89 dst->setLTRB(src.fLeft - SK_DistanceFieldPad, src.fTop - SK_DistanceFieldPad,
91}
#define SK_DistanceFieldPad
dst
Definition cp.py:12

◆ filterMask()

bool sktext::gpu::SDFMaskFilterImpl::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 49 of file SDFMaskFilter.cpp.

50 {
51 if (src.fFormat != SkMask::kA8_Format
52 && src.fFormat != SkMask::kBW_Format
53 && src.fFormat != SkMask::kLCD16_Format) {
54 return false;
55 }
56
58 dst->format() = SkMask::kSDF_Format;
59
60 if (margin) {
62 }
63
64 if (src.fImage == nullptr) {
65 return true;
66 }
67 if (dst->fImage == nullptr) {
68 dst->bounds().setEmpty();
69 return false;
70 }
71
72 if (src.fFormat == SkMask::kA8_Format) {
73 return SkGenerateDistanceFieldFromA8Image(dst->image(), src.fImage,
74 src.fBounds.width(), src.fBounds.height(),
75 src.fRowBytes);
76 } else if (src.fFormat == SkMask::kLCD16_Format) {
77 return SkGenerateDistanceFieldFromLCD16Mask(dst->image(), src.fImage,
78 src.fBounds.width(), src.fBounds.height(),
79 src.fRowBytes);
80 } else {
81 return SkGenerateDistanceFieldFromBWImage(dst->image(), src.fImage,
82 src.fBounds.width(), src.fBounds.height(),
83 src.fRowBytes);
84 }
85}
bool SkGenerateDistanceFieldFromBWImage(unsigned char *distanceField, const unsigned char *image, int width, int height, size_t rowBytes)
bool SkGenerateDistanceFieldFromA8Image(unsigned char *distanceField, const unsigned char *image, int width, int height, size_t rowBytes)
bool SkGenerateDistanceFieldFromLCD16Mask(unsigned char *distanceField, const unsigned char *image, int w, int h, size_t rowBytes)
void set(int32_t x, int32_t y)
static SkMaskBuilder PrepareDestination(int radiusX, int radiusY, const SkMask &src)
Definition SkMask.cpp:61
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition SkMask.h:31
@ kSDF_Format
8bits representing signed distance field
Definition SkMask.h:32
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition SkMask.h:27

◆ getFormat()

SkMask::Format sktext::gpu::SDFMaskFilterImpl::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 45 of file SDFMaskFilter.cpp.

45 {
47}

◆ type()

SkMaskFilterBase::Type sktext::gpu::SDFMaskFilterImpl::type ( ) const
inlineoverridevirtual

Implements SkMaskFilterBase.

Definition at line 34 of file SDFMaskFilter.cpp.


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