| 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/tree_synchronizer.h" | 5 #include "cc/trees/tree_synchronizer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
| 17 #include "cc/layers/layer_impl.h" | 17 #include "cc/layers/layer_impl.h" |
| 18 #include "cc/test/animation_test_common.h" | 18 #include "cc/test/animation_test_common.h" |
| 19 #include "cc/test/fake_impl_task_runner_provider.h" | 19 #include "cc/test/fake_impl_task_runner_provider.h" |
| 20 #include "cc/test/fake_layer_tree_host.h" | 20 #include "cc/test/fake_layer_tree_host.h" |
| 21 #include "cc/test/fake_rendering_stats_instrumentation.h" | 21 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 22 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
| 22 #include "cc/test/test_shared_bitmap_manager.h" | 23 #include "cc/test/test_shared_bitmap_manager.h" |
| 23 #include "cc/test/test_task_graph_runner.h" | 24 #include "cc/test/test_task_graph_runner.h" |
| 24 #include "cc/trees/effect_node.h" | 25 #include "cc/trees/effect_node.h" |
| 25 #include "cc/trees/layer_tree_host_common.h" | 26 #include "cc/trees/layer_tree_host_common.h" |
| 26 #include "cc/trees/single_thread_proxy.h" | 27 #include "cc/trees/single_thread_proxy.h" |
| 27 #include "cc/trees/task_runner_provider.h" | 28 #include "cc/trees/task_runner_provider.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 namespace cc { | 31 namespace cc { |
| 31 namespace { | 32 namespace { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (from_map.PendingBase() != from_other.PendingBase() || | 159 if (from_map.PendingBase() != from_other.PendingBase() || |
| 159 from_map.ActiveBase() != from_other.ActiveBase() || | 160 from_map.ActiveBase() != from_other.ActiveBase() || |
| 160 from_map.Delta() != from_other.Delta() || | 161 from_map.Delta() != from_other.Delta() || |
| 161 from_map.PendingDelta().get() != from_other.PendingDelta().get()) | 162 from_map.PendingDelta().get() != from_other.PendingDelta().get()) |
| 162 return false; | 163 return false; |
| 163 } | 164 } |
| 164 return true; | 165 return true; |
| 165 } | 166 } |
| 166 | 167 |
| 167 FakeLayerTreeHostClient client_; | 168 FakeLayerTreeHostClient client_; |
| 169 StubLayerTreeHostSingleThreadClient single_thread_client_; |
| 168 TestTaskGraphRunner task_graph_runner_; | 170 TestTaskGraphRunner task_graph_runner_; |
| 169 std::unique_ptr<FakeLayerTreeHost> host_; | 171 std::unique_ptr<FakeLayerTreeHost> host_; |
| 170 }; | 172 }; |
| 171 | 173 |
| 172 // Attempts to synchronizes a null tree. This should not crash, and should | 174 // Attempts to synchronizes a null tree. This should not crash, and should |
| 173 // return a null tree. | 175 // return a null tree. |
| 174 TEST_F(TreeSynchronizerTest, SyncNullTree) { | 176 TEST_F(TreeSynchronizerTest, SyncNullTree) { |
| 175 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), | 177 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), |
| 176 host_->active_tree()); | 178 host_->active_tree()); |
| 177 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing()); | 179 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing()); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 556 |
| 555 host_impl->CreatePendingTree(); | 557 host_impl->CreatePendingTree(); |
| 556 host_->CommitAndCreatePendingTree(); | 558 host_->CommitAndCreatePendingTree(); |
| 557 host_impl->ActivateSyncTree(); | 559 host_impl->ActivateSyncTree(); |
| 558 | 560 |
| 559 EXPECT_EQ(scroll_layer->id(), | 561 EXPECT_EQ(scroll_layer->id(), |
| 560 host_impl->active_tree()->CurrentlyScrollingLayer()->id()); | 562 host_impl->active_tree()->CurrentlyScrollingLayer()->id()); |
| 561 } | 563 } |
| 562 | 564 |
| 563 TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) { | 565 TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) { |
| 564 host_->InitializeSingleThreaded(&client_, base::ThreadTaskRunnerHandle::Get(), | 566 host_->InitializeSingleThreaded(&single_thread_client_, |
| 565 nullptr); | 567 base::ThreadTaskRunnerHandle::Get(), nullptr); |
| 566 LayerTreeSettings settings; | 568 LayerTreeSettings settings; |
| 567 FakeLayerTreeHostImplClient client; | 569 FakeLayerTreeHostImplClient client; |
| 568 FakeImplTaskRunnerProvider task_runner_provider; | 570 FakeImplTaskRunnerProvider task_runner_provider; |
| 569 FakeRenderingStatsInstrumentation stats_instrumentation; | 571 FakeRenderingStatsInstrumentation stats_instrumentation; |
| 570 TestSharedBitmapManager shared_bitmap_manager; | 572 TestSharedBitmapManager shared_bitmap_manager; |
| 571 TestTaskGraphRunner task_graph_runner; | 573 TestTaskGraphRunner task_graph_runner; |
| 572 FakeLayerTreeHostImpl* host_impl = host_->host_impl(); | 574 FakeLayerTreeHostImpl* host_impl = host_->host_impl(); |
| 573 host_impl->CreatePendingTree(); | 575 host_impl->CreatePendingTree(); |
| 574 | 576 |
| 575 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 577 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(20, 30)); | 652 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(20, 30)); |
| 651 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); | 653 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); |
| 652 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); | 654 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); |
| 653 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( | 655 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( |
| 654 gfx::ScrollOffset(100, 100)); | 656 gfx::ScrollOffset(100, 100)); |
| 655 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); | 657 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); |
| 656 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); | 658 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); |
| 657 } | 659 } |
| 658 | 660 |
| 659 TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) { | 661 TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) { |
| 660 host_->InitializeSingleThreaded(&client_, base::ThreadTaskRunnerHandle::Get(), | 662 host_->InitializeSingleThreaded(&single_thread_client_, |
| 661 nullptr); | 663 base::ThreadTaskRunnerHandle::Get(), nullptr); |
| 662 LayerTreeSettings settings; | 664 LayerTreeSettings settings; |
| 663 FakeLayerTreeHostImplClient client; | 665 FakeLayerTreeHostImplClient client; |
| 664 FakeImplTaskRunnerProvider task_runner_provider; | 666 FakeImplTaskRunnerProvider task_runner_provider; |
| 665 FakeRenderingStatsInstrumentation stats_instrumentation; | 667 FakeRenderingStatsInstrumentation stats_instrumentation; |
| 666 TestSharedBitmapManager shared_bitmap_manager; | 668 TestSharedBitmapManager shared_bitmap_manager; |
| 667 TestTaskGraphRunner task_graph_runner; | 669 TestTaskGraphRunner task_graph_runner; |
| 668 FakeLayerTreeHostImpl* host_impl = host_->host_impl(); | 670 FakeLayerTreeHostImpl* host_impl = host_->host_impl(); |
| 669 host_impl->CreatePendingTree(); | 671 host_impl->CreatePendingTree(); |
| 670 | 672 |
| 671 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 673 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 697 host_->CommitAndCreatePendingTree(); | 699 host_->CommitAndCreatePendingTree(); |
| 698 host_impl->ActivateSyncTree(); | 700 host_impl->ActivateSyncTree(); |
| 699 EXPECT_EQ( | 701 EXPECT_EQ( |
| 700 CombinedAnimationScale(0.f, 0.f), | 702 CombinedAnimationScale(0.f, 0.f), |
| 701 host_impl->active_tree()->property_trees()->GetAnimationScales( | 703 host_impl->active_tree()->property_trees()->GetAnimationScales( |
| 702 transform_layer->transform_tree_index(), host_impl->active_tree())); | 704 transform_layer->transform_tree_index(), host_impl->active_tree())); |
| 703 } | 705 } |
| 704 | 706 |
| 705 } // namespace | 707 } // namespace |
| 706 } // namespace cc | 708 } // namespace cc |
| OLD | NEW |