summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2016-03-07 20:05:19 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-08 04:08:35 +0000
commitbb0409e5c66c91cca686b4c03d1ae7a3416573c1 (patch)
tree05057506a8c7d095bd9787adc1f66828c2d6906f /cc
parent295234e15fe991abaa61ec80de8c079dea7ad330 (diff)
downloadchromium_src-bb0409e5c66c91cca686b4c03d1ae7a3416573c1.zip
chromium_src-bb0409e5c66c91cca686b4c03d1ae7a3416573c1.tar.gz
chromium_src-bb0409e5c66c91cca686b4c03d1ae7a3416573c1.tar.bz2
cc : Make tree synchronization independent of layer tree hierarchy (1)
This CL : * Stores layers that need to push properties on LayerTreeImpl(layer_set) * Deletes bools needs_push_properties and dependants_needs_push_properties from LayerImpl * Iterate the layer_set to push propeties while activating pending tree. BUG=568874 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1770913003 Cr-Commit-Position: refs/heads/master@{#379727}
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/layer_impl.cc50
-rw-r--r--cc/layers/layer_impl.h20
-rw-r--r--cc/layers/layer_impl_unittest.cc84
-rw-r--r--cc/layers/picture_layer_impl.cc2
-rw-r--r--cc/trees/layer_tree_host_impl.cc10
-rw-r--r--cc/trees/layer_tree_impl.cc18
-rw-r--r--cc/trees/layer_tree_impl.h7
-rw-r--r--cc/trees/tree_synchronizer.cc10
-rw-r--r--cc/trees/tree_synchronizer.h3
9 files changed, 97 insertions, 107 deletions
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 5d31a22..9b5c57f 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -83,8 +83,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
clip_tree_index_(-1),
scroll_tree_index_(-1),
draw_depth_(0.f),
- needs_push_properties_(false),
- num_dependents_need_push_properties_(0),
sorting_context_id_(0),
current_draw_mode_(DRAW_MODE_NONE),
element_id_(0),
@@ -129,6 +127,7 @@ LayerImpl::~LayerImpl() {
layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
layer_tree_impl_->UnregisterScrollLayer(this);
layer_tree_impl_->UnregisterLayer(this);
+ layer_tree_impl_->RemoveLayerShouldPushProperties(this);
layer_tree_impl_->RemoveFromElementMap(this);
@@ -158,12 +157,6 @@ scoped_ptr<LayerImpl> LayerImpl::RemoveChild(LayerImpl* child) {
}
void LayerImpl::SetParent(LayerImpl* parent) {
- if (parent_should_know_need_push_properties()) {
- if (parent_)
- parent_->RemoveDependentNeedsPushProperties();
- if (parent)
- parent->AddDependentNeedsPushProperties();
- }
parent_ = parent;
}
@@ -631,8 +624,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
// Reset any state that should be cleared for the next update.
layer_property_changed_ = false;
update_rect_ = gfx::Rect();
- needs_push_properties_ = false;
- num_dependents_need_push_properties_ = 0;
+ layer_tree_impl()->RemoveLayerShouldPushProperties(this);
}
bool LayerImpl::IsAffectedByPageScale() const {
@@ -763,7 +755,7 @@ const char* LayerImpl::LayerTypeAsString() const {
return "cc::LayerImpl";
}
-void LayerImpl::ResetAllChangeTrackingForSubtree() {
+void LayerImpl::ResetAllChangeTrackingForSubtreeInternal() {
layer_property_changed_ = false;
if (TransformNode* transform_node =
layer_tree_impl_->property_trees()->transform_tree.Node(
@@ -778,18 +770,20 @@ void LayerImpl::ResetAllChangeTrackingForSubtree() {
render_surface_->ResetPropertyChangedFlag();
if (mask_layer_)
- mask_layer_->ResetAllChangeTrackingForSubtree();
+ mask_layer_->ResetAllChangeTrackingForSubtreeInternal();
if (replica_layer_) {
// This also resets the replica mask, if it exists.
- replica_layer_->ResetAllChangeTrackingForSubtree();
+ replica_layer_->ResetAllChangeTrackingForSubtreeInternal();
}
for (size_t i = 0; i < children_.size(); ++i)
- children_[i]->ResetAllChangeTrackingForSubtree();
+ children_[i]->ResetAllChangeTrackingForSubtreeInternal();
+}
- needs_push_properties_ = false;
- num_dependents_need_push_properties_ = 0;
+void LayerImpl::ResetAllChangeTrackingForSubtree() {
+ layer_tree_impl()->LayersThatShouldPushProperties().clear();
+ ResetAllChangeTrackingForSubtreeInternal();
}
int LayerImpl::num_copy_requests_in_target_subtree() {
@@ -1568,28 +1562,8 @@ gfx::Vector2dF LayerImpl::ClampScrollToMaxScrollOffset() {
}
void LayerImpl::SetNeedsPushProperties() {
- if (needs_push_properties_)
- return;
- if (!parent_should_know_need_push_properties() && parent_)
- parent_->AddDependentNeedsPushProperties();
- needs_push_properties_ = true;
-}
-
-void LayerImpl::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 LayerImpl::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_impl_)
+ layer_tree_impl()->AddLayerShouldPushProperties(this);
}
void LayerImpl::GetAllPrioritizedTilesForTracing(
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 91d3e0d..211673b 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -591,16 +591,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
virtual size_t GPUMemoryUsageInBytes() const;
void SetNeedsPushProperties();
- void AddDependentNeedsPushProperties();
- void RemoveDependentNeedsPushProperties();
- bool parent_should_know_need_push_properties() const {
- return needs_push_properties() || descendant_needs_push_properties();
- }
-
- bool needs_push_properties() const { return needs_push_properties_; }
- bool descendant_needs_push_properties() const {
- return num_dependents_need_push_properties_ > 0;
- }
virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
@@ -701,6 +691,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
void NoteLayerPropertyChangedForDescendantsInternal();
void PushLayerPropertyChangedForSubtreeInternal();
+ void ResetAllChangeTrackingForSubtreeInternal();
virtual const char* LayerTypeAsString() const;
@@ -804,15 +795,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
protected:
friend class TreeSynchronizer;
- // This flag is set when the layer needs to push properties to the active
- // side.
- bool needs_push_properties_;
-
- // The number of direct children or dependent layers that need to be recursed
- // to in order for them or a descendent of them to push properties to the
- // active side.
- int num_dependents_need_push_properties_;
-
// Layers that share a sorting context id will be sorted together in 3d
// space. 0 is a special value that means this layer will not be sorted and
// will be drawn in paint order.
diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc
index a8336d8..bd221ce 100644
--- a/cc/layers/layer_impl_unittest.cc
+++ b/cc/layers/layer_impl_unittest.cc
@@ -26,48 +26,60 @@
namespace cc {
namespace {
-#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
- root->ResetAllChangeTrackingForSubtree(); \
- root->layer_tree_impl()->property_trees()->ResetAllChangeTracking( \
- PropertyTrees::ResetFlags::ALL_TREES); \
- code_to_test; \
- EXPECT_TRUE(root->needs_push_properties()); \
- EXPECT_FALSE(child->needs_push_properties()); \
- EXPECT_FALSE(grand_child->needs_push_properties()); \
- EXPECT_TRUE(root->LayerPropertyChanged()); \
- EXPECT_TRUE(child->LayerPropertyChanged()); \
+#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
+ root->ResetAllChangeTrackingForSubtree(); \
+ root->layer_tree_impl()->property_trees()->ResetAllChangeTracking( \
+ PropertyTrees::ResetFlags::ALL_TREES); \
+ code_to_test; \
+ EXPECT_TRUE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
+ EXPECT_FALSE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
+ EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
+ grand_child)); \
+ EXPECT_TRUE(root->LayerPropertyChanged()); \
+ EXPECT_TRUE(child->LayerPropertyChanged()); \
EXPECT_TRUE(grand_child->LayerPropertyChanged());
-#define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \
- root->ResetAllChangeTrackingForSubtree(); \
- code_to_test; \
- EXPECT_FALSE(root->needs_push_properties()); \
- EXPECT_FALSE(child->needs_push_properties()); \
- EXPECT_FALSE(grand_child->needs_push_properties()); \
- EXPECT_FALSE(root->LayerPropertyChanged()); \
- EXPECT_FALSE(child->LayerPropertyChanged()); \
+#define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \
+ root->ResetAllChangeTrackingForSubtree(); \
+ code_to_test; \
+ EXPECT_FALSE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
+ EXPECT_FALSE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
+ EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
+ grand_child)); \
+ EXPECT_FALSE(root->LayerPropertyChanged()); \
+ EXPECT_FALSE(child->LayerPropertyChanged()); \
EXPECT_FALSE(grand_child->LayerPropertyChanged());
-#define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \
- code_to_test) \
- root->ResetAllChangeTrackingForSubtree(); \
- code_to_test; \
- EXPECT_TRUE(root->needs_push_properties()); \
- EXPECT_FALSE(child->needs_push_properties()); \
- EXPECT_FALSE(grand_child->needs_push_properties()); \
- EXPECT_FALSE(root->LayerPropertyChanged()); \
- EXPECT_FALSE(child->LayerPropertyChanged()); \
+#define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \
+ code_to_test) \
+ root->ResetAllChangeTrackingForSubtree(); \
+ code_to_test; \
+ EXPECT_TRUE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
+ EXPECT_FALSE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
+ EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
+ grand_child)); \
+ EXPECT_FALSE(root->LayerPropertyChanged()); \
+ EXPECT_FALSE(child->LayerPropertyChanged()); \
EXPECT_FALSE(grand_child->LayerPropertyChanged());
-#define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \
- root->ResetAllChangeTrackingForSubtree(); \
- root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \
- code_to_test; \
- EXPECT_TRUE(root->needs_push_properties()); \
- EXPECT_FALSE(child->needs_push_properties()); \
- EXPECT_FALSE(grand_child->needs_push_properties()); \
- EXPECT_TRUE(root->LayerPropertyChanged()); \
- EXPECT_FALSE(child->LayerPropertyChanged()); \
+#define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \
+ root->ResetAllChangeTrackingForSubtree(); \
+ root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \
+ code_to_test; \
+ EXPECT_TRUE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
+ EXPECT_FALSE( \
+ root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
+ EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
+ grand_child)); \
+ EXPECT_TRUE(root->LayerPropertyChanged()); \
+ EXPECT_FALSE(child->LayerPropertyChanged()); \
EXPECT_FALSE(grand_child->LayerPropertyChanged());
#define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 8e823d9..a12fb282 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -140,7 +140,7 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
// We always need to push properties.
// See http://crbug.com/303943
// TODO(danakj): Stop always pushing properties since we don't swap tilings.
- needs_push_properties_ = true;
+ layer_tree_impl()->AddLayerShouldPushProperties(this);
}
void PictureLayerImpl::AppendQuads(RenderPass* render_pass,
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index c7bcf2c..adf570b 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1983,8 +1983,14 @@ void LayerTreeHostImpl::ActivateSyncTree() {
else
active_tree_->root_layer()->PushLayerPropertyChangedForSubtree();
}
- TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
- active_tree_->root_layer());
+
+ std::unordered_set<LayerImpl*> layers_that_should_push_properties =
+ pending_tree_->LayersThatShouldPushProperties();
+ for (auto pending_layer : layers_that_should_push_properties) {
+ LayerImpl* active_layer = active_tree_->LayerById(pending_layer->id());
+ DCHECK(active_layer);
+ pending_layer->PushPropertiesTo(active_layer);
+ }
pending_tree_->PushPropertiesTo(active_tree_.get());
if (pending_tree_->root_layer())
pending_tree_->property_trees()->ResetAllChangeTracking(
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 89567a5..87fe6cf 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -956,6 +956,24 @@ LayerImpl* LayerTreeImpl::LayerById(int id) const {
return iter != layer_id_map_.end() ? iter->second : NULL;
}
+void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) {
+ layers_that_should_push_properties_.insert(layer);
+}
+
+void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) {
+ layers_that_should_push_properties_.erase(layer);
+}
+
+std::unordered_set<LayerImpl*>&
+LayerTreeImpl::LayersThatShouldPushProperties() {
+ return layers_that_should_push_properties_;
+}
+
+bool LayerTreeImpl::LayerNeedsPushPropertiesForTesting(LayerImpl* layer) {
+ return layers_that_should_push_properties_.find(layer) !=
+ layers_that_should_push_properties_.end();
+}
+
void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
DCHECK(!LayerById(layer->id()));
layer_id_map_[layer->id()] = layer;
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index 9f20b13..57523f9 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -299,6 +299,11 @@ class CC_EXPORT LayerTreeImpl {
LayerImpl* LayerById(int id) const;
+ void AddLayerShouldPushProperties(LayerImpl* layer);
+ void RemoveLayerShouldPushProperties(LayerImpl* layer);
+ std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties();
+ bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer);
+
// These should be called by LayerImpl's ctor/dtor.
void RegisterLayer(LayerImpl* layer);
void UnregisterLayer(LayerImpl* layer);
@@ -515,6 +520,8 @@ class CC_EXPORT LayerTreeImpl {
using LayerIdMap = std::unordered_map<int, LayerImpl*>;
LayerIdMap layer_id_map_;
+ // Set of layers that need to push properties.
+ std::unordered_set<LayerImpl*> layers_that_should_push_properties_;
std::unordered_map<uint64_t, ElementLayers> element_layers_map_;
diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc
index a257c57..af87056 100644
--- a/cc/trees/tree_synchronizer.cc
+++ b/cc/trees/tree_synchronizer.cc
@@ -129,10 +129,8 @@ scoped_ptr<LayerImpl> SynchronizeTreesRecursive(
new_layers, old_layers, layer, tree_impl);
}
-// static
-template <typename LayerType>
void TreeSynchronizer::PushPropertiesInternal(
- LayerType* layer,
+ Layer* layer,
LayerImpl* layer_impl,
int* num_dependents_need_push_properties_for_parent) {
if (!layer) {
@@ -246,10 +244,4 @@ void TreeSynchronizer::PushProperties(Layer* layer,
#endif
}
-void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) {
- int num_dependents_need_push_properties = 0;
- PushPropertiesInternal(
- layer, layer_impl, &num_dependents_need_push_properties);
-}
-
} // namespace cc
diff --git a/cc/trees/tree_synchronizer.h b/cc/trees/tree_synchronizer.h
index a580362..2e6e8f0 100644
--- a/cc/trees/tree_synchronizer.h
+++ b/cc/trees/tree_synchronizer.h
@@ -38,9 +38,8 @@ class CC_EXPORT TreeSynchronizer {
private:
TreeSynchronizer(); // Not instantiable.
- template <typename LayerType>
static void PushPropertiesInternal(
- LayerType* layer,
+ Layer* layer,
LayerImpl* layer_impl,
int* num_dependents_need_push_properties_for_parent);