Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGPoly.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
12#include "src/base/SkTLazy.h"
13
14SkSVGPoly::SkSVGPoly(SkSVGTag t) : INHERITED(t) {}
15
16bool SkSVGPoly::parseAndSetAttribute(const char* n, const char* v) {
18 return true;
19 }
20
21 if (this->setPoints(SkSVGAttributeParser::parse<SkSVGPointsType>("points", n, v))) {
22 // TODO: we can likely just keep the points array and create the SkPath when needed.
23 fPath = SkPath::Polygon(
24 fPoints.data(), fPoints.size(),
25 this->tag() == SkSVGTag::kPolygon); // only polygons are auto-closed
26 }
27
28 // No other attributes on this node
29 return false;
30}
31
33 SkPathFillType fillType) const {
34 // the passed fillType follows inheritance rules and needs to be applied at draw time.
35 fPath.setFillType(fillType);
36 canvas->drawPath(fPath, paint);
37}
38
40 SkPath path = fPath;
41
42 // clip-rule can be inherited and needs to be applied at clip time.
43 path.setFillType(ctx.presentationContext().fInherited.fClipRule->asFillType());
44
45 this->mapToParent(&path);
46 return path;
47}
48
50 return fPath.getBounds();
51}
SkPathFillType
Definition SkPathTypes.h:11
#define INHERITED(method,...)
SkSVGTag
Definition SkSVGNode.h:23
void drawPath(const SkPath &path, const SkPaint &paint)
void setFillType(SkPathFillType ft)
Definition SkPath.h:235
const SkRect & getBounds() const
Definition SkPath.cpp:420
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition SkPath.cpp:3546
SkPathFillType asFillType() const
Definition SkSVGTypes.h:361
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition SkSVGNode.cpp:90
SkRect onObjectBoundingBox(const SkSVGRenderContext &) const override
Definition SkSVGPoly.cpp:49
void onDraw(SkCanvas *, const SkSVGLengthContext &, const SkPaint &, SkPathFillType) const override
Definition SkSVGPoly.cpp:32
SkPath onAsPath(const SkSVGRenderContext &) const override
Definition SkSVGPoly.cpp:39
bool parseAndSetAttribute(const char *, const char *) override
Definition SkSVGPoly.cpp:16
const SkSVGPresentationContext & presentationContext() const
void mapToParent(SkPath *) const
const Paint & paint
SkSVGProperty< SkSVGFillRule, true > fClipRule
SkSVGPresentationAttributes fInherited