blob: d9d4e8ddecb36e7400372d097a7e43b392fa4cf7 [file] [log] [blame]
Florin Malita4aa44412017-12-19 12:21:02 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "modules/sksg/include/SkSGNode.h"
Florin Malita4aa44412017-12-19 12:21:02 -050012
Florin Malita4aa44412017-12-19 12:21:02 -050013class SkCanvas;
14class SkPaint;
Florin Malitae6345d92018-01-03 23:37:54 -050015class SkPath;
Florin Malita4aa44412017-12-19 12:21:02 -050016
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:
Florin Malita38ea40e2018-01-29 16:31:14 -050027 void clip(SkCanvas*, bool antiAlias) const;
Florin Malita4aa44412017-12-19 12:21:02 -050028 void draw(SkCanvas*, const SkPaint&) const;
29
Florin Malitaeb46bd82019-02-12 09:33:21 -050030 bool contains(const SkPoint&) const;
31
Florin Malitae6345d92018-01-03 23:37:54 -050032 SkPath asPath() const;
Florin Malita4aa44412017-12-19 12:21:02 -050033
34protected:
Florin Malitac14f1442018-01-05 11:32:31 -050035 GeometryNode();
Florin Malita4aa44412017-12-19 12:21:02 -050036
Florin Malita38ea40e2018-01-29 16:31:14 -050037 virtual void onClip(SkCanvas*, bool antiAlias) const = 0;
38
Florin Malita4aa44412017-12-19 12:21:02 -050039 virtual void onDraw(SkCanvas*, const SkPaint&) const = 0;
40
Florin Malitaeb46bd82019-02-12 09:33:21 -050041 virtual bool onContains(const SkPoint&) const = 0;
42
Florin Malitae6345d92018-01-03 23:37:54 -050043 virtual SkPath onAsPath() const = 0;
Florin Malita4aa44412017-12-19 12:21:02 -050044
Florin Malita4aa44412017-12-19 12:21:02 -050045private:
Florin Malita2a2dfcb2017-12-28 19:24:07 -050046 friend class Draw; // wants to know the cached bounds.
47
Florin Malita4aa44412017-12-19 12:21:02 -050048 typedef Node INHERITED;
49};
50
51} // namespace sksg
52
53#endif // SkSGGeometryNode_DEFINED