Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b6a1699

Browse files
committed
remove debugging prints and update comments
1 parent 2c1c168 commit b6a1699

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

flow/layers/container_layer.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ void ContainerLayer::UpdateSceneChildren(SceneUpdateContext& context) {
8888
MergedContainerLayer::MergedContainerLayer() {
8989
// Ensure the layer has only one direct child.
9090
//
91-
// This intermediary container helps container layers that want or need
92-
// to cache the rendering of their children to do so more easily.
93-
// TBD (flar) - mention caveat and use of GetCacheableChild() here...
94-
//
95-
// Any children will be actually added as children of this empty
96-
// ContainerLayer.
91+
// Any children will actually be added as children of this empty
92+
// ContainerLayer. If only one child is ever added to this layer then
93+
// that child will become the layer returned from ::GetCacheableChild().
94+
// If multiple child layers are added, then this implicit container
95+
// child becomes the cacheable child, but at the potential cost of
96+
// not being as stable in the raster cache from frame to frame.
9797
ContainerLayer::Add(std::make_shared<ContainerLayer>());
9898
}
9999

@@ -113,7 +113,7 @@ Layer* MergedContainerLayer::GetCacheableChild() const {
113113
return child_container->layers()[0].get();
114114
}
115115

116-
FML_LOG(INFO) << "Single child layer does not contain a single child";
116+
FML_LOG(INFO) << "Single child layer contains multiple children";
117117
return child_container;
118118
}
119119

flow/layers/container_layer.h

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

flow/layers/image_filter_layer.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
5959
RasterCacheResult layer_cache =
6060
context.raster_cache->Get((Layer*)this, ctm);
6161
if (layer_cache.is_valid()) {
62-
FML_LOG(ERROR) << "Rendering filtered output from cache";
6362
layer_cache.draw(*context.leaf_nodes_canvas);
6463
return;
6564
}
@@ -68,8 +67,6 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
6867
sk_sp<SkImageFilter> transformed_filter =
6968
filter_->makeWithLocalMatrix(ctm);
7069
if (transformed_filter) {
71-
FML_LOG(ERROR) << "Filtering from cached child";
72-
7370
SkPaint paint;
7471
paint.setImageFilter(transformed_filter);
7572

@@ -79,14 +76,13 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
7976
}
8077
}
8178

82-
FML_LOG(ERROR) << "Applying filter to child on the fly";
8379
SkPaint paint;
8480
paint.setImageFilter(filter_);
8581

8682
// Normally a save_layer is sized to the current layer bounds, but in this
8783
// case the bounds of the child may not be the same as the filtered version
88-
// so we use the child_paint_bounds_ which were snapshotted from the
89-
// Preroll on the children before we adjusted them based on the filter.
84+
// so we use the bounds of the child container which do not include any
85+
// modifications that the filter might apply.
9086
Layer::AutoSaveLayer save_layer = Layer::AutoSaveLayer::Create(
9187
context, GetChildContainer()->paint_bounds(), &paint);
9288
PaintChildren(context);

flow/raster_cache.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ void RasterCache::Prepare(PrerollContext* context,
137137
entry.access_count++;
138138
entry.used_this_frame = true;
139139
if (!entry.image.is_valid()) {
140-
FML_LOG(ERROR) << "Rasterizing " << layer->unique_id();
141140
entry.image = Rasterize(
142141
context->gr_context, ctm, context->dst_color_space,
143142
checkerboard_images_, layer->paint_bounds(),

0 commit comments

Comments
 (0)