mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This reverts commit fcc4ab32301396986dd5103d6d444bff35fe0f63. Fixes https://github.com/flutter/flutter/issues/41394 and other related correctness issues. TBR: @arbreng @jason-simmons @mehmetf
72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/flow/layers/container_layer.h"
|
|
|
|
namespace flutter {
|
|
|
|
ContainerLayer::ContainerLayer() {}
|
|
|
|
ContainerLayer::~ContainerLayer() = default;
|
|
|
|
void ContainerLayer::Add(std::shared_ptr<Layer> layer) {
|
|
layer->set_parent(this);
|
|
layers_.push_back(std::move(layer));
|
|
}
|
|
|
|
void ContainerLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
TRACE_EVENT0("flutter", "ContainerLayer::Preroll");
|
|
|
|
SkRect child_paint_bounds = SkRect::MakeEmpty();
|
|
PrerollChildren(context, matrix, &child_paint_bounds);
|
|
set_paint_bounds(child_paint_bounds);
|
|
}
|
|
|
|
void ContainerLayer::PrerollChildren(PrerollContext* context,
|
|
const SkMatrix& child_matrix,
|
|
SkRect* child_paint_bounds) {
|
|
for (auto& layer : layers_) {
|
|
layer->Preroll(context, child_matrix);
|
|
|
|
if (layer->needs_system_composite()) {
|
|
set_needs_system_composite(true);
|
|
}
|
|
child_paint_bounds->join(layer->paint_bounds());
|
|
}
|
|
}
|
|
|
|
void ContainerLayer::PaintChildren(PaintContext& context) const {
|
|
FML_DCHECK(needs_painting());
|
|
|
|
// Intentionally not tracing here as there should be no self-time
|
|
// and the trace event on this common function has a small overhead.
|
|
for (auto& layer : layers_) {
|
|
if (layer->needs_painting()) {
|
|
layer->Paint(context);
|
|
}
|
|
}
|
|
}
|
|
|
|
#if defined(OS_FUCHSIA)
|
|
|
|
void ContainerLayer::UpdateScene(SceneUpdateContext& context) {
|
|
UpdateSceneChildren(context);
|
|
}
|
|
|
|
void ContainerLayer::UpdateSceneChildren(SceneUpdateContext& context) {
|
|
FML_DCHECK(needs_system_composite());
|
|
|
|
// Paint all of the layers which need to be drawn into the container.
|
|
// These may be flattened down to a containing
|
|
for (auto& layer : layers_) {
|
|
if (layer->needs_system_composite()) {
|
|
layer->UpdateScene(context);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // defined(OS_FUCHSIA)
|
|
|
|
} // namespace flutter
|