Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 SkSGPath_DEFINED |
| 9 | #define SkSGPath_DEFINED |
| 10 | |
| 11 | #include "SkSGGeometryNode.h" |
| 12 | |
| 13 | #include "SkPath.h" |
| 14 | |
| 15 | class SkCanvas; |
| 16 | class SkPaint; |
| 17 | |
| 18 | namespace sksg { |
| 19 | |
| 20 | /** |
| 21 | * Concrete Geometry node, wrapping an SkPath. |
| 22 | */ |
| 23 | class Path : public GeometryNode { |
| 24 | public: |
| 25 | static sk_sp<Path> Make() { return sk_sp<Path>(new Path(SkPath())); } |
| 26 | static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); } |
| 27 | |
| 28 | SG_ATTRIBUTE(Path, SkPath, fPath) |
Florin Malita | cd05b19 | 2018-04-25 21:43:03 -0400 | [diff] [blame] | 29 | SG_MAPPED_ATTRIBUTE(FillType, SkPath::FillType, fPath) |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 30 | |
| 31 | protected: |
Florin Malita | 38ea40e | 2018-01-29 16:31:14 -0500 | [diff] [blame] | 32 | void onClip(SkCanvas*, bool antiAlias) const override; |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 33 | void onDraw(SkCanvas*, const SkPaint&) const override; |
Florin Malita | eb46bd8 | 2019-02-12 09:33:21 -0500 | [diff] [blame] | 34 | bool onContains(const SkPoint&) const override; |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 35 | |
Florin Malita | c14f144 | 2018-01-05 11:32:31 -0500 | [diff] [blame] | 36 | SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; |
Florin Malita | e6345d9 | 2018-01-03 23:37:54 -0500 | [diff] [blame] | 37 | SkPath onAsPath() const override; |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | explicit Path(const SkPath&); |
| 41 | |
| 42 | SkPath fPath; |
Florin Malita | 51012ce | 2018-01-31 17:06:59 -0500 | [diff] [blame] | 43 | |
| 44 | using INHERITED = GeometryNode; |
Florin Malita | 047ae27 | 2017-12-27 11:13:13 -0500 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace sksg |
| 48 | |
| 49 | #endif // SkSGPath_DEFINED |