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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 on_can_draw_state_changed_called_ = false; | 566 on_can_draw_state_changed_called_ = false; |
567 | 567 |
568 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 568 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
569 EXPECT_TRUE(host_impl_->CanDraw()); | 569 EXPECT_TRUE(host_impl_->CanDraw()); |
570 EXPECT_TRUE(on_can_draw_state_changed_called_); | 570 EXPECT_TRUE(on_can_draw_state_changed_called_); |
571 on_can_draw_state_changed_called_ = false; | 571 on_can_draw_state_changed_called_ = false; |
572 } | 572 } |
573 | 573 |
574 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { | 574 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { |
575 CreateHostImpl(DefaultSettings(), | 575 CreateHostImpl(DefaultSettings(), |
576 FakeOutputSurface::CreateDelegatingSoftware( | 576 FakeOutputSurface::CreateDelegatingSoftware()); |
577 base::WrapUnique(new SoftwareOutputDevice()))); | |
578 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 577 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
579 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 578 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
580 | 579 |
581 EXPECT_TRUE(host_impl_->CanDraw()); | 580 EXPECT_TRUE(host_impl_->CanDraw()); |
582 host_impl_->SetViewportSize(gfx::Size()); | 581 host_impl_->SetViewportSize(gfx::Size()); |
583 EXPECT_FALSE(host_impl_->CanDraw()); | 582 EXPECT_FALSE(host_impl_->CanDraw()); |
584 | 583 |
585 FakeOutputSurface* fake_output_surface = | 584 FakeOutputSurface* fake_output_surface = |
586 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 585 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
587 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); | 586 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); |
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3793 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); | 3792 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
3794 host_impl_->DrawLayers(&frame); | 3793 host_impl_->DrawLayers(&frame); |
3795 host_impl_->DidDrawAllLayers(frame); | 3794 host_impl_->DidDrawAllLayers(frame); |
3796 host_impl_->SwapBuffers(frame); | 3795 host_impl_->SwapBuffers(frame); |
3797 } | 3796 } |
3798 } | 3797 } |
3799 | 3798 |
3800 TEST_F(LayerTreeHostImplTest, | 3799 TEST_F(LayerTreeHostImplTest, |
3801 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3800 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
3802 CreateHostImpl(DefaultSettings(), | 3801 CreateHostImpl(DefaultSettings(), |
3803 FakeOutputSurface::CreateDelegatingSoftware( | 3802 FakeOutputSurface::CreateDelegatingSoftware()); |
3804 base::WrapUnique(new SoftwareOutputDevice()))); | |
3805 | 3803 |
3806 const gfx::Transform external_transform; | 3804 const gfx::Transform external_transform; |
3807 const gfx::Rect external_viewport; | 3805 const gfx::Rect external_viewport; |
3808 const gfx::Rect external_clip; | 3806 const gfx::Rect external_clip; |
3809 const bool resourceless_software_draw = true; | 3807 const bool resourceless_software_draw = true; |
3810 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 3808 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
3811 external_transform); | 3809 external_transform); |
3812 | 3810 |
3813 std::vector<PrepareToDrawSuccessTestCase> cases; | 3811 std::vector<PrepareToDrawSuccessTestCase> cases; |
3814 | 3812 |
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6752 } | 6750 } |
6753 | 6751 |
6754 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6752 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
6755 protected: | 6753 protected: |
6756 LayerTreeHostImplViewportCoveredTest() : | 6754 LayerTreeHostImplViewportCoveredTest() : |
6757 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6755 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
6758 child_(NULL), | 6756 child_(NULL), |
6759 did_activate_pending_tree_(false) {} | 6757 did_activate_pending_tree_(false) {} |
6760 | 6758 |
6761 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6759 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { |
6762 if (software) { | 6760 if (software) |
6763 return FakeOutputSurface::CreateDelegatingSoftware( | 6761 return FakeOutputSurface::CreateDelegatingSoftware(); |
6764 base::WrapUnique(new SoftwareOutputDevice())); | |
6765 } | |
6766 return FakeOutputSurface::CreateDelegating3d(); | 6762 return FakeOutputSurface::CreateDelegating3d(); |
6767 } | 6763 } |
6768 | 6764 |
6769 void SetupActiveTreeLayers() { | 6765 void SetupActiveTreeLayers() { |
6770 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6766 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
6771 host_impl_->active_tree()->SetRootLayerForTesting( | 6767 host_impl_->active_tree()->SetRootLayerForTesting( |
6772 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6768 LayerImpl::Create(host_impl_->active_tree(), 1)); |
6773 host_impl_->active_tree() | 6769 host_impl_->active_tree() |
6774 ->root_layer_for_testing() | 6770 ->root_layer_for_testing() |
6775 ->test_properties() | 6771 ->test_properties() |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7636 SoftwareOutputDevice::EndPaint(); | 7632 SoftwareOutputDevice::EndPaint(); |
7637 ++frames_ended_; | 7633 ++frames_ended_; |
7638 } | 7634 } |
7639 | 7635 |
7640 int frames_began_, frames_ended_; | 7636 int frames_began_, frames_ended_; |
7641 }; | 7637 }; |
7642 | 7638 |
7643 TEST_F(LayerTreeHostImplTest, | 7639 TEST_F(LayerTreeHostImplTest, |
7644 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 7640 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
7645 set_reduce_memory_result(false); | 7641 set_reduce_memory_result(false); |
7646 EXPECT_TRUE(CreateHostImpl( | 7642 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
7647 DefaultSettings(), FakeOutputSurface::CreateDelegatingSoftware( | 7643 FakeOutputSurface::CreateDelegatingSoftware())); |
7648 base::WrapUnique(new CountingSoftwareDevice)))); | |
7649 | 7644 |
7650 const gfx::Transform external_transform; | 7645 const gfx::Transform external_transform; |
7651 const gfx::Rect external_viewport; | 7646 const gfx::Rect external_viewport; |
7652 const gfx::Rect external_clip; | 7647 const gfx::Rect external_clip; |
7653 const bool resourceless_software_draw = true; | 7648 const bool resourceless_software_draw = true; |
7654 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7649 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
7655 external_transform); | 7650 external_transform); |
7656 | 7651 |
7657 // SolidColorLayerImpl will be drawn. | 7652 // SolidColorLayerImpl will be drawn. |
7658 std::unique_ptr<SolidColorLayerImpl> root_layer = | 7653 std::unique_ptr<SolidColorLayerImpl> root_layer = |
(...skipping 3191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10850 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 10845 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
10851 host_impl_->SetVisible(true); | 10846 host_impl_->SetVisible(true); |
10852 | 10847 |
10853 // InitializeRenderer with a gpu-raster enabled output surface. | 10848 // InitializeRenderer with a gpu-raster enabled output surface. |
10854 auto gpu_raster_output_surface = | 10849 auto gpu_raster_output_surface = |
10855 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); | 10850 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); |
10856 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); | 10851 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); |
10857 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10852 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
10858 | 10853 |
10859 // Re-initialize with a software output surface. | 10854 // Re-initialize with a software output surface. |
10860 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware( | 10855 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); |
10861 base::WrapUnique(new SoftwareOutputDevice)); | |
10862 host_impl_->InitializeRenderer(output_surface_.get()); | 10856 host_impl_->InitializeRenderer(output_surface_.get()); |
10863 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10857 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10864 } | 10858 } |
10865 | 10859 |
10866 } // namespace | 10860 } // namespace |
10867 } // namespace cc | 10861 } // namespace cc |
OLD | NEW |