Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
SkSVGGradient Class Referenceabstract

#include <SkSVGGradient.h>

Inheritance diagram for SkSVGGradient:
SkSVGHiddenContainer SkSVGContainer SkSVGTransformableNode SkSVGNode SkRefCnt SkRefCntBase SkSVGLinearGradient SkSVGRadialGradient

Public Member Functions

 SVG_ATTR (GradientTransform, SkSVGTransformType, SkSVGTransformType(SkMatrix::I())) SVG_ATTR(GradientUnits
 
 SkSVGObjectBoundingBoxUnits (SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox)) protected
 
bool parseAndSetAttribute (const char *, const char *) override
 
bool onAsPaint (const SkSVGRenderContext &, SkPaint *) const final
 
virtual sk_sp< SkShaderonMakeShader (const SkSVGRenderContext &, const SkColor4f *, const SkScalar *, int count, SkTileMode, const SkMatrix &localMatrix) const =0
 
- Public Member Functions inherited from SkSVGContainer
void appendChild (sk_sp< SkSVGNode >) override
 
- Public Member Functions inherited from SkSVGTransformableNode
void setTransform (const SkSVGTransformType &t)
 
- Public Member Functions inherited from SkSVGNode
 ~SkSVGNode () override
 
SkSVGTag tag () const
 
virtual void appendChild (sk_sp< SkSVGNode >)=0
 
void render (const SkSVGRenderContext &) const
 
bool asPaint (const SkSVGRenderContext &, SkPaint *) const
 
SkPath asPath (const SkSVGRenderContext &) const
 
SkRect objectBoundingBox (const SkSVGRenderContext &) const
 
void setAttribute (SkSVGAttribute, const SkSVGValue &)
 
bool setAttribute (const char *attributeName, const char *attributeValue)
 
virtual bool parseAndSetAttribute (const char *name, const char *value)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Public Attributes

 SkSVGObjectBoundingBoxUnits
 

Additional Inherited Members

- Protected Member Functions inherited from SkSVGHiddenContainer
 SkSVGHiddenContainer (SkSVGTag t)
 
void onRender (const SkSVGRenderContext &) const final
 
- Protected Member Functions inherited from SkSVGContainer
 SkSVGContainer (SkSVGTag)
 
void onRender (const SkSVGRenderContext &) const override
 
SkPath onAsPath (const SkSVGRenderContext &) const override
 
SkRect onObjectBoundingBox (const SkSVGRenderContext &) const override
 
bool hasChildren () const final
 
template<typename NodeType , typename Func >
void forEachChild (Func func) const
 
- Protected Member Functions inherited from SkSVGTransformableNode
 SkSVGTransformableNode (SkSVGTag)
 
bool onPrepareToRender (SkSVGRenderContext *) const override
 
void onSetAttribute (SkSVGAttribute, const SkSVGValue &) override
 
void mapToParent (SkPath *) const
 
void mapToParent (SkRect *) const
 
- Protected Member Functions inherited from SkSVGNode
 SkSVGNode (SkSVGTag)
 
virtual bool onPrepareToRender (SkSVGRenderContext *) const
 
virtual void onRender (const SkSVGRenderContext &) const =0
 
virtual bool onAsPaint (const SkSVGRenderContext &, SkPaint *) const
 
virtual SkPath onAsPath (const SkSVGRenderContext &) const =0
 
virtual void onSetAttribute (SkSVGAttribute, const SkSVGValue &)
 
virtual bool hasChildren () const
 
virtual SkRect onObjectBoundingBox (const SkSVGRenderContext &) const
 
- Static Protected Member Functions inherited from SkSVGNode
static SkMatrix ComputeViewboxMatrix (const SkRect &, const SkRect &, SkSVGPreserveAspectRatio)
 
- Protected Attributes inherited from SkSVGContainer
skia_private::STArray< 1, sk_sp< SkSVGNode >, truefChildren
 

Detailed Description

Definition at line 19 of file SkSVGGradient.h.

Member Function Documentation

◆ onAsPaint()

