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 SkSGGroup_DEFINED
|
|
|
|
#define SkSGGroup_DEFINED
|
|
|
|
|
|
|
|
#include "SkSGRenderNode.h"
|
2018-09-02 17:44:13 +00:00
|
|
|
|
|
|
|
#include <vector>
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Concrete node, grouping together multiple descendants.
|
|
|
|
*/
|
|
|
|
class Group : public RenderNode {
|
|
|
|
public:
|
|
|
|
static sk_sp<Group> Make() {
|
2018-09-10 13:57:15 +00:00
|
|
|
return sk_sp<Group>(new Group(std::vector<sk_sp<RenderNode>>()));
|
|
|
|
}
|
|
|
|
|
|
|
|
static sk_sp<Group> Make(std::vector<sk_sp<RenderNode>> children) {
|
|
|
|
return sk_sp<Group>(new Group(std::move(children)));
|
2017-12-19 17:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addChild(sk_sp<RenderNode>);
|
|
|
|
void removeChild(const sk_sp<RenderNode>&);
|
|
|
|
|
2018-09-02 17:44:13 +00:00
|
|
|
size_t size() const { return fChildren.size(); }
|
2018-01-23 18:37:59 +00:00
|
|
|
bool empty() const { return fChildren.empty(); }
|
|
|
|
|
2017-12-19 17:21:02 +00:00
|
|
|
protected:
|
2018-09-10 13:57:15 +00:00
|
|
|
explicit Group(std::vector<sk_sp<RenderNode>>);
|
2017-12-19 17:21:02 +00:00
|
|
|
~Group() override;
|
|
|
|
|
2018-08-09 11:40:01 +00:00
|
|
|
void onRender(SkCanvas*, const RenderContext*) const override;
|
2018-01-05 16:32:31 +00:00
|
|
|
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-02 17:44:13 +00:00
|
|
|
std::vector<sk_sp<RenderNode>> fChildren;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
typedef RenderNode INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGGroup_DEFINED
|