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

#include <SkTriColorShader.h>

Inheritance diagram for SkTriColorShader:
SkShaderBase SkShader SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkTriColorShader (bool isOpaque, bool usePersp)
 
ShaderType type () const override
 
bool update (const SkMatrix &ctmInv, const SkPoint pts[], const SkPMColor4f colors[], int index0, int index1, int index2)
 
- 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
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 ()
 
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
 

Protected Member Functions

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

Private Member Functions

bool isOpaque () const override
 
Factory getFactory () const override
 
const char * getTypeName () const override
 

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

Detailed Description

Definition at line 18 of file SkTriColorShader.h.

Constructor & Destructor Documentation

◆ SkTriColorShader()

SkTriColorShader::SkTriColorShader ( bool  isOpaque,
bool  usePersp 
)
inline

Definition at line 20 of file SkTriColorShader.h.

20: fIsOpaque(isOpaque), fUsePersp(usePersp) {}
bool isOpaque() const override

Member Function Documentation

◆ appendStages()

bool SkTriColorShader::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 19 of file SkTriColorShader.cpp.

19 {
20 rec.fPipeline->append(SkRasterPipelineOp::seed_shader);
21 if (fUsePersp) {
22 rec.fPipeline->append(SkRasterPipelineOp::matrix_perspective, &fM33);
23 }
24 rec.fPipeline->append(SkRasterPipelineOp::matrix_4x3, &fM43);
25 return true;
26}

◆ getFactory()

Factory SkTriColorShader::getFactory ( ) const
inlineoverrideprivatevirtual

Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten().

Implements SkFlattenable.

Definition at line 38 of file SkTriColorShader.h.

38{ return nullptr; }

◆ getTypeName()

const char * SkTriColorShader::getTypeName ( ) const
inlineoverrideprivatevirtual

Returns the name of the object's class.

Implements SkFlattenable.

Definition at line 39 of file SkTriColorShader.h.

39{ return nullptr; }

◆ isOpaque()

bool SkTriColorShader::isOpaque ( ) const
inlineoverrideprivatevirtual

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 36 of file SkTriColorShader.h.

36{ return fIsOpaque; }

◆ type()

ShaderType SkTriColorShader::type ( ) const
inlineoverridevirtual

Implements SkShaderBase.

Definition at line 22 of file SkTriColorShader.h.

22{ return ShaderType::kTriColor; }

◆ update()

bool SkTriColorShader::update ( const SkMatrix ctmInv,
const SkPoint  pts[],
const SkPMColor4f  colors[],
int  index0,
int  index1,
int  index2 
)

Definition at line 28 of file SkTriColorShader.cpp.

33 {
34 SkMatrix m, im;
35 m.reset();
36 m.set(0, pts[index1].fX - pts[index0].fX);
37 m.set(1, pts[index2].fX - pts[index0].fX);
38 m.set(2, pts[index0].fX);
39 m.set(3, pts[index1].fY - pts[index0].fY);
40 m.set(4, pts[index2].fY - pts[index0].fY);
41 m.set(5, pts[index0].fY);
42 if (!m.invert(&im)) {
43 return false;
44 }
45
46 fM33.setConcat(im, ctmInv);
47
48 auto c0 = skvx::float4::Load(colors[index0].vec()),
49 c1 = skvx::float4::Load(colors[index1].vec()),
50 c2 = skvx::float4::Load(colors[index2].vec());
51
52 (c1 - c0).store(&fM43.fMat[0]);
53 (c2 - c0).store(&fM43.fMat[4]);
54 c0.store(&fM43.fMat[8]);
55
56 if (!fUsePersp) {
57 fM43.setConcat(fM43, fM33);
58 }
59 return true;
60}
SI void store(P *ptr, const T &val)
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.cpp:603
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109

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