blob: 3259bc06125c92a46a71d3d1081af56342a31145 [file] [log] [blame]
fmalita5b31f322016-08-12 12:15:33 -07001/*
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 "SkPath.h"
12#include "SkSVGShape.h"
13
14// Handles <polygon> and <polyline> elements.
15class SkSVGPoly final : public SkSVGShape {
16public:
Brian Salomond3b65972017-03-22 12:05:03 -040017 ~SkSVGPoly() override = default;
fmalita5b31f322016-08-12 12:15:33 -070018
19 static sk_sp<SkSVGPoly> MakePolygon() {
20 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
21 }
22
23 static sk_sp<SkSVGPoly> MakePolyline() {
24 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
25 }
26
27 void setPoints(const SkSVGPointsType&);
28
29protected:
30 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
31
Florin Malitae932d4b2016-12-01 13:35:11 -050032 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
33 SkPath::FillType) const override;
fmalita5b31f322016-08-12 12:15:33 -070034
Florin Malitace8840e2016-12-08 09:26:47 -050035 SkPath onAsPath(const SkSVGRenderContext&) const override;
36
fmalita5b31f322016-08-12 12:15:33 -070037private:
38 SkSVGPoly(SkSVGTag);
39
Florin Malitae932d4b2016-12-01 13:35:11 -050040 mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
fmalita5b31f322016-08-12 12:15:33 -070041
42 typedef SkSVGShape INHERITED;
43};
44
45#endif // SkSVGPoly_DEFINED