Debian Codegraph @

modules/svg/include/SkSVGPoly.h

raw
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
8 #ifndef SkSVGPoly_DEFINED
9 #define SkSVGPoly_DEFINED
10
11 #include "include/core/SkPath.h"
12 #include "include/core/SkPathTypes.h"
13 #include "include/core/SkRect.h"
14 #include "include/core/SkRefCnt.h"
15 #include "include/private/base/SkAPI.h"
16 #include "modules/svg/include/SkSVGNode.h"
17 #include "modules/svg/include/SkSVGShape.h"
18 #include "modules/svg/include/SkSVGTypes.h"
19
20 class SkCanvas;
21 class SkPaint;
22 class SkSVGLengthContext;
23 class SkSVGRenderContext;
24
25 // Handles <polygon> and <polyline> elements.
26 class SK_API SkSVGPoly final : public SkSVGShape {
27 public:
28 static sk_sp<SkSVGPoly> MakePolygon() {
29 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolygon));
30 }
31
32 static sk_sp<SkSVGPoly> MakePolyline() {
33 return sk_sp<SkSVGPoly>(new SkSVGPoly(SkSVGTag::kPolyline));
34 }
35
36 SVG_ATTR(Points, SkSVGPointsType, SkSVGPointsType())
37
38 protected:
39 bool parseAndSetAttribute(const char*, const char*) override;
40
41 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
42 SkPathFillType) const override;
43
44 SkPath onAsPath(const SkSVGRenderContext&) const override;
45
46 SkRect onTransformableObjectBoundingBox(const SkSVGRenderContext&) const override;
47
48 private:
49 explicit SkSVGPoly(SkSVGTag);
50
51 mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types.
52
53 using INHERITED = SkSVGShape;
54 };
55
56 #endif // SkSVGPoly_DEFINED