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

#include <SkColorFilterShader.h>

Inheritance diagram for SkColorFilterShader:
SkShaderBase SkShader SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkColorFilterShader (sk_sp< SkShader > shader, float alpha, sk_sp< SkColorFilter > filter)
 
ShaderType type () const override
 
sk_sp< SkShadershader () const
 
sk_sp< SkColorFilterBasefilter () const
 
float alpha () 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
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
 

Private Member Functions

bool isOpaque () const override
 
void flatten (SkWriteBuffer &) const override
 
bool appendStages (const SkStageRec &, const SkShaders::MatrixRec &) 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)
 
- Protected Member Functions inherited from SkShaderBase
 SkShaderBase ()
 
void flatten (SkWriteBuffer &) const override
 
virtual bool onAsLuminanceColor (SkColor4f *) const
 

Detailed Description

Definition at line 22 of file SkColorFilterShader.h.

Constructor & Destructor Documentation

◆ SkColorFilterShader()

SkColorFilterShader::SkColorFilterShader ( sk_sp< SkShader shader,
float  alpha,
sk_sp< SkColorFilter filter 
)

Definition at line 23 of file SkColorFilterShader.cpp.

26 : fShader(std::move(shader))
27 , fFilter(as_CFB_sp(std::move(filter)))
28 , fAlpha (alpha)
29{
30 SkASSERT(fShader);
31 SkASSERT(fFilter);
32}
#define SkASSERT(cond)
Definition SkAssert.h:116
static sk_sp< SkColorFilterBase > as_CFB_sp(sk_sp< SkColorFilter > filter)
sk_sp< SkColorFilterBase > filter() const
sk_sp< SkShader > shader() const

Member Function Documentation

◆ alpha()

float SkColorFilterShader::alpha ( ) const
inline

Definition at line 30 of file SkColorFilterShader.h.

30{ return fAlpha; }

◆ appendStages()

bool SkColorFilterShader::appendStages ( const SkStageRec ,
const SkShaders::MatrixRec  
) const
overrideprivatevirtual

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 53 of file SkColorFilterShader.cpp.

54 {
55 if (!as_SB(fShader)->appendStages(rec, mRec)) {
56 return false;
57 }
58 if (fAlpha != 1.0f) {
59 rec.fPipeline->append(SkRasterPipelineOp::scale_1_float, rec.fAlloc->make<float>(fAlpha));
60 }
61 if (!fFilter->appendStages(rec, fAlpha == 1.0f && fShader->isOpaque())) {
62 return false;
63 }
64 return true;
65}
SkShaderBase * as_SB(SkShader *shader)
virtual bool appendStages(const SkStageRec &rec, bool shaderIsOpaque) const =0
bool appendStages(const SkStageRec &, const SkShaders::MatrixRec &) const override
virtual bool isOpaque() const
Definition SkShader.h:44

◆ filter()

sk_sp< SkColorFilterBase > SkColorFilterShader::filter ( ) const
inline

Definition at line 29 of file SkColorFilterShader.h.

29{ return fFilter; }

◆ flatten()

void SkColorFilterShader::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 47 of file SkColorFilterShader.cpp.

47 {
48 buffer.writeFlattenable(fShader.get());
49 SkASSERT(fAlpha == 1.0f); // Not exposed in public API SkShader::makeWithColorFilter().
50 buffer.writeFlattenable(fFilter.get());
51}
T * get() const
Definition SkRefCnt.h:303
static const uint8_t buffer[]

◆ isOpaque()

bool SkColorFilterShader::isOpaque ( ) const
overrideprivatevirtual

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 SkColorFilterShader.cpp.

43 {
44 return fShader->isOpaque() && fAlpha == 1.0f && as_CFB(fFilter)->isAlphaUnchanged();
45}
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
bool isAlphaUnchanged() const

◆ shader()

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

Definition at line 28 of file SkColorFilterShader.h.

28{ return fShader; }

◆ type()

ShaderType SkColorFilterShader::type ( ) const
inlineoverridevirtual

Implements SkShaderBase.

Definition at line 26 of file SkColorFilterShader.h.

26{ return ShaderType::kColorFilter; }

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