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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "cc/test/fake_mask_layer_impl.h" | 53 #include "cc/test/fake_mask_layer_impl.h" |
54 #include "cc/test/fake_output_surface.h" | 54 #include "cc/test/fake_output_surface.h" |
55 #include "cc/test/fake_picture_layer_impl.h" | 55 #include "cc/test/fake_picture_layer_impl.h" |
56 #include "cc/test/fake_raster_source.h" | 56 #include "cc/test/fake_raster_source.h" |
57 #include "cc/test/fake_video_frame_provider.h" | 57 #include "cc/test/fake_video_frame_provider.h" |
58 #include "cc/test/geometry_test_utils.h" | 58 #include "cc/test/geometry_test_utils.h" |
59 #include "cc/test/gpu_rasterization_enabled_settings.h" | 59 #include "cc/test/gpu_rasterization_enabled_settings.h" |
60 #include "cc/test/layer_test_common.h" | 60 #include "cc/test/layer_test_common.h" |
61 #include "cc/test/layer_tree_test.h" | 61 #include "cc/test/layer_tree_test.h" |
62 #include "cc/test/test_compositor_frame_sink.h" | 62 #include "cc/test/test_compositor_frame_sink.h" |
63 #include "cc/test/test_gpu_memory_buffer_manager.h" | |
64 #include "cc/test/test_shared_bitmap_manager.h" | |
65 #include "cc/test/test_task_graph_runner.h" | 63 #include "cc/test/test_task_graph_runner.h" |
66 #include "cc/test/test_web_graphics_context_3d.h" | 64 #include "cc/test/test_web_graphics_context_3d.h" |
67 #include "cc/trees/effect_node.h" | 65 #include "cc/trees/effect_node.h" |
68 #include "cc/trees/layer_tree_host_common.h" | 66 #include "cc/trees/layer_tree_host_common.h" |
69 #include "cc/trees/layer_tree_impl.h" | 67 #include "cc/trees/layer_tree_impl.h" |
70 #include "cc/trees/single_thread_proxy.h" | 68 #include "cc/trees/single_thread_proxy.h" |
71 #include "cc/trees/transform_node.h" | 69 #include "cc/trees/transform_node.h" |
72 #include "media/base/media.h" | 70 #include "media/base/media.h" |
73 #include "testing/gmock/include/gmock/gmock.h" | 71 #include "testing/gmock/include/gmock/gmock.h" |
74 #include "testing/gtest/include/gtest/gtest.h" | 72 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 186 } |
189 | 187 |
190 virtual bool CreateHostImplWithTaskRunnerProvider( | 188 virtual bool CreateHostImplWithTaskRunnerProvider( |
191 const LayerTreeSettings& settings, | 189 const LayerTreeSettings& settings, |
192 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, | 190 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, |
193 TaskRunnerProvider* task_runner_provider) { | 191 TaskRunnerProvider* task_runner_provider) { |
194 if (host_impl_) | 192 if (host_impl_) |
195 host_impl_->ReleaseCompositorFrameSink(); | 193 host_impl_->ReleaseCompositorFrameSink(); |
196 host_impl_ = LayerTreeHostImpl::Create( | 194 host_impl_ = LayerTreeHostImpl::Create( |
197 settings, this, task_runner_provider, &stats_instrumentation_, | 195 settings, this, task_runner_provider, &stats_instrumentation_, |
198 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, | |
199 &task_graph_runner_, | 196 &task_graph_runner_, |
200 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 197 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
201 compositor_frame_sink_ = std::move(compositor_frame_sink); | 198 compositor_frame_sink_ = std::move(compositor_frame_sink); |
202 host_impl_->SetVisible(true); | 199 host_impl_->SetVisible(true); |
203 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 200 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
204 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 201 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
205 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 202 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
206 // Set the BeginFrameArgs so that methods which use it are able to. | 203 // Set the BeginFrameArgs so that methods which use it are able to. |
207 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 204 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
208 BEGINFRAME_FROM_HERE, | 205 BEGINFRAME_FROM_HERE, |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 begin_frame_args.frame_time = frame_time; | 486 begin_frame_args.frame_time = frame_time; |
490 host_impl_->WillBeginImplFrame(begin_frame_args); | 487 host_impl_->WillBeginImplFrame(begin_frame_args); |
491 host_impl_->Animate(); | 488 host_impl_->Animate(); |
492 host_impl_->UpdateAnimationState(true); | 489 host_impl_->UpdateAnimationState(true); |
493 host_impl_->DidFinishImplFrame(); | 490 host_impl_->DidFinishImplFrame(); |
494 } | 491 } |
495 | 492 |
496 FakeImplTaskRunnerProvider task_runner_provider_; | 493 FakeImplTaskRunnerProvider task_runner_provider_; |
497 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 494 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
498 | 495 |
499 TestSharedBitmapManager shared_bitmap_manager_; | |
500 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | |
501 TestTaskGraphRunner task_graph_runner_; | 496 TestTaskGraphRunner task_graph_runner_; |
502 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_; | 497 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_; |
503 std::unique_ptr<LayerTreeHostImpl> host_impl_; | 498 std::unique_ptr<LayerTreeHostImpl> host_impl_; |
504 FakeRenderingStatsInstrumentation stats_instrumentation_; | 499 FakeRenderingStatsInstrumentation stats_instrumentation_; |
505 bool on_can_draw_state_changed_called_; | 500 bool on_can_draw_state_changed_called_; |
506 bool did_notify_ready_to_activate_; | 501 bool did_notify_ready_to_activate_; |
507 bool did_request_commit_; | 502 bool did_request_commit_; |
508 bool did_request_redraw_; | 503 bool did_request_redraw_; |
509 bool did_request_next_frame_; | 504 bool did_request_next_frame_; |
510 bool did_request_prepare_tiles_; | 505 bool did_request_prepare_tiles_; |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f)); | 2651 inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f)); |
2657 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset()); | 2652 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset()); |
2658 } | 2653 } |
2659 | 2654 |
2660 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { | 2655 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
2661 public: | 2656 public: |
2662 LayerTreeHostImplOverridePhysicalTime( | 2657 LayerTreeHostImplOverridePhysicalTime( |
2663 const LayerTreeSettings& settings, | 2658 const LayerTreeSettings& settings, |
2664 LayerTreeHostImplClient* client, | 2659 LayerTreeHostImplClient* client, |
2665 TaskRunnerProvider* task_runner_provider, | 2660 TaskRunnerProvider* task_runner_provider, |
2666 SharedBitmapManager* manager, | |
2667 TaskGraphRunner* task_graph_runner, | 2661 TaskGraphRunner* task_graph_runner, |
2668 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 2662 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
2669 : LayerTreeHostImpl(settings, | 2663 : LayerTreeHostImpl(settings, |
2670 client, | 2664 client, |
2671 task_runner_provider, | 2665 task_runner_provider, |
2672 rendering_stats_instrumentation, | 2666 rendering_stats_instrumentation, |
2673 manager, | |
2674 nullptr, | |
2675 task_graph_runner, | 2667 task_graph_runner, |
2676 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 2668 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
2677 0) {} | 2669 0) {} |
2678 | 2670 |
2679 BeginFrameArgs CurrentBeginFrameArgs() const override { | 2671 BeginFrameArgs CurrentBeginFrameArgs() const override { |
2680 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 2672 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, |
2681 fake_current_physical_time_); | 2673 fake_current_physical_time_); |
2682 } | 2674 } |
2683 | 2675 |
2684 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 2676 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
2685 fake_current_physical_time_ = fake_now; | 2677 fake_current_physical_time_ = fake_now; |
2686 } | 2678 } |
2687 | 2679 |
2688 private: | 2680 private: |
2689 base::TimeTicks fake_current_physical_time_; | 2681 base::TimeTicks fake_current_physical_time_; |
2690 }; | 2682 }; |
2691 | 2683 |
2692 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { | 2684 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
2693 protected: | 2685 protected: |
2694 void SetupLayers(LayerTreeSettings settings) { | 2686 void SetupLayers(LayerTreeSettings settings) { |
2695 host_impl_->ReleaseCompositorFrameSink(); | 2687 host_impl_->ReleaseCompositorFrameSink(); |
2696 host_impl_ = nullptr; | 2688 host_impl_ = nullptr; |
2697 | 2689 |
2698 gfx::Size content_size(100, 100); | 2690 gfx::Size content_size(100, 100); |
2699 | 2691 |
2700 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = | 2692 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
2701 new LayerTreeHostImplOverridePhysicalTime( | 2693 new LayerTreeHostImplOverridePhysicalTime( |
2702 settings, this, &task_runner_provider_, &shared_bitmap_manager_, | 2694 settings, this, &task_runner_provider_, &task_graph_runner_, |
2703 &task_graph_runner_, &stats_instrumentation_); | 2695 &stats_instrumentation_); |
2704 host_impl_ = base::WrapUnique(host_impl_override_time); | 2696 host_impl_ = base::WrapUnique(host_impl_override_time); |
2705 compositor_frame_sink_ = CreateCompositorFrameSink(); | 2697 compositor_frame_sink_ = CreateCompositorFrameSink(); |
2706 host_impl_->SetVisible(true); | 2698 host_impl_->SetVisible(true); |
2707 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 2699 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
2708 | 2700 |
2709 SetupScrollAndContentsLayers(content_size); | 2701 SetupScrollAndContentsLayers(content_size); |
2710 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2702 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
2711 host_impl_->SetViewportSize( | 2703 host_impl_->SetViewportSize( |
2712 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 2704 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
2713 | 2705 |
(...skipping 4714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7428 FakeCompositorFrameSink* fake_compositor_frame_sink = | 7420 FakeCompositorFrameSink* fake_compositor_frame_sink = |
7429 compositor_frame_sink.get(); | 7421 compositor_frame_sink.get(); |
7430 | 7422 |
7431 // This test creates its own LayerTreeHostImpl, so | 7423 // This test creates its own LayerTreeHostImpl, so |
7432 // that we can force partial swap enabled. | 7424 // that we can force partial swap enabled. |
7433 LayerTreeSettings settings = DefaultSettings(); | 7425 LayerTreeSettings settings = DefaultSettings(); |
7434 settings.renderer_settings.partial_swap_enabled = true; | 7426 settings.renderer_settings.partial_swap_enabled = true; |
7435 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7427 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7436 LayerTreeHostImpl::Create( | 7428 LayerTreeHostImpl::Create( |
7437 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7429 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7438 &shared_bitmap_manager_, NULL, &task_graph_runner_, | 7430 &task_graph_runner_, |
7439 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7431 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7440 layer_tree_host_impl->SetVisible(true); | 7432 layer_tree_host_impl->SetVisible(true); |
7441 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7433 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
7442 layer_tree_host_impl->WillBeginImplFrame( | 7434 layer_tree_host_impl->WillBeginImplFrame( |
7443 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7435 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
7444 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7436 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
7445 | 7437 |
7446 std::unique_ptr<LayerImpl> root = | 7438 std::unique_ptr<LayerImpl> root = |
7447 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7439 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
7448 root->test_properties()->force_render_surface = true; | 7440 root->test_properties()->force_render_surface = true; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7551 private: | 7543 private: |
7552 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 7544 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
7553 : LayerImpl(tree_impl, id) {} | 7545 : LayerImpl(tree_impl, id) {} |
7554 }; | 7546 }; |
7555 | 7547 |
7556 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7548 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7557 LayerTreeSettings settings, | 7549 LayerTreeSettings settings, |
7558 bool partial_swap, | 7550 bool partial_swap, |
7559 LayerTreeHostImplClient* client, | 7551 LayerTreeHostImplClient* client, |
7560 TaskRunnerProvider* task_runner_provider, | 7552 TaskRunnerProvider* task_runner_provider, |
7561 SharedBitmapManager* manager, | |
7562 TaskGraphRunner* task_graph_runner, | 7553 TaskGraphRunner* task_graph_runner, |
7563 RenderingStatsInstrumentation* stats_instrumentation, | 7554 RenderingStatsInstrumentation* stats_instrumentation, |
7564 CompositorFrameSink* compositor_frame_sink) { | 7555 CompositorFrameSink* compositor_frame_sink) { |
7565 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7556 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7566 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7557 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7567 settings, client, task_runner_provider, stats_instrumentation, manager, | 7558 settings, client, task_runner_provider, stats_instrumentation, |
7568 nullptr, task_graph_runner, | 7559 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
7569 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7560 0); |
7570 my_host_impl->SetVisible(true); | 7561 my_host_impl->SetVisible(true); |
7571 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7562 my_host_impl->InitializeRenderer(compositor_frame_sink); |
7572 my_host_impl->WillBeginImplFrame( | 7563 my_host_impl->WillBeginImplFrame( |
7573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7564 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
7574 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7565 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7575 | 7566 |
7576 /* | 7567 /* |
7577 Layers are created as follows: | 7568 Layers are created as follows: |
7578 | 7569 |
7579 +--------------------+ | 7570 +--------------------+ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7622 | 7613 |
7623 child->test_properties()->AddChild(std::move(grand_child)); | 7614 child->test_properties()->AddChild(std::move(grand_child)); |
7624 root->test_properties()->AddChild(std::move(child)); | 7615 root->test_properties()->AddChild(std::move(child)); |
7625 | 7616 |
7626 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7617 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
7627 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7618 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
7628 return my_host_impl; | 7619 return my_host_impl; |
7629 } | 7620 } |
7630 | 7621 |
7631 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7622 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
7632 TestSharedBitmapManager shared_bitmap_manager; | |
7633 TestTaskGraphRunner task_graph_runner; | 7623 TestTaskGraphRunner task_graph_runner; |
7634 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7624 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7635 provider->BindToCurrentThread(); | 7625 provider->BindToCurrentThread(); |
7636 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7626 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7637 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7627 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
7638 FakeCompositorFrameSink::Create3d(provider)); | 7628 FakeCompositorFrameSink::Create3d(provider)); |
7639 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7629 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7640 DefaultSettings(), true, this, &task_runner_provider_, | 7630 DefaultSettings(), true, this, &task_runner_provider_, &task_graph_runner, |
7641 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7631 &stats_instrumentation_, compositor_frame_sink.get()); |
7642 compositor_frame_sink.get()); | |
7643 { | 7632 { |
7644 LayerTreeHostImpl::FrameData frame; | 7633 LayerTreeHostImpl::FrameData frame; |
7645 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7634 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7646 | 7635 |
7647 // Verify all quads have been computed | 7636 // Verify all quads have been computed |
7648 ASSERT_EQ(2U, frame.render_passes.size()); | 7637 ASSERT_EQ(2U, frame.render_passes.size()); |
7649 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7638 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7650 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7639 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7651 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7640 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7652 frame.render_passes[0]->quad_list.front()->material); | 7641 frame.render_passes[0]->quad_list.front()->material); |
7653 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7642 EXPECT_EQ(DrawQuad::RENDER_PASS, |
7654 frame.render_passes[1]->quad_list.front()->material); | 7643 frame.render_passes[1]->quad_list.front()->material); |
7655 | 7644 |
7656 my_host_impl->DrawLayers(&frame); | 7645 my_host_impl->DrawLayers(&frame); |
7657 my_host_impl->DidDrawAllLayers(frame); | 7646 my_host_impl->DidDrawAllLayers(frame); |
7658 } | 7647 } |
7659 my_host_impl->ReleaseCompositorFrameSink(); | 7648 my_host_impl->ReleaseCompositorFrameSink(); |
7660 } | 7649 } |
7661 | 7650 |
7662 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 7651 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
7663 TestSharedBitmapManager shared_bitmap_manager; | |
7664 TestTaskGraphRunner task_graph_runner; | 7652 TestTaskGraphRunner task_graph_runner; |
7665 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7653 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7666 provider->BindToCurrentThread(); | 7654 provider->BindToCurrentThread(); |
7667 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7655 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7668 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7656 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
7669 FakeCompositorFrameSink::Create3d(provider)); | 7657 FakeCompositorFrameSink::Create3d(provider)); |
7670 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7658 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7671 DefaultSettings(), false, this, &task_runner_provider_, | 7659 DefaultSettings(), false, this, &task_runner_provider_, |
7672 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7660 &task_graph_runner, &stats_instrumentation_, compositor_frame_sink.get()); |
7673 compositor_frame_sink.get()); | |
7674 { | 7661 { |
7675 LayerTreeHostImpl::FrameData frame; | 7662 LayerTreeHostImpl::FrameData frame; |
7676 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7663 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7677 | 7664 |
7678 // Verify all quads have been computed | 7665 // Verify all quads have been computed |
7679 ASSERT_EQ(2U, frame.render_passes.size()); | 7666 ASSERT_EQ(2U, frame.render_passes.size()); |
7680 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7667 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7681 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7668 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7682 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7669 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7683 frame.render_passes[0]->quad_list.front()->material); | 7670 frame.render_passes[0]->quad_list.front()->material); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8033 EXPECT_NE(kGpuTileCutoff, kNothingTileCutoff); | 8020 EXPECT_NE(kGpuTileCutoff, kNothingTileCutoff); |
8034 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); | 8021 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); |
8035 | 8022 |
8036 LayerTreeSettings settings = DefaultSettings(); | 8023 LayerTreeSettings settings = DefaultSettings(); |
8037 settings.gpu_memory_policy = | 8024 settings.gpu_memory_policy = |
8038 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); | 8025 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); |
8039 settings.software_memory_policy = ManagedMemoryPolicy( | 8026 settings.software_memory_policy = ManagedMemoryPolicy( |
8040 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); | 8027 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); |
8041 host_impl_ = LayerTreeHostImpl::Create( | 8028 host_impl_ = LayerTreeHostImpl::Create( |
8042 settings, this, &task_runner_provider_, &stats_instrumentation_, | 8029 settings, this, &task_runner_provider_, &stats_instrumentation_, |
8043 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 8030 &task_graph_runner_, |
8044 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 8031 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
8045 | 8032 |
8046 // Gpu compositing. | 8033 // Gpu compositing. |
8047 compositor_frame_sink_ = | 8034 compositor_frame_sink_ = |
8048 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 8035 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
8049 host_impl_->SetVisible(true); | 8036 host_impl_->SetVisible(true); |
8050 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 8037 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
8051 { | 8038 { |
8052 const auto& state = host_impl_->global_tile_state(); | 8039 const auto& state = host_impl_->global_tile_state(); |
8053 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); | 8040 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8148 | 8135 |
8149 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 8136 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
8150 host_impl_->SetHasGpuRasterizationTrigger(true); | 8137 host_impl_->SetHasGpuRasterizationTrigger(true); |
8151 host_impl_->CommitComplete(); | 8138 host_impl_->CommitComplete(); |
8152 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8139 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
8153 } | 8140 } |
8154 | 8141 |
8155 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 8142 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
8156 public: | 8143 public: |
8157 void SetUp() override { | 8144 void SetUp() override { |
8158 fake_host_impl_ = | 8145 fake_host_impl_ = new FakeLayerTreeHostImpl( |
8159 new FakeLayerTreeHostImpl(LayerTreeSettings(), &task_runner_provider_, | 8146 LayerTreeSettings(), &task_runner_provider_, &task_graph_runner_); |
8160 &shared_bitmap_manager_, &task_graph_runner_); | |
8161 host_impl_.reset(fake_host_impl_); | 8147 host_impl_.reset(fake_host_impl_); |
8162 compositor_frame_sink_ = CreateCompositorFrameSink(); | 8148 compositor_frame_sink_ = CreateCompositorFrameSink(); |
8163 host_impl_->SetVisible(true); | 8149 host_impl_->SetVisible(true); |
8164 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 8150 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
8165 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 8151 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
8166 } | 8152 } |
8167 | 8153 |
8168 FakeLayerTreeHostImpl* fake_host_impl_; | 8154 FakeLayerTreeHostImpl* fake_host_impl_; |
8169 }; | 8155 }; |
8170 | 8156 |
(...skipping 3338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11509 // rasterization status. | 11495 // rasterization status. |
11510 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { | 11496 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { |
11511 host_impl_->ReleaseCompositorFrameSink(); | 11497 host_impl_->ReleaseCompositorFrameSink(); |
11512 host_impl_ = nullptr; | 11498 host_impl_ = nullptr; |
11513 | 11499 |
11514 LayerTreeSettings settings = DefaultSettings(); | 11500 LayerTreeSettings settings = DefaultSettings(); |
11515 settings.gpu_rasterization_forced = true; | 11501 settings.gpu_rasterization_forced = true; |
11516 | 11502 |
11517 host_impl_ = LayerTreeHostImpl::Create( | 11503 host_impl_ = LayerTreeHostImpl::Create( |
11518 settings, this, &task_runner_provider_, &stats_instrumentation_, | 11504 settings, this, &task_runner_provider_, &stats_instrumentation_, |
11519 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 11505 &task_graph_runner_, |
11520 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 11506 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
11521 host_impl_->SetVisible(true); | 11507 host_impl_->SetVisible(true); |
11522 | 11508 |
11523 // InitializeRenderer with a gpu-raster enabled output surface. | 11509 // InitializeRenderer with a gpu-raster enabled output surface. |
11524 auto gpu_raster_compositor_frame_sink = | 11510 auto gpu_raster_compositor_frame_sink = |
11525 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 11511 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
11526 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); | 11512 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); |
11527 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11513 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11528 | 11514 |
11529 // Re-initialize with a software output surface. | 11515 // Re-initialize with a software output surface. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11652 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11638 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11653 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11639 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11654 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11640 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11655 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11641 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11656 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11642 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11657 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11643 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11658 } | 11644 } |
11659 | 11645 |
11660 } // namespace | 11646 } // namespace |
11661 } // namespace cc | 11647 } // namespace cc |
OLD | NEW |