2017-12-19 17:21:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSGGeometryNode_DEFINED
|
|
|
|
#define SkSGGeometryNode_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/sksg/include/SkSGNode.h"
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
class SkCanvas;
|
|
|
|
class SkPaint;
|
2018-01-04 04:37:54 +00:00
|
|
|
class SkPath;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for nodes which provide 'geometry' (as opposed to paint)
|
|
|
|
* for drawing.
|
|
|
|
*
|
|
|
|
* Think SkRect, SkPath, etc.
|
|
|
|
*/
|
|
|
|
class GeometryNode : public Node {
|
|
|
|
public:
|
2018-01-29 21:31:14 +00:00
|
|
|
void clip(SkCanvas*, bool antiAlias) const;
|
2017-12-19 17:21:02 +00:00
|
|
|
void draw(SkCanvas*, const SkPaint&) const;
|
|
|
|
|
2019-02-12 14:33:21 +00:00
|
|
|
bool contains(const SkPoint&) const;
|
|
|
|
|
2018-01-04 04:37:54 +00:00
|
|
|
SkPath asPath() const;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
protected:
|
2018-01-05 16:32:31 +00:00
|
|
|
GeometryNode();
|
2017-12-19 17:21:02 +00:00
|
|
|
|
2018-01-29 21:31:14 +00:00
|
|
|
virtual void onClip(SkCanvas*, bool antiAlias) const = 0;
|
|
|
|
|
2017-12-19 17:21:02 +00:00
|
|
|
virtual void onDraw(SkCanvas*, const SkPaint&) const = 0;
|
|
|
|
|
2019-02-12 14:33:21 +00:00
|
|
|
virtual bool onContains(const SkPoint&) const = 0;
|
|
|
|
|
2018-01-04 04:37:54 +00:00
|
|
|
virtual SkPath onAsPath() const = 0;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-29 00:24:07 +00:00
|
|
|
friend class Draw; // wants to know the cached bounds.
|
|
|
|
|
2017-12-19 17:21:02 +00:00
|
|
|
typedef Node INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGGeometryNode_DEFINED
|