blob: c6a49f199f289a2bbb93b59f3732676a0d3c2c58 [file] [log] [blame]
Florin Malitab3418102020-10-15 18:10:29 -04001/*
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
8#ifndef SkSVGPoly_DEFINED
9#define SkSVGPoly_DEFINED
10
11#include "include/core/SkPath.h"
12#include "modules/svg/include/SkSVGShape.h"
13
14// Handles <polygon> and <polyline> elements.
15class SkSVGPoly final : public SkSVGShape {
16public:
Florin Malitab3418102020-10-15 18:10:29 -040017 static sk_sp<SkSVGPoly> MakePolygon() {
18 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
19 }
20
21 static sk_sp<SkSVGPoly> MakePolyline() {
22 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
23 }
24
Tyler Dennistonc6834822021-02-08 15:07:03 -050025 SVG_ATTR(Points, SkSVGPointsType, SkSVGPointsType())
Florin Malitab3418102020-10-15 18:10:29 -040026
27protected:
Tyler Dennistonc6834822021-02-08 15:07:03 -050028 bool parseAndSetAttribute(const char*, const char*) override;
Florin Malitab3418102020-10-15 18:10:29 -040029
30 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
31 SkPathFillType) const override;
32
33 SkPath onAsPath(const SkSVGRenderContext&) const override;
34
Tyler Dennistondcf288b2020-12-11 16:28:34 -050035 SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
36
Florin Malitab3418102020-10-15 18:10:29 -040037private:
38 SkSVGPoly(SkSVGTag);
39
40 mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
41
42 using INHERITED = SkSVGShape;
43};
44
45#endif // SkSVGPoly_DEFINED