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 4692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7406 FakeCompositorFrameSink* fake_compositor_frame_sink = | 7398 FakeCompositorFrameSink* fake_compositor_frame_sink = |
7407 compositor_frame_sink.get(); | 7399 compositor_frame_sink.get(); |
7408 | 7400 |
7409 // This test creates its own LayerTreeHostImpl, so | 7401 // This test creates its own LayerTreeHostImpl, so |
7410 // that we can force partial swap enabled. | 7402 // that we can force partial swap enabled. |
7411 LayerTreeSettings settings = DefaultSettings(); | 7403 LayerTreeSettings settings = DefaultSettings(); |
7412 settings.renderer_settings.partial_swap_enabled = true; | 7404 settings.renderer_settings.partial_swap_enabled = true; |
7413 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7405 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7414 LayerTreeHostImpl::Create( | 7406 LayerTreeHostImpl::Create( |
7415 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7407 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7416 &shared_bitmap_manager_, NULL, &task_graph_runner_, | 7408 &task_graph_runner_, |
7417 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7409 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7418 layer_tree_host_impl->SetVisible(true); | 7410 layer_tree_host_impl->SetVisible(true); |
7419 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7411 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
7420 layer_tree_host_impl->WillBeginImplFrame( | 7412 layer_tree_host_impl->WillBeginImplFrame( |
7421 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7413 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
7422 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7414 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
7423 | 7415 |
7424 std::unique_ptr<LayerImpl> root = | 7416 std::unique_ptr<LayerImpl> root = |
7425 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7417 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
7426 root->test_properties()->force_render_surface = true; | 7418 root->test_properties()->force_render_surface = true; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7529 private: | 7521 private: |
7530 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 7522 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
7531 : LayerImpl(tree_impl, id) {} | 7523 : LayerImpl(tree_impl, id) {} |
7532 }; | 7524 }; |
7533 | 7525 |
7534 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7526 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7535 LayerTreeSettings settings, | 7527 LayerTreeSettings settings, |
7536 bool partial_swap, | 7528 bool partial_swap, |
7537 LayerTreeHostImplClient* client, | 7529 LayerTreeHostImplClient* client, |
7538 TaskRunnerProvider* task_runner_provider, | 7530 TaskRunnerProvider* task_runner_provider, |
7539 SharedBitmapManager* manager, | |
7540 TaskGraphRunner* task_graph_runner, | 7531 TaskGraphRunner* task_graph_runner, |
7541 RenderingStatsInstrumentation* stats_instrumentation, | 7532 RenderingStatsInstrumentation* stats_instrumentation, |
7542 CompositorFrameSink* compositor_frame_sink) { | 7533 CompositorFrameSink* compositor_frame_sink) { |
7543 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7534 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7544 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7535 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7545 settings, client, task_runner_provider, stats_instrumentation, manager, | 7536 settings, client, task_runner_provider, stats_instrumentation, |
7546 nullptr, task_graph_runner, | 7537 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
7547 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7538 0); |
7548 my_host_impl->SetVisible(true); | 7539 my_host_impl->SetVisible(true); |
7549 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7540 my_host_impl->InitializeRenderer(compositor_frame_sink); |
7550 my_host_impl->WillBeginImplFrame( | 7541 my_host_impl->WillBeginImplFrame( |
7551 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7542 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
7552 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7543 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7553 | 7544 |
7554 /* | 7545 /* |
7555 Layers are created as follows: | 7546 Layers are created as follows: |
7556 | 7547 |
7557 +--------------------+ | 7548 +--------------------+ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7600 | 7591 |
7601 child->test_properties()->AddChild(std::move(grand_child)); | 7592 child->test_properties()->AddChild(std::move(grand_child)); |
7602 root->test_properties()->AddChild(std::move(child)); | 7593 root->test_properties()->AddChild(std::move(child)); |
7603 | 7594 |
7604 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7595 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
7605 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7596 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
7606 return my_host_impl; | 7597 return my_host_impl; |
7607 } | 7598 } |
7608 | 7599 |
7609 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7600 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
7610 TestSharedBitmapManager shared_bitmap_manager; | |
7611 TestTaskGraphRunner task_graph_runner; | 7601 TestTaskGraphRunner task_graph_runner; |
7612 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7602 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7613 provider->BindToCurrentThread(); | 7603 provider->BindToCurrentThread(); |
7614 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7604 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7615 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7605 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
7616 FakeCompositorFrameSink::Create3d(provider)); | 7606 FakeCompositorFrameSink::Create3d(provider)); |
7617 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7607 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7618 DefaultSettings(), true, this, &task_runner_provider_, | 7608 DefaultSettings(), true, this, &task_runner_provider_, &task_graph_runner, |
7619 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7609 &stats_instrumentation_, compositor_frame_sink.get()); |
7620 compositor_frame_sink.get()); | |
7621 { | 7610 { |
7622 LayerTreeHostImpl::FrameData frame; | 7611 LayerTreeHostImpl::FrameData frame; |
7623 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7612 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7624 | 7613 |
7625 // Verify all quads have been computed | 7614 // Verify all quads have been computed |
7626 ASSERT_EQ(2U, frame.render_passes.size()); | 7615 ASSERT_EQ(2U, frame.render_passes.size()); |
7627 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7616 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7628 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7617 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7629 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7618 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7630 frame.render_passes[0]->quad_list.front()->material); | 7619 frame.render_passes[0]->quad_list.front()->material); |
7631 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7620 EXPECT_EQ(DrawQuad::RENDER_PASS, |
7632 frame.render_passes[1]->quad_list.front()->material); | 7621 frame.render_passes[1]->quad_list.front()->material); |
7633 | 7622 |
7634 my_host_impl->DrawLayers(&frame); | 7623 my_host_impl->DrawLayers(&frame); |
7635 my_host_impl->DidDrawAllLayers(frame); | 7624 my_host_impl->DidDrawAllLayers(frame); |
7636 } | 7625 } |
7637 my_host_impl->ReleaseCompositorFrameSink(); | 7626 my_host_impl->ReleaseCompositorFrameSink(); |
7638 } | 7627 } |
7639 | 7628 |
7640 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 7629 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
7641 TestSharedBitmapManager shared_bitmap_manager; | |
7642 TestTaskGraphRunner task_graph_runner; | 7630 TestTaskGraphRunner task_graph_runner; |
7643 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7631 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7644 provider->BindToCurrentThread(); | 7632 provider->BindToCurrentThread(); |
7645 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7633 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7646 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7634 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
7647 FakeCompositorFrameSink::Create3d(provider)); | 7635 FakeCompositorFrameSink::Create3d(provider)); |
7648 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7636 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7649 DefaultSettings(), false, this, &task_runner_provider_, | 7637 DefaultSettings(), false, this, &task_runner_provider_, |
7650 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7638 &task_graph_runner, &stats_instrumentation_, compositor_frame_sink.get()); |
7651 compositor_frame_sink.get()); | |
7652 { | 7639 { |
7653 LayerTreeHostImpl::FrameData frame; | 7640 LayerTreeHostImpl::FrameData frame; |
7654 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7641 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7655 | 7642 |
7656 // Verify all quads have been computed | 7643 // Verify all quads have been computed |
7657 ASSERT_EQ(2U, frame.render_passes.size()); | 7644 ASSERT_EQ(2U, frame.render_passes.size()); |
7658 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7645 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7659 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7646 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7660 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7647 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7661 frame.render_passes[0]->quad_list.front()->material); | 7648 frame.render_passes[0]->quad_list.front()->material); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8011 EXPECT_NE(kGpuTileCutoff, kNothingTileCutoff); | 7998 EXPECT_NE(kGpuTileCutoff, kNothingTileCutoff); |
8012 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); | 7999 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff); |
8013 | 8000 |
8014 LayerTreeSettings settings = DefaultSettings(); | 8001 LayerTreeSettings settings = DefaultSettings(); |
8015 settings.gpu_memory_policy = | 8002 settings.gpu_memory_policy = |
8016 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); | 8003 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); |
8017 settings.software_memory_policy = ManagedMemoryPolicy( | 8004 settings.software_memory_policy = ManagedMemoryPolicy( |
8018 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); | 8005 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); |
8019 host_impl_ = LayerTreeHostImpl::Create( | 8006 host_impl_ = LayerTreeHostImpl::Create( |
8020 settings, this, &task_runner_provider_, &stats_instrumentation_, | 8007 settings, this, &task_runner_provider_, &stats_instrumentation_, |
8021 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 8008 &task_graph_runner_, |
8022 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 8009 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
8023 | 8010 |
8024 // Gpu compositing. | 8011 // Gpu compositing. |
8025 compositor_frame_sink_ = | 8012 compositor_frame_sink_ = |
8026 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 8013 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
8027 host_impl_->SetVisible(true); | 8014 host_impl_->SetVisible(true); |
8028 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 8015 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
8029 { | 8016 { |
8030 const auto& state = host_impl_->global_tile_state(); | 8017 const auto& state = host_impl_->global_tile_state(); |
8031 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); | 8018 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8126 | 8113 |
8127 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 8114 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
8128 host_impl_->SetHasGpuRasterizationTrigger(true); | 8115 host_impl_->SetHasGpuRasterizationTrigger(true); |
8129 host_impl_->CommitComplete(); | 8116 host_impl_->CommitComplete(); |
8130 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8117 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
8131 } | 8118 } |
8132 | 8119 |
8133 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 8120 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
8134 public: | 8121 public: |
8135 void SetUp() override { | 8122 void SetUp() override { |
8136 fake_host_impl_ = | 8123 fake_host_impl_ = new FakeLayerTreeHostImpl( |
8137 new FakeLayerTreeHostImpl(LayerTreeSettings(), &task_runner_provider_, | 8124 LayerTreeSettings(), &task_runner_provider_, &task_graph_runner_); |
8138 &shared_bitmap_manager_, &task_graph_runner_); | |
8139 host_impl_.reset(fake_host_impl_); | 8125 host_impl_.reset(fake_host_impl_); |
8140 compositor_frame_sink_ = CreateCompositorFrameSink(); | 8126 compositor_frame_sink_ = CreateCompositorFrameSink(); |
8141 host_impl_->SetVisible(true); | 8127 host_impl_->SetVisible(true); |
8142 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 8128 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
8143 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 8129 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
8144 } | 8130 } |
8145 | 8131 |
8146 FakeLayerTreeHostImpl* fake_host_impl_; | 8132 FakeLayerTreeHostImpl* fake_host_impl_; |
8147 }; | 8133 }; |
8148 | 8134 |
(...skipping 3325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11474 // rasterization status. | 11460 // rasterization status. |
11475 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { | 11461 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { |
11476 host_impl_->ReleaseCompositorFrameSink(); | 11462 host_impl_->ReleaseCompositorFrameSink(); |
11477 host_impl_ = nullptr; | 11463 host_impl_ = nullptr; |
11478 | 11464 |
11479 LayerTreeSettings settings = DefaultSettings(); | 11465 LayerTreeSettings settings = DefaultSettings(); |
11480 settings.gpu_rasterization_forced = true; | 11466 settings.gpu_rasterization_forced = true; |
11481 | 11467 |
11482 host_impl_ = LayerTreeHostImpl::Create( | 11468 host_impl_ = LayerTreeHostImpl::Create( |
11483 settings, this, &task_runner_provider_, &stats_instrumentation_, | 11469 settings, this, &task_runner_provider_, &stats_instrumentation_, |
11484 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 11470 &task_graph_runner_, |
11485 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 11471 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
11486 host_impl_->SetVisible(true); | 11472 host_impl_->SetVisible(true); |
11487 | 11473 |
11488 // InitializeRenderer with a gpu-raster enabled output surface. | 11474 // InitializeRenderer with a gpu-raster enabled output surface. |
11489 auto gpu_raster_compositor_frame_sink = | 11475 auto gpu_raster_compositor_frame_sink = |
11490 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); | 11476 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
11491 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); | 11477 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); |
11492 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11478 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11493 | 11479 |
11494 // Re-initialize with a software output surface. | 11480 // Re-initialize with a software output surface. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11617 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11603 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11618 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11604 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11619 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11605 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11620 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11606 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11621 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11607 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11622 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11608 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11623 } | 11609 } |
11624 | 11610 |
11625 } // namespace | 11611 } // namespace |
11626 } // namespace cc | 11612 } // namespace cc |
OLD | NEW |