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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 Layer* root_layer = layer_tree_host()->root_layer(); | 850 Layer* root_layer = layer_tree_host()->root_layer(); |
851 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 851 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
852 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 852 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), | 853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
854 2 * root_layer->bounds().height())); | 854 2 * root_layer->bounds().height())); |
855 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); | 855 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); |
856 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 856 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
857 // This test requires the page_scale and inner viewport layers to be | 857 // This test requires the page_scale and inner viewport layers to be |
858 // identified. | 858 // identified. |
859 layer_tree_host()->RegisterViewportLayers( | 859 layer_tree_host()->RegisterViewportLayers( |
860 root_layer, scroll_layer_.get(), NULL); | 860 root_layer, scroll_layer_.get(), nullptr); |
861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
862 } | 862 } |
863 | 863 |
864 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 864 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
865 | 865 |
866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
867 float scale, | 867 float scale, |
868 float) override { | 868 float) override { |
869 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); | 869 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); |
870 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, | 870 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1893 int num_complete_commits_; | 1893 int num_complete_commits_; |
1894 }; | 1894 }; |
1895 | 1895 |
1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); | 1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); |
1897 | 1897 |
1898 class LayerTreeHostWithProxy : public LayerTreeHost { | 1898 class LayerTreeHostWithProxy : public LayerTreeHost { |
1899 public: | 1899 public: |
1900 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, | 1900 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, |
1901 const LayerTreeSettings& settings, | 1901 const LayerTreeSettings& settings, |
1902 scoped_ptr<FakeProxy> proxy) | 1902 scoped_ptr<FakeProxy> proxy) |
1903 : LayerTreeHost(client, NULL, settings) { | 1903 : LayerTreeHost(client, nullptr, settings) { |
1904 proxy->SetLayerTreeHost(this); | 1904 proxy->SetLayerTreeHost(this); |
1905 client->SetLayerTreeHost(this); | 1905 client->SetLayerTreeHost(this); |
1906 InitializeForTesting(proxy.Pass()); | 1906 InitializeForTesting(proxy.Pass()); |
1907 } | 1907 } |
1908 }; | 1908 }; |
1909 | 1909 |
1910 TEST(LayerTreeHostTest, LimitPartialUpdates) { | 1910 TEST(LayerTreeHostTest, LimitPartialUpdates) { |
1911 // When partial updates are not allowed, max updates should be 0. | 1911 // When partial updates are not allowed, max updates should be 0. |
1912 { | 1912 { |
1913 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1913 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3279 break; | 3279 break; |
3280 case 16: | 3280 case 16: |
3281 // Second child is invalidated with SetNeedsDisplay | 3281 // Second child is invalidated with SetNeedsDisplay |
3282 ++expected_push_properties_child2_impl_; | 3282 ++expected_push_properties_child2_impl_; |
3283 | 3283 |
3284 // The leaf that always pushed is pushed. | 3284 // The leaf that always pushed is pushed. |
3285 ++expected_push_properties_grandchild_impl_; | 3285 ++expected_push_properties_grandchild_impl_; |
3286 break; | 3286 break; |
3287 } | 3287 } |
3288 | 3288 |
3289 PushPropertiesCountingLayerImpl* root_impl_ = NULL; | 3289 PushPropertiesCountingLayerImpl* root_impl_ = nullptr; |
3290 PushPropertiesCountingLayerImpl* child_impl_ = NULL; | 3290 PushPropertiesCountingLayerImpl* child_impl_ = nullptr; |
3291 PushPropertiesCountingLayerImpl* child2_impl_ = NULL; | 3291 PushPropertiesCountingLayerImpl* child2_impl_ = nullptr; |
3292 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; | 3292 PushPropertiesCountingLayerImpl* grandchild_impl_ = nullptr; |
3293 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; | 3293 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = nullptr; |
3294 | 3294 |
3295 // Pull the layers that we need from the tree assuming the same structure | 3295 // Pull the layers that we need from the tree assuming the same structure |
3296 // as LayerTreeHostTestLayersPushProperties | 3296 // as LayerTreeHostTestLayersPushProperties |
3297 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3297 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
3298 host_impl->RootLayer()); | 3298 host_impl->RootLayer()); |
3299 | 3299 |
3300 if (root_impl_ && root_impl_->children().size() > 0) { | 3300 if (root_impl_ && root_impl_->children().size() > 0) { |
3301 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3301 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
3302 root_impl_->children()[0]); | 3302 root_impl_->children()[0]); |
3303 | 3303 |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4648 virtual void WillBeginMainFrame() override { | 4648 virtual void WillBeginMainFrame() override { |
4649 if (TestEnded()) | 4649 if (TestEnded()) |
4650 return; | 4650 return; |
4651 | 4651 |
4652 int set_needs_commit_count = 0; | 4652 int set_needs_commit_count = 0; |
4653 int set_needs_redraw_count = 0; | 4653 int set_needs_redraw_count = 0; |
4654 | 4654 |
4655 { | 4655 { |
4656 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4656 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4657 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4657 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4658 NULL, | 4658 nullptr, |
4659 &set_needs_commit_count, | 4659 &set_needs_commit_count, |
4660 &set_needs_redraw_count)); | 4660 &set_needs_redraw_count)); |
4661 layer_tree_host()->SetNeedsCommit(); | 4661 layer_tree_host()->SetNeedsCommit(); |
4662 EXPECT_EQ(1, set_needs_commit_count); | 4662 EXPECT_EQ(1, set_needs_commit_count); |
4663 EXPECT_EQ(0, set_needs_redraw_count); | 4663 EXPECT_EQ(0, set_needs_redraw_count); |
4664 } | 4664 } |
4665 | 4665 |
4666 // Now the monitor is destroyed, SetNeedsCommit() is no longer being | 4666 // Now the monitor is destroyed, SetNeedsCommit() is no longer being |
4667 // monitored. | 4667 // monitored. |
4668 layer_tree_host()->SetNeedsCommit(); | 4668 layer_tree_host()->SetNeedsCommit(); |
4669 EXPECT_EQ(1, set_needs_commit_count); | 4669 EXPECT_EQ(1, set_needs_commit_count); |
4670 EXPECT_EQ(0, set_needs_redraw_count); | 4670 EXPECT_EQ(0, set_needs_redraw_count); |
4671 | 4671 |
4672 { | 4672 { |
4673 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4673 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4674 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4674 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4675 NULL, | 4675 nullptr, |
4676 &set_needs_commit_count, | 4676 &set_needs_commit_count, |
4677 &set_needs_redraw_count)); | 4677 &set_needs_redraw_count)); |
4678 layer_tree_host()->SetNeedsUpdateLayers(); | 4678 layer_tree_host()->SetNeedsUpdateLayers(); |
4679 EXPECT_EQ(2, set_needs_commit_count); | 4679 EXPECT_EQ(2, 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 { | 4683 { |
4684 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4684 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4685 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4685 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4686 NULL, | 4686 nullptr, |
4687 &set_needs_commit_count, | 4687 &set_needs_commit_count, |
4688 &set_needs_redraw_count)); | 4688 &set_needs_redraw_count)); |
4689 layer_tree_host()->SetNeedsAnimate(); | 4689 layer_tree_host()->SetNeedsAnimate(); |
4690 EXPECT_EQ(3, set_needs_commit_count); | 4690 EXPECT_EQ(3, set_needs_commit_count); |
4691 EXPECT_EQ(0, set_needs_redraw_count); | 4691 EXPECT_EQ(0, set_needs_redraw_count); |
4692 } | 4692 } |
4693 | 4693 |
4694 EndTest(); | 4694 EndTest(); |
4695 } | 4695 } |
4696 | 4696 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4926 virtual void AfterTest() override {} | 4926 virtual void AfterTest() override {} |
4927 | 4927 |
4928 FakeContentLayerClient layer_client_; | 4928 FakeContentLayerClient layer_client_; |
4929 }; | 4929 }; |
4930 | 4930 |
4931 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4931 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4932 | 4932 |
4933 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | 4933 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { |
4934 public: | 4934 public: |
4935 LayerTreeHostTestContinuousPainting() | 4935 LayerTreeHostTestContinuousPainting() |
4936 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 4936 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(nullptr) { } |
danakj
2014/10/09 16:00:53
and here
| |
4937 | 4937 |
4938 protected: | 4938 protected: |
4939 enum { kExpectedNumCommits = 10 }; | 4939 enum { kExpectedNumCommits = 10 }; |
4940 | 4940 |
4941 virtual void SetupTree() override { | 4941 virtual void SetupTree() override { |
4942 scoped_refptr<Layer> root_layer = Layer::Create(); | 4942 scoped_refptr<Layer> root_layer = Layer::Create(); |
4943 root_layer->SetBounds(bounds_); | 4943 root_layer->SetBounds(bounds_); |
4944 | 4944 |
4945 if (layer_tree_host()->settings().impl_side_painting) { | 4945 if (layer_tree_host()->settings().impl_side_painting) { |
4946 picture_layer_ = FakePictureLayer::Create(&client_); | 4946 picture_layer_ = FakePictureLayer::Create(&client_); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5073 bool visible_; | 5073 bool visible_; |
5074 | 5074 |
5075 FakeContentLayerClient client_; | 5075 FakeContentLayerClient client_; |
5076 scoped_refptr<FakePictureLayer> picture_layer_; | 5076 scoped_refptr<FakePictureLayer> picture_layer_; |
5077 }; | 5077 }; |
5078 | 5078 |
5079 // TODO(vmpstr): Enable with single thread impl-side painting. | 5079 // TODO(vmpstr): Enable with single thread impl-side painting. |
5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); | 5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); |
5081 | 5081 |
5082 } // namespace cc | 5082 } // namespace cc |
OLD | NEW |