@@ -47,17 +47,33 @@ class MergedContainerLayer : public ContainerLayer {
4747 void Add (std::shared_ptr<Layer> layer) override ;
4848
4949 protected:
50+ // Return the implicit container layer created by the constructor that
51+ // is guaranteed to contain all children of this layer. This particular
52+ // layer may not be the best choice for caching the children in the
53+ // raster cache, though. See ::GetCacheableChild() for more details.
5054 ContainerLayer* GetChildContainer () const ;
5155
52- // The ChildContainer will be created anew whenever the MergedContainerLayer
53- // subclass is created even though the real child of the container may be
54- // the same child. If the MergedContainerLayer wants to cache the rendering
55- // of its "child" then the cache will need to be redrawn on every frame that
56- // the MergedContainer is different, defeating the purpose of caching. This
57- // method will attempt to return the real child (if there is only one) to
58- // improve the chance of caching.
56+ // Return a single layer that both represents all children of this layer
57+ // and which is most likely to remain stable from frame to frame for
58+ // purposes of keeping it in the raster cache.
59+ //
60+ // Most every use of this utility container subclass will involve only a
61+ // single actual child, but this utility exists to enforce that condition
62+ // so that we always have a single child even when the scene builders do
63+ // not follow that guideline.
64+ //
65+ // If the guidelines are followed then the single actual child is the best
66+ // choice for caching since it will often be reused from scene to scene and
67+ // will remain in the cache from frame to frame. If the guidelines are not
68+ // followed and some agent building scenes has added multiple children to
69+ // this layer, then the only "single child" we have for caching is the
70+ // implicit ChildContainer created in the constructor. That implicit child
71+ // can still be cacheable as long as this layer is not recreated on every
72+ // frame, but it is less likely to be so, especially if this layer is
73+ // actively being animated (Opacity animation for example).
5974 Layer* GetCacheableChild () const ;
6075
76+ private:
6177 FML_DISALLOW_COPY_AND_ASSIGN (MergedContainerLayer);
6278};
6379
0 commit comments