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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "cc/test/animation_test_common.h" | 48 #include "cc/test/animation_test_common.h" |
49 #include "cc/test/begin_frame_args_test.h" | 49 #include "cc/test/begin_frame_args_test.h" |
50 #include "cc/test/fake_compositor_frame_sink.h" | 50 #include "cc/test/fake_compositor_frame_sink.h" |
51 #include "cc/test/fake_layer_tree_host_impl.h" | 51 #include "cc/test/fake_layer_tree_host_impl.h" |
52 #include "cc/test/fake_mask_layer_impl.h" | 52 #include "cc/test/fake_mask_layer_impl.h" |
53 #include "cc/test/fake_output_surface.h" | 53 #include "cc/test/fake_output_surface.h" |
54 #include "cc/test/fake_picture_layer_impl.h" | 54 #include "cc/test/fake_picture_layer_impl.h" |
55 #include "cc/test/fake_raster_source.h" | 55 #include "cc/test/fake_raster_source.h" |
56 #include "cc/test/fake_video_frame_provider.h" | 56 #include "cc/test/fake_video_frame_provider.h" |
57 #include "cc/test/geometry_test_utils.h" | 57 #include "cc/test/geometry_test_utils.h" |
58 #include "cc/test/gpu_rasterization_enabled_settings.h" | |
59 #include "cc/test/layer_test_common.h" | 58 #include "cc/test/layer_test_common.h" |
60 #include "cc/test/layer_tree_test.h" | 59 #include "cc/test/layer_tree_test.h" |
61 #include "cc/test/test_compositor_frame_sink.h" | 60 #include "cc/test/test_compositor_frame_sink.h" |
62 #include "cc/test/test_task_graph_runner.h" | 61 #include "cc/test/test_task_graph_runner.h" |
63 #include "cc/test/test_web_graphics_context_3d.h" | 62 #include "cc/test/test_web_graphics_context_3d.h" |
64 #include "cc/trees/effect_node.h" | 63 #include "cc/trees/effect_node.h" |
65 #include "cc/trees/layer_tree_host_common.h" | 64 #include "cc/trees/layer_tree_host_common.h" |
66 #include "cc/trees/layer_tree_impl.h" | 65 #include "cc/trees/layer_tree_impl.h" |
67 #include "cc/trees/mutator_host.h" | 66 #include "cc/trees/mutator_host.h" |
68 #include "cc/trees/single_thread_proxy.h" | 67 #include "cc/trees/single_thread_proxy.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 did_request_prepare_tiles_(false), | 104 did_request_prepare_tiles_(false), |
106 did_complete_page_scale_animation_(false), | 105 did_complete_page_scale_animation_(false), |
107 reduce_memory_result_(true) { | 106 reduce_memory_result_(true) { |
108 media::InitializeMediaLibrary(); | 107 media::InitializeMediaLibrary(); |
109 } | 108 } |
110 | 109 |
111 LayerTreeSettings DefaultSettings() { | 110 LayerTreeSettings DefaultSettings() { |
112 LayerTreeSettings settings; | 111 LayerTreeSettings settings; |
113 settings.minimum_occlusion_tracking_size = gfx::Size(); | 112 settings.minimum_occlusion_tracking_size = gfx::Size(); |
114 settings.renderer_settings.texture_id_allocation_chunk_size = 1; | 113 settings.renderer_settings.texture_id_allocation_chunk_size = 1; |
115 settings.gpu_rasterization_enabled = true; | |
116 settings.verify_clip_tree_calculations = true; | 114 settings.verify_clip_tree_calculations = true; |
117 settings.renderer_settings.buffer_to_texture_target_map = | 115 settings.renderer_settings.buffer_to_texture_target_map = |
118 DefaultBufferToTextureTargetMapForTesting(); | 116 DefaultBufferToTextureTargetMapForTesting(); |
119 return settings; | 117 return settings; |
120 } | 118 } |
121 | 119 |
122 void SetUp() override { | 120 void SetUp() override { |
123 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); | 121 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); |
124 } | 122 } |
125 | 123 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 float device_scale_factor); | 460 float device_scale_factor); |
463 | 461 |
464 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 462 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
465 | 463 |
466 void SetupMouseMoveAtTestScrollbarStates(bool main_thread_scrolling); | 464 void SetupMouseMoveAtTestScrollbarStates(bool main_thread_scrolling); |
467 | 465 |
468 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 466 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
469 | 467 |
470 protected: | 468 protected: |
471 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() { | 469 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() { |
472 return FakeCompositorFrameSink::Create3d(); | 470 return FakeCompositorFrameSink::Create3dForGpuRasterization(); |
473 } | 471 } |
474 | 472 |
475 void DrawOneFrame() { | 473 void DrawOneFrame() { |
476 LayerTreeHostImpl::FrameData frame_data; | 474 LayerTreeHostImpl::FrameData frame_data; |
477 host_impl_->PrepareToDraw(&frame_data); | 475 host_impl_->PrepareToDraw(&frame_data); |
478 host_impl_->DidDrawAllLayers(frame_data); | 476 host_impl_->DidDrawAllLayers(frame_data); |
479 } | 477 } |
480 | 478 |
481 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 479 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
482 const gfx::Vector2dF& delta) { | 480 const gfx::Vector2dF& delta) { |
(...skipping 10747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11230 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11228 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11231 EXPECT_FALSE(host_impl_->use_msaa()); | 11229 EXPECT_FALSE(host_impl_->use_msaa()); |
11232 } | 11230 } |
11233 | 11231 |
11234 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization. | 11232 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization. |
11235 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) { | 11233 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) { |
11236 // Create a host impl with MSAA support. | 11234 // Create a host impl with MSAA support. |
11237 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 11235 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
11238 TestWebGraphicsContext3D::Create(); | 11236 TestWebGraphicsContext3D::Create(); |
11239 context_with_msaa->SetMaxSamples(4); | 11237 context_with_msaa->SetMaxSamples(4); |
11240 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 11238 context_with_msaa->set_gpu_rasterization(true); |
| 11239 LayerTreeSettings msaaSettings = DefaultSettings(); |
11241 msaaSettings.gpu_rasterization_msaa_sample_count = -1; | 11240 msaaSettings.gpu_rasterization_msaa_sample_count = -1; |
11242 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( | 11241 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( |
11243 std::move(context_with_msaa)))); | 11242 std::move(context_with_msaa)))); |
11244 | 11243 |
11245 // Set initial state, before varying scale factor. | 11244 // Set initial state, before varying scale factor. |
11246 host_impl_->SetHasGpuRasterizationTrigger(true); | 11245 host_impl_->SetHasGpuRasterizationTrigger(true); |
11247 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11246 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11248 host_impl_->CommitComplete(); | 11247 host_impl_->CommitComplete(); |
11249 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11248 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
11250 host_impl_->gpu_rasterization_status()); | 11249 host_impl_->gpu_rasterization_status()); |
(...skipping 16 matching lines...) Expand all Loading... |
11267 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11266 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11268 EXPECT_FALSE(host_impl_->use_msaa()); | 11267 EXPECT_FALSE(host_impl_->use_msaa()); |
11269 } | 11268 } |
11270 | 11269 |
11271 // Tests that explicit MSAA sample count correctly impacts GPU rasterization. | 11270 // Tests that explicit MSAA sample count correctly impacts GPU rasterization. |
11272 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) { | 11271 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) { |
11273 // Create a host impl with MSAA support and a forced sample count of 4. | 11272 // Create a host impl with MSAA support and a forced sample count of 4. |
11274 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 11273 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
11275 TestWebGraphicsContext3D::Create(); | 11274 TestWebGraphicsContext3D::Create(); |
11276 context_with_msaa->SetMaxSamples(4); | 11275 context_with_msaa->SetMaxSamples(4); |
11277 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 11276 context_with_msaa->set_gpu_rasterization(true); |
| 11277 LayerTreeSettings msaaSettings = DefaultSettings(); |
11278 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 11278 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
11279 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( | 11279 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( |
11280 std::move(context_with_msaa)))); | 11280 std::move(context_with_msaa)))); |
11281 | 11281 |
11282 host_impl_->SetHasGpuRasterizationTrigger(true); | 11282 host_impl_->SetHasGpuRasterizationTrigger(true); |
11283 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11283 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11284 host_impl_->CommitComplete(); | 11284 host_impl_->CommitComplete(); |
11285 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 11285 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
11286 host_impl_->gpu_rasterization_status()); | 11286 host_impl_->gpu_rasterization_status()); |
11287 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11287 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11288 EXPECT_TRUE(host_impl_->use_msaa()); | 11288 EXPECT_TRUE(host_impl_->use_msaa()); |
11289 } | 11289 } |
11290 | 11290 |
| 11291 class GpuRasterizationDisabledLayerTreeHostImplTest |
| 11292 : public LayerTreeHostImplTest { |
| 11293 public: |
| 11294 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
| 11295 return FakeCompositorFrameSink::Create3d(); |
| 11296 } |
| 11297 }; |
| 11298 |
11291 // Tests that GPU rasterization overrides work as expected. | 11299 // Tests that GPU rasterization overrides work as expected. |
11292 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusOverrides) { | 11300 TEST_F(GpuRasterizationDisabledLayerTreeHostImplTest, |
| 11301 GpuRasterizationStatusOverrides) { |
11293 // GPU rasterization explicitly disabled. | 11302 // GPU rasterization explicitly disabled. |
11294 LayerTreeSettings settings = DefaultSettings(); | 11303 LayerTreeSettings settings = DefaultSettings(); |
11295 settings.gpu_rasterization_enabled = false; | |
11296 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); | 11304 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); |
11297 host_impl_->SetHasGpuRasterizationTrigger(true); | 11305 host_impl_->SetHasGpuRasterizationTrigger(true); |
11298 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 11306 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
11299 host_impl_->CommitComplete(); | 11307 host_impl_->CommitComplete(); |
11300 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, | 11308 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, |
11301 host_impl_->gpu_rasterization_status()); | 11309 host_impl_->gpu_rasterization_status()); |
11302 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11310 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11303 | 11311 |
11304 // GPU rasterization explicitly forced. | 11312 // GPU rasterization explicitly forced. |
11305 settings.gpu_rasterization_forced = true; | 11313 settings.gpu_rasterization_forced = true; |
11306 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); | 11314 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); |
11307 | 11315 |
11308 host_impl_->SetHasGpuRasterizationTrigger(false); | 11316 host_impl_->SetHasGpuRasterizationTrigger(false); |
11309 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11317 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11310 host_impl_->CommitComplete(); | 11318 host_impl_->CommitComplete(); |
11311 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 11319 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
11312 host_impl_->gpu_rasterization_status()); | 11320 host_impl_->gpu_rasterization_status()); |
11313 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11321 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11314 } | 11322 } |
11315 | 11323 |
11316 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { | 11324 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { |
11317 public: | 11325 public: |
11318 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { | 11326 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { |
11319 LayerTreeSettings settings = DefaultSettings(); | 11327 LayerTreeSettings settings = DefaultSettings(); |
11320 settings.gpu_rasterization_enabled = true; | |
11321 settings.gpu_rasterization_msaa_sample_count = 4; | 11328 settings.gpu_rasterization_msaa_sample_count = 4; |
11322 auto context_provider = TestContextProvider::Create(); | 11329 auto context_provider = TestContextProvider::Create(); |
11323 context_provider->UnboundTestContext3d()->SetMaxSamples(4); | 11330 context_provider->UnboundTestContext3d()->SetMaxSamples(4); |
11324 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); | 11331 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); |
| 11332 context_provider->UnboundTestContext3d()->set_gpu_rasterization(true); |
11325 auto msaa_is_normal_compositor_frame_sink = | 11333 auto msaa_is_normal_compositor_frame_sink = |
11326 FakeCompositorFrameSink::Create3d(context_provider); | 11334 FakeCompositorFrameSink::Create3d(context_provider); |
11327 EXPECT_TRUE(CreateHostImpl( | 11335 EXPECT_TRUE(CreateHostImpl( |
11328 settings, std::move(msaa_is_normal_compositor_frame_sink))); | 11336 settings, std::move(msaa_is_normal_compositor_frame_sink))); |
11329 } | 11337 } |
11330 }; | 11338 }; |
11331 | 11339 |
11332 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { | 11340 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { |
11333 // Ensure that without the msaa_is_slow cap we raster unsuitable content with | 11341 // Ensure that without the msaa_is_slow cap we raster unsuitable content with |
11334 // msaa. | 11342 // msaa. |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11716 SetupMouseMoveAtTestScrollbarStates(true); | 11724 SetupMouseMoveAtTestScrollbarStates(true); |
11717 } | 11725 } |
11718 | 11726 |
11719 TEST_F(LayerTreeHostImplTest, | 11727 TEST_F(LayerTreeHostImplTest, |
11720 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | 11728 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { |
11721 SetupMouseMoveAtTestScrollbarStates(false); | 11729 SetupMouseMoveAtTestScrollbarStates(false); |
11722 } | 11730 } |
11723 | 11731 |
11724 } // namespace | 11732 } // namespace |
11725 } // namespace cc | 11733 } // namespace cc |
OLD | NEW |