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

#include <SkColorShader.h>

Inheritance diagram for SkColor4Shader:
SkShaderBase SkShader SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkColor4Shader (const SkColor4f &, sk_sp< SkColorSpace >)
 
bool isOpaque () const override
 
bool isConstant () const override
 
ShaderType type () const override
 
sk_sp< SkColorSpacecolorSpace () const
 
SkColor4f color () const
 
- Public Member Functions inherited from SkShaderBase
 ~SkShaderBase () override
 
sk_sp< SkShadermakeInvertAlpha () const
 
sk_sp< SkShadermakeWithCTM (const SkMatrix &) 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

void flatten (SkWriteBuffer &) const override
 
bool onAsLuminanceColor (SkColor4f *lum) 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
 

Detailed Description

Definition at line 57 of file SkColorShader.h.

Constructor & Destructor Documentation

◆ SkColor4Shader()

SkColor4Shader::SkColor4Shader ( const SkColor4f color,
sk_sp< SkColorSpace space 
)

Definition at line 41 of file SkColorShader.cpp.

42 : fColorSpace(std::move(space))
43 , fColor({color.fR, color.fG, color.fB, SkTPin(color.fA, 0.0f, 1.0f)})
44{}
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition SkTPin.h:19
SkColor4f color() const

Member Function Documentation

◆ appendStages()

bool SkColor4Shader::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 76 of file SkColorShader.cpp.

76 {
77 SkColor4f color = fColor;
79 rec.fDstCS, kUnpremul_SkAlphaType).apply(color.vec());
80 rec.fPipeline->appendConstantColor(rec.fAlloc, color.premul().vec());
81 return true;
82}
kUnpremul_SkAlphaType
T * get() const
Definition SkRefCnt.h:303
void apply(float rgba[4]) const

◆ color()

SkColor4f SkColor4Shader::color ( ) const
inline

Definition at line 67 of file SkColorShader.h.

67{ return fColor; }

◆ colorSpace()

sk_sp< SkColorSpace > SkColor4Shader::colorSpace ( ) const
inline

Definition at line 66 of file SkColorShader.h.

66{ return fColorSpace; }

◆ flatten()

void SkColor4Shader::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 57 of file SkColorShader.cpp.

57 {
58 buffer.writeColor4f(fColor);
59 sk_sp<SkData> colorSpaceData = fColorSpace ? fColorSpace->serialize() : nullptr;
60 if (colorSpaceData) {
61 buffer.writeBool(true);
62 buffer.writeDataAsByteArray(colorSpaceData.get());
63 } else {
64 buffer.writeBool(false);
65 }
66}
sk_sp< SkData > serialize() const
static const uint8_t buffer[]

◆ isConstant()

bool SkColor4Shader::isConstant ( ) const
inlineoverridevirtual

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 62 of file SkColorShader.h.

62{ return true; }

◆ isOpaque()

bool SkColor4Shader::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 61 of file SkColorShader.h.

61{ return fColor.isOpaque(); }

◆ onAsLuminanceColor()

bool SkColor4Shader::onAsLuminanceColor ( SkColor4f lum) const
overrideprivatevirtual

Reimplemented from SkShaderBase.

Definition at line 84 of file SkColorShader.cpp.

84 {
85 SkColor4f color = fColor;
88 *lum = color;
89 return true;
90}
SkColorSpace * sk_srgb_singleton()
static float lum(float r, float g, float b)
Definition hsl.cpp:52

◆ type()

ShaderType SkColor4Shader::type ( ) const
inlineoverridevirtual

Implements SkShaderBase.

Definition at line 64 of file SkColorShader.h.

64{ return ShaderType::kColor4; }

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