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
13class SkCanvas;
14class SkPaint;
15class SkPath;
16
17namespace 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 */
25class GeometryNode : public Node {
26public:
27 void clip(SkCanvas*, bool antiAlias) const;
28 void draw(SkCanvas*, const SkPaint&) const;
29
30 bool contains(const SkPoint&) const;
31
32 SkPath asPath() const;
33
34protected:
35 GeometryNode();
36
37 virtual void onClip(SkCanvas*, bool antiAlias) const = 0;
38
39 virtual void onDraw(SkCanvas*, const SkPaint&) const = 0;
40
41 virtual bool onContains(const SkPoint&) const = 0;
42
43 virtual SkPath onAsPath() const = 0;
44
45private:
46 friend class Draw; // wants to know the cached bounds.
47
48 typedef Node INHERITED;
49};
50
51} // namespace sksg
52
53#endif // SkSGGeometryNode_DEFINED
54