Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkSVGMask Class Referencefinal

#include <SkSVGMask.h>

Inheritance diagram for SkSVGMask:
SkSVGHiddenContainer SkSVGContainer SkSVGTransformableNode SkSVGNode SkRefCnt SkRefCntBase

Public Types

using INHERITED = SkSVGHiddenContainer
 

Public Member Functions

 SVG_ATTR (MaskUnits, SkSVGObjectBoundingBoxUnits, SkSVGObjectBoundingBoxUnits(SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox)) SVG_ATTR(MaskContentUnits
 
SkSVGObjectBoundingBoxUnits(SkSVGObjectBoundingBoxUnits::Type::kUserSpaceOnUse)) private SkSVGMask ()
 
bool parseAndSetAttribute (const char *, const char *) override
 
SkRect bounds (const SkSVGRenderContext &) const
 
void renderMask (const SkSVGRenderContext &) const
 
- 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
 
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)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkSVGMaskMake ()
 

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)
 
SkPath onAsPath (const SkSVGRenderContext &) const override
 
SkRect onObjectBoundingBox (const SkSVGRenderContext &) const override
 
bool hasChildren () const final
 
- 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 onAsPaint (const SkSVGRenderContext &, SkPaint *) 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 >, true > fChildren
 

Detailed Description

Definition at line 14 of file SkSVGMask.h.

Member Typedef Documentation

◆ INHERITED

Definition at line 40 of file SkSVGMask.h.

Constructor & Destructor Documentation

◆ SkSVGMask()

Definition at line 33 of file SkSVGMask.h.

SkSVGHiddenContainer INHERITED
Definition SkSVGMask.h:40

Member Function Documentation

◆ bounds()

SkRect SkSVGMask::bounds ( const SkSVGRenderContext ctx) const

Definition at line 27 of file SkSVGMask.cpp.

27 {
28 return ctx.resolveOBBRect(fX, fY, fWidth, fHeight, fMaskUnits);
29}
SkRect resolveOBBRect(const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h, SkSVGObjectBoundingBoxUnits) const

◆ Make()

static sk_sp< SkSVGMask > SkSVGMask::Make ( )
inlinestatic

Definition at line 16 of file SkSVGMask.h.

16 {
17 return sk_sp<SkSVGMask>(new SkSVGMask());
18 }
SkSVGObjectBoundingBoxUnits(SkSVGObjectBoundingBoxUnits::Type::kUserSpaceOnUse)) private SkSVGMask()
Definition SkSVGMask.h:33

◆ parseAndSetAttribute()

bool SkSVGMask::parseAndSetAttribute ( const char *  n,
const char *  v 
)
overridevirtual

Reimplemented from SkSVGNode.

Definition at line 15 of file SkSVGMask.cpp.

15 {
17 this->setX(SkSVGAttributeParser::parse<SkSVGLength>("x", n, v)) ||
18 this->setY(SkSVGAttributeParser::parse<SkSVGLength>("y", n, v)) ||
19 this->setWidth(SkSVGAttributeParser::parse<SkSVGLength>("width", n, v)) ||
20 this->setHeight(SkSVGAttributeParser::parse<SkSVGLength>("height", n, v)) ||
21 this->setMaskUnits(
22 SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>("maskUnits", n, v)) ||
23 this->setMaskContentUnits(
24 SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>("maskContentUnits", n, v));
25}
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition SkSVGNode.cpp:90

◆ renderMask()

void SkSVGMask::renderMask ( const SkSVGRenderContext ctx) const

Definition at line 31 of file SkSVGMask.cpp.

31 {
32 // https://www.w3.org/TR/SVG11/masking.html#Masking
33
34 // Propagate any inherited properties that may impact mask effect behavior (e.g.
35 // color-interpolation). We call this explicitly here because the SkSVGMask
36 // nodes do not participate in the normal onRender path, which is when property
37 // propagation currently occurs.
38 // The local context also restores the filter layer created below on scope exit.
39 SkSVGRenderContext lctx(ctx);
40 this->onPrepareToRender(&lctx);
41
42 const auto ci = *lctx.presentationContext().fInherited.fColorInterpolation;
43 auto ci_filter = (ci == SkSVGColorspace::kLinearRGB)
45 : nullptr;
46
47 SkPaint mask_filter;
48 mask_filter.setColorFilter(
49 SkColorFilters::Compose(SkLumaColorFilter::Make(), std::move(ci_filter)));
50
51 // Mask color filter layer.
52 // Note: We could avoid this extra layer if we invert the stacking order
53 // (mask/content -> content/mask, kSrcIn -> kDstIn) and apply the filter
54 // via the top (mask) layer paint. That requires deferring mask rendering
55 // until after node content, which introduces extra state/complexity.
56 // Something to consider if masking performance ever becomes an issue.
57 lctx.canvas()->saveLayer(nullptr, &mask_filter);
58
59 const auto obbt = ctx.transformForCurrentOBB(fMaskContentUnits);
60 lctx.canvas()->translate(obbt.offset.x, obbt.offset.y);
61 lctx.canvas()->scale(obbt.scale.x, obbt.scale.y);
62
63 for (const auto& child : fChildren) {
64 child->render(lctx);
65 }
66}
static sk_sp< SkColorFilter > Compose(const sk_sp< SkColorFilter > &outer, sk_sp< SkColorFilter > inner)
static sk_sp< SkColorFilter > SRGBToLinearGamma()
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
skia_private::STArray< 1, sk_sp< SkSVGNode >, true > fChildren
OBBTransform transformForCurrentOBB(SkSVGObjectBoundingBoxUnits) const
bool onPrepareToRender(SkSVGRenderContext *) const override
static sk_sp< SkColorFilter > Make()

◆ SVG_ATTR()

Member Data Documentation

◆ SkSVGObjectBoundingBoxUnits

SkSVGMask::SkSVGObjectBoundingBoxUnits

Definition at line 27 of file SkSVGMask.h.


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