1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2016 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef SkSVGPoly_DEFINED
9cb93a386Sopenharmony_ci#define SkSVGPoly_DEFINED
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "include/core/SkPath.h"
12cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGShape.h"
13cb93a386Sopenharmony_ci
14cb93a386Sopenharmony_ci// Handles <polygon> and <polyline> elements.
15cb93a386Sopenharmony_ciclass SkSVGPoly final : public SkSVGShape {
16cb93a386Sopenharmony_cipublic:
17cb93a386Sopenharmony_ci    static sk_sp<SkSVGPoly> MakePolygon() {
18cb93a386Sopenharmony_ci        return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
19cb93a386Sopenharmony_ci    }
20cb93a386Sopenharmony_ci
21cb93a386Sopenharmony_ci    static sk_sp<SkSVGPoly> MakePolyline() {
22cb93a386Sopenharmony_ci        return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
23cb93a386Sopenharmony_ci    }
24cb93a386Sopenharmony_ci
25cb93a386Sopenharmony_ci    SVG_ATTR(Points, SkSVGPointsType, SkSVGPointsType())
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ciprotected:
28cb93a386Sopenharmony_ci    bool parseAndSetAttribute(const char*, const char*) override;
29cb93a386Sopenharmony_ci
30cb93a386Sopenharmony_ci    void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
31cb93a386Sopenharmony_ci                SkPathFillType) const override;
32cb93a386Sopenharmony_ci
33cb93a386Sopenharmony_ci    SkPath onAsPath(const SkSVGRenderContext&) const override;
34cb93a386Sopenharmony_ci
35cb93a386Sopenharmony_ci    SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
36cb93a386Sopenharmony_ci
37cb93a386Sopenharmony_ciprivate:
38cb93a386Sopenharmony_ci    SkSVGPoly(SkSVGTag);
39cb93a386Sopenharmony_ci
40cb93a386Sopenharmony_ci    mutable SkPath fPath;  // mutated in onDraw(), to apply inherited fill types.
41cb93a386Sopenharmony_ci
42cb93a386Sopenharmony_ci    using INHERITED = SkSVGShape;
43cb93a386Sopenharmony_ci};
44cb93a386Sopenharmony_ci
45cb93a386Sopenharmony_ci#endif // SkSVGPoly_DEFINED
46