Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkLocalMatrixShader Class Referencefinal

#include <SkLocalMatrixShader.h>

Inheritance diagram for SkLocalMatrixShader:
SkShaderBase SkShader SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkLocalMatrixShader (sk_sp< SkShader > wrapped, const SkMatrix &localMatrix)
 
bool isOpaque () const override
 
bool isConstant () const override
 
GradientType asGradient (GradientInfo *info, SkMatrix *localMatrix) const override
 
ShaderType type () const override
 
sk_sp< SkShadermakeAsALocalMatrixShader (SkMatrix *localMatrix) const override
 
const SkMatrixlocalMatrix () const
 
sk_sp< SkShaderwrappedShader () const
 
- Public Member Functions inherited from SkShaderBase
 ~SkShaderBase () override
 
sk_sp< SkShadermakeInvertAlpha () const
 
sk_sp< SkShadermakeWithCTM (const SkMatrix &) 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
 
- Public Member Functions inherited from SkShader
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

template<typename T , typename... Args>
static std::enable_if_t< std::is_base_of_v< SkShader, T >, sk_sp< SkShader > > MakeWrapped (const SkMatrix *localMatrix, Args &&... args)
 
- 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

void flatten (SkWriteBuffer &) const override
 
SkImageonIsAImage (SkMatrix *matrix, SkTileMode *mode) 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 28 of file SkLocalMatrixShader.h.

Constructor & Destructor Documentation

◆ SkLocalMatrixShader()

SkLocalMatrixShader::SkLocalMatrixShader ( sk_sp< SkShader wrapped,
const SkMatrix localMatrix 
)
inline

Definition at line 40 of file SkLocalMatrixShader.h.

41 : fLocalMatrix(localMatrix), fWrappedShader(std::move(wrapped)) {}
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
const SkMatrix & localMatrix() const

Member Function Documentation

◆ appendStages()

bool SkLocalMatrixShader::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 61 of file SkLocalMatrixShader.cpp.

62 {
63 return as_SB(fWrappedShader)->appendStages(rec, mRec.concat(fLocalMatrix));
64}
SkShaderBase * as_SB(SkShader *shader)
virtual bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const =0

◆ asGradient()

SkShaderBase::GradientType SkLocalMatrixShader::asGradient ( GradientInfo info,
SkMatrix localMatrix 
) const
overridevirtual

Reimplemented from SkShaderBase.

Definition at line 20 of file SkLocalMatrixShader.cpp.

21 {
22 GradientType type = as_SB(fWrappedShader)->asGradient(info, localMatrix);
25 }
26 return type;
27}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
ShaderType type() const override
virtual GradientType asGradient(GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
static SkMatrix ConcatLocalMatrices(const SkMatrix &parentLM, const SkMatrix &childLM)

◆ flatten()

void SkLocalMatrixShader::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 39 of file SkLocalMatrixShader.cpp.

39 {
40 buffer.writeMatrix(fLocalMatrix);
41 buffer.writeFlattenable(fWrappedShader.get());
42}
T * get() const
Definition SkRefCnt.h:303
static const uint8_t buffer[]

◆ isConstant()

bool SkLocalMatrixShader::isConstant ( ) const
overridevirtual

Returns true if the shader is guaranteed to produce only a single color. Subclasses can override this to allow loop-hoisting optimization.

Reimplemented from SkShaderBase.

Definition at line 16 of file SkLocalMatrixShader.cpp.

16 {
17 return as_SB(fWrappedShader)->isConstant();
18}
virtual bool isConstant() const

◆ isOpaque()

bool SkLocalMatrixShader::isOpaque ( ) const
inlineoverridevirtual

Returns true if the shader is guaranteed to produce only opaque colors, subject to the SkPaint using the shader to apply an opaque alpha value. Subclasses should override this to allow some optimizations.

Reimplemented from SkShader.

Definition at line 43 of file SkLocalMatrixShader.h.

43{ return as_SB(fWrappedShader)->isOpaque(); }
virtual bool isOpaque() const
Definition SkShader.h:44

◆ localMatrix()

const SkMatrix & SkLocalMatrixShader::localMatrix ( ) const
inline

Definition at line 56 of file SkLocalMatrixShader.h.

56{ return fLocalMatrix; }

◆ makeAsALocalMatrixShader()

sk_sp< SkShader > SkLocalMatrixShader::makeAsALocalMatrixShader ( SkMatrix localMatrix) const
inlineoverridevirtual

DEPRECATED. skbug.com/8941 If this shader can be represented by another shader + a localMatrix, return that shader and the localMatrix. If not, return nullptr and ignore the localMatrix parameter.

Reimplemented from SkShaderBase.

Definition at line 49 of file SkLocalMatrixShader.h.

49 {
50 if (localMatrix) {
51 *localMatrix = fLocalMatrix;
52 }
53 return fWrappedShader;
54 }

◆ MakeWrapped()

template<typename T , typename... Args>
static std::enable_if_t< std::is_base_of_v< SkShader, T >, sk_sp< SkShader > > SkLocalMatrixShader::MakeWrapped ( const SkMatrix localMatrix,
Args &&...  args 
)
inlinestatic

Definition at line 32 of file SkLocalMatrixShader.h.

32 {
33 auto t = sk_make_sp<T>(std::forward<Args>(args)...);
34 if (localMatrix) {
35 return t->makeWithLocalMatrix(*localMatrix);
36 }
37 return t;
38 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ onIsAImage()

SkImage * SkLocalMatrixShader::onIsAImage ( SkMatrix matrix,
SkTileMode mode 
) const
overrideprotected

Definition at line 51 of file SkLocalMatrixShader.cpp.

51 {
52 SkMatrix imageMatrix;
53 SkImage* image = fWrappedShader->isAImage(&imageMatrix, mode);
54 if (image && outMatrix) {
55 *outMatrix = ConcatLocalMatrices(fLocalMatrix, imageMatrix);
56 }
57
58 return image;
59}
SkImage * isAImage(SkMatrix *localMatrix, SkTileMode xy[2]) const
Definition SkShader.cpp:22
sk_sp< SkImage > image
Definition examples.cpp:29

◆ type()

ShaderType SkLocalMatrixShader::type ( ) const
inlineoverridevirtual

Implements SkShaderBase.

Definition at line 47 of file SkLocalMatrixShader.h.

47{ return ShaderType::kLocalMatrix; }

◆ wrappedShader()

sk_sp< SkShader > SkLocalMatrixShader::wrappedShader ( ) const
inline

Definition at line 57 of file SkLocalMatrixShader.h.

57{ return fWrappedShader; }

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