Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
SkShaderMaskFilterImpl Class Reference

#include <SkShaderMaskFilterImpl.h>

Inheritance diagram for SkShaderMaskFilterImpl:
SkMaskFilterBase SkMaskFilter SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

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

Private Member Functions

void flatten (SkWriteBuffer &) const override
 

Friends

class SkShaderMaskFilter
 

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 25 of file SkShaderMaskFilterImpl.h.

Constructor & Destructor Documentation

◆ SkShaderMaskFilterImpl()

SkShaderMaskFilterImpl::SkShaderMaskFilterImpl ( sk_sp< SkShader shader)
inline

Definition at line 27 of file SkShaderMaskFilterImpl.h.

27: fShader(std::move(shader)) {}
sk_sp< SkShader > shader() const

Member Function Documentation

◆ asABlur()

bool SkShaderMaskFilterImpl::asABlur ( BlurRec ) const
inlineoverridevirtual

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 from SkMaskFilterBase.

Definition at line 39 of file SkShaderMaskFilterImpl.h.

39{ return false; }

◆ computeFastBounds()

void SkShaderMaskFilterImpl::computeFastBounds ( const SkRect src,
SkRect dest 
) const
inlineoverridevirtual

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 35 of file SkShaderMaskFilterImpl.h.

35 {
36 *dst = src;
37 }
dst
Definition cp.py:12

◆ filterMask()

bool SkShaderMaskFilterImpl::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 SkShaderMaskFilterImpl.cpp.

50 {
51 if (src.fFormat != SkMask::kA8_Format) {
52 return false;
53 }
54
55 if (margin) {
56 margin->set(0, 0);
57 }
58 dst->bounds() = src.fBounds;
59 dst->rowBytes() = src.fBounds.width(); // need alignment?
60 dst->format() = SkMask::kA8_Format;
61
62 if (src.fImage == nullptr) {
63 dst->image() = nullptr;
64 return true;
65 }
66 size_t size = dst->computeImageSize();
67 if (0 == size) {
68 return false; // too big to allocate, abort
69 }
70
71 // Allocate and initialize dst image with a copy of the src image
72 dst->image() = SkMaskBuilder::AllocImage(size);
73 rect_memcpy(dst->image(), dst->fRowBytes, src.fImage, src.fRowBytes,
74 src.fBounds.width() * sizeof(uint8_t), src.fBounds.height());
75
76 // Now we have a dst-mask, just need to setup a canvas and draw into it
78 if (!bitmap.installMaskPixels(*dst)) {
79 return false;
80 }
81
83 paint.setShader(fShader);
84 // this blendmode is the trick: we only draw the shader where the mask is
85 paint.setBlendMode(SkBlendMode::kSrcIn);
86
87 SkCanvas canvas(bitmap);
88 canvas.translate(-SkIntToScalar(dst->fBounds.fLeft), -SkIntToScalar(dst->fBounds.fTop));
89 canvas.concat(ctm);
90 canvas.drawPaint(paint);
91 return true;
92}
@ kSrcIn
r = s * da
static bool rect_memcpy(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, const SkImageInfo &srcInfo, const void *srcPixels, size_t srcRB, const SkColorSpaceXformSteps &steps)
#define SkIntToScalar(x)
Definition SkScalar.h:57
const Paint & paint
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
void set(int32_t x, int32_t y)
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 SkShaderMaskFilterImpl::flatten ( SkWriteBuffer ) const
overrideprivatevirtual

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 36 of file SkShaderMaskFilterImpl.cpp.

36 {
37 buffer.writeFlattenable(fShader.get());
38}
T * get() const
Definition SkRefCnt.h:303
static const uint8_t buffer[]

◆ getFormat()

SkMask::Format SkShaderMaskFilterImpl::getFormat ( ) const
inlineoverridevirtual

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

Implements SkMaskFilterBase.

Definition at line 29 of file SkShaderMaskFilterImpl.h.

29{ return SkMask::kA8_Format; }

◆ shader()

sk_sp< SkShader > SkShaderMaskFilterImpl::shader ( ) const
inline

Definition at line 40 of file SkShaderMaskFilterImpl.h.

40{ return fShader; }

◆ type()

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

Friends And Related Symbol Documentation

◆ SkShaderMaskFilter

friend class SkShaderMaskFilter
friend

Definition at line 50 of file SkShaderMaskFilterImpl.h.


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