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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 373113003: Keeping track of descendants that draw content instead of recalcualting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index b37d41b37e879af8c2b7fe33db78c784103d2c33..1fc7d4d5c04e56851dbd67b30f0a1a08f6ad8c28 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -2976,6 +2976,10 @@ class PushPropertiesCountingLayer : public Layer {
PassAs<LayerImpl>();
}
+ void SetDrawsContent(bool draws_content) {
+ UpdateDrawsContent(draws_content);
+ }
+
size_t push_properties_count() const { return push_properties_count_; }
void reset_push_properties_count() { push_properties_count_ = 0; }
@@ -3104,14 +3108,18 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
case 6:
child_->RemoveFromParent();
// No layers need commit.
danakj 2014/07/17 17:21:25 Update comment explaining why this happens now
awoloszyn 2014/07/17 20:45:00 Done.
+ ++expected_push_properties_root_;
break;
case 7:
root_->AddChild(child_);
// Layers added to the tree get committed.
danakj 2014/07/17 17:21:26 update comment
awoloszyn 2014/07/17 20:45:01 Done.
++expected_push_properties_child_;
++expected_push_properties_grandchild_;
+ ++expected_push_properties_root_;
break;
case 8:
+ ++expected_push_properties_root_;
danakj 2014/07/17 17:21:26 move below the comment and update it to reflect wh
awoloszyn 2014/07/17 20:45:00 Done.
+ ++expected_push_properties_child_;
grandchild_->RemoveFromParent();
// No layers need commit.
break;
@@ -3119,6 +3127,8 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
child_->AddChild(grandchild_);
// Layers added to the tree get committed.
danakj 2014/07/17 17:21:26 update comment
awoloszyn 2014/07/17 20:45:01 Done.
++expected_push_properties_grandchild_;
+ ++expected_push_properties_root_;
+ ++expected_push_properties_child_;
break;
case 10:
layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
@@ -3144,6 +3154,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
// Layers added to the tree get committed.
danakj 2014/07/17 17:21:26 update comment
awoloszyn 2014/07/17 20:45:00 Done.
++expected_push_properties_child_;
++expected_push_properties_grandchild_;
+ ++expected_push_properties_root_;
break;
case 15:
grandchild_->SetPosition(gfx::Point(1, 1));
@@ -3256,6 +3267,7 @@ class LayerTreeHostTestImplLayersPushProperties
// grandchild_impl is now the leaf that always pushes. It is pushed.
++expected_push_properties_grandchild_impl_;
+ ++expected_push_properties_root_impl_;
danakj 2014/07/17 17:21:25 explain this one in comment too
awoloszyn 2014/07/17 20:45:00 Done.
break;
case 7:
// The leaf that always pushes is pushed.
@@ -3264,6 +3276,7 @@ class LayerTreeHostTestImplLayersPushProperties
// Child is added back. New layers are initialized.
++expected_push_properties_grandchild2_impl_;
++expected_push_properties_child2_impl_;
+ ++expected_push_properties_root_impl_;
danakj 2014/07/17 17:21:26 explain with commetn
awoloszyn 2014/07/17 20:45:00 Done.
break;
case 8:
// Leaf is removed.
@@ -3271,6 +3284,8 @@ class LayerTreeHostTestImplLayersPushProperties
// Always pushing.
++expected_push_properties_grandchild_impl_;
+ ++expected_push_properties_child2_impl_;
danakj 2014/07/17 17:21:26 explain with comment
awoloszyn 2014/07/17 20:45:01 Done.
+ ++expected_push_properties_root_impl_;
break;
case 9:
// Leaf is added back
@@ -3278,6 +3293,8 @@ class LayerTreeHostTestImplLayersPushProperties
// The leaf that always pushes is pushed.
++expected_push_properties_grandchild_impl_;
+ ++expected_push_properties_root_impl_;
danakj 2014/07/17 17:21:26 explain with comment
awoloszyn 2014/07/17 20:45:00 Done.
+ ++expected_push_properties_child2_impl_;
break;
case 10:
// The leaf that always pushes is pushed.
@@ -3312,6 +3329,7 @@ class LayerTreeHostTestImplLayersPushProperties
++expected_push_properties_child2_impl_;
++expected_push_properties_grandchild2_impl_;
+ ++expected_push_properties_root_impl_;
break;
case 15:
// The position of this child was changed.
@@ -3444,6 +3462,59 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
+class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
+ protected:
+ virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+
+ virtual void SetupTree() OVERRIDE {
+ root_ = PushPropertiesCountingLayer::Create();
+ child_ = PushPropertiesCountingLayer::Create();
+ root_->AddChild(child_);
+
+ layer_tree_host()->SetRootLayer(root_);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ virtual void DidCommitAndDrawFrame() OVERRIDE {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 0:
+ break;
+ case 1: {
+ // During update, the ignore_set_needs_commit_ bit is set to true to
+ // avoid causing a second commit to be scheduled. If a property change
+ // is made during this, however, it needs to be pushed in the upcoming
+ // commit.
+ EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_EQ(1, root_->NumDescendantsThatDrawContent());
+ root_->reset_push_properties_count();
+ child_->reset_push_properties_count();
+ child_->SetDrawsContent(false);
+ EXPECT_EQ(0, root_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(0u, root_->push_properties_count());
+ EXPECT_EQ(0u, child_->push_properties_count());
+ EXPECT_TRUE(root_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
+ break;
+ }
+ case 2:
+ EXPECT_EQ(1u, root_->push_properties_count());
+ EXPECT_EQ(1u, child_->push_properties_count());
+ EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_FALSE(child_->needs_push_properties());
+ EndTest();
+ break;
+ }
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ scoped_refptr<PushPropertiesCountingLayer> root_;
+ scoped_refptr<PushPropertiesCountingLayer> child_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit);
+
class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
: public LayerTreeHostTest {
protected:
@@ -3551,9 +3622,9 @@ class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
grandchild1_->RemoveFromParent();
grandchild1_->SetPosition(gfx::Point(1, 1));
- EXPECT_FALSE(root_->needs_push_properties());
- EXPECT_FALSE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->descendant_needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
EXPECT_FALSE(grandchild2_->needs_push_properties());
EXPECT_FALSE(grandchild2_->descendant_needs_push_properties());
@@ -3562,9 +3633,9 @@ class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
child_->AddChild(grandchild1_);
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
EXPECT_TRUE(grandchild1_->needs_push_properties());
EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
@@ -3575,9 +3646,9 @@ class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
grandchild2_->SetPosition(gfx::Point(1, 1));
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
EXPECT_TRUE(grandchild1_->needs_push_properties());
EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
@@ -3589,18 +3660,18 @@ class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
// grandchild2_ will still need a push properties.
grandchild1_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
// grandchild3_ does not need a push properties, so recursing should
// no longer be needed.
grandchild2_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
- EXPECT_FALSE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->descendant_needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
EndTest();
break;
@@ -3636,18 +3707,19 @@ class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
// grandchild2_ will still need a push properties.
grandchild1_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ // We will need push properties because our drawable children changed
danakj 2014/07/17 17:21:25 nit: .
awoloszyn 2014/07/17 20:45:00 Done.
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
// grandchild3_ does not need a push properties, so recursing should
// no longer be needed.
grandchild2_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
- EXPECT_FALSE(root_->descendant_needs_push_properties());
- EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->descendant_needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
EndTest();
break;
@@ -3685,7 +3757,7 @@ class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
grandchild2_->SetPosition(gfx::Point(1, 1));
root_->AddChild(child_);
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
@@ -3698,21 +3770,21 @@ class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
grandchild1_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
grandchild2_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
grandchild3_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
@@ -3764,21 +3836,21 @@ class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
grandchild1_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
grandchild2_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
child_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_FALSE(root_->descendant_needs_push_properties());
EndTest();
@@ -3828,21 +3900,21 @@ class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
grandchild1_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_TRUE(child_->descendant_needs_push_properties());
grandchild2_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_TRUE(root_->descendant_needs_push_properties());
EXPECT_TRUE(child_->needs_push_properties());
EXPECT_FALSE(child_->descendant_needs_push_properties());
child_->RemoveFromParent();
- EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_TRUE(root_->needs_push_properties());
EXPECT_FALSE(root_->descendant_needs_push_properties());
EndTest();

Powered by Google App Engine
This is Rietveld 408576698