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

Unified Diff: cc/layers/layer.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/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 7f51dc0ec41a2608db8036fd1b22c8b8461d1049..e895cf38601b36a7bd5e7909f529932cd14c3a27 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -50,9 +50,7 @@ scoped_refptr<Layer> Layer::Create(const LayerSettings& settings) {
}
Layer::Layer(const LayerSettings& settings)
- : needs_push_properties_(false),
- num_dependents_need_push_properties_(0),
- // Layer IDs start from 1.
+ : // Layer IDs start from 1.
layer_id_(g_next_layer_id.GetNext() + 1),
ignore_set_needs_commit_(false),
sorting_context_id_(0),
@@ -150,9 +148,8 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) {
host->RegisterLayer(this);
}
- InvalidatePropertyTreesIndices();
-
layer_tree_host_ = host;
jaydasika 2016/03/17 23:38:37 This is to ensure that layer is added to right set
+ InvalidatePropertyTreesIndices();
// When changing hosts, the layer needs to commit its properties to the impl
// side for the new host.
@@ -224,28 +221,8 @@ void Layer::SetNextCommitWaitsForActivation() {
}
void Layer::SetNeedsPushProperties() {
- if (needs_push_properties_)
- return;
- if (!parent_should_know_need_push_properties() && parent_)
- parent_->AddDependentNeedsPushProperties();
- needs_push_properties_ = true;
-}
-
-void Layer::AddDependentNeedsPushProperties() {
- DCHECK_GE(num_dependents_need_push_properties_, 0);
-
- if (!parent_should_know_need_push_properties() && parent_)
- parent_->AddDependentNeedsPushProperties();
-
- num_dependents_need_push_properties_++;
-}
-
-void Layer::RemoveDependentNeedsPushProperties() {
- num_dependents_need_push_properties_--;
- DCHECK_GE(num_dependents_need_push_properties_, 0);
-
- if (!parent_should_know_need_push_properties() && parent_)
- parent_->RemoveDependentNeedsPushProperties();
+ if (layer_tree_host_)
+ layer_tree_host_->AddLayerShouldPushProperties(this);
}
bool Layer::IsPropertyChangeAllowed() const {
@@ -265,13 +242,6 @@ skia::RefPtr<SkPicture> Layer::GetPicture() const {
void Layer::SetParent(Layer* layer) {
DCHECK(!layer || !layer->HasAncestor(this));
- if (parent_should_know_need_push_properties()) {
- if (parent_)
- parent_->RemoveDependentNeedsPushProperties();
- if (layer)
- layer->AddDependentNeedsPushProperties();
- }
-
parent_ = layer;
SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr);
@@ -1396,8 +1366,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
subtree_property_changed_ = false;
update_rect_ = gfx::Rect();
- needs_push_properties_ = false;
- num_dependents_need_push_properties_ = 0;
+ layer_tree_host()->RemoveLayerShouldPushProperties(this);
}
void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const {
@@ -1487,41 +1456,16 @@ void Layer::FromLayerNodeProto(const proto::LayerNode& proto,
}
}
-bool Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) {
- if (!needs_push_properties_ && num_dependents_need_push_properties_ == 0)
- return false;
-
+void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) {
// Always set properties metadata for serialized layers.
proto::LayerProperties* proto = layer_update->add_layers();
proto->set_id(layer_id_);
- proto->set_needs_push_properties(needs_push_properties_);
- proto->set_num_dependents_need_push_properties(
- num_dependents_need_push_properties_);
-
- if (needs_push_properties_)
- LayerSpecificPropertiesToProto(proto);
-
- needs_push_properties_ = false;
-
- bool descendant_needs_push_properties =
- num_dependents_need_push_properties_ > 0;
- num_dependents_need_push_properties_ = 0;
-
- return descendant_needs_push_properties;
+ LayerSpecificPropertiesToProto(proto);
}
void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) {
DCHECK(proto.has_id());
DCHECK_EQ(layer_id_, proto.id());
- DCHECK(proto.has_needs_push_properties());
- needs_push_properties_ = proto.needs_push_properties();
- DCHECK(proto.has_num_dependents_need_push_properties());
- num_dependents_need_push_properties_ =
- proto.num_dependents_need_push_properties();
-
- if (!needs_push_properties_)
- return;
-
FromLayerSpecificPropertiesProto(proto);
}

Powered by Google App Engine
This is Rietveld 408576698