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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/sksg/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(); }
|
2019-02-01 22:59:25 +00:00
|
|
|
void clear();
|
2018-01-23 18:37:59 +00:00
|
|
|
|
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;
|
2019-02-12 14:33:21 +00:00
|
|
|
const RenderNode* onNodeAt(const SkPoint&) 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;
|
2020-02-07 22:51:49 +00:00
|
|
|
bool fRequiresIsolation = true;
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
typedef RenderNode INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGGroup_DEFINED
|