/src/skia/modules/svg/include/SkSVGLine.h
Line | Count | Source |
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 SkSVGLine_DEFINED |
9 | | #define SkSVGLine_DEFINED |
10 | | |
11 | | #include "include/core/SkPath.h" |
12 | | #include "include/core/SkRefCnt.h" |
13 | | #include "include/private/base/SkAPI.h" |
14 | | #include "modules/svg/include/SkSVGNode.h" |
15 | | #include "modules/svg/include/SkSVGShape.h" |
16 | | #include "modules/svg/include/SkSVGTypes.h" |
17 | | |
18 | | #include <tuple> |
19 | | |
20 | | class SkCanvas; |
21 | | class SkPaint; |
22 | | class SkSVGLengthContext; |
23 | | class SkSVGRenderContext; |
24 | | enum class SkPathFillType; |
25 | | struct SkPoint; |
26 | | |
27 | | class SK_API SkSVGLine final : public SkSVGShape { |
28 | | public: |
29 | 144 | static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); } |
30 | | |
31 | | SVG_ATTR(X1, SkSVGLength, SkSVGLength(0)) |
32 | | SVG_ATTR(Y1, SkSVGLength, SkSVGLength(0)) |
33 | | SVG_ATTR(X2, SkSVGLength, SkSVGLength(0)) |
34 | | SVG_ATTR(Y2, SkSVGLength, SkSVGLength(0)) |
35 | | |
36 | | protected: |
37 | | bool parseAndSetAttribute(const char*, const char*) override; |
38 | | |
39 | | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
40 | | SkPathFillType) const override; |
41 | | |
42 | | SkPath onAsPath(const SkSVGRenderContext&) const override; |
43 | | |
44 | | private: |
45 | | SkSVGLine(); |
46 | | |
47 | | // resolve and return the two endpoints |
48 | | std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const; |
49 | | |
50 | | using INHERITED = SkSVGShape; |
51 | | }; |
52 | | |
53 | | #endif // SkSVGLine_DEFINED |