60 const char* stringValue) {
61 auto parseResult = SkSVGAttributeParser::parse<SkSVGIRI>(stringValue);
62 if (!parseResult.isValid()) {
71 const char* stringValue) {
72 SkString str(stringValue, strlen(stringValue));
79 const char* stringValue) {
80 auto parseResult = SkSVGAttributeParser::parse<SkSVGTransformType>(stringValue);
81 if (!parseResult.isValid()) {
90 const char* stringValue) {
91 auto parseResult = SkSVGAttributeParser::parse<SkSVGLength>(stringValue);
92 if (!parseResult.isValid()) {
101 const char* stringValue) {
104 if (!
parser.parseViewBox(&viewBox)) {
114 const char* stringValue) {
115 auto parseResult = SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>(stringValue);
116 if (!parseResult.isValid()) {
125 const char* stringValue) {
128 if (!
parser.parsePreserveAspectRatio(&par)) {
136SkString TrimmedString(
const char* first,
const char* last) {
141 while (first <= last && *first <=
' ') { first++; }
142 while (first <= last && *last <=
' ') { last--; }
145 return SkString(first, SkTo<size_t>(last - first + 1));
151 StyleIterator(
const char* str) : fPos(str) { }
153 std::tuple<SkString, SkString>
next() {
157 const char*
sep = this->nextSeparator();
160 const char* valueSep = strchr(fPos,
':');
161 if (valueSep && valueSep <
sep) {
162 name = TrimmedString(fPos, valueSep - 1);
163 value = TrimmedString(valueSep + 1,
sep - 1);
166 fPos = *
sep ?
sep + 1 :
nullptr;
173 const char* nextSeparator()
const {
174 const char*
sep = fPos;
175 while (*
sep !=
';' && *
sep !=
'\0') {
187 const char* stringValue) {
190 StyleIterator iter(stringValue);
193 if (
name.isEmpty()) {
196 set_string_attribute(node,
name.c_str(),
value.c_str());
203struct SortedDictionaryEntry {
208struct AttrParseInfo {
213SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = {
217 SetObjectBoundingBoxUnitsAttribute }},
223 SetPreserveAspectRatioAttribute }},
241SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = {
289struct ConstructionContext {
290 ConstructionContext(
SkSVGIDMapper* mapper) : fParent(nullptr), fIDMapper(mapper) {}
291 ConstructionContext(
const ConstructionContext& other,
const sk_sp<SkSVGNode>& newParent)
292 : fParent(newParent.
get()), fIDMapper(other.fIDMapper) {}
304 const int attrIndex =
SkStrSearch(&gAttributeParseInfo[0].fKey,
305 SkTo<int>(
std::size(gAttributeParseInfo)),
306 name,
sizeof(gAttributeParseInfo[0]));
308#if defined(SK_VERBOSE_SVG_PARSING)
315 const auto& attrInfo = gAttributeParseInfo[attrIndex].fValue;
316 if (!attrInfo.fSetter(node, attrInfo.fAttr,
value)) {
317#if defined(SK_VERBOSE_SVG_PARSING)
332 if (!strcmp(
name,
"id")) {
336 set_string_attribute(svgNode,
name,
value);
342 const char* elem =
dom.getName(xmlNode);
350 ctx.fParent->appendChild(std::move(
txt));
357 auto make_node = [](
const ConstructionContext& ctx,
const char* elem) ->
sk_sp<SkSVGNode> {
358 if (strcmp(elem,
"svg") == 0) {
364 const int tagIndex =
SkStrSearch(&gTagFactories[0].fKey,
366 elem,
sizeof(gTagFactories[0]));
368#if defined(SK_VERBOSE_SVG_PARSING)
369 SkDebugf(
"unhandled element: <%s>\n", elem);
375 return gTagFactories[tagIndex].fValue();
378 auto node = make_node(ctx, elem);
383 parse_node_attributes(
dom, xmlNode, node, ctx.fIDMapper);
385 ConstructionContext localCtx(ctx, node);
386 for (
auto* child =
dom.getFirstChild(xmlNode,
nullptr); child;
387 child =
dom.getNextSibling(child)) {
400 fFontMgr = std::move(fmgr);
405 fResourceProvider = std::move(rp);
410 fTextShapingFactory =
f;
417 if (!xmlDom.
build(str)) {
422 ConstructionContext ctx(&mapper);
430 sk_sp<SkData> load(
const char[],
const char[])
const override {
return nullptr; }
433 auto resource_provider = fResourceProvider ? fResourceProvider
434 : sk_make_sp<NullResourceProvider>();
440 std::move(resource_provider),
442 std::move(factory)));
451 , fFontMgr(
std::move(fmgr))
452 , fTextShapingFactory(
std::move(fact))
453 , fResourceProvider(
std::move(rp))
454 , fIDMapper(
std::move(mapper))
472 fTextShapingFactory));
488 fTextShapingFactory),
494 return fContainerSize;
504 return this->fIDMapper.
find(idStr);
509 return set_string_attribute(
sk_ref_sp(
this), attributeName, attributeValue);
static float next(float f)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
sk_sp< T > sk_ref_sp(T *obj)
SkSVGWrapperValue< SkSVGPreserveAspectRatio, SkSVGValue::Type::kPreserveAspectRatio > SkSVGPreserveAspectRatioValue
SkSVGWrapperValue< SkSVGObjectBoundingBoxUnits, SkSVGValue::Type::kObjectBoundingBoxUnits > SkSVGObjectBoundingBoxUnitsValue
SkSVGWrapperValue< SkSVGViewBoxType, SkSVGValue::Type::kViewBox > SkSVGViewBoxValue
SkSVGWrapperValue< SkSVGStringType, SkSVGValue::Type::kString > SkSVGStringValue
SkSVGWrapperValue< SkSVGTransformType, SkSVGValue::Type::kTransform > SkSVGTransformValue
SkSVGWrapperValue< SkSVGLength, SkSVGValue::Type::kLength > SkSVGLengthValue
int SkStrSearch(const char *const *base, int count, const char target[], size_t target_len, size_t elemSize)
const Node * getRootNode() const
const Node * build(SkStream &)
static sk_sp< SkSVGCircle > Make()
static sk_sp< SkSVGClipPath > Make()
Builder & setTextShapingFactory(sk_sp< SkShapers::Factory >)
sk_sp< SkSVGDOM > make(SkStream &) const
Builder & setFontManager(sk_sp< SkFontMgr >)
Builder & setResourceProvider(sk_sp< skresources::ResourceProvider >)
void renderNode(SkCanvas *, SkSVGPresentationContext &, const char *id) const
sk_sp< SkSVGNode > * findNodeById(const char *id)
void render(SkCanvas *) const
void setContainerSize(const SkSize &)
const SkSize & containerSize() const
static sk_sp< SkSVGDefs > Make()
static sk_sp< SkSVGEllipse > Make()
static sk_sp< SkSVGFeBlend > Make()
static sk_sp< SkSVGFeColorMatrix > Make()
static sk_sp< SkSVGFeComponentTransfer > Make()
static sk_sp< SkSVGFeComposite > Make()
static sk_sp< SkSVGFeDiffuseLighting > Make()
static sk_sp< SkSVGFeDisplacementMap > Make()
static sk_sp< SkSVGFeDistantLight > Make()
static sk_sp< SkSVGFeFlood > Make()
static sk_sp< SkSVGFeFunc > MakeFuncG()
static sk_sp< SkSVGFeFunc > MakeFuncR()
static sk_sp< SkSVGFeFunc > MakeFuncB()
static sk_sp< SkSVGFeFunc > MakeFuncA()
static sk_sp< SkSVGFeGaussianBlur > Make()
static sk_sp< SkSVGFeImage > Make()
static sk_sp< SkSVGFeMergeNode > Make()
static sk_sp< SkSVGFeMerge > Make()
static sk_sp< SkSVGFeMorphology > Make()
static sk_sp< SkSVGFeOffset > Make()
static sk_sp< SkSVGFePointLight > Make()
static sk_sp< SkSVGFeSpecularLighting > Make()
static sk_sp< SkSVGFeSpotLight > Make()
static sk_sp< SkSVGFeTurbulence > Make()
static sk_sp< SkSVGFilter > Make()
static sk_sp< SkSVGG > Make()
static sk_sp< SkSVGImage > Make()
static sk_sp< SkSVGLine > Make()
static sk_sp< SkSVGLinearGradient > Make()
static sk_sp< SkSVGMask > Make()
virtual bool parseAndSetAttribute(const char *name, const char *value)
void setAttribute(SkSVGAttribute, const SkSVGValue &)
virtual void appendChild(sk_sp< SkSVGNode >)=0
static sk_sp< SkSVGPath > Make()
static sk_sp< SkSVGPattern > Make()
static sk_sp< SkSVGPoly > MakePolygon()
static sk_sp< SkSVGPoly > MakePolyline()
static sk_sp< SkSVGRadialGradient > Make()
static sk_sp< SkSVGRect > Make()
static sk_sp< SkSVGSVG > Make(Type t=Type::kInner)
static sk_sp< SkSVGStop > Make()
static sk_sp< SkSVGTSpan > Make()
static sk_sp< SkSVGTextLiteral > Make()
static sk_sp< SkSVGTextPath > Make()
static sk_sp< SkSVGText > Make()
static sk_sp< SkSVGUse > Make()
V * find(const K &key) const
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
SKSHAPER_API sk_sp< Factory > Factory()
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
const myers::Point & get(const myers::Segment &)
#define TRACE_EVENT0(category_group, name)