blob: 1a8718868d2e0e691b2b36fcb033f3f11e416826 [file] [log] [blame]
Florin Malita047ae272017-12-27 11:13:13 -05001/*
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
15class SkCanvas;
16class SkPaint;
17
18namespace sksg {
19
20/**
21 * Concrete Geometry node, wrapping an SkPath.
22 */
23class Path : public GeometryNode {
24public:
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 Malitacd05b192018-04-25 21:43:03 -040029 SG_MAPPED_ATTRIBUTE(FillType, SkPath::FillType, fPath)
Florin Malita047ae272017-12-27 11:13:13 -050030
31protected:
Florin Malita38ea40e2018-01-29 16:31:14 -050032 void onClip(SkCanvas*, bool antiAlias) const override;
Florin Malita047ae272017-12-27 11:13:13 -050033 void onDraw(SkCanvas*, const SkPaint&) const override;
34
Florin Malitac14f1442018-01-05 11:32:31 -050035 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
Florin Malitae6345d92018-01-03 23:37:54 -050036 SkPath onAsPath() const override;
Florin Malita047ae272017-12-27 11:13:13 -050037
38private:
39 explicit Path(const SkPath&);
40
41 SkPath fPath;
Florin Malita51012ce2018-01-31 17:06:59 -050042
43 using INHERITED = GeometryNode;
Florin Malita047ae272017-12-27 11:13:13 -050044};
45
46} // namespace sksg
47
48#endif // SkSGPath_DEFINED