/src/skia/modules/sksg/include/SkSGGroup.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
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 SkSGGroup_DEFINED  | 
9  |  | #define SkSGGroup_DEFINED  | 
10  |  |  | 
11  |  | #include "modules/sksg/include/SkSGRenderNode.h"  | 
12  |  |  | 
13  |  | #include <vector>  | 
14  |  |  | 
15  |  | namespace sksg { | 
16  |  |  | 
17  |  | /**  | 
18  |  |  * Concrete node, grouping together multiple descendants.  | 
19  |  |  */  | 
20  |  | class Group : public RenderNode { | 
21  |  | public:  | 
22  | 1.53k  |     static sk_sp<Group> Make() { | 
23  | 1.53k  |         return sk_sp<Group>(new Group(std::vector<sk_sp<RenderNode>>()));  | 
24  | 1.53k  |     }  | 
25  |  |  | 
26  | 21.9k  |     static sk_sp<Group> Make(std::vector<sk_sp<RenderNode>> children) { | 
27  | 21.9k  |         return sk_sp<Group>(new Group(std::move(children)));  | 
28  | 21.9k  |     }  | 
29  |  |  | 
30  |  |     void addChild(sk_sp<RenderNode>);  | 
31  |  |     void removeChild(const sk_sp<RenderNode>&);  | 
32  |  |  | 
33  | 0  |     size_t size() const { return fChildren.size(); } | 
34  | 0  |     bool  empty() const { return fChildren.empty(); } | 
35  |  |     void  clear();  | 
36  |  |  | 
37  |  | protected:  | 
38  |  |     Group();  | 
39  |  |     explicit Group(std::vector<sk_sp<RenderNode>>);  | 
40  |  |     ~Group() override;  | 
41  |  |  | 
42  |  |     void onRender(SkCanvas*, const RenderContext*) const override;  | 
43  |  |     const RenderNode* onNodeAt(const SkPoint&)     const override;  | 
44  |  |  | 
45  |  |     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;  | 
46  |  |  | 
47  |  | private:  | 
48  |  |     std::vector<sk_sp<RenderNode>> fChildren;  | 
49  |  |     bool                           fRequiresIsolation = true;  | 
50  |  |  | 
51  |  |     using INHERITED = RenderNode;  | 
52  |  | };  | 
53  |  |  | 
54  |  | } // namespace sksg  | 
55  |  |  | 
56  |  | #endif // SkSGGroup_DEFINED  |