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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 virtual bool CreateHostImplWithTaskRunnerProvider( | 193 virtual bool CreateHostImplWithTaskRunnerProvider( |
194 const LayerTreeSettings& settings, | 194 const LayerTreeSettings& settings, |
195 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, | 195 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, |
196 TaskRunnerProvider* task_runner_provider) { | 196 TaskRunnerProvider* task_runner_provider) { |
197 if (host_impl_) | 197 if (host_impl_) |
198 host_impl_->ReleaseCompositorFrameSink(); | 198 host_impl_->ReleaseCompositorFrameSink(); |
199 host_impl_ = LayerTreeHostImpl::Create( | 199 host_impl_ = LayerTreeHostImpl::Create( |
200 settings, this, task_runner_provider, &stats_instrumentation_, | 200 settings, this, task_runner_provider, &stats_instrumentation_, |
201 &task_graph_runner_, | 201 &task_graph_runner_, |
202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr); | 202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
203 compositor_frame_sink_ = std::move(compositor_frame_sink); | 203 compositor_frame_sink_ = std::move(compositor_frame_sink); |
204 host_impl_->SetVisible(true); | 204 host_impl_->SetVisible(true); |
205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
206 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 206 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
208 // Set the BeginFrameArgs so that methods which use it are able to. | 208 // Set the BeginFrameArgs so that methods which use it are able to. |
209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
210 BEGINFRAME_FROM_HERE, 0, 1, | 210 BEGINFRAME_FROM_HERE, 0, 1, |
211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
212 host_impl_->DidFinishImplFrame(); | 212 host_impl_->DidFinishImplFrame(); |
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 LayerTreeHostImplClient* client, | 2702 LayerTreeHostImplClient* client, |
2703 TaskRunnerProvider* task_runner_provider, | 2703 TaskRunnerProvider* task_runner_provider, |
2704 TaskGraphRunner* task_graph_runner, | 2704 TaskGraphRunner* task_graph_runner, |
2705 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 2705 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
2706 : LayerTreeHostImpl(settings, | 2706 : LayerTreeHostImpl(settings, |
2707 client, | 2707 client, |
2708 task_runner_provider, | 2708 task_runner_provider, |
2709 rendering_stats_instrumentation, | 2709 rendering_stats_instrumentation, |
2710 task_graph_runner, | 2710 task_graph_runner, |
2711 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 2711 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
2712 0, | 2712 0) {} |
2713 nullptr) {} | |
2714 | 2713 |
2715 BeginFrameArgs CurrentBeginFrameArgs() const override { | 2714 BeginFrameArgs CurrentBeginFrameArgs() const override { |
2716 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, | 2715 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, |
2717 fake_current_physical_time_); | 2716 fake_current_physical_time_); |
2718 } | 2717 } |
2719 | 2718 |
2720 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 2719 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
2721 fake_current_physical_time_ = fake_now; | 2720 fake_current_physical_time_ = fake_now; |
2722 } | 2721 } |
2723 | 2722 |
(...skipping 4849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7573 compositor_frame_sink.get(); | 7572 compositor_frame_sink.get(); |
7574 | 7573 |
7575 // This test creates its own LayerTreeHostImpl, so | 7574 // This test creates its own LayerTreeHostImpl, so |
7576 // that we can force partial swap enabled. | 7575 // that we can force partial swap enabled. |
7577 LayerTreeSettings settings = DefaultSettings(); | 7576 LayerTreeSettings settings = DefaultSettings(); |
7578 settings.renderer_settings.partial_swap_enabled = true; | 7577 settings.renderer_settings.partial_swap_enabled = true; |
7579 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7580 LayerTreeHostImpl::Create( | 7579 LayerTreeHostImpl::Create( |
7581 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7580 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7582 &task_graph_runner_, | 7581 &task_graph_runner_, |
7583 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr); | 7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7584 layer_tree_host_impl->SetVisible(true); | 7583 layer_tree_host_impl->SetVisible(true); |
7585 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
7586 layer_tree_host_impl->WillBeginImplFrame( | 7585 layer_tree_host_impl->WillBeginImplFrame( |
7587 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); | 7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7588 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
7589 | 7588 |
7590 std::unique_ptr<LayerImpl> root = | 7589 std::unique_ptr<LayerImpl> root = |
7591 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
7592 root->test_properties()->force_render_surface = true; | 7591 root->test_properties()->force_render_surface = true; |
7593 std::unique_ptr<LayerImpl> child = | 7592 std::unique_ptr<LayerImpl> child = |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7702 bool partial_swap, | 7701 bool partial_swap, |
7703 LayerTreeHostImplClient* client, | 7702 LayerTreeHostImplClient* client, |
7704 TaskRunnerProvider* task_runner_provider, | 7703 TaskRunnerProvider* task_runner_provider, |
7705 TaskGraphRunner* task_graph_runner, | 7704 TaskGraphRunner* task_graph_runner, |
7706 RenderingStatsInstrumentation* stats_instrumentation, | 7705 RenderingStatsInstrumentation* stats_instrumentation, |
7707 CompositorFrameSink* compositor_frame_sink) { | 7706 CompositorFrameSink* compositor_frame_sink) { |
7708 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7707 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7709 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7710 settings, client, task_runner_provider, stats_instrumentation, | 7709 settings, client, task_runner_provider, stats_instrumentation, |
7711 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
7712 0, nullptr); | 7711 0); |
7713 my_host_impl->SetVisible(true); | 7712 my_host_impl->SetVisible(true); |
7714 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7713 my_host_impl->InitializeRenderer(compositor_frame_sink); |
7715 my_host_impl->WillBeginImplFrame( | 7714 my_host_impl->WillBeginImplFrame( |
7716 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); | 7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7717 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7718 | 7717 |
7719 /* | 7718 /* |
7720 Layers are created as follows: | 7719 Layers are created as follows: |
7721 | 7720 |
7722 +--------------------+ | 7721 +--------------------+ |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8170 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); | 8169 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); |
8171 | 8170 |
8172 LayerTreeSettings settings = DefaultSettings(); | 8171 LayerTreeSettings settings = DefaultSettings(); |
8173 settings.gpu_memory_policy = | 8172 settings.gpu_memory_policy = |
8174 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); | 8173 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); |
8175 settings.software_memory_policy = ManagedMemoryPolicy( | 8174 settings.software_memory_policy = ManagedMemoryPolicy( |
8176 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); | 8175 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); |
8177 host_impl_ = LayerTreeHostImpl::Create( | 8176 host_impl_ = LayerTreeHostImpl::Create( |
8178 settings, this, &task_runner_provider_, &stats_instrumentation_, | 8177 settings, this, &task_runner_provider_, &stats_instrumentation_, |
8179 &task_graph_runner_, | 8178 &task_graph_runner_, |
8180 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr); | 8179 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
8181 | 8180 |
8182 // Gpu compositing. | 8181 // Gpu compositing. |
8183 compositor_frame_sink_ = | 8182 compositor_frame_sink_ = |
8184 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 8183 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
8185 host_impl_->SetVisible(true); | 8184 host_impl_->SetVisible(true); |
8186 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 8185 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
8187 { | 8186 { |
8188 const auto& state = host_impl_->global_tile_state(); | 8187 const auto& state = host_impl_->global_tile_state(); |
8189 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); | 8188 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); |
8190 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); | 8189 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); |
(...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11626 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { | 11625 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { |
11627 host_impl_->ReleaseCompositorFrameSink(); | 11626 host_impl_->ReleaseCompositorFrameSink(); |
11628 host_impl_ = nullptr; | 11627 host_impl_ = nullptr; |
11629 | 11628 |
11630 LayerTreeSettings settings = DefaultSettings(); | 11629 LayerTreeSettings settings = DefaultSettings(); |
11631 settings.gpu_rasterization_forced = true; | 11630 settings.gpu_rasterization_forced = true; |
11632 | 11631 |
11633 host_impl_ = LayerTreeHostImpl::Create( | 11632 host_impl_ = LayerTreeHostImpl::Create( |
11634 settings, this, &task_runner_provider_, &stats_instrumentation_, | 11633 settings, this, &task_runner_provider_, &stats_instrumentation_, |
11635 &task_graph_runner_, | 11634 &task_graph_runner_, |
11636 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0, nullptr); | 11635 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
11637 host_impl_->SetVisible(true); | 11636 host_impl_->SetVisible(true); |
11638 | 11637 |
11639 // InitializeRenderer with a gpu-raster enabled output surface. | 11638 // InitializeRenderer with a gpu-raster enabled output surface. |
11640 auto gpu_raster_compositor_frame_sink = | 11639 auto gpu_raster_compositor_frame_sink = |
11641 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 11640 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
11642 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); | 11641 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); |
11643 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11642 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11644 | 11643 |
11645 // Re-initialize with a software output surface. | 11644 // Re-initialize with a software output surface. |
11646 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11645 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11768 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11769 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11771 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11773 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11774 } | 11773 } |
11775 | 11774 |
11776 } // namespace | 11775 } // namespace |
11777 } // namespace cc | 11776 } // namespace cc |
OLD | NEW |