• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SkSGGeometryNode_DEFINED
9 #define SkSGGeometryNode_DEFINED
10 
11 #include "SkSGNode.h"
12 
13 class SkCanvas;
14 class SkPaint;
15 class SkPath;
16 
17 namespace sksg {
18 
19 /**
20  * Base class for nodes which provide 'geometry' (as opposed to paint)
21  * for drawing.
22  *
23  * Think SkRect, SkPath, etc.
24  */
25 class GeometryNode : public Node {
26 public:
27     void clip(SkCanvas*, bool antiAlias) const;
28     void draw(SkCanvas*, const SkPaint&) const;
29 
30     SkPath asPath() const;
31 
32 protected:
33     GeometryNode();
34 
35     virtual void onClip(SkCanvas*, bool antiAlias) const = 0;
36 
37     virtual void onDraw(SkCanvas*, const SkPaint&) const = 0;
38 
39     virtual SkPath onAsPath() const = 0;
40 
41 private:
42     friend class Draw; // wants to know the cached bounds.
43 
44     typedef Node INHERITED;
45 };
46 
47 } // namespace sksg
48 
49 #endif // SkSGGeometryNode_DEFINED
50