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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 Layer* root_layer = layer_tree_host()->root_layer(); | 853 Layer* root_layer = layer_tree_host()->root_layer(); |
854 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 854 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
855 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 855 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
856 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), | 856 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
857 2 * root_layer->bounds().height())); | 857 2 * root_layer->bounds().height())); |
858 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); | 858 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); |
859 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 859 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
860 // This test requires the page_scale and inner viewport layers to be | 860 // This test requires the page_scale and inner viewport layers to be |
861 // identified. | 861 // identified. |
862 layer_tree_host()->RegisterViewportLayers( | 862 layer_tree_host()->RegisterViewportLayers( |
863 root_layer, scroll_layer_.get(), NULL); | 863 root_layer, scroll_layer_.get(), nullptr); |
864 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 864 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
865 } | 865 } |
866 | 866 |
867 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 867 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
868 | 868 |
869 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 869 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
870 float scale, | 870 float scale, |
871 float) override { | 871 float) override { |
872 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); | 872 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); |
873 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, | 873 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 int num_complete_commits_; | 1896 int num_complete_commits_; |
1897 }; | 1897 }; |
1898 | 1898 |
1899 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); | 1899 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); |
1900 | 1900 |
1901 class LayerTreeHostWithProxy : public LayerTreeHost { | 1901 class LayerTreeHostWithProxy : public LayerTreeHost { |
1902 public: | 1902 public: |
1903 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, | 1903 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, |
1904 const LayerTreeSettings& settings, | 1904 const LayerTreeSettings& settings, |
1905 scoped_ptr<FakeProxy> proxy) | 1905 scoped_ptr<FakeProxy> proxy) |
1906 : LayerTreeHost(client, NULL, settings) { | 1906 : LayerTreeHost(client, nullptr, settings) { |
1907 proxy->SetLayerTreeHost(this); | 1907 proxy->SetLayerTreeHost(this); |
1908 client->SetLayerTreeHost(this); | 1908 client->SetLayerTreeHost(this); |
1909 InitializeForTesting(proxy.Pass()); | 1909 InitializeForTesting(proxy.Pass()); |
1910 } | 1910 } |
1911 }; | 1911 }; |
1912 | 1912 |
1913 TEST(LayerTreeHostTest, LimitPartialUpdates) { | 1913 TEST(LayerTreeHostTest, LimitPartialUpdates) { |
1914 // When partial updates are not allowed, max updates should be 0. | 1914 // When partial updates are not allowed, max updates should be 0. |
1915 { | 1915 { |
1916 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1916 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 break; | 3289 break; |
3290 case 16: | 3290 case 16: |
3291 // Second child is invalidated with SetNeedsDisplay | 3291 // Second child is invalidated with SetNeedsDisplay |
3292 ++expected_push_properties_child2_impl_; | 3292 ++expected_push_properties_child2_impl_; |
3293 | 3293 |
3294 // The leaf that always pushed is pushed. | 3294 // The leaf that always pushed is pushed. |
3295 ++expected_push_properties_grandchild_impl_; | 3295 ++expected_push_properties_grandchild_impl_; |
3296 break; | 3296 break; |
3297 } | 3297 } |
3298 | 3298 |
3299 PushPropertiesCountingLayerImpl* root_impl_ = NULL; | 3299 PushPropertiesCountingLayerImpl* root_impl_ = nullptr; |
3300 PushPropertiesCountingLayerImpl* child_impl_ = NULL; | 3300 PushPropertiesCountingLayerImpl* child_impl_ = nullptr; |
3301 PushPropertiesCountingLayerImpl* child2_impl_ = NULL; | 3301 PushPropertiesCountingLayerImpl* child2_impl_ = nullptr; |
3302 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; | 3302 PushPropertiesCountingLayerImpl* grandchild_impl_ = nullptr; |
3303 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; | 3303 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = nullptr; |
3304 | 3304 |
3305 // Pull the layers that we need from the tree assuming the same structure | 3305 // Pull the layers that we need from the tree assuming the same structure |
3306 // as LayerTreeHostTestLayersPushProperties | 3306 // as LayerTreeHostTestLayersPushProperties |
3307 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3307 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
3308 host_impl->RootLayer()); | 3308 host_impl->RootLayer()); |
3309 | 3309 |
3310 if (root_impl_ && root_impl_->children().size() > 0) { | 3310 if (root_impl_ && root_impl_->children().size() > 0) { |
3311 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3311 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
3312 root_impl_->children()[0]); | 3312 root_impl_->children()[0]); |
3313 | 3313 |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4658 virtual void WillBeginMainFrame() override { | 4658 virtual void WillBeginMainFrame() override { |
4659 if (TestEnded()) | 4659 if (TestEnded()) |
4660 return; | 4660 return; |
4661 | 4661 |
4662 int set_needs_commit_count = 0; | 4662 int set_needs_commit_count = 0; |
4663 int set_needs_redraw_count = 0; | 4663 int set_needs_redraw_count = 0; |
4664 | 4664 |
4665 { | 4665 { |
4666 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4666 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4667 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4667 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4668 NULL, | 4668 nullptr, |
4669 &set_needs_commit_count, | 4669 &set_needs_commit_count, |
4670 &set_needs_redraw_count)); | 4670 &set_needs_redraw_count)); |
4671 layer_tree_host()->SetNeedsCommit(); | 4671 layer_tree_host()->SetNeedsCommit(); |
4672 EXPECT_EQ(1, set_needs_commit_count); | 4672 EXPECT_EQ(1, set_needs_commit_count); |
4673 EXPECT_EQ(0, set_needs_redraw_count); | 4673 EXPECT_EQ(0, set_needs_redraw_count); |
4674 } | 4674 } |
4675 | 4675 |
4676 // Now the monitor is destroyed, SetNeedsCommit() is no longer being | 4676 // Now the monitor is destroyed, SetNeedsCommit() is no longer being |
4677 // monitored. | 4677 // monitored. |
4678 layer_tree_host()->SetNeedsCommit(); | 4678 layer_tree_host()->SetNeedsCommit(); |
4679 EXPECT_EQ(1, set_needs_commit_count); | 4679 EXPECT_EQ(1, set_needs_commit_count); |
4680 EXPECT_EQ(0, set_needs_redraw_count); | 4680 EXPECT_EQ(0, set_needs_redraw_count); |
4681 | 4681 |
4682 { | 4682 { |
4683 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4683 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4684 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4684 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4685 NULL, | 4685 nullptr, |
4686 &set_needs_commit_count, | 4686 &set_needs_commit_count, |
4687 &set_needs_redraw_count)); | 4687 &set_needs_redraw_count)); |
4688 layer_tree_host()->SetNeedsUpdateLayers(); | 4688 layer_tree_host()->SetNeedsUpdateLayers(); |
4689 EXPECT_EQ(2, set_needs_commit_count); | 4689 EXPECT_EQ(2, set_needs_commit_count); |
4690 EXPECT_EQ(0, set_needs_redraw_count); | 4690 EXPECT_EQ(0, set_needs_redraw_count); |
4691 } | 4691 } |
4692 | 4692 |
4693 { | 4693 { |
4694 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4694 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4695 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4695 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4696 NULL, | 4696 nullptr, |
4697 &set_needs_commit_count, | 4697 &set_needs_commit_count, |
4698 &set_needs_redraw_count)); | 4698 &set_needs_redraw_count)); |
4699 layer_tree_host()->SetNeedsAnimate(); | 4699 layer_tree_host()->SetNeedsAnimate(); |
4700 EXPECT_EQ(3, set_needs_commit_count); | 4700 EXPECT_EQ(3, set_needs_commit_count); |
4701 EXPECT_EQ(0, set_needs_redraw_count); | 4701 EXPECT_EQ(0, set_needs_redraw_count); |
4702 } | 4702 } |
4703 | 4703 |
4704 EndTest(); | 4704 EndTest(); |
4705 } | 4705 } |
4706 | 4706 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4936 virtual void AfterTest() override {} | 4936 virtual void AfterTest() override {} |
4937 | 4937 |
4938 FakeContentLayerClient layer_client_; | 4938 FakeContentLayerClient layer_client_; |
4939 }; | 4939 }; |
4940 | 4940 |
4941 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4941 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4942 | 4942 |
4943 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | 4943 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { |
4944 public: | 4944 public: |
4945 LayerTreeHostTestContinuousPainting() | 4945 LayerTreeHostTestContinuousPainting() |
4946 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 4946 : num_commits_(0), |
| 4947 num_draws_(0), |
| 4948 bounds_(20, 20), |
| 4949 child_layer_(nullptr) {} |
4947 | 4950 |
4948 protected: | 4951 protected: |
4949 enum { kExpectedNumCommits = 10 }; | 4952 enum { kExpectedNumCommits = 10 }; |
4950 | 4953 |
4951 virtual void SetupTree() override { | 4954 virtual void SetupTree() override { |
4952 scoped_refptr<Layer> root_layer = Layer::Create(); | 4955 scoped_refptr<Layer> root_layer = Layer::Create(); |
4953 root_layer->SetBounds(bounds_); | 4956 root_layer->SetBounds(bounds_); |
4954 | 4957 |
4955 if (layer_tree_host()->settings().impl_side_painting) { | 4958 if (layer_tree_host()->settings().impl_side_painting) { |
4956 picture_layer_ = FakePictureLayer::Create(&client_); | 4959 picture_layer_ = FakePictureLayer::Create(&client_); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5160 } | 5163 } |
5161 | 5164 |
5162 int commit_count_; | 5165 int commit_count_; |
5163 TestSwapPromiseResult swap_promise_result_[3]; | 5166 TestSwapPromiseResult swap_promise_result_[3]; |
5164 }; | 5167 }; |
5165 | 5168 |
5166 // Impl-side painting is not supported for synchronous compositing. | 5169 // Impl-side painting is not supported for synchronous compositing. |
5167 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); | 5170 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); |
5168 | 5171 |
5169 } // namespace cc | 5172 } // namespace cc |
OLD | NEW |