Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: cc/trees/layer_tree_host.cc

Issue 1808373002: cc : Make tree synchronization independent of layer tree hierarchy (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index d5f9b58577ab099d8d980a2fd152ae6da1e40528..ef27f9428f7230e52e041a9ab658bdfdd231c683 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -482,7 +482,14 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
{
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
- TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
+
+ std::unordered_set<Layer*> layers_that_should_push_properties =
+ layers_that_should_push_properties_;
+ for (auto layer : layers_that_should_push_properties) {
+ LayerImpl* sync_tree_layer = sync_tree->LayerById(layer->id());
+ DCHECK(sync_tree_layer);
+ layer->PushPropertiesTo(sync_tree_layer);
+ }
if (animation_host_) {
TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
@@ -1259,6 +1266,23 @@ Layer* LayerTreeHost::LayerById(int id) const {
return iter != layer_id_map_.end() ? iter->second : NULL;
}
+void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) {
+ layers_that_should_push_properties_.insert(layer);
+}
+
+void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) {
+ layers_that_should_push_properties_.erase(layer);
+}
+
+std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() {
+ return layers_that_should_push_properties_;
+}
+
+bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) {
+ return layers_that_should_push_properties_.find(layer) !=
+ layers_that_should_push_properties_.end();
+}
+
void LayerTreeHost::RegisterLayer(Layer* layer) {
DCHECK(!LayerById(layer->id()));
DCHECK(!in_paint_layer_contents_);
@@ -1270,6 +1294,7 @@ void LayerTreeHost::RegisterLayer(Layer* layer) {
void LayerTreeHost::UnregisterLayer(Layer* layer) {
DCHECK(LayerById(layer->id()));
DCHECK(!in_paint_layer_contents_);
+ RemoveLayerShouldPushProperties(layer);
ajuma 2016/03/18 14:33:16 Do we have a test that removes a layer needing pus
jaydasika 2016/03/19 02:17:58 There are many tests that check this implicitly. M
if (animation_host_)
animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
layer_id_map_.erase(layer->id());
@@ -1459,8 +1484,8 @@ bool LayerTreeHost::IsRemoteClient() const {
task_runner_provider_->HasImplThread();
}
-void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) const {
- // Not all fields are serialized, as they are eiher not needed for a commit,
+void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
+ // Not all fields are serialized, as they are either not needed for a commit,
// or implementation isn't ready yet.
// Unsupported items:
// - animations
@@ -1487,7 +1512,11 @@ void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) const {
meta_information_sequence_number_);
LayerProtoConverter::SerializeLayerHierarchy(root_layer_,
proto->mutable_root_layer());
- LayerProtoConverter::SerializeLayerProperties(root_layer_.get(),
+ // layers_that_should_push_properties_ should be serialized before layer
+ // properties because the it is cleared during the properties serialization.
+ for (auto layer : layers_that_should_push_properties_)
+ proto->add_layers_that_should_push_properties(layer->id());
+ LayerProtoConverter::SerializeLayerProperties(this,
proto->mutable_layer_updates());
proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID);
debug_state_.ToProtobuf(proto->mutable_debug_state());
@@ -1556,6 +1585,8 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) {
LayerTreeHostCommon::CallFunctionForSubtree(
root_layer(),
[this](Layer* layer) { layer_id_map_[layer->id()] = layer; });
+ for (auto layer_id : proto.layers_that_should_push_properties())
+ layers_that_should_push_properties_.insert(layer_id_map_[layer_id]);
LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(),
proto.layer_updates());

Powered by Google App Engine
This is Rietveld 408576698