Skia
2D Graphics Library
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 
12 
13 #include "include/core/SkPath.h"
14 
15 class SkCanvas;
16 class SkPaint;
17 
18 namespace sksg {
19 
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)
29 
30  // Temporarily inlined for SkPathFillType staging
31  // SG_MAPPED_ATTRIBUTE(FillType, SkPathFillType, fPath)
32 
34  return fPath.getFillType();
35  }
36 
37  void setFillType(SkPathFillType fillType) {
38  if (fillType != fPath.getFillType()) {
39  fPath.setFillType(fillType);
40  this->invalidate();
41  }
42  }
43 
44 protected:
45  void onClip(SkCanvas*, bool antiAlias) const override;
46  void onDraw(SkCanvas*, const SkPaint&) const override;
47  bool onContains(const SkPoint&) const override;
48 
50  SkPath onAsPath() const override;
51 
52 private:
53  explicit Path(const SkPath&);
54 
55  SkPath fPath;
56 
57  using INHERITED = GeometryNode;
58 };
59 
60 } // namespace sksg
61 
62 #endif // SkSGPath_DEFINED
SkPathFillType
Definition: SkPathTypes.h:11
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition: SkSGNode.h:99
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:99
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
SkPath contain geometry.
Definition: SkPath.h:58
SkPathFillType getFillType() const
Returns SkPathFillType, the rule used to fill SkPath.
Definition: SkPath.h:217
void setFillType(SkPathFillType ft)
Sets FillType, the rule used to fill SkPath.
Definition: SkPath.h:222
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:220
Base class for nodes which provide 'geometry' (as opposed to paint) for drawing.
Definition: SkSGGeometryNode.h:25
Receiver for invalidation events.
Definition: SkSGInvalidationController.h:25
Base class for all scene graph nodes.
Definition: SkSGNode.h:32
void invalidate(bool damage=true)
Concrete Geometry node, wrapping an SkPath.
Definition: SkSGPath.h:23
static sk_sp< Path > Make()
Definition: SkSGPath.h:25
SkPath onAsPath() const override
void setFillType(SkPathFillType fillType)
Definition: SkSGPath.h:37
SkPathFillType getFillType() const
Definition: SkSGPath.h:33
static sk_sp< Path > Make(const SkPath &r)
Definition: SkSGPath.h:26
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
bool onContains(const SkPoint &) const override
void onClip(SkCanvas *, bool antiAlias) const override
void onDraw(SkCanvas *, const SkPaint &) const override
Definition: Skottie.h:30
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582