Flutter Engine
The Flutter Engine
Classes | Protected Member Functions | List of all members
sksg::Gradient Class Referenceabstract

#include <SkSGGradient.h>

Inheritance diagram for sksg::Gradient:
sksg::Shader sksg::Node SkRefCnt SkRefCntBase sksg::LinearGradient sksg::RadialGradient

Classes

struct  ColorStop
 

Protected Member Functions

sk_sp< SkShaderonRevalidateShader () final
 
virtual sk_sp< SkShaderonMakeShader (const std::vector< SkColor4f > &colors, const std::vector< SkScalar > &positions) const =0
 
 Gradient ()=default
 
- Protected Member Functions inherited from sksg::Shader
 Shader ()
 
SkRect onRevalidate (InvalidationController *, const SkMatrix &) final
 
virtual sk_sp< SkShaderonRevalidateShader ()=0
 
- Protected Member Functions inherited from sksg::Node
 Node (uint32_t invalTraits)
 
 ~Node () override
 
const SkRectbounds () const
 
bool hasInval () const
 
virtual SkRect onRevalidate (InvalidationController *, const SkMatrix &ctm)=0
 
void observeInval (const sk_sp< Node > &)
 
void unobserveInval (const sk_sp< Node > &)
 

Additional Inherited Members

- Public Member Functions inherited from sksg::Shader
 ~Shader () override
 
const sk_sp< SkShader > & getShader () const
 
- Public Member Functions inherited from sksg::Node
const SkRectrevalidate (InvalidationController *, const SkMatrix &)
 
void invalidate (bool damage=true)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
- Protected Types inherited from sksg::Node
enum  InvalTraits { kBubbleDamage_Trait = 1 << 0 , kOverrideDamage_Trait = 1 << 1 }
 

Detailed Description

Gradient base class.

Definition at line 28 of file SkSGGradient.h.

Constructor & Destructor Documentation

◆ Gradient()

sksg::Gradient::Gradient ( )
protecteddefault

Member Function Documentation

◆ onMakeShader()

virtual sk_sp< SkShader > sksg::Gradient::onMakeShader ( const std::vector< SkColor4f > &  colors,
const std::vector< SkScalar > &  positions 
) const
protectedpure virtual

◆ onRevalidateShader()

sk_sp< SkShader > sksg::Gradient::onRevalidateShader ( )
finalprotectedvirtual

Implements sksg::Shader.

Definition at line 19 of file SkSGGradient.cpp.

19 {
20 if (fColorStops.empty()) {
21 return nullptr;
22 }
23
24 std::vector<SkColor4f> colors;
25 std::vector<SkScalar> positions;
26 colors.reserve(fColorStops.size());
27 positions.reserve(fColorStops.size());
28
29 SkScalar position = 0;
30 for (const auto& stop : fColorStops) {
31 colors.push_back(stop.fColor);
32 position = SkTPin(stop.fPosition, position, 1.0f);
33 positions.push_back(position);
34 }
35
36 // TODO: detect even stop distributions, pass null for positions.
37 return this->onMakeShader(colors, positions);
38}
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition: SkTPin.h:19
virtual sk_sp< SkShader > onMakeShader(const std::vector< SkColor4f > &colors, const std::vector< SkScalar > &positions) const =0
float SkScalar
Definition: extension.cpp:12
PODArray< SkColor > colors
Definition: SkRecords.h:276

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