Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
SkMaskFilterBase Class Referenceabstract

#include <SkMaskFilterBase.h>

Inheritance diagram for SkMaskFilterBase:
SkMaskFilter SkFlattenable SkRefCnt SkRefCntBase SkBlurMaskFilterImpl SkEmbossMaskFilter SkShaderMaskFilterImpl SkTableMaskFilterImpl sktext::gpu::SDFMaskFilterImpl

Classes

struct  BlurRec
 
class  NinePatch
 

Public Types

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 &)
 

Public Member Functions

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
 

Static Public Member Functions

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

enum  FilterReturn { kFalse_FilterReturn , kTrue_FilterReturn , kUnimplemented_FilterReturn }
 

Protected Member Functions

 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
 

Friends

class SkDraw
 
class SkDrawBase
 

Detailed Description

Definition at line 45 of file SkMaskFilterBase.h.

Member Enumeration Documentation

◆ FilterReturn

Enumerator
kFalse_FilterReturn 
kTrue_FilterReturn 
kUnimplemented_FilterReturn 

Definition at line 119 of file SkMaskFilterBase.h.

◆ Type

enum class SkMaskFilterBase::Type
strong
Enumerator
kBlur 
kEmboss 
kSDF 
kShader 
kTable 

Definition at line 68 of file SkMaskFilterBase.h.

68 {
69 kBlur,
70 kEmboss,
71 kSDF,
72 kShader,
73 kTable,
74 };
@ kBlur
Definition: paint.cc:59

Constructor & Destructor Documentation

◆ SkMaskFilterBase()

SkMaskFilterBase::SkMaskFilterBase ( )
inlineprotected

Definition at line 117 of file SkMaskFilterBase.h.

117{}

Member Function Documentation

◆ asABlur()

bool SkMaskFilterBase::asABlur ( BlurRec ) const
virtual

If this filter can be represented by a BlurRec, return true and (if not null) fill in the provided BlurRec parameter. If this effect cannot be represented as a BlurRec, return false and ignore the BlurRec parameter.

Reimplemented in SkBlurMaskFilterImpl, and SkShaderMaskFilterImpl.

Definition at line 46 of file SkMaskFilter.cpp.

46 {
47 return false;
48}

◆ asImageFilter()

sk_sp< SkImageFilter > SkMaskFilterBase::asImageFilter ( const SkMatrix ctm) const
virtual

Return an SkImageFilter representation of this mask filter that SkCanvas can apply to an alpha-only image to produce an equivalent effect to running the mask filter directly.

Reimplemented in SkBlurMaskFilterImpl.

Definition at line 50 of file SkMaskFilter.cpp.

50 {
51 return nullptr;
52}

◆ computeFastBounds()

void SkMaskFilterBase::computeFastBounds ( const SkRect src,
SkRect dest 
) const
virtual

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 in SkBlurMaskFilterImpl, sktext::gpu::SDFMaskFilterImpl, and SkShaderMaskFilterImpl.

Definition at line 305 of file SkMaskFilter.cpp.

305 {
306 SkMask srcM(nullptr, src.roundOut(), 0, SkMask::kA8_Format);
307 SkMaskBuilder dstM;
308
309 SkIPoint margin; // ignored
310 if (this->filterMask(&dstM, srcM, SkMatrix::I(), &margin)) {
311 dst->set(dstM.fBounds);
312 } else {
313 dst->set(srcM.fBounds);
314 }
315}
virtual bool filterMask(SkMaskBuilder *dst, const SkMask &src, const SkMatrix &, SkIPoint *margin) const =0
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
dst
Definition: cp.py:12
Definition: SkMask.h:25
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
const SkIRect fBounds
Definition: SkMask.h:42

◆ filterMask()

virtual bool SkMaskFilterBase::filterMask ( SkMaskBuilder dst,
const SkMask src,
const SkMatrix ,
SkIPoint margin 
) const
pure virtual

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.

Implemented in SkTableMaskFilterImpl, SkBlurMaskFilterImpl, SkEmbossMaskFilter, SkShaderMaskFilterImpl, and sktext::gpu::SDFMaskFilterImpl.

◆ filterRectsToNine()

SkMaskFilterBase::FilterReturn SkMaskFilterBase::filterRectsToNine ( const  SkRect[],
int  count,
const SkMatrix ,
const SkIRect clipBounds,
SkTLazy< NinePatch > *   
) const
protectedvirtual

Override if your subclass can filter a rect, and return the answer as a ninepatch mask to be stretched over the returned outerRect. On success return kTrue_FilterReturn. On failure (e.g. out of memory) return kFalse_FilterReturn. If the normal filterMask() entry-point should be called (the default) return kUnimplemented_FilterReturn.

By convention, the caller will take the center rol/col from the returned mask as the slice it can replicate horizontally and vertically as we stretch the mask to fit inside outerRect. It is an error for outerRect to be smaller than the mask's bounds. This would imply that the width and height of the mask should be odd. This is not required, just that the caller will call mask.fBounds.centerX() and centerY() to find the strips that will be replicated.

Definition at line 300 of file SkMaskFilter.cpp.

301 {
303}

◆ filterRRectToNine()

SkMaskFilterBase::FilterReturn SkMaskFilterBase::filterRRectToNine ( const SkRRect ,
const SkMatrix ,
const SkIRect clipBounds,
SkTLazy< NinePatch > *   
) const
protectedvirtual

Similar to filterRectsToNine, except it performs the work on a round rect.

Definition at line 294 of file SkMaskFilter.cpp.

295 {
297}

◆ GetFlattenableType()

static SkFlattenable::Type SkMaskFilterBase::GetFlattenableType ( )
inlinestatic

Definition at line 108 of file SkMaskFilterBase.h.

108 {
109 return kSkMaskFilter_Type;
110 }

◆ getFlattenableType()

SkFlattenable::Type SkMaskFilterBase::getFlattenableType ( ) const
inlineoverridevirtual

Implements SkFlattenable.

Definition at line 112 of file SkMaskFilterBase.h.

112 {
113 return kSkMaskFilter_Type;
114 }

◆ getFormat()

virtual SkMask::Format SkMaskFilterBase::getFormat ( ) const
pure virtual

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

Implemented in SkBlurMaskFilterImpl, SkEmbossMaskFilter, SkShaderMaskFilterImpl, SkTableMaskFilterImpl, and sktext::gpu::SDFMaskFilterImpl.

◆ type()

virtual Type SkMaskFilterBase::type ( ) const
pure virtual

Friends And Related Function Documentation

◆ SkDraw

friend class SkDraw
friend

Definition at line 164 of file SkMaskFilterBase.h.

◆ SkDrawBase

friend class SkDrawBase
friend

Definition at line 165 of file SkMaskFilterBase.h.


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