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:
Make()25     static sk_sp<Path> Make()                { return sk_sp<Path>(new Path(SkPath())); }
Make(const SkPath & r)26     static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); }
27 
28     SG_ATTRIBUTE(Path, SkPath, fPath)
29     SG_MAPPED_ATTRIBUTE(FillType, SkPath::FillType, fPath)
30 
31 protected:
32     void onClip(SkCanvas*, bool antiAlias) const override;
33     void onDraw(SkCanvas*, const SkPaint&) const override;
34 
35     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
36     SkPath onAsPath() const override;
37 
38 private:
39     explicit Path(const SkPath&);
40 
41     SkPath fPath;
42 
43     using INHERITED = GeometryNode;
44 };
45 
46 } // namespace sksg
47 
48 #endif // SkSGPath_DEFINED
49