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 "SkSGRenderNode.h" 12 13 #include "SkTArray.h" 14 15 namespace sksg { 16 17 /** 18 * Concrete node, grouping together multiple descendants. 19 */ 20 class Group : public RenderNode { 21 public: 22 static sk_sp<Group> Make() { 23 return sk_sp<Group>(new Group()); 24 } 25 26 void addChild(sk_sp<RenderNode>); 27 void removeChild(const sk_sp<RenderNode>&); 28 29 size_t size() const { return SkTo<size_t>(fChildren.count()); } 30 bool empty() const { return fChildren.empty(); } 31 32 protected: 33 Group(); 34 ~Group() override; 35 36 void onRender(SkCanvas*) const override; 37 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 38 39 private: 40 SkTArray<sk_sp<RenderNode>, true> fChildren; 41 42 typedef RenderNode INHERITED; 43 }; 44 45 } // namespace sksg 46 47 #endif // SkSGGroup_DEFINED 48