Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
SkSVGDOM Class Reference

#include <SkSVGDOM.h>

Inheritance diagram for SkSVGDOM:
SkRefCnt SkRefCntBase

Classes

class  Builder
 

Public Member Functions

SkSVGSVGgetRoot () const
 
void setContainerSize (const SkSize &)
 
const SkSizecontainerSize () const
 
sk_sp< SkSVGNode > * findNodeById (const char *id)
 
void render (SkCanvas *) const
 
void renderNode (SkCanvas *, SkSVGPresentationContext &, const char *id) const
 
- 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< SkSVGDOMMakeFromStream (SkStream &str)
 

Detailed Description

Definition at line 26 of file SkSVGDOM.h.

Member Function Documentation

◆ containerSize()

const SkSize & SkSVGDOM::containerSize ( ) const

DEPRECATED: use getRoot()->intrinsicSize() to query the root element intrinsic size.

Returns the SVG dom container size.

If the client specified a container size via setContainerSize(), then the same size is returned.

When unspecified by clients, this returns the intrinsic size of the root element, as defined by its width/height attributes. If either width or height is specified in relative units (e.g. "100%"), then the corresponding intrinsic size dimension is zero.

Definition at line 493 of file SkSVGDOM.cpp.

493 {
494 return fContainerSize;
495}

◆ findNodeById()

sk_sp< SkSVGNode > * SkSVGDOM::findNodeById ( const char *  id)

Definition at line 502 of file SkSVGDOM.cpp.

502 {
503 SkString idStr(id);
504 return this->fIDMapper.find(idStr);
505}
V * find(const K &key) const
Definition: SkTHash.h:494

◆ getRoot()

SkSVGSVG * SkSVGDOM::getRoot ( ) const
inline

Returns the root (outermost) SVG element.

Definition at line 64 of file SkSVGDOM.h.

64{ return fRoot.get(); }

◆ MakeFromStream()

static sk_sp< SkSVGDOM > SkSVGDOM::MakeFromStream ( SkStream str)
inlinestatic

Definition at line 57 of file SkSVGDOM.h.

57 {
58 return Builder().make(str);
59 }
DlVertices::Builder Builder

◆ render()

void SkSVGDOM::render ( SkCanvas canvas) const

Definition at line 460 of file SkSVGDOM.cpp.

460 {
461 TRACE_EVENT0("skia", TRACE_FUNC);
462 if (fRoot) {
463 SkSVGLengthContext lctx(fContainerSize);
465 fRoot->render(SkSVGRenderContext(canvas,
466 fFontMgr,
467 fResourceProvider,
468 fIDMapper,
469 lctx,
470 pctx,
471 {nullptr, nullptr},
472 fTextShapingFactory));
473 }
474}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ renderNode()

void SkSVGDOM::renderNode ( SkCanvas canvas,
SkSVGPresentationContext pctx,
const char *  id 
) const

Render the node with the given id as if it were the only child of the root.

Definition at line 476 of file SkSVGDOM.cpp.

476 {
477 TRACE_EVENT0("skia", TRACE_FUNC);
478
479 if (fRoot) {
480 SkSVGLengthContext lctx(fContainerSize);
481 fRoot->renderNode(SkSVGRenderContext(canvas,
482 fFontMgr,
483 fResourceProvider,
484 fIDMapper,
485 lctx,
486 pctx,
487 {nullptr, nullptr},
488 fTextShapingFactory),
490 }
491}
SkString SkSVGStringType
Definition: SkSVGTypes.h:28

◆ setContainerSize()

void SkSVGDOM::setContainerSize ( const SkSize containerSize)

Specify a "container size" for the SVG dom.

This is used to resolve the initial viewport when the root SVG width/height are specified in relative units.

If the root dimensions are in absolute units, then the container size has no effect since the initial viewport is fixed.

Definition at line 497 of file SkSVGDOM.cpp.

497 {
498 // TODO: inval
499 fContainerSize = containerSize;
500}
const SkSize & containerSize() const
Definition: SkSVGDOM.cpp:493

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