Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkPictureShader Class Reference

#include <SkPictureShader.h>

Inheritance diagram for SkPictureShader:
SkShaderBase SkShader SkFlattenable SkRefCnt SkRefCntBase

Classes

struct  CachedImageInfo
 

Public Member Functions

 SkPictureShader (sk_sp< SkPicture >, SkTileMode, SkTileMode, SkFilterMode, const SkRect *)
 
ShaderType type () const override
 
sk_sp< SkPicturepicture () const
 
SkRect tile () const
 
SkTileMode tileModeX () const
 
SkTileMode tileModeY () const
 
SkFilterMode filter () const
 
- Public Member Functions inherited from SkShaderBase
 ~SkShaderBase () override
 
sk_sp< SkShadermakeInvertAlpha () const
 
sk_sp< SkShadermakeWithCTM (const SkMatrix &) const
 
virtual bool isConstant () const
 
virtual GradientType asGradient (GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
 
ContextmakeContext (const ContextRec &, SkArenaAlloc *) const
 
bool asLuminanceColor (SkColor4f *) const
 
bool appendRootStages (const SkStageRec &rec, const SkMatrix &ctm) const
 
virtual SkImageonIsAImage (SkMatrix *, SkTileMode[2]) const
 
virtual SkRuntimeEffectasRuntimeEffect () const
 
Type getFlattenableType () const override
 
virtual sk_sp< SkShadermakeAsALocalMatrixShader (SkMatrix *localMatrix) const
 
- Public Member Functions inherited from SkShader
virtual bool isOpaque () const
 
SkImageisAImage (SkMatrix *localMatrix, SkTileMode xy[2]) const
 
bool isAImage () const
 
sk_sp< SkShadermakeWithLocalMatrix (const SkMatrix &) const
 
sk_sp< SkShadermakeWithColorFilter (sk_sp< SkColorFilter >) const
 
sk_sp< SkShadermakeWithWorkingColorSpace (sk_sp< SkColorSpace >) 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
 

Static Public Member Functions

static sk_sp< SkShaderMake (sk_sp< SkPicture >, SkTileMode, SkTileMode, SkFilterMode, const SkMatrix *, const SkRect *)
 
- Static Public Member Functions inherited from SkShaderBase
static Type GetFlattenableType ()
 
static sk_sp< SkShaderBaseDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
static void RegisterFlattenables ()
 
static SkMatrix ConcatLocalMatrices (const SkMatrix &parentLM, const SkMatrix &childLM)
 
- 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 Member Functions

 SkPictureShader (SkReadBuffer &)
 
void flatten (SkWriteBuffer &) const override
 
bool appendStages (const SkStageRec &, const SkShaders::MatrixRec &) const override
 
- Protected Member Functions inherited from SkShaderBase
 SkShaderBase ()
 
void flatten (SkWriteBuffer &) const override
 
virtual bool onAsLuminanceColor (SkColor4f *) const
 

Additional Inherited Members

- Public Types inherited from SkShaderBase
enum class  ShaderType { M }
 
enum class  GradientType { kNone , M }
 
enum  Flags { kOpaqueAlpha_Flag = 1 << 0 }
 
- 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 &)
 

Detailed Description

Definition at line 40 of file SkPictureShader.h.

Constructor & Destructor Documentation

◆ SkPictureShader() [1/2]

SkPictureShader::SkPictureShader ( sk_sp< SkPicture picture,
SkTileMode  tmx,
SkTileMode  tmy,
SkFilterMode  filter,
const SkRect tile 
)

Definition at line 113 of file SkPictureShader.cpp.

118 : fPicture(std::move(picture))
119 , fTile(tile ? *tile : fPicture->cullRect())
120 , fTmx(tmx)
121 , fTmy(tmy)
122 , fFilter(filter) {}
SkRect tile() const
SkFilterMode filter() const
sk_sp< SkPicture > picture() const
SkTileMode tmy
SkTileMode tmx

◆ SkPictureShader() [2/2]

SkPictureShader::SkPictureShader ( SkReadBuffer )
protected

Member Function Documentation

◆ appendStages()

bool SkPictureShader::appendStages ( const SkStageRec ,
const SkShaders::MatrixRec  
) const
overrideprotectedvirtual

Adds stages to implement this shader. To ensure that the correct input coords are present in r,g MatrixRec::apply() must be called (unless the shader doesn't require it's input coords). The default impl creates shadercontext and calls that (not very efficient).

Implements SkShaderBase.

Definition at line 288 of file SkPictureShader.cpp.

288 {
289 // Keep bitmapShader alive by using alloc instead of stack memory
290 auto& bitmapShader = *rec.fAlloc->make<sk_sp<SkShader>>();
291 // We don't check whether the total local matrix is valid here because we have to assume *some*
292 // mapping to make an image. It could be wildly wrong if there is a runtime shader transforming
293 // the coordinates in a manner we don't know about here. However, that is a fundamental problem
294 // with the technique of converting a picture to an image to implement this shader.
295 bitmapShader = this->rasterShader(mRec.totalMatrix(),
296 rec.fDstColorType,
297 rec.fDstCS,
298 rec.fSurfaceProps);
299 if (!bitmapShader) {
300 return false;
301 }
302 return as_SB(bitmapShader)->appendStages(rec, mRec);
303}
SkShaderBase * as_SB(SkShader *shader)
virtual bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const =0

◆ filter()

SkFilterMode SkPictureShader::filter ( ) const
inline

Definition at line 53 of file SkPictureShader.h.

53{ return fFilter; }

◆ flatten()

void SkPictureShader::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 168 of file SkPictureShader.cpp.

168 {
169 buffer.write32((unsigned)fTmx);
170 buffer.write32((unsigned)fTmy);
171 buffer.writeRect(fTile);
172 buffer.write32((unsigned)fFilter);
174}
static void Flatten(const sk_sp< const SkPicture >, SkWriteBuffer &buffer)
static const uint8_t buffer[]

◆ Make()

sk_sp< SkShader > SkPictureShader::Make ( sk_sp< SkPicture picture,
SkTileMode  tmx,
SkTileMode  tmy,
SkFilterMode  filter,
const SkMatrix lm,
const SkRect tile 
)
static

Definition at line 124 of file SkPictureShader.cpp.

125 {
126 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
127 return SkShaders::Empty();
128 }
129 return SkLocalMatrixShader::MakeWrapped<SkPictureShader>(lm,
130 std::move(picture),
131 tmx, tmy,
132 filter,
133 tile);
134}
virtual SkRect cullRect() const =0
bool isEmpty() const
Definition SkRect.h:693

◆ picture()

sk_sp< SkPicture > SkPictureShader::picture ( ) const
inline

Definition at line 49 of file SkPictureShader.h.

49{ return fPicture; }

◆ tile()

SkRect SkPictureShader::tile ( ) const
inline

Definition at line 50 of file SkPictureShader.h.

50{ return fTile; }

◆ tileModeX()

SkTileMode SkPictureShader::tileModeX ( ) const
inline

Definition at line 51 of file SkPictureShader.h.

51{ return fTmx; }

◆ tileModeY()

SkTileMode SkPictureShader::tileModeY ( ) const
inline

Definition at line 52 of file SkPictureShader.h.

52{ return fTmy; }

◆ type()

ShaderType SkPictureShader::type ( ) const
inlineoverridevirtual

Implements SkShaderBase.

Definition at line 47 of file SkPictureShader.h.

47{ return ShaderType::kPicture; }

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