Make Layer::AssignOldLayer non virtual (flutter/engine#26740)

This commit is contained in:
Matej Knopp
2021-06-15 00:59:02 +02:00
committed by GitHub
parent 59f3e87feb
commit 6f17ca29d7
3 changed files with 25 additions and 9 deletions

View File

@@ -242,11 +242,23 @@ MergedContainerLayer::MergedContainerLayer() {
ContainerLayer::Add(std::make_shared<ContainerLayer>());
}
void MergedContainerLayer::AssignOldLayer(Layer* old_layer) {
ContainerLayer::AssignOldLayer(old_layer);
auto layer = static_cast<MergedContainerLayer*>(old_layer);
GetChildContainer()->AssignOldLayer(layer->GetChildContainer());
#ifdef FLUTTER_ENABLE_DIFF_CONTEXT
void MergedContainerLayer::DiffChildren(DiffContext* context,
const ContainerLayer* old_layer) {
if (context->IsSubtreeDirty()) {
GetChildContainer()->Diff(context, nullptr);
return;
}
FML_DCHECK(old_layer);
// For MergedContainerLayer we want to diff children of ChildContainer
// instead of the ChildContainer itself. This works around the fact
// that ChildContainerLayer is ephemeral and its original_layer_id_ is always
// different.
auto layer = static_cast<const MergedContainerLayer*>(old_layer);
GetChildContainer()->DiffChildren(context, layer->GetChildContainer());
}
#endif
void MergedContainerLayer::Add(std::shared_ptr<Layer> layer) {
GetChildContainer()->Add(std::move(layer));

View File

@@ -33,13 +33,14 @@ class ContainerLayer : public Layer {
const std::vector<std::shared_ptr<Layer>>& layers() const { return layers_; }
protected:
#ifdef FLUTTER_ENABLE_DIFF_CONTEXT
void DiffChildren(DiffContext* context, const ContainerLayer* old_layer);
virtual void DiffChildren(DiffContext* context,
const ContainerLayer* old_layer);
#endif // FLUTTER_ENABLE_DIFF_CONTEXT
protected:
void PrerollChildren(PrerollContext* context,
const SkMatrix& child_matrix,
SkRect* child_paint_bounds);
@@ -114,10 +115,13 @@ class MergedContainerLayer : public ContainerLayer {
public:
MergedContainerLayer();
void AssignOldLayer(Layer* old_layer) override;
void Add(std::shared_ptr<Layer> layer) override;
#ifdef FLUTTER_ENABLE_DIFF_CONTEXT
void DiffChildren(DiffContext* context,
const ContainerLayer* old_layer) override;
#endif
protected:
/**
* @brief Returns the ContainerLayer used to hold all of the children of the

View File

@@ -85,7 +85,7 @@ class Layer {
Layer();
virtual ~Layer();
virtual void AssignOldLayer(Layer* old_layer) {
void AssignOldLayer(Layer* old_layer) {
original_layer_id_ = old_layer->original_layer_id_;
}