fmalita | 6ceef3d | 2016-07-26 18:46:34 -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 SkSVGPath_DEFINED |
| 9 | #define SkSVGPath_DEFINED |
| 10 | |
| 11 | #include "SkPath.h" |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 12 | #include "SkSVGShape.h" |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 13 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 14 | class SkSVGPath final : public SkSVGShape { |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 15 | public: |
| 16 | virtual ~SkSVGPath() = default; |
| 17 | static sk_sp<SkSVGPath> Make() { return sk_sp<SkSVGPath>(new SkSVGPath()); } |
| 18 | |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 19 | void setPath(const SkPath& path) { fPath = path; } |
| 20 | |
| 21 | protected: |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 22 | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
| 23 | |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 24 | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 25 | SkPath::FillType) const override; |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 26 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 27 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 28 | |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 29 | private: |
| 30 | SkSVGPath(); |
| 31 | |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 32 | mutable SkPath fPath; // mutated in onDraw(), to apply inherited fill types. |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 33 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 34 | typedef SkSVGShape INHERITED; |
fmalita | 6ceef3d | 2016-07-26 18:46:34 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | #endif // SkSVGPath_DEFINED |