diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:19:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:01:50 +0000 |
commit | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch) | |
tree | 835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/cc/trees/tree_synchronizer.cc | |
parent | 6036726eb981b6c4b42047513b9d3f4ac865daac (diff) | |
download | qtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz |
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/cc/trees/tree_synchronizer.cc')
-rw-r--r-- | chromium/cc/trees/tree_synchronizer.cc | 156 |
1 files changed, 89 insertions, 67 deletions
diff --git a/chromium/cc/trees/tree_synchronizer.cc b/chromium/cc/trees/tree_synchronizer.cc index 7dadbbe1476..c4b44c933c8 100644 --- a/chromium/cc/trees/tree_synchronizer.cc +++ b/chromium/cc/trees/tree_synchronizer.cc @@ -8,7 +8,9 @@ #include <set> +#include "base/containers/flat_set.h" #include "base/logging.h" +#include "base/stl_util.h" #include "base/trace_event/trace_event.h" #include "cc/layers/layer.h" #include "cc/layers/layer_collections.h" @@ -17,6 +19,72 @@ #include "cc/trees/layer_tree_impl.h" namespace cc { +namespace { +#if DCHECK_IS_ON() +template <typename LayerType> +static void AssertValidPropertyTreeIndices(LayerType* layer) { + DCHECK(layer); + DCHECK_NE(layer->transform_tree_index(), TransformTree::kInvalidNodeId); + DCHECK_NE(layer->effect_tree_index(), EffectTree::kInvalidNodeId); + DCHECK_NE(layer->clip_tree_index(), ClipTree::kInvalidNodeId); + DCHECK_NE(layer->scroll_tree_index(), ScrollTree::kInvalidNodeId); +} + +static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { + DCHECK(layer); + return layer->transform_tree_index() != TransformTree::kInvalidNodeId && + layer->effect_tree_index() != EffectTree::kInvalidNodeId && + layer->clip_tree_index() != ClipTree::kInvalidNodeId && + layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; +} + +static bool LayerWillPushProperties(LayerTreeHost* host, Layer* layer) { + return base::ContainsKey(host->LayersThatShouldPushProperties(), layer); +} + +static bool LayerWillPushProperties(LayerTreeImpl* tree, LayerImpl* layer) { + return base::ContainsKey(tree->LayersThatShouldPushProperties(), layer) || + // TODO(crbug.com/303943): Stop always pushing PictureLayerImpl + // properties. + base::ContainsValue(tree->picture_layers(), layer); +} +#endif + +template <typename LayerType> +std::unique_ptr<LayerImpl> ReuseOrCreateLayerImpl(OwnedLayerImplMap* old_layers, + LayerType* layer, + LayerTreeImpl* tree_impl) { + if (!layer) + return nullptr; + std::unique_ptr<LayerImpl> layer_impl = std::move((*old_layers)[layer->id()]); + if (!layer_impl) + layer_impl = layer->CreateLayerImpl(tree_impl); + return layer_impl; +} + +template <typename LayerTreeType> +void PushLayerList(OwnedLayerImplMap* old_layers, + LayerTreeType* host, + LayerTreeImpl* tree_impl) { + tree_impl->ClearLayerList(); + for (auto* layer : *host) { + std::unique_ptr<LayerImpl> layer_impl( + ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); + +#if DCHECK_IS_ON() + // Every layer should have valid property tree indices + AssertValidPropertyTreeIndices(layer); + // Every layer_impl should either have valid property tree indices already + // or the corresponding layer should push them onto layer_impl. + DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || + LayerWillPushProperties(host, layer)); +#endif + + tree_impl->AddToLayerList(layer_impl.get()); + tree_impl->AddLayer(std::move(layer_impl)); + } + tree_impl->OnCanDrawStateChangedForTree(); +} template <typename LayerTreeType> void SynchronizeTreesInternal(LayerTreeType* source_tree, @@ -42,6 +110,8 @@ void SynchronizeTreesInternal(LayerTreeType* source_tree, } } +} // namespace + void TreeSynchronizer::SynchronizeTrees(Layer* layer_root, LayerTreeImpl* tree_impl) { if (!layer_root) { @@ -62,86 +132,38 @@ void TreeSynchronizer::SynchronizeTrees(LayerTreeImpl* pending_tree, } } -template <typename LayerType> -std::unique_ptr<LayerImpl> ReuseOrCreateLayerImpl(OwnedLayerImplMap* old_layers, - LayerType* layer, - LayerTreeImpl* tree_impl) { - if (!layer) - return nullptr; - std::unique_ptr<LayerImpl> layer_impl = std::move((*old_layers)[layer->id()]); - if (!layer_impl) - layer_impl = layer->CreateLayerImpl(tree_impl); - return layer_impl; -} - -#if DCHECK_IS_ON() -template <typename LayerType> -static void AssertValidPropertyTreeIndices(LayerType* layer) { - DCHECK(layer); - DCHECK_NE(layer->transform_tree_index(), TransformTree::kInvalidNodeId); - DCHECK_NE(layer->effect_tree_index(), EffectTree::kInvalidNodeId); - DCHECK_NE(layer->clip_tree_index(), ClipTree::kInvalidNodeId); - DCHECK_NE(layer->scroll_tree_index(), ScrollTree::kInvalidNodeId); -} - -static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { - DCHECK(layer); - return layer->transform_tree_index() != TransformTree::kInvalidNodeId && - layer->effect_tree_index() != EffectTree::kInvalidNodeId && - layer->clip_tree_index() != ClipTree::kInvalidNodeId && - layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; -} -#endif - -template <typename LayerTreeType> -void PushLayerList(OwnedLayerImplMap* old_layers, - LayerTreeType* host, - LayerTreeImpl* tree_impl) { - tree_impl->ClearLayerList(); - for (auto* layer : *host) { - std::unique_ptr<LayerImpl> layer_impl( - ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); - -#if DCHECK_IS_ON() - // Every layer should have valid property tree indices - AssertValidPropertyTreeIndices(layer); - // Every layer_impl should either have valid property tree indices already - // or the corresponding layer should push them onto layer_impl. - DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || - host->LayerNeedsPushPropertiesForTesting(layer)); -#endif - - tree_impl->AddToLayerList(layer_impl.get()); - tree_impl->AddLayer(std::move(layer_impl)); - } - tree_impl->OnCanDrawStateChangedForTree(); -} - -template <typename LayerType> -static void PushLayerPropertiesInternal( - std::unordered_set<LayerType*> layers_that_should_push_properties, - LayerTreeImpl* impl_tree) { - for (auto layer : layers_that_should_push_properties) { - LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); - DCHECK(layer_impl); - layer->PushPropertiesTo(layer_impl); +template <typename Iterator> +static void PushLayerPropertiesInternal(Iterator source_layers_begin, + Iterator source_layers_end, + LayerTreeImpl* target_impl_tree) { + for (Iterator it = source_layers_begin; it != source_layers_end; ++it) { + auto* source_layer = *it; + LayerImpl* target_layer = target_impl_tree->LayerById(source_layer->id()); + DCHECK(target_layer); + source_layer->PushPropertiesTo(target_layer); } } void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, LayerTreeImpl* active_tree) { const auto& layers = pending_tree->LayersThatShouldPushProperties(); + // TODO(crbug.com/303943): Stop always pushing PictureLayerImpl properties. + const auto& picture_layers = pending_tree->picture_layers(); TRACE_EVENT1("cc", "TreeSynchronizer::PushLayerPropertiesTo.Impl", - "layer_count", layers.size()); - PushLayerPropertiesInternal(layers, active_tree); + "layer_count", layers.size() + picture_layers.size()); + PushLayerPropertiesInternal(layers.begin(), layers.end(), active_tree); + PushLayerPropertiesInternal(picture_layers.begin(), picture_layers.end(), + active_tree); + pending_tree->ClearLayersThatShouldPushProperties(); } void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, LayerTreeImpl* impl_tree) { - const auto& layers = host_tree->LayersThatShouldPushProperties(); + auto layers = host_tree->LayersThatShouldPushProperties(); TRACE_EVENT1("cc", "TreeSynchronizer::PushLayerPropertiesTo.Main", "layer_count", layers.size()); - PushLayerPropertiesInternal(layers, impl_tree); + PushLayerPropertiesInternal(layers.begin(), layers.end(), impl_tree); + host_tree->ClearLayersThatShouldPushProperties(); } } // namespace cc |