Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkSVGDOM::Builder Class Referencefinal

#include <SkSVGDOM.h>

Public Member Functions

BuildersetFontManager (sk_sp< SkFontMgr >)
 
BuildersetResourceProvider (sk_sp< skresources::ResourceProvider >)
 
BuildersetTextShapingFactory (sk_sp< SkShapers::Factory >)
 
sk_sp< SkSVGDOMmake (SkStream &) const
 

Detailed Description

Definition at line 28 of file SkSVGDOM.h.

Member Function Documentation

◆ make()

sk_sp< SkSVGDOM > SkSVGDOM::Builder::make ( SkStream str) const

Definition at line 414 of file SkSVGDOM.cpp.

414 {
415 TRACE_EVENT0("skia", TRACE_FUNC);
416 SkDOM xmlDom;
417 if (!xmlDom.build(str)) {
418 return nullptr;
419 }
420
421 SkSVGIDMapper mapper;
422 ConstructionContext ctx(&mapper);
423
424 auto root = construct_svg_node(xmlDom, ctx, xmlDom.getRootNode());
425 if (!root || root->tag() != SkSVGTag::kSvg) {
426 return nullptr;
427 }
428
429 class NullResourceProvider final : public skresources::ResourceProvider {
430 sk_sp<SkData> load(const char[], const char[]) const override { return nullptr; }
431 };
432
433 auto resource_provider = fResourceProvider ? fResourceProvider
434 : sk_make_sp<NullResourceProvider>();
435
436 auto factory = fTextShapingFactory ? fTextShapingFactory : SkShapers::Primitive::Factory();
437
438 return sk_sp<SkSVGDOM>(new SkSVGDOM(sk_sp<SkSVGSVG>(static_cast<SkSVGSVG*>(root.release())),
439 std::move(fFontMgr),
440 std::move(resource_provider),
441 std::move(mapper),
442 std::move(factory)));
443}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
SI T load(const P *ptr)
Definition: Transform_inl.h:98
Definition: SkDOM.h:24
const Node * getRootNode() const
Definition: SkDOM.cpp:76
const Node * build(SkStream &)
Definition: SkDOM.cpp:294
SKSHAPER_API sk_sp< Factory > Factory()
string root
Definition: scale_cpu.py:20
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ setFontManager()

SkSVGDOM::Builder & SkSVGDOM::Builder::setFontManager ( sk_sp< SkFontMgr fmgr)

Specify a font manager for loading fonts (e.g. from the system) to render <text> SVG nodes. If this is not set, but a font is required as part of rendering, the text will not be displayed.

Definition at line 399 of file SkSVGDOM.cpp.

399 {
400 fFontMgr = std::move(fmgr);
401 return *this;
402}

◆ setResourceProvider()

SkSVGDOM::Builder & SkSVGDOM::Builder::setResourceProvider ( sk_sp< skresources::ResourceProvider rp)

Specify a resource provider for loading images etc.

Definition at line 404 of file SkSVGDOM.cpp.

404 {
405 fResourceProvider = std::move(rp);
406 return *this;
407}

◆ setTextShapingFactory()

SkSVGDOM::Builder & SkSVGDOM::Builder::setTextShapingFactory ( sk_sp< SkShapers::Factory f)

Specify the callbacks for dealing with shaping text. See also modules/skshaper/utils/FactoryHelpers.h

Definition at line 409 of file SkSVGDOM.cpp.

409 {
410 fTextShapingFactory = f;
411 return *this;
412}

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