Flutter Engine
The Flutter Engine
SkSGPath.h
Go to the documentation of this file.
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 "include/core/SkPath.h"
12#include "include/core/SkRect.h"
16
17class SkCanvas;
18class SkMatrix;
19class SkPaint;
20enum class SkPathFillType;
21struct SkPoint;
22
23namespace sksg {
24class InvalidationController;
25
26/**
27 * Concrete Geometry node, wrapping an SkPath.
28 */
29class Path : public GeometryNode {
30public:
31 static sk_sp<Path> Make() { return sk_sp<Path>(new Path(SkPath())); }
32 static sk_sp<Path> Make(const SkPath& r) { return sk_sp<Path>(new Path(r)); }
33
34 SG_ATTRIBUTE(Path, SkPath, fPath)
35
36 // Temporarily inlined for SkPathFillType staging
37 // SG_MAPPED_ATTRIBUTE(FillType, SkPathFillType, fPath)
38
40 return fPath.getFillType();
41 }
42
43 void setFillType(SkPathFillType fillType) {
44 if (fillType != fPath.getFillType()) {
45 fPath.setFillType(fillType);
46 this->invalidate();
47 }
48 }
49
50protected:
51 void onClip(SkCanvas*, bool antiAlias) const override;
52 void onDraw(SkCanvas*, const SkPaint&) const override;
53 bool onContains(const SkPoint&) const override;
54
56 SkPath onAsPath() const override;
57
58private:
59 explicit Path(const SkPath&);
60
61 SkPath fPath;
62
63 using INHERITED = GeometryNode;
64};
65
66} // namespace sksg
67
68#endif // SkSGPath_DEFINED
SkPathFillType
Definition: SkPathTypes.h:11
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition: SkSGNode.h:100
Definition: SkPath.h:59
SkPathFillType getFillType() const
Definition: SkPath.h:230
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
void invalidate(bool damage=true)
Definition: SkSGNode.cpp:113
SkPath onAsPath() const override
Definition: SkSGPath.cpp:46
void setFillType(SkPathFillType fillType)
Definition: SkSGPath.h:43
SkPathFillType getFillType() const
Definition: SkSGPath.h:39
static sk_sp< Path > Make(const SkPath &r)
Definition: SkSGPath.h:32
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition: SkSGPath.cpp:35
static sk_sp< Path > Make()
Definition: SkSGPath.h:31
bool onContains(const SkPoint &) const override
Definition: SkSGPath.cpp:31
void onClip(SkCanvas *, bool antiAlias) const override
Definition: SkSGPath.cpp:23
void onDraw(SkCanvas *, const SkPaint &) const override
Definition: SkSGPath.cpp:27
Definition: Skottie.h:32