Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 6705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6716 external_transform.Translate(20, 20); | 6716 external_transform.Translate(20, 20); |
| 6717 host_impl_->SetExternalDrawConstraints(external_transform, | 6717 host_impl_->SetExternalDrawConstraints(external_transform, |
| 6718 external_viewport, | 6718 external_viewport, |
| 6719 external_clip, | 6719 external_clip, |
| 6720 valid_for_tile_management); | 6720 valid_for_tile_management); |
| 6721 DrawFrame(); | 6721 DrawFrame(); |
| 6722 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6722 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 6723 external_transform, layer->draw_properties().target_space_transform); | 6723 external_transform, layer->draw_properties().target_space_transform); |
| 6724 } | 6724 } |
| 6725 | 6725 |
| 6726 TEST_F(LayerTreeHostImplTest, TestLayerCountingZeroInit) { | |
|
Ian Vollick
2014/07/10 03:16:23
Nice tests!
dneto
2014/07/10 18:44:17
Thanks, but obviated by danakj's suggestion. :-)
| |
| 6727 EXPECT_EQ(0u, host_impl_->num_layers_for_testing()); | |
| 6728 } | |
| 6729 | |
| 6730 TEST_F(LayerTreeHostImplTest, TestLayerCountingRootOnly) { | |
| 6731 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 6732 SetupRootLayerImpl(root.Pass()); | |
| 6733 DrawFrame(); | |
| 6734 EXPECT_EQ(1u, host_impl_->num_layers_for_testing()); | |
| 6735 } | |
| 6736 | |
| 6737 TEST_F(LayerTreeHostImplTest, TestLayerCountingSmallTree) { | |
| 6738 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 6739 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | |
| 6740 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); | |
| 6741 root->child_at(1)->AddChild(LayerImpl::Create(host_impl_->active_tree(), 4)); | |
| 6742 SetupRootLayerImpl(root.Pass()); | |
| 6743 DrawFrame(); | |
| 6744 EXPECT_EQ(4u, host_impl_->num_layers_for_testing()); | |
| 6745 } | |
| 6746 | |
| 6747 TEST_F(LayerTreeHostImplTest, TestLayerCountingWithSequenceOfTrees) { | |
| 6748 // The first tree has two nodes. | |
| 6749 scoped_ptr<LayerImpl> root0 = LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 6750 root0->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | |
| 6751 SetupRootLayerImpl(root0.Pass()); | |
| 6752 DrawFrame(); | |
| 6753 EXPECT_EQ(2u, host_impl_->num_layers_for_testing()); | |
| 6754 | |
| 6755 // We haven't changed anything. The count should stay the same. | |
| 6756 // In particular the count should not accumulate. | |
| 6757 DrawFrame(); | |
| 6758 EXPECT_EQ(2u, host_impl_->num_layers_for_testing()); | |
| 6759 | |
| 6760 // Set a new tree, with just a root. | |
| 6761 // Should have a lower count now. | |
| 6762 host_impl_->ResetTreesForTesting(); | |
| 6763 scoped_ptr<LayerImpl> root1 = LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 6764 SetupRootLayerImpl(root1.Pass()); | |
| 6765 DrawFrame(); | |
| 6766 EXPECT_EQ(1u, host_impl_->num_layers_for_testing()); | |
| 6767 | |
| 6768 // And it should go back up when we use a tree with more nodes. | |
| 6769 host_impl_->ResetTreesForTesting(); | |
| 6770 scoped_ptr<LayerImpl> root2 = LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 6771 root2->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | |
| 6772 SetupRootLayerImpl(root2.Pass()); | |
| 6773 DrawFrame(); | |
| 6774 EXPECT_EQ(2u, host_impl_->num_layers_for_testing()); | |
| 6775 } | |
| 6776 | |
| 6726 } // namespace | 6777 } // namespace |
| 6727 } // namespace cc | 6778 } // namespace cc |
| OLD | NEW |