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
|
|
|
|
|
|
|
|
#include "SkSGNode.h"
|
|
|
|
|
|
|
|
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:
|
|
|
|
void draw(SkCanvas*, const SkPaint&) const;
|
|
|
|
|
2018-01-04 04:37:54 +00:00
|
|
|
SkPath asPath() const;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
protected:
|
2018-01-03 21:17:29 +00:00
|
|
|
GeometryNode() = default;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
virtual void onDraw(SkCanvas*, const SkPaint&) 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
|