fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [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 "SkSVGShape.h" |
| 12 | #include "SkSVGTypes.h" |
| 13 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 14 | struct SkPoint; |
| 15 | |
fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [diff] [blame] | 16 | class SkSVGLine final : public SkSVGShape { |
| 17 | public: |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 18 | ~SkSVGLine() override = default; |
fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [diff] [blame] | 19 | static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); } |
| 20 | |
| 21 | void setX1(const SkSVGLength&); |
| 22 | void setY1(const SkSVGLength&); |
| 23 | void setX2(const SkSVGLength&); |
| 24 | void setY2(const SkSVGLength&); |
| 25 | |
| 26 | protected: |
| 27 | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
| 28 | |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 29 | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 30 | SkPath::FillType) const override; |
fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [diff] [blame] | 31 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 32 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 33 | |
fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [diff] [blame] | 34 | private: |
| 35 | SkSVGLine(); |
| 36 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 37 | // resolve and return the two endpoints |
| 38 | std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const; |
| 39 | |
fmalita | d24ee14 | 2016-08-17 08:38:15 -0700 | [diff] [blame] | 40 | SkSVGLength fX1 = SkSVGLength(0); |
| 41 | SkSVGLength fY1 = SkSVGLength(0); |
| 42 | SkSVGLength fX2 = SkSVGLength(0); |
| 43 | SkSVGLength fY2 = SkSVGLength(0); |
| 44 | |
| 45 | typedef SkSVGShape INHERITED; |
| 46 | }; |
| 47 | |
| 48 | #endif // SkSVGLine_DEFINED |