Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 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 "modules/svg/include/SkSVGShape.h" |
| 12 | #include "modules/svg/include/SkSVGTypes.h" |
| 13 | |
| 14 | struct SkPoint; |
| 15 | |
| 16 | class SkSVGLine final : public SkSVGShape { |
| 17 | public: |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 18 | static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); } |
| 19 | |
Tyler Denniston | 52d9475 | 2021-02-05 10:23:34 -0500 | [diff] [blame] | 20 | SVG_ATTR(X1, SkSVGLength, SkSVGLength(0)) |
| 21 | SVG_ATTR(Y1, SkSVGLength, SkSVGLength(0)) |
| 22 | SVG_ATTR(X2, SkSVGLength, SkSVGLength(0)) |
| 23 | SVG_ATTR(Y2, SkSVGLength, SkSVGLength(0)) |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 24 | |
| 25 | protected: |
Tyler Denniston | 52d9475 | 2021-02-05 10:23:34 -0500 | [diff] [blame] | 26 | bool parseAndSetAttribute(const char*, const char*) override; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 27 | |
| 28 | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 29 | SkPathFillType) const override; |
| 30 | |
| 31 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 32 | |
| 33 | private: |
| 34 | SkSVGLine(); |
| 35 | |
| 36 | // resolve and return the two endpoints |
| 37 | std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const; |
| 38 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 39 | using INHERITED = SkSVGShape; |
| 40 | }; |
| 41 | |
| 42 | #endif // SkSVGLine_DEFINED |