bool SkSVGGradient::onAsPaint ( const SkSVGRenderContext ctx,
SkPaint paint 
) const
finalvirtual

Reimplemented from SkSVGNode.

Definition at line 66 of file SkSVGGradient.cpp.

66 {
67 StopColorArray colors;
68 StopPositionArray pos;
69
70 this->collectColorStops(ctx, &pos, &colors);
71
72 // TODO:
73 // * stop (lazy?) sorting
74 // * href loop detection
75 // * href attribute inheritance (not just color stops)
76 // * objectBoundingBox units support
77
78 static_assert(static_cast<SkTileMode>(SkSVGSpreadMethod::Type::kPad) ==
79 SkTileMode::kClamp, "SkSVGSpreadMethod::Type is out of sync");
80 static_assert(static_cast<SkTileMode>(SkSVGSpreadMethod::Type::kRepeat) ==
81 SkTileMode::kRepeat, "SkSVGSpreadMethod::Type is out of sync");
82 static_assert(static_cast<SkTileMode>(SkSVGSpreadMethod::Type::kReflect) ==
83 SkTileMode::kMirror, "SkSVGSpreadMethod::Type is out of sync");
84 const auto tileMode = static_cast<SkTileMode>(fSpreadMethod.type());
85
86 const auto obbt = ctx.transformForCurrentOBB(fGradientUnits);
87 const auto localMatrix = SkMatrix::Translate(obbt.offset.x, obbt.offset.y)
88 * SkMatrix::Scale(obbt.scale.x, obbt.scale.y)
89 * fGradientTransform;
90
91 paint->setShader(this->onMakeShader(ctx, colors.begin(), pos.begin(), colors.size(), tileMode,
92 localMatrix));
93 return true;
94}
SkPoint pos
SkTileMode
Definition: SkTileMode.h:13
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
virtual sk_sp< SkShader > onMakeShader(const SkSVGRenderContext &, const SkColor4f *, const SkScalar *, int count, SkTileMode, const SkMatrix &localMatrix) const =0
OBBTransform transformForCurrentOBB(SkSVGObjectBoundingBoxUnits) const
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276

◆ onMakeShader()

virtual sk_sp< SkShader > SkSVGGradient::onMakeShader ( const SkSVGRenderContext ,
const SkColor4f ,
const SkScalar ,
int  count,
SkTileMode  ,
const SkMatrix localMatrix 
) const
pure virtual

◆ parseAndSetAttribute()

bool SkSVGGradient::parseAndSetAttribute ( const char *  name,
const char *  value 
)
overridevirtual

Reimplemented from SkSVGNode.

Reimplemented in SkSVGLinearGradient, and SkSVGRadialGradient.

Definition at line 15 of file SkSVGGradient.cpp.

15 {
17 this->setGradientTransform(SkSVGAttributeParser::parse<SkSVGTransformType>(
18 "gradientTransform", name, value)) ||
19 this->setHref(SkSVGAttributeParser::parse<SkSVGIRI>("xlink:href", name, value)) ||
20 this->setSpreadMethod(
21 SkSVGAttributeParser::parse<SkSVGSpreadMethod>("spreadMethod", name, value)) ||
22 this->setGradientUnits(SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>(
23 "gradientUnits", name, value));
24}
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition: SkSVGNode.cpp:90
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ SkSVGObjectBoundingBoxUnits()

SkSVGGradient::SkSVGObjectBoundingBoxUnits ( SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox  )
inline

Definition at line 26 of file SkSVGGradient.h.

28 :
29 explicit SkSVGGradient(SkSVGTag t) : INHERITED(t) {}
SkSVGTag
Definition: SkSVGNode.h:23

◆ SVG_ATTR()

SkSVGGradient::SVG_ATTR ( GradientTransform  ,
SkSVGTransformType  ,
SkSVGTransformType(SkMatrix::I())   
)

Member Data Documentation

◆ SkSVGObjectBoundingBoxUnits

SkSVGGradient::SkSVGObjectBoundingBoxUnits

Definition at line 25 of file SkSVGGradient.h.


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