[skottie] More efficient group sizing
Replace sksg::Group::shrink_to_fit() with a factory accepting an
externally-built children array.
This provides more control for clients (e.g. reserve() instead of
shrink_to_fit()).
Change-Id: Iad587435e0e9da15251a9d3bc2510ca945950b5d
Reviewed-on: https://skia-review.googlesource.com/152861
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/modules/sksg/src/SkSGGroup.cpp b/modules/sksg/src/SkSGGroup.cpp
index 2c0a9d7..4841714 100644
--- a/modules/sksg/src/SkSGGroup.cpp
+++ b/modules/sksg/src/SkSGGroup.cpp
@@ -11,7 +11,12 @@
namespace sksg {
-Group::Group() {}
+Group::Group(std::vector<sk_sp<RenderNode>> children)
+ : fChildren(std::move(children)) {
+ for (const auto& child : fChildren) {
+ this->observeInval(child);
+ }
+}
Group::~Group() {
for (const auto& child : fChildren) {
@@ -41,10 +46,6 @@
this->invalidate();
}
-void Group::shrink_to_fit() {
- fChildren.shrink_to_fit();
-}
-
void Group::onRender(SkCanvas* canvas, const RenderContext* ctx) const {
// TODO: this heuristic works at the moment, but:
// a) it is fragile because it relies on all leaf render nodes being atomic draws