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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 175 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
176 scoped_ptr<OutputSurface> output_surface) { | 176 scoped_ptr<OutputSurface> output_surface) { |
177 host_impl_ = LayerTreeHostImpl::Create( | 177 host_impl_ = LayerTreeHostImpl::Create( |
178 settings, this, &proxy_, &stats_instrumentation_, | 178 settings, this, &proxy_, &stats_instrumentation_, |
179 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), | 179 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), |
180 task_graph_runner_.get(), 0); | 180 task_graph_runner_.get(), 0); |
181 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); | 181 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); |
182 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 182 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 183 // Set the BeginFrameArgs so that methods which use it are able to. |
| 184 host_impl_->WillBeginImplFrame( |
| 185 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
183 return init; | 186 return init; |
184 } | 187 } |
185 | 188 |
186 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 189 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
187 root->SetPosition(gfx::PointF()); | 190 root->SetPosition(gfx::PointF()); |
188 root->SetBounds(gfx::Size(10, 10)); | 191 root->SetBounds(gfx::Size(10, 10)); |
189 root->SetContentBounds(gfx::Size(10, 10)); | 192 root->SetContentBounds(gfx::Size(10, 10)); |
190 root->SetDrawsContent(true); | 193 root->SetDrawsContent(true); |
191 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 194 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
192 root->SetHasRenderSurface(true); | 195 root->SetHasRenderSurface(true); |
(...skipping 4919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 | 5115 |
5113 // This test creates its own LayerTreeHostImpl, so | 5116 // This test creates its own LayerTreeHostImpl, so |
5114 // that we can force partial swap enabled. | 5117 // that we can force partial swap enabled. |
5115 LayerTreeSettings settings; | 5118 LayerTreeSettings settings; |
5116 settings.renderer_settings.partial_swap_enabled = true; | 5119 settings.renderer_settings.partial_swap_enabled = true; |
5117 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 5120 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
5118 LayerTreeHostImpl::Create( | 5121 LayerTreeHostImpl::Create( |
5119 settings, this, &proxy_, &stats_instrumentation_, | 5122 settings, this, &proxy_, &stats_instrumentation_, |
5120 shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0); | 5123 shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0); |
5121 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 5124 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 5125 layer_tree_host_impl->WillBeginImplFrame( |
| 5126 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
5122 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 5127 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
5123 | 5128 |
5124 scoped_ptr<LayerImpl> root = | 5129 scoped_ptr<LayerImpl> root = |
5125 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 5130 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
5126 root->SetHasRenderSurface(true); | 5131 root->SetHasRenderSurface(true); |
5127 scoped_ptr<LayerImpl> child = | 5132 scoped_ptr<LayerImpl> child = |
5128 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 5133 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
5129 child->SetPosition(gfx::PointF(12.f, 13.f)); | 5134 child->SetPosition(gfx::PointF(12.f, 13.f)); |
5130 child->SetBounds(gfx::Size(14, 15)); | 5135 child->SetBounds(gfx::Size(14, 15)); |
5131 child->SetContentBounds(gfx::Size(14, 15)); | 5136 child->SetContentBounds(gfx::Size(14, 15)); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5400 scoped_ptr<OutputSurface> output_surface( | 5405 scoped_ptr<OutputSurface> output_surface( |
5401 FakeOutputSurface::Create3d(provider)); | 5406 FakeOutputSurface::Create3d(provider)); |
5402 provider->BindToCurrentThread(); | 5407 provider->BindToCurrentThread(); |
5403 provider->TestContext3d()->set_have_post_sub_buffer(true); | 5408 provider->TestContext3d()->set_have_post_sub_buffer(true); |
5404 | 5409 |
5405 LayerTreeSettings settings; | 5410 LayerTreeSettings settings; |
5406 settings.renderer_settings.partial_swap_enabled = partial_swap; | 5411 settings.renderer_settings.partial_swap_enabled = partial_swap; |
5407 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 5412 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
5408 settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0); | 5413 settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0); |
5409 my_host_impl->InitializeRenderer(output_surface.Pass()); | 5414 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 5415 my_host_impl->WillBeginImplFrame( |
| 5416 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
5410 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 5417 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
5411 | 5418 |
5412 /* | 5419 /* |
5413 Layers are created as follows: | 5420 Layers are created as follows: |
5414 | 5421 |
5415 +--------------------+ | 5422 +--------------------+ |
5416 | 1 | | 5423 | 1 | |
5417 | +-----------+ | | 5424 | +-----------+ | |
5418 | | 2 | | | 5425 | | 2 | | |
5419 | | +-------------------+ | 5426 | | +-------------------+ |
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7751 begin_frame_args_ = args; | 7758 begin_frame_args_ = args; |
7752 } | 7759 } |
7753 | 7760 |
7754 const BeginFrameArgs& begin_frame_args() { return begin_frame_args_; } | 7761 const BeginFrameArgs& begin_frame_args() { return begin_frame_args_; } |
7755 | 7762 |
7756 private: | 7763 private: |
7757 BeginFrameArgs begin_frame_args_; | 7764 BeginFrameArgs begin_frame_args_; |
7758 }; | 7765 }; |
7759 | 7766 |
7760 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { | 7767 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { |
| 7768 host_impl_->DidFinishImplFrame(); |
| 7769 |
7761 BeginFrameArgs begin_frame_args = | 7770 BeginFrameArgs begin_frame_args = |
7762 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 7771 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
7763 FakeVideoFrameController controller; | 7772 FakeVideoFrameController controller; |
7764 | 7773 |
7765 host_impl_->WillBeginImplFrame(begin_frame_args); | 7774 host_impl_->WillBeginImplFrame(begin_frame_args); |
7766 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 7775 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
7767 host_impl_->AddVideoFrameController(&controller); | 7776 host_impl_->AddVideoFrameController(&controller); |
7768 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 7777 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
7769 host_impl_->DidFinishImplFrame(); | 7778 host_impl_->DidFinishImplFrame(); |
7770 } | 7779 } |
7771 | 7780 |
7772 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { | 7781 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { |
| 7782 host_impl_->DidFinishImplFrame(); |
| 7783 |
7773 BeginFrameArgs begin_frame_args = | 7784 BeginFrameArgs begin_frame_args = |
7774 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 7785 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
7775 FakeVideoFrameController controller; | 7786 FakeVideoFrameController controller; |
7776 | 7787 |
7777 host_impl_->WillBeginImplFrame(begin_frame_args); | 7788 host_impl_->WillBeginImplFrame(begin_frame_args); |
7778 host_impl_->DidFinishImplFrame(); | 7789 host_impl_->DidFinishImplFrame(); |
7779 | 7790 |
7780 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 7791 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
7781 host_impl_->AddVideoFrameController(&controller); | 7792 host_impl_->AddVideoFrameController(&controller); |
7782 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 7793 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7872 // Hold an unowned pointer to the output surface to use for mock expectations. | 7883 // Hold an unowned pointer to the output surface to use for mock expectations. |
7873 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 7884 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
7874 | 7885 |
7875 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 7886 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
7876 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 7887 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
7877 host_impl_->BeginCommit(); | 7888 host_impl_->BeginCommit(); |
7878 } | 7889 } |
7879 | 7890 |
7880 } // namespace | 7891 } // namespace |
7881 } // namespace cc | 7892 } // namespace cc |
OLD | NEW |