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