| 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 30 matching lines...) Expand all Loading... |
| 41 #include "cc/output/gl_renderer.h" | 41 #include "cc/output/gl_renderer.h" |
| 42 #include "cc/output/latency_info_swap_promise.h" | 42 #include "cc/output/latency_info_swap_promise.h" |
| 43 #include "cc/quads/render_pass_draw_quad.h" | 43 #include "cc/quads/render_pass_draw_quad.h" |
| 44 #include "cc/quads/solid_color_draw_quad.h" | 44 #include "cc/quads/solid_color_draw_quad.h" |
| 45 #include "cc/quads/texture_draw_quad.h" | 45 #include "cc/quads/texture_draw_quad.h" |
| 46 #include "cc/quads/tile_draw_quad.h" | 46 #include "cc/quads/tile_draw_quad.h" |
| 47 #include "cc/resources/ui_resource_bitmap.h" | 47 #include "cc/resources/ui_resource_bitmap.h" |
| 48 #include "cc/resources/ui_resource_manager.h" | 48 #include "cc/resources/ui_resource_manager.h" |
| 49 #include "cc/test/animation_test_common.h" | 49 #include "cc/test/animation_test_common.h" |
| 50 #include "cc/test/begin_frame_args_test.h" | 50 #include "cc/test/begin_frame_args_test.h" |
| 51 #include "cc/test/fake_compositor_frame_sink.h" |
| 51 #include "cc/test/fake_layer_tree_host_impl.h" | 52 #include "cc/test/fake_layer_tree_host_impl.h" |
| 52 #include "cc/test/fake_mask_layer_impl.h" | 53 #include "cc/test/fake_mask_layer_impl.h" |
| 53 #include "cc/test/fake_output_surface.h" | 54 #include "cc/test/fake_output_surface.h" |
| 54 #include "cc/test/fake_output_surface_client.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_delegating_output_surface.h" | 62 #include "cc/test/test_compositor_frame_sink.h" |
| 63 #include "cc/test/test_gpu_memory_buffer_manager.h" | 63 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 64 #include "cc/test/test_shared_bitmap_manager.h" | 64 #include "cc/test/test_shared_bitmap_manager.h" |
| 65 #include "cc/test/test_task_graph_runner.h" | 65 #include "cc/test/test_task_graph_runner.h" |
| 66 #include "cc/test/test_web_graphics_context_3d.h" | 66 #include "cc/test/test_web_graphics_context_3d.h" |
| 67 #include "cc/trees/effect_node.h" | 67 #include "cc/trees/effect_node.h" |
| 68 #include "cc/trees/layer_tree_host_common.h" | 68 #include "cc/trees/layer_tree_host_common.h" |
| 69 #include "cc/trees/layer_tree_impl.h" | 69 #include "cc/trees/layer_tree_impl.h" |
| 70 #include "cc/trees/single_thread_proxy.h" | 70 #include "cc/trees/single_thread_proxy.h" |
| 71 #include "cc/trees/transform_node.h" | 71 #include "cc/trees/transform_node.h" |
| 72 #include "media/base/media.h" | 72 #include "media/base/media.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 settings.renderer_settings.texture_id_allocation_chunk_size = 1; | 116 settings.renderer_settings.texture_id_allocation_chunk_size = 1; |
| 117 settings.gpu_rasterization_enabled = true; | 117 settings.gpu_rasterization_enabled = true; |
| 118 settings.verify_clip_tree_calculations = true; | 118 settings.verify_clip_tree_calculations = true; |
| 119 settings.verify_transform_tree_calculations = true; | 119 settings.verify_transform_tree_calculations = true; |
| 120 settings.renderer_settings.buffer_to_texture_target_map = | 120 settings.renderer_settings.buffer_to_texture_target_map = |
| 121 DefaultBufferToTextureTargetMapForTesting(); | 121 DefaultBufferToTextureTargetMapForTesting(); |
| 122 return settings; | 122 return settings; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SetUp() override { | 125 void SetUp() override { |
| 126 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); | 126 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TearDown() override { | 129 void TearDown() override { |
| 130 if (host_impl_) | 130 if (host_impl_) |
| 131 host_impl_->ReleaseOutputSurface(); | 131 host_impl_->ReleaseCompositorFrameSink(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void DidLoseOutputSurfaceOnImplThread() override {} | 134 void DidLoseCompositorFrameSinkOnImplThread() override {} |
| 135 void SetBeginFrameSource(BeginFrameSource* source) override {} | 135 void SetBeginFrameSource(BeginFrameSource* source) override {} |
| 136 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} | 136 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} |
| 137 void DidSwapBuffersCompleteOnImplThread() override {} | 137 void DidSwapBuffersCompleteOnImplThread() override {} |
| 138 void OnCanDrawStateChanged(bool can_draw) override { | 138 void OnCanDrawStateChanged(bool can_draw) override { |
| 139 on_can_draw_state_changed_called_ = true; | 139 on_can_draw_state_changed_called_ = true; |
| 140 } | 140 } |
| 141 void NotifyReadyToActivate() override { | 141 void NotifyReadyToActivate() override { |
| 142 did_notify_ready_to_activate_ = true; | 142 did_notify_ready_to_activate_ = true; |
| 143 host_impl_->ActivateSyncTree(); | 143 host_impl_->ActivateSyncTree(); |
| 144 } | 144 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 163 base::TimeDelta delay) override { | 163 base::TimeDelta delay) override { |
| 164 animation_task_ = task; | 164 animation_task_ = task; |
| 165 requested_animation_delay_ = delay; | 165 requested_animation_delay_ = delay; |
| 166 } | 166 } |
| 167 void DidActivateSyncTree() override {} | 167 void DidActivateSyncTree() override {} |
| 168 void WillPrepareTiles() override {} | 168 void WillPrepareTiles() override {} |
| 169 void DidPrepareTiles() override {} | 169 void DidPrepareTiles() override {} |
| 170 void DidCompletePageScaleAnimationOnImplThread() override { | 170 void DidCompletePageScaleAnimationOnImplThread() override { |
| 171 did_complete_page_scale_animation_ = true; | 171 did_complete_page_scale_animation_ = true; |
| 172 } | 172 } |
| 173 void OnDrawForOutputSurface(bool resourceless_software_draw) override { | 173 void OnDrawForCompositorFrameSink(bool resourceless_software_draw) override { |
| 174 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( | 174 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( |
| 175 new LayerTreeHostImpl::FrameData); | 175 new LayerTreeHostImpl::FrameData); |
| 176 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get())); | 176 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get())); |
| 177 last_on_draw_render_passes_.clear(); | 177 last_on_draw_render_passes_.clear(); |
| 178 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); | 178 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); |
| 179 host_impl_->DrawLayers(frame.get()); | 179 host_impl_->DrawLayers(frame.get()); |
| 180 host_impl_->DidDrawAllLayers(*frame); | 180 host_impl_->DidDrawAllLayers(*frame); |
| 181 last_on_draw_frame_ = std::move(frame); | 181 last_on_draw_frame_ = std::move(frame); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void set_reduce_memory_result(bool reduce_memory_result) { | 184 void set_reduce_memory_result(bool reduce_memory_result) { |
| 185 reduce_memory_result_ = reduce_memory_result; | 185 reduce_memory_result_ = reduce_memory_result; |
| 186 } | 186 } |
| 187 | 187 |
| 188 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 188 virtual bool CreateHostImpl( |
| 189 std::unique_ptr<OutputSurface> output_surface) { | 189 const LayerTreeSettings& settings, |
| 190 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) { |
| 190 return CreateHostImplWithTaskRunnerProvider( | 191 return CreateHostImplWithTaskRunnerProvider( |
| 191 settings, std::move(output_surface), &task_runner_provider_); | 192 settings, std::move(compositor_frame_sink), &task_runner_provider_); |
| 192 } | 193 } |
| 193 | 194 |
| 194 virtual bool CreateHostImplWithTaskRunnerProvider( | 195 virtual bool CreateHostImplWithTaskRunnerProvider( |
| 195 const LayerTreeSettings& settings, | 196 const LayerTreeSettings& settings, |
| 196 std::unique_ptr<OutputSurface> output_surface, | 197 std::unique_ptr<CompositorFrameSink> compositor_frame_sink, |
| 197 TaskRunnerProvider* task_runner_provider) { | 198 TaskRunnerProvider* task_runner_provider) { |
| 198 if (host_impl_) | 199 if (host_impl_) |
| 199 host_impl_->ReleaseOutputSurface(); | 200 host_impl_->ReleaseCompositorFrameSink(); |
| 200 host_impl_ = LayerTreeHostImpl::Create( | 201 host_impl_ = LayerTreeHostImpl::Create( |
| 201 settings, this, task_runner_provider, &stats_instrumentation_, | 202 settings, this, task_runner_provider, &stats_instrumentation_, |
| 202 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, | 203 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, |
| 203 &task_graph_runner_, | 204 &task_graph_runner_, |
| 204 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 205 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 205 output_surface_ = std::move(output_surface); | 206 compositor_frame_sink_ = std::move(compositor_frame_sink); |
| 206 host_impl_->SetVisible(true); | 207 host_impl_->SetVisible(true); |
| 207 bool init = host_impl_->InitializeRenderer(output_surface_.get()); | 208 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 208 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 209 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 209 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 210 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 210 // Set the BeginFrameArgs so that methods which use it are able to. | 211 // Set the BeginFrameArgs so that methods which use it are able to. |
| 211 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 212 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
| 212 BEGINFRAME_FROM_HERE, | 213 BEGINFRAME_FROM_HERE, |
| 213 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 214 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
| 214 host_impl_->DidFinishImplFrame(); | 215 host_impl_->DidFinishImplFrame(); |
| 215 | 216 |
| 216 timeline_ = | 217 timeline_ = |
| 217 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 218 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 463 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 463 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 464 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 464 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 465 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 465 float device_scale_factor); | 466 float device_scale_factor); |
| 466 | 467 |
| 467 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 468 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
| 468 | 469 |
| 469 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 470 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
| 470 | 471 |
| 471 protected: | 472 protected: |
| 472 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { | 473 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() { |
| 473 return FakeOutputSurface::CreateDelegating3d(); | 474 return FakeCompositorFrameSink::Create3d(); |
| 474 } | 475 } |
| 475 | 476 |
| 476 void DrawOneFrame() { | 477 void DrawOneFrame() { |
| 477 LayerTreeHostImpl::FrameData frame_data; | 478 LayerTreeHostImpl::FrameData frame_data; |
| 478 host_impl_->PrepareToDraw(&frame_data); | 479 host_impl_->PrepareToDraw(&frame_data); |
| 479 host_impl_->DidDrawAllLayers(frame_data); | 480 host_impl_->DidDrawAllLayers(frame_data); |
| 480 } | 481 } |
| 481 | 482 |
| 482 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 483 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
| 483 const gfx::Vector2dF& delta) { | 484 const gfx::Vector2dF& delta) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 497 host_impl_->UpdateAnimationState(true); | 498 host_impl_->UpdateAnimationState(true); |
| 498 host_impl_->DidFinishImplFrame(); | 499 host_impl_->DidFinishImplFrame(); |
| 499 } | 500 } |
| 500 | 501 |
| 501 FakeImplTaskRunnerProvider task_runner_provider_; | 502 FakeImplTaskRunnerProvider task_runner_provider_; |
| 502 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 503 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
| 503 | 504 |
| 504 TestSharedBitmapManager shared_bitmap_manager_; | 505 TestSharedBitmapManager shared_bitmap_manager_; |
| 505 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 506 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 506 TestTaskGraphRunner task_graph_runner_; | 507 TestTaskGraphRunner task_graph_runner_; |
| 507 std::unique_ptr<OutputSurface> output_surface_; | 508 std::unique_ptr<CompositorFrameSink> compositor_frame_sink_; |
| 508 std::unique_ptr<LayerTreeHostImpl> host_impl_; | 509 std::unique_ptr<LayerTreeHostImpl> host_impl_; |
| 509 FakeRenderingStatsInstrumentation stats_instrumentation_; | 510 FakeRenderingStatsInstrumentation stats_instrumentation_; |
| 510 bool on_can_draw_state_changed_called_; | 511 bool on_can_draw_state_changed_called_; |
| 511 bool did_notify_ready_to_activate_; | 512 bool did_notify_ready_to_activate_; |
| 512 bool did_request_commit_; | 513 bool did_request_commit_; |
| 513 bool did_request_redraw_; | 514 bool did_request_redraw_; |
| 514 bool did_request_next_frame_; | 515 bool did_request_next_frame_; |
| 515 bool did_request_prepare_tiles_; | 516 bool did_request_prepare_tiles_; |
| 516 bool did_complete_page_scale_animation_; | 517 bool did_complete_page_scale_animation_; |
| 517 bool reduce_memory_result_; | 518 bool reduce_memory_result_; |
| 518 base::Closure animation_task_; | 519 base::Closure animation_task_; |
| 519 base::TimeDelta requested_animation_delay_; | 520 base::TimeDelta requested_animation_delay_; |
| 520 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; | 521 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; |
| 521 RenderPassList last_on_draw_render_passes_; | 522 RenderPassList last_on_draw_render_passes_; |
| 522 scoped_refptr<AnimationTimeline> timeline_; | 523 scoped_refptr<AnimationTimeline> timeline_; |
| 523 }; | 524 }; |
| 524 | 525 |
| 525 // A test fixture for new animation timelines tests. | 526 // A test fixture for new animation timelines tests. |
| 526 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { | 527 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { |
| 527 public: | 528 public: |
| 528 void SetUp() override { | 529 void SetUp() override { |
| 529 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); | 530 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); |
| 530 } | 531 } |
| 531 }; | 532 }; |
| 532 | 533 |
| 533 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 534 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
| 534 // Note: It is not possible to disable the renderer once it has been set, | 535 // Note: It is not possible to disable the renderer once it has been set, |
| 535 // so we do not need to test that disabling the renderer notifies us | 536 // so we do not need to test that disabling the renderer notifies us |
| 536 // that can_draw changed. | 537 // that can_draw changed. |
| 537 EXPECT_FALSE(host_impl_->CanDraw()); | 538 EXPECT_FALSE(host_impl_->CanDraw()); |
| 538 on_can_draw_state_changed_called_ = false; | 539 on_can_draw_state_changed_called_ = false; |
| 539 | 540 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 561 EXPECT_TRUE(on_can_draw_state_changed_called_); | 562 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 562 on_can_draw_state_changed_called_ = false; | 563 on_can_draw_state_changed_called_ = false; |
| 563 | 564 |
| 564 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 565 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 565 EXPECT_TRUE(host_impl_->CanDraw()); | 566 EXPECT_TRUE(host_impl_->CanDraw()); |
| 566 EXPECT_TRUE(on_can_draw_state_changed_called_); | 567 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 567 on_can_draw_state_changed_called_ = false; | 568 on_can_draw_state_changed_called_ = false; |
| 568 } | 569 } |
| 569 | 570 |
| 570 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { | 571 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { |
| 571 CreateHostImpl(DefaultSettings(), | 572 CreateHostImpl(DefaultSettings(), FakeCompositorFrameSink::CreateSoftware()); |
| 572 FakeOutputSurface::CreateDelegatingSoftware()); | |
| 573 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 573 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 574 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 574 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 575 | 575 |
| 576 EXPECT_TRUE(host_impl_->CanDraw()); | 576 EXPECT_TRUE(host_impl_->CanDraw()); |
| 577 host_impl_->SetViewportSize(gfx::Size()); | 577 host_impl_->SetViewportSize(gfx::Size()); |
| 578 EXPECT_FALSE(host_impl_->CanDraw()); | 578 EXPECT_FALSE(host_impl_->CanDraw()); |
| 579 | 579 |
| 580 FakeOutputSurface* fake_output_surface = | 580 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 581 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 581 static_cast<FakeCompositorFrameSink*>( |
| 582 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); | 582 host_impl_->compositor_frame_sink()); |
| 583 EXPECT_EQ(fake_compositor_frame_sink->num_sent_frames(), 0u); |
| 583 gfx::Transform identity; | 584 gfx::Transform identity; |
| 584 gfx::Rect viewport(100, 100); | 585 gfx::Rect viewport(100, 100); |
| 585 const bool resourceless_software_draw = true; | 586 const bool resourceless_software_draw = true; |
| 586 host_impl_->OnDraw(identity, viewport, resourceless_software_draw); | 587 host_impl_->OnDraw(identity, viewport, resourceless_software_draw); |
| 587 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); | 588 ASSERT_EQ(fake_compositor_frame_sink->num_sent_frames(), 1u); |
| 588 EXPECT_EQ(gfx::SizeF(100.f, 100.f), | 589 EXPECT_EQ( |
| 589 fake_output_surface->last_sent_frame()->metadata.root_layer_size); | 590 gfx::SizeF(100.f, 100.f), |
| 591 fake_compositor_frame_sink->last_sent_frame()->metadata.root_layer_size); |
| 590 } | 592 } |
| 591 | 593 |
| 592 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 594 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
| 593 ASSERT_FALSE(host_impl_->active_tree()->root_layer_for_testing()); | 595 ASSERT_FALSE(host_impl_->active_tree()->root_layer_for_testing()); |
| 594 | 596 |
| 595 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 597 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 596 host_impl_->ProcessScrollDeltas(); | 598 host_impl_->ProcessScrollDeltas(); |
| 597 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 599 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 598 } | 600 } |
| 599 | 601 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 730 } |
| 729 | 731 |
| 730 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 732 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
| 731 std::unique_ptr<TestWebGraphicsContext3D> context_owned = | 733 std::unique_ptr<TestWebGraphicsContext3D> context_owned = |
| 732 TestWebGraphicsContext3D::Create(); | 734 TestWebGraphicsContext3D::Create(); |
| 733 context_owned->set_context_lost(true); | 735 context_owned->set_context_lost(true); |
| 734 | 736 |
| 735 // Initialization will fail. | 737 // Initialization will fail. |
| 736 EXPECT_FALSE(CreateHostImpl( | 738 EXPECT_FALSE(CreateHostImpl( |
| 737 DefaultSettings(), | 739 DefaultSettings(), |
| 738 FakeOutputSurface::CreateDelegating3d(std::move(context_owned)))); | 740 FakeCompositorFrameSink::Create3d(std::move(context_owned)))); |
| 739 | 741 |
| 740 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 742 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 741 | 743 |
| 742 // We should not crash when trying to scroll after the renderer initialization | 744 // We should not crash when trying to scroll after the renderer initialization |
| 743 // fails. | 745 // fails. |
| 744 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 746 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 745 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 747 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 746 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 748 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 747 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 749 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 748 status.main_thread_scrolling_reasons); | 750 status.main_thread_scrolling_reasons); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 // An animation exists on the active layer. Doing Animate() requests another | 1411 // An animation exists on the active layer. Doing Animate() requests another |
| 1410 // frame after the current one. | 1412 // frame after the current one. |
| 1411 EXPECT_TRUE(did_request_next_frame_); | 1413 EXPECT_TRUE(did_request_next_frame_); |
| 1412 // The animation should cause us to draw at the frame's deadline. | 1414 // The animation should cause us to draw at the frame's deadline. |
| 1413 EXPECT_TRUE(did_request_redraw_); | 1415 EXPECT_TRUE(did_request_redraw_); |
| 1414 EXPECT_FALSE(did_request_commit_); | 1416 EXPECT_FALSE(did_request_commit_); |
| 1415 } | 1417 } |
| 1416 | 1418 |
| 1417 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { | 1419 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
| 1418 FakeImplTaskRunnerProvider provider(nullptr); | 1420 FakeImplTaskRunnerProvider provider(nullptr); |
| 1419 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), | 1421 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), |
| 1420 &provider); | 1422 CreateCompositorFrameSink(), &provider); |
| 1421 EXPECT_TRUE(host_impl_->CommitToActiveTree()); | 1423 EXPECT_TRUE(host_impl_->CommitToActiveTree()); |
| 1422 | 1424 |
| 1423 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1425 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1424 | 1426 |
| 1425 auto root_owned = LayerImpl::Create(host_impl_->active_tree(), 1); | 1427 auto root_owned = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1426 auto* root = root_owned.get(); | 1428 auto* root = root_owned.get(); |
| 1427 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_owned)); | 1429 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_owned)); |
| 1428 root->SetBounds(gfx::Size(50, 50)); | 1430 root->SetBounds(gfx::Size(50, 50)); |
| 1429 root->SetHasRenderSurface(true); | 1431 root->SetHasRenderSurface(true); |
| 1430 | 1432 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1453 | 1455 |
| 1454 host_impl_->CommitComplete(); | 1456 host_impl_->CommitComplete(); |
| 1455 | 1457 |
| 1456 // Animations on the active tree should be started and ticked, and a new frame | 1458 // Animations on the active tree should be started and ticked, and a new frame |
| 1457 // should be requested to continue ticking them. | 1459 // should be requested to continue ticking them. |
| 1458 EXPECT_TRUE(did_request_next_frame_); | 1460 EXPECT_TRUE(did_request_next_frame_); |
| 1459 EXPECT_TRUE(did_request_redraw_); | 1461 EXPECT_TRUE(did_request_redraw_); |
| 1460 EXPECT_FALSE(did_request_commit_); | 1462 EXPECT_FALSE(did_request_commit_); |
| 1461 | 1463 |
| 1462 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. | 1464 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
| 1463 host_impl_->ReleaseOutputSurface(); | 1465 host_impl_->ReleaseCompositorFrameSink(); |
| 1464 host_impl_ = nullptr; | 1466 host_impl_ = nullptr; |
| 1465 } | 1467 } |
| 1466 | 1468 |
| 1467 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { | 1469 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
| 1468 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1470 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1469 | 1471 |
| 1470 host_impl_->active_tree()->SetRootLayerForTesting( | 1472 host_impl_->active_tree()->SetRootLayerForTesting( |
| 1471 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1473 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1472 LayerImpl* root = *host_impl_->active_tree()->begin(); | 1474 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1473 root->SetBounds(gfx::Size(50, 50)); | 1475 root->SetBounds(gfx::Size(50, 50)); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 1697 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 1696 host_impl_->ProcessScrollDeltas(); | 1698 host_impl_->ProcessScrollDeltas(); |
| 1697 EXPECT_TRUE(ScrollInfoContains( | 1699 EXPECT_TRUE(ScrollInfoContains( |
| 1698 *scroll_info.get(), scroll_layer->id(), | 1700 *scroll_info.get(), scroll_layer->id(), |
| 1699 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); | 1701 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); |
| 1700 } | 1702 } |
| 1701 } | 1703 } |
| 1702 | 1704 |
| 1703 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { | 1705 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { |
| 1704 LayerTreeSettings settings = DefaultSettings(); | 1706 LayerTreeSettings settings = DefaultSettings(); |
| 1705 CreateHostImpl(settings, | 1707 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1706 CreateOutputSurface()); | |
| 1707 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); | 1708 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); |
| 1708 | 1709 |
| 1709 const gfx::Size content_size(1000, 1000); | 1710 const gfx::Size content_size(1000, 1000); |
| 1710 const gfx::Size viewport_size(500, 500); | 1711 const gfx::Size viewport_size(500, 500); |
| 1711 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1712 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1712 | 1713 |
| 1713 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1714 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1714 outer_scroll_layer->SetDrawsContent(true); | 1715 outer_scroll_layer->SetDrawsContent(true); |
| 1715 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1716 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1716 inner_scroll_layer->SetDrawsContent(true); | 1717 inner_scroll_layer->SetDrawsContent(true); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 inner_scroll_layer->CurrentScrollOffset()); | 1763 inner_scroll_layer->CurrentScrollOffset()); |
| 1763 EXPECT_VECTOR_EQ( | 1764 EXPECT_VECTOR_EQ( |
| 1764 gfx::Vector2dF(300, 300), | 1765 gfx::Vector2dF(300, 300), |
| 1765 outer_scroll_layer->CurrentScrollOffset()); | 1766 outer_scroll_layer->CurrentScrollOffset()); |
| 1766 } | 1767 } |
| 1767 | 1768 |
| 1768 // Make sure scrolls smaller than a unit applied to the viewport don't get | 1769 // Make sure scrolls smaller than a unit applied to the viewport don't get |
| 1769 // dropped. crbug.com/539334. | 1770 // dropped. crbug.com/539334. |
| 1770 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { | 1771 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { |
| 1771 LayerTreeSettings settings = DefaultSettings(); | 1772 LayerTreeSettings settings = DefaultSettings(); |
| 1772 CreateHostImpl(settings, CreateOutputSurface()); | 1773 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1773 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1774 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1774 | 1775 |
| 1775 const gfx::Size content_size(1000, 1000); | 1776 const gfx::Size content_size(1000, 1000); |
| 1776 const gfx::Size viewport_size(500, 500); | 1777 const gfx::Size viewport_size(500, 500); |
| 1777 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1778 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1778 | 1779 |
| 1779 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1780 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1780 outer_scroll_layer->SetDrawsContent(true); | 1781 outer_scroll_layer->SetDrawsContent(true); |
| 1781 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1782 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1782 inner_scroll_layer->SetDrawsContent(true); | 1783 inner_scroll_layer->SetDrawsContent(true); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 gfx::Vector2dF(0.25f, 0.25f), | 1817 gfx::Vector2dF(0.25f, 0.25f), |
| 1817 inner_scroll_layer->CurrentScrollOffset()); | 1818 inner_scroll_layer->CurrentScrollOffset()); |
| 1818 host_impl_->ScrollEnd(EndState().get()); | 1819 host_impl_->ScrollEnd(EndState().get()); |
| 1819 } | 1820 } |
| 1820 | 1821 |
| 1821 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work | 1822 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work |
| 1822 // as expected. That is, scrolling during a pinch should bubble from the inner | 1823 // as expected. That is, scrolling during a pinch should bubble from the inner |
| 1823 // to the outer viewport. | 1824 // to the outer viewport. |
| 1824 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { | 1825 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { |
| 1825 LayerTreeSettings settings = DefaultSettings(); | 1826 LayerTreeSettings settings = DefaultSettings(); |
| 1826 CreateHostImpl(settings, | 1827 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1827 CreateOutputSurface()); | |
| 1828 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1828 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1829 | 1829 |
| 1830 const gfx::Size content_size(1000, 1000); | 1830 const gfx::Size content_size(1000, 1000); |
| 1831 const gfx::Size viewport_size(500, 500); | 1831 const gfx::Size viewport_size(500, 500); |
| 1832 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1832 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1833 | 1833 |
| 1834 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1834 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1835 outer_scroll_layer->SetDrawsContent(true); | 1835 outer_scroll_layer->SetDrawsContent(true); |
| 1836 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1836 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1837 inner_scroll_layer->SetDrawsContent(true); | 1837 inner_scroll_layer->SetDrawsContent(true); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 | 1878 |
| 1879 host_impl_->PinchGestureEnd(); | 1879 host_impl_->PinchGestureEnd(); |
| 1880 host_impl_->ScrollEnd(EndState().get()); | 1880 host_impl_->ScrollEnd(EndState().get()); |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when | 1883 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when |
| 1884 // a pinch zoom is anchored within a certain margin of the screen edge, we | 1884 // a pinch zoom is anchored within a certain margin of the screen edge, we |
| 1885 // should assume the user means to scroll into the edge of the screen. | 1885 // should assume the user means to scroll into the edge of the screen. |
| 1886 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { | 1886 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { |
| 1887 LayerTreeSettings settings = DefaultSettings(); | 1887 LayerTreeSettings settings = DefaultSettings(); |
| 1888 CreateHostImpl(settings, | 1888 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1889 CreateOutputSurface()); | |
| 1890 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1889 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1891 | 1890 |
| 1892 const gfx::Size content_size(1000, 1000); | 1891 const gfx::Size content_size(1000, 1000); |
| 1893 const gfx::Size viewport_size(500, 500); | 1892 const gfx::Size viewport_size(500, 500); |
| 1894 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1893 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1895 | 1894 |
| 1896 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; | 1895 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; |
| 1897 gfx::Point anchor(viewport_size.width() - offsetFromEdge, | 1896 gfx::Point anchor(viewport_size.width() - offsetFromEdge, |
| 1898 viewport_size.height() - offsetFromEdge); | 1897 viewport_size.height() - offsetFromEdge); |
| 1899 | 1898 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 fake_current_physical_time_ = fake_now; | 2721 fake_current_physical_time_ = fake_now; |
| 2723 } | 2722 } |
| 2724 | 2723 |
| 2725 private: | 2724 private: |
| 2726 base::TimeTicks fake_current_physical_time_; | 2725 base::TimeTicks fake_current_physical_time_; |
| 2727 }; | 2726 }; |
| 2728 | 2727 |
| 2729 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { | 2728 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
| 2730 protected: | 2729 protected: |
| 2731 void SetupLayers(LayerTreeSettings settings) { | 2730 void SetupLayers(LayerTreeSettings settings) { |
| 2732 host_impl_->ReleaseOutputSurface(); | 2731 host_impl_->ReleaseCompositorFrameSink(); |
| 2733 host_impl_ = nullptr; | 2732 host_impl_ = nullptr; |
| 2734 | 2733 |
| 2735 gfx::Size content_size(100, 100); | 2734 gfx::Size content_size(100, 100); |
| 2736 | 2735 |
| 2737 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = | 2736 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
| 2738 new LayerTreeHostImplOverridePhysicalTime( | 2737 new LayerTreeHostImplOverridePhysicalTime( |
| 2739 settings, this, &task_runner_provider_, &shared_bitmap_manager_, | 2738 settings, this, &task_runner_provider_, &shared_bitmap_manager_, |
| 2740 &task_graph_runner_, &stats_instrumentation_); | 2739 &task_graph_runner_, &stats_instrumentation_); |
| 2741 host_impl_ = base::WrapUnique(host_impl_override_time); | 2740 host_impl_ = base::WrapUnique(host_impl_override_time); |
| 2742 output_surface_ = CreateOutputSurface(); | 2741 compositor_frame_sink_ = CreateCompositorFrameSink(); |
| 2743 host_impl_->SetVisible(true); | 2742 host_impl_->SetVisible(true); |
| 2744 host_impl_->InitializeRenderer(output_surface_.get()); | 2743 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 2745 | 2744 |
| 2746 SetupScrollAndContentsLayers(content_size); | 2745 SetupScrollAndContentsLayers(content_size); |
| 2747 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2746 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
| 2748 host_impl_->SetViewportSize( | 2747 host_impl_->SetViewportSize( |
| 2749 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 2748 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
| 2750 | 2749 |
| 2751 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2750 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 2752 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | 2751 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, |
| 2753 VERTICAL, 10, 0, false, true); | 2752 VERTICAL, 10, 0, false, true); |
| 2754 scrollbar->test_properties()->opacity = 0.f; | 2753 scrollbar->test_properties()->opacity = 0.f; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2959 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2961 LayerTreeSettings settings = DefaultSettings(); | 2960 LayerTreeSettings settings = DefaultSettings(); |
| 2962 settings.scrollbar_animator = animator; | 2961 settings.scrollbar_animator = animator; |
| 2963 settings.scrollbar_fade_delay_ms = 20; | 2962 settings.scrollbar_fade_delay_ms = 20; |
| 2964 settings.scrollbar_fade_duration_ms = 20; | 2963 settings.scrollbar_fade_duration_ms = 20; |
| 2965 gfx::Size content_size(100, 100); | 2964 gfx::Size content_size(100, 100); |
| 2966 | 2965 |
| 2967 // If no animator is set, scrollbar won't show and no animation is expected. | 2966 // If no animator is set, scrollbar won't show and no animation is expected. |
| 2968 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; | 2967 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; |
| 2969 | 2968 |
| 2970 CreateHostImpl(settings, CreateOutputSurface()); | 2969 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 2971 host_impl_->CreatePendingTree(); | 2970 host_impl_->CreatePendingTree(); |
| 2972 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 2971 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
| 2973 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2972 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 2974 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 2973 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
| 2975 VERTICAL, 10, 0, false, true); | 2974 VERTICAL, 10, 0, false, true); |
| 2976 scrollbar->test_properties()->opacity = 0.f; | 2975 scrollbar->test_properties()->opacity = 0.f; |
| 2977 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 2976 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
| 2978 LayerImpl* container = | 2977 LayerImpl* container = |
| 2979 host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2978 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 2980 scrollbar->SetScrollLayerId(scroll->id()); | 2979 scrollbar->SetScrollLayerId(scroll->id()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3049 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { | 3048 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { |
| 3050 RunTest(LayerTreeSettings::THINNING); | 3049 RunTest(LayerTreeSettings::THINNING); |
| 3051 } | 3050 } |
| 3052 | 3051 |
| 3053 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { | 3052 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { |
| 3054 RunTest(LayerTreeSettings::NO_ANIMATOR); | 3053 RunTest(LayerTreeSettings::NO_ANIMATOR); |
| 3055 } | 3054 } |
| 3056 | 3055 |
| 3057 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { | 3056 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { |
| 3058 LayerTreeSettings settings = DefaultSettings(); | 3057 LayerTreeSettings settings = DefaultSettings(); |
| 3059 CreateHostImpl(settings, CreateOutputSurface()); | 3058 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3060 | 3059 |
| 3061 gfx::Size inner_viewport_size(315, 200); | 3060 gfx::Size inner_viewport_size(315, 200); |
| 3062 gfx::Size outer_viewport_size(300, 200); | 3061 gfx::Size outer_viewport_size(300, 200); |
| 3063 gfx::Size content_size(1000, 1000); | 3062 gfx::Size content_size(1000, 1000); |
| 3064 | 3063 |
| 3065 const int horiz_id = 11; | 3064 const int horiz_id = 11; |
| 3066 const int child_clip_id = 14; | 3065 const int child_clip_id = 14; |
| 3067 const int child_scroll_id = 15; | 3066 const int child_scroll_id = 15; |
| 3068 | 3067 |
| 3069 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 3068 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3086 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); | 3085 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); |
| 3087 | 3086 |
| 3088 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); | 3087 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); |
| 3089 } | 3088 } |
| 3090 | 3089 |
| 3091 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { | 3090 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { |
| 3092 LayerTreeSettings settings = DefaultSettings(); | 3091 LayerTreeSettings settings = DefaultSettings(); |
| 3093 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | 3092 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; |
| 3094 settings.scrollbar_fade_delay_ms = 20; | 3093 settings.scrollbar_fade_delay_ms = 20; |
| 3095 settings.scrollbar_fade_duration_ms = 20; | 3094 settings.scrollbar_fade_duration_ms = 20; |
| 3096 CreateHostImpl(settings, CreateOutputSurface()); | 3095 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3097 | 3096 |
| 3098 gfx::Size viewport_size(300, 200); | 3097 gfx::Size viewport_size(300, 200); |
| 3099 gfx::Size content_size(1000, 1000); | 3098 gfx::Size content_size(1000, 1000); |
| 3100 | 3099 |
| 3101 const int vert_1_id = 10; | 3100 const int vert_1_id = 10; |
| 3102 const int horiz_1_id = 11; | 3101 const int horiz_1_id = 11; |
| 3103 const int vert_2_id = 12; | 3102 const int vert_2_id = 12; |
| 3104 const int horiz_2_id = 13; | 3103 const int horiz_2_id = 13; |
| 3105 const int child_clip_id = 14; | 3104 const int child_clip_id = 14; |
| 3106 const int child_scroll_id = 15; | 3105 const int child_scroll_id = 15; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 settings.scrollbar_fade_delay_ms = 500; | 3213 settings.scrollbar_fade_delay_ms = 500; |
| 3215 settings.scrollbar_fade_duration_ms = 300; | 3214 settings.scrollbar_fade_duration_ms = 300; |
| 3216 settings.scrollbar_animator = LayerTreeSettings::THINNING; | 3215 settings.scrollbar_animator = LayerTreeSettings::THINNING; |
| 3217 | 3216 |
| 3218 gfx::Size viewport_size(300, 200); | 3217 gfx::Size viewport_size(300, 200); |
| 3219 gfx::Size device_viewport_size = | 3218 gfx::Size device_viewport_size = |
| 3220 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); | 3219 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); |
| 3221 gfx::Size content_size(1000, 1000); | 3220 gfx::Size content_size(1000, 1000); |
| 3222 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); | 3221 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); |
| 3223 | 3222 |
| 3224 CreateHostImpl(settings, CreateOutputSurface()); | 3223 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3225 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); | 3224 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 3226 host_impl_->SetViewportSize(device_viewport_size); | 3225 host_impl_->SetViewportSize(device_viewport_size); |
| 3227 | 3226 |
| 3228 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 3227 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| 3229 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 3228 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
| 3230 viewport_size); | 3229 viewport_size); |
| 3231 LayerImpl* root_scroll = | 3230 LayerImpl* root_scroll = |
| 3232 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3231 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 3233 // The scrollbar is on the left side. | 3232 // The scrollbar is on the left side. |
| 3234 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 3233 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3831 | 3830 |
| 3832 LayerTreeHostImpl::FrameData frame; | 3831 LayerTreeHostImpl::FrameData frame; |
| 3833 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); | 3832 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
| 3834 host_impl_->DrawLayers(&frame); | 3833 host_impl_->DrawLayers(&frame); |
| 3835 host_impl_->DidDrawAllLayers(frame); | 3834 host_impl_->DidDrawAllLayers(frame); |
| 3836 } | 3835 } |
| 3837 } | 3836 } |
| 3838 | 3837 |
| 3839 TEST_F(LayerTreeHostImplTest, | 3838 TEST_F(LayerTreeHostImplTest, |
| 3840 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3839 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
| 3841 CreateHostImpl(DefaultSettings(), | 3840 CreateHostImpl(DefaultSettings(), FakeCompositorFrameSink::CreateSoftware()); |
| 3842 FakeOutputSurface::CreateDelegatingSoftware()); | |
| 3843 | 3841 |
| 3844 const gfx::Transform external_transform; | 3842 const gfx::Transform external_transform; |
| 3845 const gfx::Rect external_viewport; | 3843 const gfx::Rect external_viewport; |
| 3846 const bool resourceless_software_draw = true; | 3844 const bool resourceless_software_draw = true; |
| 3847 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 3845 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 3848 external_transform); | 3846 external_transform); |
| 3849 | 3847 |
| 3850 std::vector<PrepareToDrawSuccessTestCase> cases; | 3848 std::vector<PrepareToDrawSuccessTestCase> cases; |
| 3851 | 3849 |
| 3852 // 0. Default case. | 3850 // 0. Default case. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3948 LayerTreeHostImplTopControlsTest() | 3946 LayerTreeHostImplTopControlsTest() |
| 3949 // Make the clip size the same as the layer (content) size so the layer is | 3947 // Make the clip size the same as the layer (content) size so the layer is |
| 3950 // non-scrollable. | 3948 // non-scrollable. |
| 3951 : layer_size_(10, 10), | 3949 : layer_size_(10, 10), |
| 3952 clip_size_(layer_size_), | 3950 clip_size_(layer_size_), |
| 3953 top_controls_height_(50) { | 3951 top_controls_height_(50) { |
| 3954 viewport_size_ = gfx::Size(clip_size_.width(), | 3952 viewport_size_ = gfx::Size(clip_size_.width(), |
| 3955 clip_size_.height() + top_controls_height_); | 3953 clip_size_.height() + top_controls_height_); |
| 3956 } | 3954 } |
| 3957 | 3955 |
| 3958 bool CreateHostImpl(const LayerTreeSettings& settings, | 3956 bool CreateHostImpl( |
| 3959 std::unique_ptr<OutputSurface> output_surface) override { | 3957 const LayerTreeSettings& settings, |
| 3958 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { |
| 3960 bool init = LayerTreeHostImplTest::CreateHostImpl( | 3959 bool init = LayerTreeHostImplTest::CreateHostImpl( |
| 3961 settings, std::move(output_surface)); | 3960 settings, std::move(compositor_frame_sink)); |
| 3962 if (init) { | 3961 if (init) { |
| 3963 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 3962 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 3964 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 3963 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 3965 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3964 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3966 } | 3965 } |
| 3967 return init; | 3966 return init; |
| 3968 } | 3967 } |
| 3969 | 3968 |
| 3970 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 3969 void SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3971 const gfx::Size& inner_viewport_size, | 3970 const gfx::Size& inner_viewport_size, |
| 3972 const gfx::Size& outer_viewport_size, | 3971 const gfx::Size& outer_viewport_size, |
| 3973 const gfx::Size& scroll_layer_size) { | 3972 const gfx::Size& scroll_layer_size) { |
| 3974 settings_ = DefaultSettings(); | 3973 settings_ = DefaultSettings(); |
| 3975 CreateHostImpl(settings_, CreateOutputSurface()); | 3974 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 3976 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3975 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3977 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size, | 3976 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size, |
| 3978 scroll_layer_size); | 3977 scroll_layer_size); |
| 3979 } | 3978 } |
| 3980 | 3979 |
| 3981 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 3980 void SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3982 LayerTreeImpl* tree_impl, | 3981 LayerTreeImpl* tree_impl, |
| 3983 const gfx::Size& inner_viewport_size, | 3982 const gfx::Size& inner_viewport_size, |
| 3984 const gfx::Size& outer_viewport_size, | 3983 const gfx::Size& outer_viewport_size, |
| 3985 const gfx::Size& scroll_layer_size) { | 3984 const gfx::Size& scroll_layer_size) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4376 // Top controls should be hidden | 4375 // Top controls should be hidden |
| 4377 EXPECT_EQ(scroll_delta.y(), | 4376 EXPECT_EQ(scroll_delta.y(), |
| 4378 top_controls_height_ - | 4377 top_controls_height_ - |
| 4379 host_impl_->top_controls_manager()->ContentTopOffset()); | 4378 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4380 } | 4379 } |
| 4381 | 4380 |
| 4382 // Ensure setting the top controls position explicitly using the setters on the | 4381 // Ensure setting the top controls position explicitly using the setters on the |
| 4383 // TreeImpl correctly affects the top controls manager and viewport bounds. | 4382 // TreeImpl correctly affects the top controls manager and viewport bounds. |
| 4384 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { | 4383 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
| 4385 settings_ = DefaultSettings(); | 4384 settings_ = DefaultSettings(); |
| 4386 CreateHostImpl(settings_, CreateOutputSurface()); | 4385 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4387 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4386 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4388 layer_size_, layer_size_, layer_size_); | 4387 layer_size_, layer_size_, layer_size_); |
| 4389 DrawFrame(); | 4388 DrawFrame(); |
| 4390 | 4389 |
| 4391 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4390 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4392 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4391 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4393 30.f / top_controls_height_); | 4392 30.f / top_controls_height_); |
| 4394 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4393 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4395 EXPECT_FLOAT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4394 EXPECT_FLOAT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4396 EXPECT_FLOAT_EQ(-20.f, | 4395 EXPECT_FLOAT_EQ(-20.f, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4409 ->parent->test_properties() | 4408 ->parent->test_properties() |
| 4410 ->parent; | 4409 ->parent; |
| 4411 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4410 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4412 } | 4411 } |
| 4413 | 4412 |
| 4414 // Test that the top_controls delta and sent delta are appropriately | 4413 // Test that the top_controls delta and sent delta are appropriately |
| 4415 // applied on sync tree activation. The total top controls offset shouldn't | 4414 // applied on sync tree activation. The total top controls offset shouldn't |
| 4416 // change after the activation. | 4415 // change after the activation. |
| 4417 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { | 4416 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
| 4418 settings_ = DefaultSettings(); | 4417 settings_ = DefaultSettings(); |
| 4419 CreateHostImpl(settings_, CreateOutputSurface()); | 4418 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4420 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4419 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4421 layer_size_, layer_size_, layer_size_); | 4420 layer_size_, layer_size_, layer_size_); |
| 4422 DrawFrame(); | 4421 DrawFrame(); |
| 4423 | 4422 |
| 4424 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4423 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4425 20.f / top_controls_height_); | 4424 20.f / top_controls_height_); |
| 4426 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4425 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4427 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( | 4426 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( |
| 4428 15.f / top_controls_height_); | 4427 15.f / top_controls_height_); |
| 4429 host_impl_->active_tree() | 4428 host_impl_->active_tree() |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4458 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * | 4457 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * |
| 4459 top_controls_height_); | 4458 top_controls_height_); |
| 4460 } | 4459 } |
| 4461 | 4460 |
| 4462 // Test that changing the top controls layout height is correctly applied to | 4461 // Test that changing the top controls layout height is correctly applied to |
| 4463 // the inner viewport container bounds. That is, the top controls layout | 4462 // the inner viewport container bounds. That is, the top controls layout |
| 4464 // height is the amount that the inner viewport container was shrunk outside | 4463 // height is the amount that the inner viewport container was shrunk outside |
| 4465 // the compositor to accommodate the top controls. | 4464 // the compositor to accommodate the top controls. |
| 4466 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { | 4465 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { |
| 4467 settings_ = DefaultSettings(); | 4466 settings_ = DefaultSettings(); |
| 4468 CreateHostImpl(settings_, CreateOutputSurface()); | 4467 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4469 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4468 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4470 layer_size_, layer_size_, layer_size_); | 4469 layer_size_, layer_size_, layer_size_); |
| 4471 DrawFrame(); | 4470 DrawFrame(); |
| 4472 | 4471 |
| 4473 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); | 4472 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); |
| 4474 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 4473 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 4475 | 4474 |
| 4476 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4475 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4477 1.f); | 4476 1.f); |
| 4478 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4477 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4690 EXPECT_FLOAT_EQ( | 4689 EXPECT_FLOAT_EQ( |
| 4691 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 4690 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 4692 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | 4691 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); |
| 4693 | 4692 |
| 4694 host_impl_->ScrollEnd(EndState().get()); | 4693 host_impl_->ScrollEnd(EndState().get()); |
| 4695 } | 4694 } |
| 4696 | 4695 |
| 4697 TEST_F(LayerTreeHostImplTopControlsTest, | 4696 TEST_F(LayerTreeHostImplTopControlsTest, |
| 4698 ScrollNonScrollableRootWithTopControls) { | 4697 ScrollNonScrollableRootWithTopControls) { |
| 4699 settings_ = DefaultSettings(); | 4698 settings_ = DefaultSettings(); |
| 4700 CreateHostImpl(settings_, CreateOutputSurface()); | 4699 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4701 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4700 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4702 layer_size_, layer_size_, layer_size_); | 4701 layer_size_, layer_size_, layer_size_); |
| 4703 DrawFrame(); | 4702 DrawFrame(); |
| 4704 | 4703 |
| 4705 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4704 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4706 host_impl_ | 4705 host_impl_ |
| 4707 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4706 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4708 InputHandler::TOUCHSCREEN) | 4707 InputHandler::TOUCHSCREEN) |
| 4709 .thread); | 4708 .thread); |
| 4710 | 4709 |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5953 // sees the correct size of the new tree. | 5952 // sees the correct size of the new tree. |
| 5954 gfx::Size new_size(42, 24); | 5953 gfx::Size new_size(42, 24); |
| 5955 host_impl_->CreatePendingTree(); | 5954 host_impl_->CreatePendingTree(); |
| 5956 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 5955 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 5957 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); | 5956 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); |
| 5958 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 5957 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 5959 host_impl_->ActivateSyncTree(); | 5958 host_impl_->ActivateSyncTree(); |
| 5960 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); | 5959 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); |
| 5961 | 5960 |
| 5962 // Tear down the LayerTreeHostImpl before the InputHandlerClient. | 5961 // Tear down the LayerTreeHostImpl before the InputHandlerClient. |
| 5963 host_impl_->ReleaseOutputSurface(); | 5962 host_impl_->ReleaseCompositorFrameSink(); |
| 5964 host_impl_ = nullptr; | 5963 host_impl_ = nullptr; |
| 5965 } | 5964 } |
| 5966 | 5965 |
| 5967 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { | 5966 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
| 5968 const gfx::Transform target_space_transform = | 5967 const gfx::Transform target_space_transform = |
| 5969 layer->draw_properties().target_space_transform; | 5968 layer->draw_properties().target_space_transform; |
| 5970 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); | 5969 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); |
| 5971 gfx::Point translated_point; | 5970 gfx::Point translated_point; |
| 5972 target_space_transform.TransformPoint(&translated_point); | 5971 target_space_transform.TransformPoint(&translated_point); |
| 5973 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); | 5972 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6248 EXPECT_FALSE(scroll_result.did_scroll); | 6247 EXPECT_FALSE(scroll_result.did_scroll); |
| 6249 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6248 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| 6250 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 6249 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
| 6251 host_impl_->ScrollEnd(EndState().get()); | 6250 host_impl_->ScrollEnd(EndState().get()); |
| 6252 } | 6251 } |
| 6253 } | 6252 } |
| 6254 | 6253 |
| 6255 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 6254 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 6256 InputHandlerScrollResult scroll_result; | 6255 InputHandlerScrollResult scroll_result; |
| 6257 LayerTreeSettings settings = DefaultSettings(); | 6256 LayerTreeSettings settings = DefaultSettings(); |
| 6258 CreateHostImpl(settings, CreateOutputSurface()); | 6257 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 6259 | 6258 |
| 6260 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 6259 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 6261 LayerImpl* clip_layer = | 6260 LayerImpl* clip_layer = |
| 6262 scroll_layer->test_properties()->parent->test_properties()->parent; | 6261 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 6263 | 6262 |
| 6264 clip_layer->SetBounds(gfx::Size(50, 50)); | 6263 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 6265 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6264 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6266 | 6265 |
| 6267 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6266 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6268 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6267 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6342 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6341 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6343 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6342 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 6344 host_impl_->accumulated_root_overscroll().ToString()); | 6343 host_impl_->accumulated_root_overscroll().ToString()); |
| 6345 host_impl_->ScrollEnd(EndState().get()); | 6344 host_impl_->ScrollEnd(EndState().get()); |
| 6346 } | 6345 } |
| 6347 } | 6346 } |
| 6348 | 6347 |
| 6349 TEST_F(LayerTreeHostImplTest, OverscrollOnMainThread) { | 6348 TEST_F(LayerTreeHostImplTest, OverscrollOnMainThread) { |
| 6350 InputHandlerScrollResult scroll_result; | 6349 InputHandlerScrollResult scroll_result; |
| 6351 LayerTreeSettings settings = DefaultSettings(); | 6350 LayerTreeSettings settings = DefaultSettings(); |
| 6352 CreateHostImpl(settings, CreateOutputSurface()); | 6351 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 6353 | 6352 |
| 6354 const gfx::Size content_size(50, 50); | 6353 const gfx::Size content_size(50, 50); |
| 6355 const gfx::Size viewport_size(50, 50); | 6354 const gfx::Size viewport_size(50, 50); |
| 6356 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 6355 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 6357 | 6356 |
| 6358 LayerImpl* scroll_layer = | 6357 LayerImpl* scroll_layer = |
| 6359 host_impl_->active_tree()->InnerViewportScrollLayer(); | 6358 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 6360 scroll_layer->set_main_thread_scrolling_reasons( | 6359 scroll_layer->set_main_thread_scrolling_reasons( |
| 6361 MainThreadScrollingReason::kThreadedScrollingDisabled); | 6360 MainThreadScrollingReason::kThreadedScrollingDisabled); |
| 6362 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6361 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6510 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), | 6509 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), |
| 6511 outer_scroll_layer->CurrentScrollOffset()); | 6510 outer_scroll_layer->CurrentScrollOffset()); |
| 6512 EXPECT_VECTOR_EQ(gfx::Vector2dF(50.f, 50.f), | 6511 EXPECT_VECTOR_EQ(gfx::Vector2dF(50.f, 50.f), |
| 6513 scroll_layer->CurrentScrollOffset()); | 6512 scroll_layer->CurrentScrollOffset()); |
| 6514 } | 6513 } |
| 6515 } | 6514 } |
| 6516 | 6515 |
| 6517 TEST_F(LayerTreeHostImplTest, OverscrollOnImplThread) { | 6516 TEST_F(LayerTreeHostImplTest, OverscrollOnImplThread) { |
| 6518 InputHandlerScrollResult scroll_result; | 6517 InputHandlerScrollResult scroll_result; |
| 6519 LayerTreeSettings settings = DefaultSettings(); | 6518 LayerTreeSettings settings = DefaultSettings(); |
| 6520 CreateHostImpl(settings, CreateOutputSurface()); | 6519 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 6521 | 6520 |
| 6522 const gfx::Size content_size(50, 50); | 6521 const gfx::Size content_size(50, 50); |
| 6523 const gfx::Size viewport_size(50, 50); | 6522 const gfx::Size viewport_size(50, 50); |
| 6524 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 6523 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 6525 | 6524 |
| 6526 // By default, no main thread scrolling reasons should exist. | 6525 // By default, no main thread scrolling reasons should exist. |
| 6527 LayerImpl* scroll_layer = | 6526 LayerImpl* scroll_layer = |
| 6528 host_impl_->active_tree()->InnerViewportScrollLayer(); | 6527 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 6529 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 6528 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 6530 scroll_layer->main_thread_scrolling_reasons()); | 6529 scroll_layer->main_thread_scrolling_reasons()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6931 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); | 6930 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6932 } | 6931 } |
| 6933 | 6932 |
| 6934 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6933 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 6935 protected: | 6934 protected: |
| 6936 LayerTreeHostImplViewportCoveredTest() : | 6935 LayerTreeHostImplViewportCoveredTest() : |
| 6937 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6936 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 6938 child_(NULL), | 6937 child_(NULL), |
| 6939 did_activate_pending_tree_(false) {} | 6938 did_activate_pending_tree_(false) {} |
| 6940 | 6939 |
| 6941 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6940 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( |
| 6941 bool software) { |
| 6942 if (software) | 6942 if (software) |
| 6943 return FakeOutputSurface::CreateDelegatingSoftware(); | 6943 return FakeCompositorFrameSink::CreateSoftware(); |
| 6944 return FakeOutputSurface::CreateDelegating3d(); | 6944 return FakeCompositorFrameSink::Create3d(); |
| 6945 } | 6945 } |
| 6946 | 6946 |
| 6947 void SetupActiveTreeLayers() { | 6947 void SetupActiveTreeLayers() { |
| 6948 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6948 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 6949 host_impl_->active_tree()->SetRootLayerForTesting( | 6949 host_impl_->active_tree()->SetRootLayerForTesting( |
| 6950 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6950 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 6951 host_impl_->active_tree() | 6951 host_impl_->active_tree() |
| 6952 ->root_layer_for_testing() | 6952 ->root_layer_for_testing() |
| 6953 ->test_properties() | 6953 ->test_properties() |
| 6954 ->force_render_surface = true; | 6954 ->force_render_surface = true; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7150 gfx::Size gutter_texture_size_; | 7150 gfx::Size gutter_texture_size_; |
| 7151 gfx::Size viewport_size_; | 7151 gfx::Size viewport_size_; |
| 7152 BlendStateCheckLayer* child_; | 7152 BlendStateCheckLayer* child_; |
| 7153 bool did_activate_pending_tree_; | 7153 bool did_activate_pending_tree_; |
| 7154 }; | 7154 }; |
| 7155 | 7155 |
| 7156 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCovered) { | 7156 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCovered) { |
| 7157 viewport_size_ = gfx::Size(1000, 1000); | 7157 viewport_size_ = gfx::Size(1000, 1000); |
| 7158 | 7158 |
| 7159 bool software = false; | 7159 bool software = false; |
| 7160 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); | 7160 CreateHostImpl(DefaultSettings(), CreateFakeCompositorFrameSink(software)); |
| 7161 | 7161 |
| 7162 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 7162 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
| 7163 SetupActiveTreeLayers(); | 7163 SetupActiveTreeLayers(); |
| 7164 EXPECT_SCOPED(TestLayerCoversFullViewport()); | 7164 EXPECT_SCOPED(TestLayerCoversFullViewport()); |
| 7165 EXPECT_SCOPED(TestEmptyLayer()); | 7165 EXPECT_SCOPED(TestEmptyLayer()); |
| 7166 EXPECT_SCOPED(TestLayerInMiddleOfViewport()); | 7166 EXPECT_SCOPED(TestLayerInMiddleOfViewport()); |
| 7167 EXPECT_SCOPED(TestLayerIsLargerThanViewport()); | 7167 EXPECT_SCOPED(TestLayerIsLargerThanViewport()); |
| 7168 } | 7168 } |
| 7169 | 7169 |
| 7170 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredScaled) { | 7170 TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredScaled) { |
| 7171 viewport_size_ = gfx::Size(1000, 1000); | 7171 viewport_size_ = gfx::Size(1000, 1000); |
| 7172 | 7172 |
| 7173 bool software = false; | 7173 bool software = false; |
| 7174 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); | 7174 CreateHostImpl(DefaultSettings(), CreateFakeCompositorFrameSink(software)); |
| 7175 | 7175 |
| 7176 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); | 7176 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); |
| 7177 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 7177 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
| 7178 SetupActiveTreeLayers(); | 7178 SetupActiveTreeLayers(); |
| 7179 EXPECT_SCOPED(TestLayerCoversFullViewport()); | 7179 EXPECT_SCOPED(TestLayerCoversFullViewport()); |
| 7180 EXPECT_SCOPED(TestEmptyLayer()); | 7180 EXPECT_SCOPED(TestEmptyLayer()); |
| 7181 EXPECT_SCOPED(TestLayerInMiddleOfViewport()); | 7181 EXPECT_SCOPED(TestLayerInMiddleOfViewport()); |
| 7182 EXPECT_SCOPED(TestLayerIsLargerThanViewport()); | 7182 EXPECT_SCOPED(TestLayerIsLargerThanViewport()); |
| 7183 } | 7183 } |
| 7184 | 7184 |
| 7185 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeGrowViewportInvalid) { | 7185 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeGrowViewportInvalid) { |
| 7186 viewport_size_ = gfx::Size(1000, 1000); | 7186 viewport_size_ = gfx::Size(1000, 1000); |
| 7187 | 7187 |
| 7188 bool software = true; | 7188 bool software = true; |
| 7189 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); | 7189 CreateHostImpl(DefaultSettings(), CreateFakeCompositorFrameSink(software)); |
| 7190 | 7190 |
| 7191 // Pending tree to force active_tree size invalid. Not used otherwise. | 7191 // Pending tree to force active_tree size invalid. Not used otherwise. |
| 7192 host_impl_->CreatePendingTree(); | 7192 host_impl_->CreatePendingTree(); |
| 7193 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 7193 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
| 7194 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); | 7194 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); |
| 7195 | 7195 |
| 7196 SetupActiveTreeLayers(); | 7196 SetupActiveTreeLayers(); |
| 7197 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); | 7197 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); |
| 7198 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); | 7198 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); |
| 7199 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); | 7199 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); |
| 7200 } | 7200 } |
| 7201 | 7201 |
| 7202 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeShrinkViewportInvalid) { | 7202 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeShrinkViewportInvalid) { |
| 7203 viewport_size_ = gfx::Size(1000, 1000); | 7203 viewport_size_ = gfx::Size(1000, 1000); |
| 7204 | 7204 |
| 7205 bool software = true; | 7205 bool software = true; |
| 7206 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); | 7206 CreateHostImpl(DefaultSettings(), CreateFakeCompositorFrameSink(software)); |
| 7207 | 7207 |
| 7208 // Set larger viewport and activate it to active tree. | 7208 // Set larger viewport and activate it to active tree. |
| 7209 host_impl_->CreatePendingTree(); | 7209 host_impl_->CreatePendingTree(); |
| 7210 gfx::Size larger_viewport(viewport_size_.width() + 100, | 7210 gfx::Size larger_viewport(viewport_size_.width() + 100, |
| 7211 viewport_size_.height() + 100); | 7211 viewport_size_.height() + 100); |
| 7212 host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport)); | 7212 host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport)); |
| 7213 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); | 7213 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); |
| 7214 host_impl_->ActivateSyncTree(); | 7214 host_impl_->ActivateSyncTree(); |
| 7215 EXPECT_TRUE(did_activate_pending_tree_); | 7215 EXPECT_TRUE(did_activate_pending_tree_); |
| 7216 EXPECT_FALSE(host_impl_->active_tree()->ViewportSizeInvalid()); | 7216 EXPECT_FALSE(host_impl_->active_tree()->ViewportSizeInvalid()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7237 }; | 7237 }; |
| 7238 | 7238 |
| 7239 // Make sure damage tracking propagates all the way to the graphics context, | 7239 // Make sure damage tracking propagates all the way to the graphics context, |
| 7240 // where it should request to swap only the sub-buffer that is damaged. | 7240 // where it should request to swap only the sub-buffer that is damaged. |
| 7241 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 7241 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
| 7242 scoped_refptr<TestContextProvider> context_provider( | 7242 scoped_refptr<TestContextProvider> context_provider( |
| 7243 TestContextProvider::Create()); | 7243 TestContextProvider::Create()); |
| 7244 context_provider->BindToCurrentThread(); | 7244 context_provider->BindToCurrentThread(); |
| 7245 context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 7245 context_provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 7246 | 7246 |
| 7247 std::unique_ptr<FakeOutputSurface> output_surface( | 7247 std::unique_ptr<FakeCompositorFrameSink> compositor_frame_sink( |
| 7248 FakeOutputSurface::CreateDelegating3d(context_provider)); | 7248 FakeCompositorFrameSink::Create3d(context_provider)); |
| 7249 FakeOutputSurface* fake_output_surface = output_surface.get(); | 7249 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 7250 compositor_frame_sink.get(); |
| 7250 | 7251 |
| 7251 // This test creates its own LayerTreeHostImpl, so | 7252 // This test creates its own LayerTreeHostImpl, so |
| 7252 // that we can force partial swap enabled. | 7253 // that we can force partial swap enabled. |
| 7253 LayerTreeSettings settings = DefaultSettings(); | 7254 LayerTreeSettings settings = DefaultSettings(); |
| 7254 settings.renderer_settings.partial_swap_enabled = true; | 7255 settings.renderer_settings.partial_swap_enabled = true; |
| 7255 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7256 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
| 7256 LayerTreeHostImpl::Create( | 7257 LayerTreeHostImpl::Create( |
| 7257 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7258 settings, this, &task_runner_provider_, &stats_instrumentation_, |
| 7258 &shared_bitmap_manager_, NULL, &task_graph_runner_, | 7259 &shared_bitmap_manager_, NULL, &task_graph_runner_, |
| 7259 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7260 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 7260 layer_tree_host_impl->SetVisible(true); | 7261 layer_tree_host_impl->SetVisible(true); |
| 7261 layer_tree_host_impl->InitializeRenderer(output_surface.get()); | 7262 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
| 7262 layer_tree_host_impl->WillBeginImplFrame( | 7263 layer_tree_host_impl->WillBeginImplFrame( |
| 7263 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7264 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
| 7264 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7265 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 7265 | 7266 |
| 7266 std::unique_ptr<LayerImpl> root = | 7267 std::unique_ptr<LayerImpl> root = |
| 7267 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7268 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 7268 root->test_properties()->force_render_surface = true; | 7269 root->test_properties()->force_render_surface = true; |
| 7269 std::unique_ptr<LayerImpl> child = | 7270 std::unique_ptr<LayerImpl> child = |
| 7270 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 7271 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 7271 child->SetPosition(gfx::PointF(12.f, 13.f)); | 7272 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 7272 child->SetBounds(gfx::Size(14, 15)); | 7273 child->SetBounds(gfx::Size(14, 15)); |
| 7273 child->SetDrawsContent(true); | 7274 child->SetDrawsContent(true); |
| 7274 root->SetBounds(gfx::Size(500, 500)); | 7275 root->SetBounds(gfx::Size(500, 500)); |
| 7275 root->SetDrawsContent(true); | 7276 root->SetDrawsContent(true); |
| 7276 root->test_properties()->AddChild(std::move(child)); | 7277 root->test_properties()->AddChild(std::move(child)); |
| 7277 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7278 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7278 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7279 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7279 | 7280 |
| 7280 LayerTreeHostImpl::FrameData frame; | 7281 LayerTreeHostImpl::FrameData frame; |
| 7281 | 7282 |
| 7282 // First frame, the entire screen should get swapped. | 7283 // First frame, the entire screen should get swapped. |
| 7283 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7284 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 7284 layer_tree_host_impl->DrawLayers(&frame); | 7285 layer_tree_host_impl->DrawLayers(&frame); |
| 7285 layer_tree_host_impl->DidDrawAllLayers(frame); | 7286 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 7286 gfx::Rect expected_swap_rect(500, 500); | 7287 gfx::Rect expected_swap_rect(500, 500); |
| 7287 EXPECT_EQ(expected_swap_rect.ToString(), | 7288 EXPECT_EQ(expected_swap_rect.ToString(), |
| 7288 fake_output_surface->last_swap_rect().ToString()); | 7289 fake_compositor_frame_sink->last_swap_rect().ToString()); |
| 7289 | 7290 |
| 7290 // Second frame, only the damaged area should get swapped. Damage should be | 7291 // Second frame, only the damaged area should get swapped. Damage should be |
| 7291 // the union of old and new child rects: gfx::Rect(26, 28). | 7292 // the union of old and new child rects: gfx::Rect(26, 28). |
| 7292 layer_tree_host_impl->active_tree() | 7293 layer_tree_host_impl->active_tree() |
| 7293 ->root_layer_for_testing() | 7294 ->root_layer_for_testing() |
| 7294 ->test_properties() | 7295 ->test_properties() |
| 7295 ->children[0] | 7296 ->children[0] |
| 7296 ->SetPosition(gfx::PointF()); | 7297 ->SetPosition(gfx::PointF()); |
| 7297 layer_tree_host_impl->active_tree() | 7298 layer_tree_host_impl->active_tree() |
| 7298 ->root_layer_for_testing() | 7299 ->root_layer_for_testing() |
| 7299 ->test_properties() | 7300 ->test_properties() |
| 7300 ->children[0] | 7301 ->children[0] |
| 7301 ->NoteLayerPropertyChanged(); | 7302 ->NoteLayerPropertyChanged(); |
| 7302 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7303 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7303 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7304 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 7304 layer_tree_host_impl->DrawLayers(&frame); | 7305 layer_tree_host_impl->DrawLayers(&frame); |
| 7305 host_impl_->DidDrawAllLayers(frame); | 7306 host_impl_->DidDrawAllLayers(frame); |
| 7306 | 7307 |
| 7307 expected_swap_rect = gfx::Rect(26, 28); | 7308 expected_swap_rect = gfx::Rect(26, 28); |
| 7308 EXPECT_EQ(expected_swap_rect.ToString(), | 7309 EXPECT_EQ(expected_swap_rect.ToString(), |
| 7309 fake_output_surface->last_swap_rect().ToString()); | 7310 fake_compositor_frame_sink->last_swap_rect().ToString()); |
| 7310 | 7311 |
| 7311 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 7312 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
| 7312 // This will damage everything. | 7313 // This will damage everything. |
| 7313 layer_tree_host_impl->active_tree() | 7314 layer_tree_host_impl->active_tree() |
| 7314 ->root_layer_for_testing() | 7315 ->root_layer_for_testing() |
| 7315 ->SetBackgroundColor(SK_ColorBLACK); | 7316 ->SetBackgroundColor(SK_ColorBLACK); |
| 7316 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7317 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 7317 layer_tree_host_impl->DrawLayers(&frame); | 7318 layer_tree_host_impl->DrawLayers(&frame); |
| 7318 host_impl_->DidDrawAllLayers(frame); | 7319 host_impl_->DidDrawAllLayers(frame); |
| 7319 | 7320 |
| 7320 expected_swap_rect = gfx::Rect(10, 10); | 7321 expected_swap_rect = gfx::Rect(10, 10); |
| 7321 EXPECT_EQ(expected_swap_rect.ToString(), | 7322 EXPECT_EQ(expected_swap_rect.ToString(), |
| 7322 fake_output_surface->last_swap_rect().ToString()); | 7323 fake_compositor_frame_sink->last_swap_rect().ToString()); |
| 7323 | 7324 |
| 7324 layer_tree_host_impl->ReleaseOutputSurface(); | 7325 layer_tree_host_impl->ReleaseCompositorFrameSink(); |
| 7325 } | 7326 } |
| 7326 | 7327 |
| 7327 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 7328 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 7328 std::unique_ptr<LayerImpl> root = | 7329 std::unique_ptr<LayerImpl> root = |
| 7329 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 7330 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7330 std::unique_ptr<LayerImpl> child = | 7331 std::unique_ptr<LayerImpl> child = |
| 7331 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 7332 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 7332 child->SetBounds(gfx::Size(10, 10)); | 7333 child->SetBounds(gfx::Size(10, 10)); |
| 7333 child->SetDrawsContent(true); | 7334 child->SetDrawsContent(true); |
| 7334 root->SetBounds(gfx::Size(10, 10)); | 7335 root->SetBounds(gfx::Size(10, 10)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7374 }; | 7375 }; |
| 7375 | 7376 |
| 7376 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7377 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 7377 LayerTreeSettings settings, | 7378 LayerTreeSettings settings, |
| 7378 bool partial_swap, | 7379 bool partial_swap, |
| 7379 LayerTreeHostImplClient* client, | 7380 LayerTreeHostImplClient* client, |
| 7380 TaskRunnerProvider* task_runner_provider, | 7381 TaskRunnerProvider* task_runner_provider, |
| 7381 SharedBitmapManager* manager, | 7382 SharedBitmapManager* manager, |
| 7382 TaskGraphRunner* task_graph_runner, | 7383 TaskGraphRunner* task_graph_runner, |
| 7383 RenderingStatsInstrumentation* stats_instrumentation, | 7384 RenderingStatsInstrumentation* stats_instrumentation, |
| 7384 OutputSurface* output_surface) { | 7385 CompositorFrameSink* compositor_frame_sink) { |
| 7385 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7386 settings.renderer_settings.partial_swap_enabled = partial_swap; |
| 7386 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7387 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
| 7387 settings, client, task_runner_provider, stats_instrumentation, manager, | 7388 settings, client, task_runner_provider, stats_instrumentation, manager, |
| 7388 nullptr, task_graph_runner, | 7389 nullptr, task_graph_runner, |
| 7389 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7390 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 7390 my_host_impl->SetVisible(true); | 7391 my_host_impl->SetVisible(true); |
| 7391 my_host_impl->InitializeRenderer(output_surface); | 7392 my_host_impl->InitializeRenderer(compositor_frame_sink); |
| 7392 my_host_impl->WillBeginImplFrame( | 7393 my_host_impl->WillBeginImplFrame( |
| 7393 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7394 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
| 7394 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7395 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
| 7395 | 7396 |
| 7396 /* | 7397 /* |
| 7397 Layers are created as follows: | 7398 Layers are created as follows: |
| 7398 | 7399 |
| 7399 +--------------------+ | 7400 +--------------------+ |
| 7400 | 1 | | 7401 | 1 | |
| 7401 | +-----------+ | | 7402 | +-----------+ | |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7447 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7448 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7448 return my_host_impl; | 7449 return my_host_impl; |
| 7449 } | 7450 } |
| 7450 | 7451 |
| 7451 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7452 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
| 7452 TestSharedBitmapManager shared_bitmap_manager; | 7453 TestSharedBitmapManager shared_bitmap_manager; |
| 7453 TestTaskGraphRunner task_graph_runner; | 7454 TestTaskGraphRunner task_graph_runner; |
| 7454 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7455 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 7455 provider->BindToCurrentThread(); | 7456 provider->BindToCurrentThread(); |
| 7456 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7457 provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 7457 std::unique_ptr<OutputSurface> output_surface( | 7458 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 7458 FakeOutputSurface::CreateDelegating3d(provider)); | 7459 FakeCompositorFrameSink::Create3d(provider)); |
| 7459 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7460 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
| 7460 DefaultSettings(), true, this, &task_runner_provider_, | 7461 DefaultSettings(), true, this, &task_runner_provider_, |
| 7461 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7462 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
| 7462 output_surface.get()); | 7463 compositor_frame_sink.get()); |
| 7463 { | 7464 { |
| 7464 LayerTreeHostImpl::FrameData frame; | 7465 LayerTreeHostImpl::FrameData frame; |
| 7465 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7466 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
| 7466 | 7467 |
| 7467 // Verify all quads have been computed | 7468 // Verify all quads have been computed |
| 7468 ASSERT_EQ(2U, frame.render_passes.size()); | 7469 ASSERT_EQ(2U, frame.render_passes.size()); |
| 7469 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7470 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 7470 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7471 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 7471 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7472 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 7472 frame.render_passes[0]->quad_list.front()->material); | 7473 frame.render_passes[0]->quad_list.front()->material); |
| 7473 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7474 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 7474 frame.render_passes[1]->quad_list.front()->material); | 7475 frame.render_passes[1]->quad_list.front()->material); |
| 7475 | 7476 |
| 7476 my_host_impl->DrawLayers(&frame); | 7477 my_host_impl->DrawLayers(&frame); |
| 7477 my_host_impl->DidDrawAllLayers(frame); | 7478 my_host_impl->DidDrawAllLayers(frame); |
| 7478 } | 7479 } |
| 7479 my_host_impl->ReleaseOutputSurface(); | 7480 my_host_impl->ReleaseCompositorFrameSink(); |
| 7480 } | 7481 } |
| 7481 | 7482 |
| 7482 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 7483 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 7483 TestSharedBitmapManager shared_bitmap_manager; | 7484 TestSharedBitmapManager shared_bitmap_manager; |
| 7484 TestTaskGraphRunner task_graph_runner; | 7485 TestTaskGraphRunner task_graph_runner; |
| 7485 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7486 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 7486 provider->BindToCurrentThread(); | 7487 provider->BindToCurrentThread(); |
| 7487 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7488 provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 7488 std::unique_ptr<OutputSurface> output_surface( | 7489 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 7489 FakeOutputSurface::CreateDelegating3d(provider)); | 7490 FakeCompositorFrameSink::Create3d(provider)); |
| 7490 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7491 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
| 7491 DefaultSettings(), false, this, &task_runner_provider_, | 7492 DefaultSettings(), false, this, &task_runner_provider_, |
| 7492 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7493 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
| 7493 output_surface.get()); | 7494 compositor_frame_sink.get()); |
| 7494 { | 7495 { |
| 7495 LayerTreeHostImpl::FrameData frame; | 7496 LayerTreeHostImpl::FrameData frame; |
| 7496 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7497 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
| 7497 | 7498 |
| 7498 // Verify all quads have been computed | 7499 // Verify all quads have been computed |
| 7499 ASSERT_EQ(2U, frame.render_passes.size()); | 7500 ASSERT_EQ(2U, frame.render_passes.size()); |
| 7500 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7501 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 7501 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7502 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 7502 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7503 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 7503 frame.render_passes[0]->quad_list.front()->material); | 7504 frame.render_passes[0]->quad_list.front()->material); |
| 7504 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7505 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 7505 frame.render_passes[1]->quad_list.front()->material); | 7506 frame.render_passes[1]->quad_list.front()->material); |
| 7506 | 7507 |
| 7507 my_host_impl->DrawLayers(&frame); | 7508 my_host_impl->DrawLayers(&frame); |
| 7508 my_host_impl->DidDrawAllLayers(frame); | 7509 my_host_impl->DidDrawAllLayers(frame); |
| 7509 } | 7510 } |
| 7510 my_host_impl->ReleaseOutputSurface(); | 7511 my_host_impl->ReleaseCompositorFrameSink(); |
| 7511 } | 7512 } |
| 7512 | 7513 |
| 7513 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 7514 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
| 7514 std::unique_ptr<TestWebGraphicsContext3D> context = | 7515 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 7515 TestWebGraphicsContext3D::Create(); | 7516 TestWebGraphicsContext3D::Create(); |
| 7516 TestWebGraphicsContext3D* context3d = context.get(); | 7517 TestWebGraphicsContext3D* context3d = context.get(); |
| 7517 std::unique_ptr<OutputSurface> output_surface( | 7518 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 7518 FakeOutputSurface::CreateDelegating3d(std::move(context))); | 7519 FakeCompositorFrameSink::Create3d(std::move(context))); |
| 7519 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7520 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 7520 | 7521 |
| 7521 std::unique_ptr<LayerImpl> root_layer = | 7522 std::unique_ptr<LayerImpl> root_layer = |
| 7522 LayerImpl::Create(host_impl_->active_tree(), 1); | 7523 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 7523 root_layer->SetBounds(gfx::Size(10, 10)); | 7524 root_layer->SetBounds(gfx::Size(10, 10)); |
| 7524 root_layer->test_properties()->force_render_surface = true; | 7525 root_layer->test_properties()->force_render_surface = true; |
| 7525 | 7526 |
| 7526 scoped_refptr<VideoFrame> softwareFrame = | 7527 scoped_refptr<VideoFrame> softwareFrame = |
| 7527 media::VideoFrame::CreateColorFrame( | 7528 media::VideoFrame::CreateColorFrame( |
| 7528 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7529 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 7529 FakeVideoFrameProvider provider; | 7530 FakeVideoFrameProvider provider; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7587 host_impl_->SetFullViewportDamage(); | 7588 host_impl_->SetFullViewportDamage(); |
| 7588 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7589 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7589 { | 7590 { |
| 7590 const auto& root_pass = frame.render_passes.back(); | 7591 const auto& root_pass = frame.render_passes.back(); |
| 7591 ASSERT_EQ(0u, root_pass->quad_list.size()); | 7592 ASSERT_EQ(0u, root_pass->quad_list.size()); |
| 7592 } | 7593 } |
| 7593 host_impl_->DrawLayers(&frame); | 7594 host_impl_->DrawLayers(&frame); |
| 7594 host_impl_->DidDrawAllLayers(frame); | 7595 host_impl_->DidDrawAllLayers(frame); |
| 7595 } | 7596 } |
| 7596 | 7597 |
| 7597 class LayerTreeHostImplTestWithDelegatingRenderer | 7598 class LayerTreeHostImplTestDrawAndTestDamage : public LayerTreeHostImplTest { |
| 7598 : public LayerTreeHostImplTest { | |
| 7599 protected: | 7599 protected: |
| 7600 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 7600 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
| 7601 return FakeOutputSurface::CreateDelegating3d(); | 7601 return FakeCompositorFrameSink::Create3d(); |
| 7602 } | 7602 } |
| 7603 | 7603 |
| 7604 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { | 7604 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { |
| 7605 bool expect_to_draw = !expected_damage.IsEmpty(); | 7605 bool expect_to_draw = !expected_damage.IsEmpty(); |
| 7606 | 7606 |
| 7607 LayerTreeHostImpl::FrameData frame; | 7607 LayerTreeHostImpl::FrameData frame; |
| 7608 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7608 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7609 | 7609 |
| 7610 if (!expect_to_draw) { | 7610 if (!expect_to_draw) { |
| 7611 // With no damage, we don't draw, and no quads are created. | 7611 // With no damage, we don't draw, and no quads are created. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 7633 gfx::Rect expected_root_visible_rect(root->bounds()); | 7633 gfx::Rect expected_root_visible_rect(root->bounds()); |
| 7634 EXPECT_EQ(expected_root_visible_rect, | 7634 EXPECT_EQ(expected_root_visible_rect, |
| 7635 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 7635 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
| 7636 } | 7636 } |
| 7637 | 7637 |
| 7638 EXPECT_EQ(expect_to_draw, host_impl_->DrawLayers(&frame)); | 7638 EXPECT_EQ(expect_to_draw, host_impl_->DrawLayers(&frame)); |
| 7639 host_impl_->DidDrawAllLayers(frame); | 7639 host_impl_->DidDrawAllLayers(frame); |
| 7640 } | 7640 } |
| 7641 }; | 7641 }; |
| 7642 | 7642 |
| 7643 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 7643 TEST_F(LayerTreeHostImplTestDrawAndTestDamage, FrameIncludesDamageRect) { |
| 7644 std::unique_ptr<SolidColorLayerImpl> root = | 7644 std::unique_ptr<SolidColorLayerImpl> root = |
| 7645 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7645 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7646 root->SetPosition(gfx::PointF()); | 7646 root->SetPosition(gfx::PointF()); |
| 7647 root->SetBounds(gfx::Size(10, 10)); | 7647 root->SetBounds(gfx::Size(10, 10)); |
| 7648 root->SetDrawsContent(true); | 7648 root->SetDrawsContent(true); |
| 7649 root->test_properties()->force_render_surface = true; | 7649 root->test_properties()->force_render_surface = true; |
| 7650 | 7650 |
| 7651 // Child layer is in the bottom right corner. | 7651 // Child layer is in the bottom right corner. |
| 7652 std::unique_ptr<SolidColorLayerImpl> child = | 7652 std::unique_ptr<SolidColorLayerImpl> child = |
| 7653 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7653 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7795 ++frames_ended_; | 7795 ++frames_ended_; |
| 7796 } | 7796 } |
| 7797 | 7797 |
| 7798 int frames_began_, frames_ended_; | 7798 int frames_began_, frames_ended_; |
| 7799 }; | 7799 }; |
| 7800 | 7800 |
| 7801 TEST_F(LayerTreeHostImplTest, | 7801 TEST_F(LayerTreeHostImplTest, |
| 7802 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 7802 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
| 7803 set_reduce_memory_result(false); | 7803 set_reduce_memory_result(false); |
| 7804 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), | 7804 EXPECT_TRUE(CreateHostImpl(DefaultSettings(), |
| 7805 FakeOutputSurface::CreateDelegatingSoftware())); | 7805 FakeCompositorFrameSink::CreateSoftware())); |
| 7806 | 7806 |
| 7807 const gfx::Transform external_transform; | 7807 const gfx::Transform external_transform; |
| 7808 const gfx::Rect external_viewport; | 7808 const gfx::Rect external_viewport; |
| 7809 const bool resourceless_software_draw = true; | 7809 const bool resourceless_software_draw = true; |
| 7810 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7810 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 7811 external_transform); | 7811 external_transform); |
| 7812 | 7812 |
| 7813 // SolidColorLayerImpl will be drawn. | 7813 // SolidColorLayerImpl will be drawn. |
| 7814 std::unique_ptr<SolidColorLayerImpl> root_layer = | 7814 std::unique_ptr<SolidColorLayerImpl> root_layer = |
| 7815 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7815 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7827 host_impl_->OnDraw(external_transform, external_viewport, | 7827 host_impl_->OnDraw(external_transform, external_viewport, |
| 7828 resourceless_software_draw); | 7828 resourceless_software_draw); |
| 7829 | 7829 |
| 7830 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7830 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
| 7831 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), | 7831 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), |
| 7832 last_on_draw_frame_->will_draw_layers[0]); | 7832 last_on_draw_frame_->will_draw_layers[0]); |
| 7833 } | 7833 } |
| 7834 | 7834 |
| 7835 // Checks that we use the memory limits provided. | 7835 // Checks that we use the memory limits provided. |
| 7836 TEST_F(LayerTreeHostImplTest, MemoryLimits) { | 7836 TEST_F(LayerTreeHostImplTest, MemoryLimits) { |
| 7837 host_impl_->ReleaseOutputSurface(); | 7837 host_impl_->ReleaseCompositorFrameSink(); |
| 7838 host_impl_ = nullptr; | 7838 host_impl_ = nullptr; |
| 7839 | 7839 |
| 7840 const size_t kGpuByteLimit = 1234321; | 7840 const size_t kGpuByteLimit = 1234321; |
| 7841 const size_t kSoftwareByteLimit = 4321234; | 7841 const size_t kSoftwareByteLimit = 4321234; |
| 7842 const size_t kGpuResourceLimit = 2345432; | 7842 const size_t kGpuResourceLimit = 2345432; |
| 7843 const size_t kSoftwareResourceLimit = 5432345; | 7843 const size_t kSoftwareResourceLimit = 5432345; |
| 7844 const gpu::MemoryAllocation::PriorityCutoff kGpuCutoff = | 7844 const gpu::MemoryAllocation::PriorityCutoff kGpuCutoff = |
| 7845 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; | 7845 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; |
| 7846 const gpu::MemoryAllocation::PriorityCutoff kSoftwareCutoff = | 7846 const gpu::MemoryAllocation::PriorityCutoff kSoftwareCutoff = |
| 7847 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 7847 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7861 settings.gpu_memory_policy = | 7861 settings.gpu_memory_policy = |
| 7862 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); | 7862 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit); |
| 7863 settings.software_memory_policy = ManagedMemoryPolicy( | 7863 settings.software_memory_policy = ManagedMemoryPolicy( |
| 7864 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); | 7864 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit); |
| 7865 host_impl_ = LayerTreeHostImpl::Create( | 7865 host_impl_ = LayerTreeHostImpl::Create( |
| 7866 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7866 settings, this, &task_runner_provider_, &stats_instrumentation_, |
| 7867 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 7867 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, |
| 7868 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7868 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 7869 | 7869 |
| 7870 // Gpu compositing. | 7870 // Gpu compositing. |
| 7871 output_surface_ = | 7871 compositor_frame_sink_ = |
| 7872 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); | 7872 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
| 7873 host_impl_->SetVisible(true); | 7873 host_impl_->SetVisible(true); |
| 7874 host_impl_->InitializeRenderer(output_surface_.get()); | 7874 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 7875 { | 7875 { |
| 7876 const auto& state = host_impl_->global_tile_state(); | 7876 const auto& state = host_impl_->global_tile_state(); |
| 7877 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); | 7877 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); |
| 7878 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); | 7878 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); |
| 7879 EXPECT_EQ(kGpuTileCutoff, state.memory_limit_policy); | 7879 EXPECT_EQ(kGpuTileCutoff, state.memory_limit_policy); |
| 7880 } | 7880 } |
| 7881 | 7881 |
| 7882 // Not visible, drops to 0. | 7882 // Not visible, drops to 0. |
| 7883 host_impl_->SetVisible(false); | 7883 host_impl_->SetVisible(false); |
| 7884 { | 7884 { |
| 7885 const auto& state = host_impl_->global_tile_state(); | 7885 const auto& state = host_impl_->global_tile_state(); |
| 7886 EXPECT_EQ(0u, state.hard_memory_limit_in_bytes); | 7886 EXPECT_EQ(0u, state.hard_memory_limit_in_bytes); |
| 7887 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); | 7887 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); |
| 7888 EXPECT_EQ(kNothingTileCutoff, state.memory_limit_policy); | 7888 EXPECT_EQ(kNothingTileCutoff, state.memory_limit_policy); |
| 7889 } | 7889 } |
| 7890 | 7890 |
| 7891 // Visible, is the gpu limit again. | 7891 // Visible, is the gpu limit again. |
| 7892 host_impl_->SetVisible(true); | 7892 host_impl_->SetVisible(true); |
| 7893 { | 7893 { |
| 7894 const auto& state = host_impl_->global_tile_state(); | 7894 const auto& state = host_impl_->global_tile_state(); |
| 7895 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); | 7895 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes); |
| 7896 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); | 7896 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit); |
| 7897 } | 7897 } |
| 7898 | 7898 |
| 7899 // Software compositing. | 7899 // Software compositing. |
| 7900 host_impl_->ReleaseOutputSurface(); | 7900 host_impl_->ReleaseCompositorFrameSink(); |
| 7901 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); | 7901 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 7902 host_impl_->InitializeRenderer(output_surface_.get()); | 7902 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 7903 { | 7903 { |
| 7904 const auto& state = host_impl_->global_tile_state(); | 7904 const auto& state = host_impl_->global_tile_state(); |
| 7905 EXPECT_EQ(kSoftwareByteLimit, state.hard_memory_limit_in_bytes); | 7905 EXPECT_EQ(kSoftwareByteLimit, state.hard_memory_limit_in_bytes); |
| 7906 EXPECT_EQ(kSoftwareResourceLimit, state.num_resources_limit); | 7906 EXPECT_EQ(kSoftwareResourceLimit, state.num_resources_limit); |
| 7907 EXPECT_EQ(kSoftwareTileCutoff, state.memory_limit_policy); | 7907 EXPECT_EQ(kSoftwareTileCutoff, state.memory_limit_policy); |
| 7908 } | 7908 } |
| 7909 | 7909 |
| 7910 // Not visible, drops to 0. | 7910 // Not visible, drops to 0. |
| 7911 host_impl_->SetVisible(false); | 7911 host_impl_->SetVisible(false); |
| 7912 { | 7912 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7976 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 7976 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 7977 } | 7977 } |
| 7978 | 7978 |
| 7979 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 7979 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
| 7980 public: | 7980 public: |
| 7981 void SetUp() override { | 7981 void SetUp() override { |
| 7982 fake_host_impl_ = | 7982 fake_host_impl_ = |
| 7983 new FakeLayerTreeHostImpl(LayerTreeSettings(), &task_runner_provider_, | 7983 new FakeLayerTreeHostImpl(LayerTreeSettings(), &task_runner_provider_, |
| 7984 &shared_bitmap_manager_, &task_graph_runner_); | 7984 &shared_bitmap_manager_, &task_graph_runner_); |
| 7985 host_impl_.reset(fake_host_impl_); | 7985 host_impl_.reset(fake_host_impl_); |
| 7986 output_surface_ = CreateOutputSurface(); | 7986 compositor_frame_sink_ = CreateCompositorFrameSink(); |
| 7987 host_impl_->SetVisible(true); | 7987 host_impl_->SetVisible(true); |
| 7988 host_impl_->InitializeRenderer(output_surface_.get()); | 7988 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 7989 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 7989 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 7990 } | 7990 } |
| 7991 | 7991 |
| 7992 FakeLayerTreeHostImpl* fake_host_impl_; | 7992 FakeLayerTreeHostImpl* fake_host_impl_; |
| 7993 }; | 7993 }; |
| 7994 | 7994 |
| 7995 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { | 7995 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { |
| 7996 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 7996 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
| 7997 host_impl_->SetVisible(false); | 7997 host_impl_->SetVisible(false); |
| 7998 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); | 7998 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); |
| 7999 host_impl_->SetVisible(true); | 7999 host_impl_->SetVisible(true); |
| 8000 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 8000 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
| 8001 } | 8001 } |
| 8002 | 8002 |
| 8003 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 8003 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 8004 std::unique_ptr<TestWebGraphicsContext3D> context = | 8004 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 8005 TestWebGraphicsContext3D::Create(); | 8005 TestWebGraphicsContext3D::Create(); |
| 8006 TestWebGraphicsContext3D* context3d = context.get(); | 8006 TestWebGraphicsContext3D* context3d = context.get(); |
| 8007 std::unique_ptr<FakeOutputSurface> output_surface = | 8007 std::unique_ptr<FakeCompositorFrameSink> compositor_frame_sink = |
| 8008 FakeOutputSurface::CreateDelegating3d(); | 8008 FakeCompositorFrameSink::Create3d(); |
| 8009 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 8009 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 8010 | 8010 |
| 8011 EXPECT_EQ(0u, context3d->NumTextures()); | 8011 EXPECT_EQ(0u, context3d->NumTextures()); |
| 8012 | 8012 |
| 8013 UIResourceId ui_resource_id = 1; | 8013 UIResourceId ui_resource_id = 1; |
| 8014 bool is_opaque = false; | 8014 bool is_opaque = false; |
| 8015 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 8015 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
| 8016 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 8016 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 8017 EXPECT_EQ(1u, context3d->NumTextures()); | 8017 EXPECT_EQ(1u, context3d->NumTextures()); |
| 8018 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 8018 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 8019 EXPECT_NE(0u, id1); | 8019 EXPECT_NE(0u, id1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 8041 | 8041 |
| 8042 // Should not change state for multiple deletion on one UIResourceId | 8042 // Should not change state for multiple deletion on one UIResourceId |
| 8043 host_impl_->DeleteUIResource(ui_resource_id); | 8043 host_impl_->DeleteUIResource(ui_resource_id); |
| 8044 EXPECT_EQ(0u, context3d->NumTextures()); | 8044 EXPECT_EQ(0u, context3d->NumTextures()); |
| 8045 } | 8045 } |
| 8046 | 8046 |
| 8047 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { | 8047 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { |
| 8048 std::unique_ptr<TestWebGraphicsContext3D> context = | 8048 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 8049 TestWebGraphicsContext3D::Create(); | 8049 TestWebGraphicsContext3D::Create(); |
| 8050 TestWebGraphicsContext3D* context3d = context.get(); | 8050 TestWebGraphicsContext3D* context3d = context.get(); |
| 8051 CreateHostImpl(DefaultSettings(), FakeOutputSurface::CreateDelegating3d()); | 8051 CreateHostImpl(DefaultSettings(), FakeCompositorFrameSink::Create3d()); |
| 8052 | 8052 |
| 8053 EXPECT_EQ(0u, context3d->NumTextures()); | 8053 EXPECT_EQ(0u, context3d->NumTextures()); |
| 8054 | 8054 |
| 8055 gfx::Size size(4, 4); | 8055 gfx::Size size(4, 4); |
| 8056 // SkImageInfo has no support for ETC1. The |info| below contains the right | 8056 // SkImageInfo has no support for ETC1. The |info| below contains the right |
| 8057 // total pixel size for the bitmap but not the right height and width. The | 8057 // total pixel size for the bitmap but not the right height and width. The |
| 8058 // correct width/height are passed directly to UIResourceBitmap. | 8058 // correct width/height are passed directly to UIResourceBitmap. |
| 8059 SkImageInfo info = | 8059 SkImageInfo info = |
| 8060 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); | 8060 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); |
| 8061 sk_sp<SkPixelRef> pixel_ref(SkMallocPixelRef::NewAllocate(info, 0, 0)); | 8061 sk_sp<SkPixelRef> pixel_ref(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
| 8062 pixel_ref->setImmutable(); | 8062 pixel_ref->setImmutable(); |
| 8063 UIResourceBitmap bitmap(std::move(pixel_ref), size); | 8063 UIResourceBitmap bitmap(std::move(pixel_ref), size); |
| 8064 UIResourceId ui_resource_id = 1; | 8064 UIResourceId ui_resource_id = 1; |
| 8065 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 8065 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 8066 EXPECT_EQ(1u, context3d->NumTextures()); | 8066 EXPECT_EQ(1u, context3d->NumTextures()); |
| 8067 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 8067 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 8068 EXPECT_NE(0u, id1); | 8068 EXPECT_NE(0u, id1); |
| 8069 } | 8069 } |
| 8070 | 8070 |
| 8071 void ShutdownReleasesContext_Callback( | 8071 void ShutdownReleasesContext_Callback( |
| 8072 std::unique_ptr<CopyOutputResult> result) {} | 8072 std::unique_ptr<CopyOutputResult> result) {} |
| 8073 | 8073 |
| 8074 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8074 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 8075 scoped_refptr<TestContextProvider> context_provider = | 8075 scoped_refptr<TestContextProvider> context_provider = |
| 8076 TestContextProvider::Create(); | 8076 TestContextProvider::Create(); |
| 8077 | 8077 |
| 8078 CreateHostImpl( | 8078 CreateHostImpl( |
| 8079 DefaultSettings(), | 8079 DefaultSettings(), |
| 8080 base::MakeUnique<TestDelegatingOutputSurface>( | 8080 base::MakeUnique<TestCompositorFrameSink>( |
| 8081 context_provider, TestContextProvider::CreateWorker(), | 8081 context_provider, TestContextProvider::CreateWorker(), |
| 8082 FakeOutputSurface::Create3d(context_provider), nullptr, nullptr, | 8082 FakeOutputSurface::Create3d(context_provider), nullptr, nullptr, |
| 8083 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8083 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
| 8084 true /* synchronous_composite */, | 8084 true /* synchronous_composite */, |
| 8085 false /* force_disable_reclaim_resources */)); | 8085 false /* force_disable_reclaim_resources */)); |
| 8086 | 8086 |
| 8087 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8087 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 8088 | 8088 |
| 8089 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8089 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 8090 root->test_properties()->copy_requests.push_back( | 8090 root->test_properties()->copy_requests.push_back( |
| 8091 CopyOutputRequest::CreateRequest( | 8091 CopyOutputRequest::CreateRequest( |
| 8092 base::Bind(&ShutdownReleasesContext_Callback))); | 8092 base::Bind(&ShutdownReleasesContext_Callback))); |
| 8093 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8093 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8094 | 8094 |
| 8095 LayerTreeHostImpl::FrameData frame; | 8095 LayerTreeHostImpl::FrameData frame; |
| 8096 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 8096 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8097 host_impl_->DrawLayers(&frame); | 8097 host_impl_->DrawLayers(&frame); |
| 8098 host_impl_->DidDrawAllLayers(frame); | 8098 host_impl_->DidDrawAllLayers(frame); |
| 8099 | 8099 |
| 8100 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 8100 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
| 8101 // texture in a texture mailbox. | 8101 // texture in a texture mailbox. |
| 8102 EXPECT_FALSE(context_provider->HasOneRef()); | 8102 EXPECT_FALSE(context_provider->HasOneRef()); |
| 8103 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 8103 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
| 8104 | 8104 |
| 8105 host_impl_->ReleaseOutputSurface(); | 8105 host_impl_->ReleaseCompositorFrameSink(); |
| 8106 host_impl_ = nullptr; | 8106 host_impl_ = nullptr; |
| 8107 | 8107 |
| 8108 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 8108 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
| 8109 // released, and the texture deleted. | 8109 // released, and the texture deleted. |
| 8110 EXPECT_TRUE(context_provider->HasOneRef()); | 8110 EXPECT_TRUE(context_provider->HasOneRef()); |
| 8111 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 8111 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 8112 } | 8112 } |
| 8113 | 8113 |
| 8114 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 8114 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 8115 // When flinging via touch, only the child should scroll (we should not | 8115 // When flinging via touch, only the child should scroll (we should not |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8526 std::unique_ptr<SolidColorLayerImpl> root = | 8526 std::unique_ptr<SolidColorLayerImpl> root = |
| 8527 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8527 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 8528 root->SetPosition(gfx::PointF()); | 8528 root->SetPosition(gfx::PointF()); |
| 8529 root->SetBounds(gfx::Size(10, 10)); | 8529 root->SetBounds(gfx::Size(10, 10)); |
| 8530 root->SetDrawsContent(true); | 8530 root->SetDrawsContent(true); |
| 8531 root->test_properties()->force_render_surface = true; | 8531 root->test_properties()->force_render_surface = true; |
| 8532 | 8532 |
| 8533 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8533 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8534 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8534 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8535 | 8535 |
| 8536 FakeOutputSurface* fake_output_surface = | 8536 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 8537 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8537 static_cast<FakeCompositorFrameSink*>( |
| 8538 host_impl_->compositor_frame_sink()); |
| 8538 | 8539 |
| 8539 ui::LatencyInfo latency_info; | 8540 ui::LatencyInfo latency_info; |
| 8540 latency_info.AddLatencyNumber( | 8541 latency_info.AddLatencyNumber( |
| 8541 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8542 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
| 8542 std::unique_ptr<SwapPromise> swap_promise( | 8543 std::unique_ptr<SwapPromise> swap_promise( |
| 8543 new LatencyInfoSwapPromise(latency_info)); | 8544 new LatencyInfoSwapPromise(latency_info)); |
| 8544 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8545 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
| 8545 | 8546 |
| 8546 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8547 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 8547 LayerTreeHostImpl::FrameData frame; | 8548 LayerTreeHostImpl::FrameData frame; |
| 8548 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 8549 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8549 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); | 8550 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); |
| 8550 host_impl_->DidDrawAllLayers(frame); | 8551 host_impl_->DidDrawAllLayers(frame); |
| 8551 | 8552 |
| 8552 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 8553 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
| 8553 fake_output_surface->last_sent_frame()->metadata.latency_info; | 8554 fake_compositor_frame_sink->last_sent_frame()->metadata.latency_info; |
| 8554 EXPECT_EQ(1u, metadata_latency_after.size()); | 8555 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 8555 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8556 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 8556 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8557 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 8557 } | 8558 } |
| 8558 | 8559 |
| 8559 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8560 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 8560 int root_layer_id = 1; | 8561 int root_layer_id = 1; |
| 8561 std::unique_ptr<SolidColorLayerImpl> root = | 8562 std::unique_ptr<SolidColorLayerImpl> root = |
| 8562 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8563 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 8563 root->SetPosition(gfx::PointF()); | 8564 root->SetPosition(gfx::PointF()); |
| 8564 root->SetBounds(gfx::Size(10, 10)); | 8565 root->SetBounds(gfx::Size(10, 10)); |
| 8565 root->SetDrawsContent(true); | 8566 root->SetDrawsContent(true); |
| 8566 root->test_properties()->force_render_surface = true; | 8567 root->test_properties()->force_render_surface = true; |
| 8567 | 8568 |
| 8568 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8569 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8569 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8570 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8570 | 8571 |
| 8571 // Ensure the default frame selection bounds are empty. | 8572 // Ensure the default frame selection bounds are empty. |
| 8572 FakeOutputSurface* fake_output_surface = | 8573 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 8573 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8574 static_cast<FakeCompositorFrameSink*>( |
| 8575 host_impl_->compositor_frame_sink()); |
| 8574 | 8576 |
| 8575 // Plumb the layer-local selection bounds. | 8577 // Plumb the layer-local selection bounds. |
| 8576 gfx::Point selection_top(5, 0); | 8578 gfx::Point selection_top(5, 0); |
| 8577 gfx::Point selection_bottom(5, 5); | 8579 gfx::Point selection_bottom(5, 5); |
| 8578 LayerSelection selection; | 8580 LayerSelection selection; |
| 8579 selection.start.type = gfx::SelectionBound::CENTER; | 8581 selection.start.type = gfx::SelectionBound::CENTER; |
| 8580 selection.start.layer_id = root_layer_id; | 8582 selection.start.layer_id = root_layer_id; |
| 8581 selection.start.edge_bottom = selection_bottom; | 8583 selection.start.edge_bottom = selection_bottom; |
| 8582 selection.start.edge_top = selection_top; | 8584 selection.start.edge_top = selection_top; |
| 8583 selection.end = selection.start; | 8585 selection.end = selection.start; |
| 8584 host_impl_->active_tree()->RegisterSelection(selection); | 8586 host_impl_->active_tree()->RegisterSelection(selection); |
| 8585 | 8587 |
| 8586 // Trigger a draw-swap sequence. | 8588 // Trigger a draw-swap sequence. |
| 8587 host_impl_->SetNeedsRedraw(); | 8589 host_impl_->SetNeedsRedraw(); |
| 8588 | 8590 |
| 8589 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8591 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 8590 LayerTreeHostImpl::FrameData frame; | 8592 LayerTreeHostImpl::FrameData frame; |
| 8591 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 8593 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8592 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); | 8594 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); |
| 8593 host_impl_->DidDrawAllLayers(frame); | 8595 host_impl_->DidDrawAllLayers(frame); |
| 8594 | 8596 |
| 8595 // Ensure the selection bounds have propagated to the frame metadata. | 8597 // Ensure the selection bounds have propagated to the frame metadata. |
| 8596 const Selection<gfx::SelectionBound>& selection_after = | 8598 const Selection<gfx::SelectionBound>& selection_after = |
| 8597 fake_output_surface->last_sent_frame()->metadata.selection; | 8599 fake_compositor_frame_sink->last_sent_frame()->metadata.selection; |
| 8598 EXPECT_EQ(selection.start.type, selection_after.start.type()); | 8600 EXPECT_EQ(selection.start.type, selection_after.start.type()); |
| 8599 EXPECT_EQ(selection.end.type, selection_after.end.type()); | 8601 EXPECT_EQ(selection.end.type, selection_after.end.type()); |
| 8600 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); | 8602 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); |
| 8601 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); | 8603 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); |
| 8602 EXPECT_TRUE(selection_after.start.visible()); | 8604 EXPECT_TRUE(selection_after.start.visible()); |
| 8603 EXPECT_TRUE(selection_after.start.visible()); | 8605 EXPECT_TRUE(selection_after.start.visible()); |
| 8604 } | 8606 } |
| 8605 | 8607 |
| 8606 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 8608 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
| 8607 public: | 8609 public: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8720 EXPECT_EQ(0, set_needs_commit_count); | 8722 EXPECT_EQ(0, set_needs_commit_count); |
| 8721 EXPECT_EQ(2, set_needs_redraw_count); | 8723 EXPECT_EQ(2, set_needs_redraw_count); |
| 8722 EXPECT_EQ(1, forward_to_main_count); | 8724 EXPECT_EQ(1, forward_to_main_count); |
| 8723 } | 8725 } |
| 8724 } | 8726 } |
| 8725 | 8727 |
| 8726 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 8728 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
| 8727 public: | 8729 public: |
| 8728 void SetUp() override { | 8730 void SetUp() override { |
| 8729 LayerTreeSettings settings = DefaultSettings(); | 8731 LayerTreeSettings settings = DefaultSettings(); |
| 8730 CreateHostImpl(settings, CreateOutputSurface()); | 8732 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 8731 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 8733 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 8732 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 8734 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 8733 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 8735 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 8734 } | 8736 } |
| 8735 | 8737 |
| 8736 protected: | 8738 protected: |
| 8737 static const int top_controls_height_; | 8739 static const int top_controls_height_; |
| 8738 }; | 8740 }; |
| 8739 | 8741 |
| 8740 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 8742 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9631 // When inner viewport is unscrollable, a fling gives zero overscroll. | 9633 // When inner viewport is unscrollable, a fling gives zero overscroll. |
| 9632 EXPECT_FALSE(scroll_result.did_overscroll_root); | 9634 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 9633 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 9635 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 9634 } | 9636 } |
| 9635 | 9637 |
| 9636 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { | 9638 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { |
| 9637 public: | 9639 public: |
| 9638 void SetUp() override { | 9640 void SetUp() override { |
| 9639 LayerTreeSettings settings = DefaultSettings(); | 9641 LayerTreeSettings settings = DefaultSettings(); |
| 9640 settings.max_memory_for_prepaint_percentage = 50; | 9642 settings.max_memory_for_prepaint_percentage = 50; |
| 9641 CreateHostImpl(settings, CreateOutputSurface()); | 9643 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 9642 } | 9644 } |
| 9643 }; | 9645 }; |
| 9644 | 9646 |
| 9645 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { | 9647 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { |
| 9646 // Set up a memory policy and percentages which could cause | 9648 // Set up a memory policy and percentages which could cause |
| 9647 // 32-bit integer overflows. | 9649 // 32-bit integer overflows. |
| 9648 ManagedMemoryPolicy mem_policy(300 * 1024 * 1024); // 300MB | 9650 ManagedMemoryPolicy mem_policy(300 * 1024 * 1024); // 300MB |
| 9649 | 9651 |
| 9650 // Verify implicit limits are calculated correctly with no overflows | 9652 // Verify implicit limits are calculated correctly with no overflows |
| 9651 host_impl_->SetMemoryPolicy(mem_policy); | 9653 host_impl_->SetMemoryPolicy(mem_policy); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9736 // Different draw params does swap. | 9738 // Different draw params does swap. |
| 9737 did_request_redraw_ = false; | 9739 did_request_redraw_ = false; |
| 9738 host_impl_->OnDraw(draw_transform, draw_viewport2, | 9740 host_impl_->OnDraw(draw_transform, draw_viewport2, |
| 9739 resourceless_software_draw); | 9741 resourceless_software_draw); |
| 9740 EXPECT_TRUE(did_request_redraw_); | 9742 EXPECT_TRUE(did_request_redraw_); |
| 9741 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9743 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
| 9742 } | 9744 } |
| 9743 | 9745 |
| 9744 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 9746 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| 9745 protected: | 9747 protected: |
| 9746 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 9748 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
| 9747 return FakeOutputSurface::CreateDelegating3d(); | 9749 return FakeCompositorFrameSink::Create3d(); |
| 9748 } | 9750 } |
| 9749 }; | 9751 }; |
| 9750 | 9752 |
| 9751 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9753 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
| 9752 ResourcelessSoftwareSetNeedsRedraw) { | 9754 ResourcelessSoftwareSetNeedsRedraw) { |
| 9753 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9755 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9754 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9756 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9755 | 9757 |
| 9756 const gfx::Size viewport_size(100, 100); | 9758 const gfx::Size viewport_size(100, 100); |
| 9757 host_impl_->SetViewportSize(viewport_size); | 9759 host_impl_->SetViewportSize(viewport_size); |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10732 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 10734 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 10733 host_impl_->ScrollEnd(EndState().get()); | 10735 host_impl_->ScrollEnd(EndState().get()); |
| 10734 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 10736 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 10735 scroll_layer->CurrentScrollOffset()); | 10737 scroll_layer->CurrentScrollOffset()); |
| 10736 } | 10738 } |
| 10737 } | 10739 } |
| 10738 | 10740 |
| 10739 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 10741 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
| 10740 public: | 10742 public: |
| 10741 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 10743 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
| 10742 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } | 10744 void DidLoseCompositorFrameSinkOnImplThread() override { |
| 10745 num_lost_surfaces_++; |
| 10746 } |
| 10743 | 10747 |
| 10744 protected: | 10748 protected: |
| 10745 int num_lost_surfaces_; | 10749 int num_lost_surfaces_; |
| 10746 }; | 10750 }; |
| 10747 | 10751 |
| 10748 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { | 10752 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { |
| 10749 // Really we just need at least one client notification each time | 10753 // Really we just need at least one client notification each time |
| 10750 // we go from having a valid output surface to not having a valid output | 10754 // we go from having a valid output surface to not having a valid output |
| 10751 // surface. | 10755 // surface. |
| 10752 EXPECT_EQ(0, num_lost_surfaces_); | 10756 EXPECT_EQ(0, num_lost_surfaces_); |
| 10753 host_impl_->DidLoseOutputSurface(); | 10757 host_impl_->DidLoseCompositorFrameSink(); |
| 10754 EXPECT_EQ(1, num_lost_surfaces_); | 10758 EXPECT_EQ(1, num_lost_surfaces_); |
| 10755 host_impl_->DidLoseOutputSurface(); | 10759 host_impl_->DidLoseCompositorFrameSink(); |
| 10756 EXPECT_LE(1, num_lost_surfaces_); | 10760 EXPECT_LE(1, num_lost_surfaces_); |
| 10757 } | 10761 } |
| 10758 | 10762 |
| 10759 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { | 10763 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { |
| 10760 return std::count_if( | 10764 return std::count_if( |
| 10761 list.begin(), list.end(), | 10765 list.begin(), list.end(), |
| 10762 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); | 10766 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); |
| 10763 } | 10767 } |
| 10764 | 10768 |
| 10765 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { | 10769 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10980 host_impl_->gpu_rasterization_status()); | 10984 host_impl_->gpu_rasterization_status()); |
| 10981 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10985 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10982 EXPECT_FALSE(host_impl_->use_msaa()); | 10986 EXPECT_FALSE(host_impl_->use_msaa()); |
| 10983 | 10987 |
| 10984 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 10988 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
| 10985 TestWebGraphicsContext3D::Create(); | 10989 TestWebGraphicsContext3D::Create(); |
| 10986 context_with_msaa->SetMaxSamples(8); | 10990 context_with_msaa->SetMaxSamples(8); |
| 10987 | 10991 |
| 10988 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 10992 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
| 10989 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 10993 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
| 10990 EXPECT_TRUE(CreateHostImpl( | 10994 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( |
| 10991 msaaSettings, | 10995 std::move(context_with_msaa)))); |
| 10992 FakeOutputSurface::CreateDelegating3d(std::move(context_with_msaa)))); | |
| 10993 host_impl_->SetHasGpuRasterizationTrigger(true); | 10996 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 10994 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10997 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 10995 host_impl_->CommitComplete(); | 10998 host_impl_->CommitComplete(); |
| 10996 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 10999 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
| 10997 host_impl_->gpu_rasterization_status()); | 11000 host_impl_->gpu_rasterization_status()); |
| 10998 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11001 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 10999 EXPECT_TRUE(host_impl_->use_msaa()); | 11002 EXPECT_TRUE(host_impl_->use_msaa()); |
| 11000 | 11003 |
| 11001 LayerTreeSettings settings = DefaultSettings(); | 11004 LayerTreeSettings settings = DefaultSettings(); |
| 11002 settings.gpu_rasterization_enabled = false; | 11005 settings.gpu_rasterization_enabled = false; |
| 11003 EXPECT_TRUE( | 11006 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); |
| 11004 CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d())); | |
| 11005 host_impl_->SetHasGpuRasterizationTrigger(true); | 11007 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 11006 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 11008 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
| 11007 host_impl_->CommitComplete(); | 11009 host_impl_->CommitComplete(); |
| 11008 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, | 11010 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, |
| 11009 host_impl_->gpu_rasterization_status()); | 11011 host_impl_->gpu_rasterization_status()); |
| 11010 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11012 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11011 | 11013 |
| 11012 settings.gpu_rasterization_forced = true; | 11014 settings.gpu_rasterization_forced = true; |
| 11013 EXPECT_TRUE( | 11015 EXPECT_TRUE(CreateHostImpl(settings, FakeCompositorFrameSink::Create3d())); |
| 11014 CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d())); | |
| 11015 | 11016 |
| 11016 host_impl_->SetHasGpuRasterizationTrigger(false); | 11017 host_impl_->SetHasGpuRasterizationTrigger(false); |
| 11017 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11018 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 11018 host_impl_->CommitComplete(); | 11019 host_impl_->CommitComplete(); |
| 11019 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 11020 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
| 11020 host_impl_->gpu_rasterization_status()); | 11021 host_impl_->gpu_rasterization_status()); |
| 11021 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11022 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11022 } | 11023 } |
| 11023 | 11024 |
| 11024 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { | 11025 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| 11025 public: | 11026 public: |
| 11026 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { | 11027 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { |
| 11027 LayerTreeSettings settings = DefaultSettings(); | 11028 LayerTreeSettings settings = DefaultSettings(); |
| 11028 settings.gpu_rasterization_enabled = true; | 11029 settings.gpu_rasterization_enabled = true; |
| 11029 settings.gpu_rasterization_msaa_sample_count = 4; | 11030 settings.gpu_rasterization_msaa_sample_count = 4; |
| 11030 auto context_provider = TestContextProvider::Create(); | 11031 auto context_provider = TestContextProvider::Create(); |
| 11031 context_provider->UnboundTestContext3d()->SetMaxSamples(4); | 11032 context_provider->UnboundTestContext3d()->SetMaxSamples(4); |
| 11032 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); | 11033 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); |
| 11033 auto msaa_is_normal_output_surface = | 11034 auto msaa_is_normal_compositor_frame_sink = |
| 11034 FakeOutputSurface::CreateDelegating3d(context_provider); | 11035 FakeCompositorFrameSink::Create3d(context_provider); |
| 11035 EXPECT_TRUE( | 11036 EXPECT_TRUE(CreateHostImpl( |
| 11036 CreateHostImpl(settings, std::move(msaa_is_normal_output_surface))); | 11037 settings, std::move(msaa_is_normal_compositor_frame_sink))); |
| 11037 } | 11038 } |
| 11038 }; | 11039 }; |
| 11039 | 11040 |
| 11040 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { | 11041 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { |
| 11041 // Ensure that without the msaa_is_slow cap we raster unsuitable content with | 11042 // Ensure that without the msaa_is_slow cap we raster unsuitable content with |
| 11042 // msaa. | 11043 // msaa. |
| 11043 CreateHostImplWithMsaaIsSlow(false); | 11044 CreateHostImplWithMsaaIsSlow(false); |
| 11044 host_impl_->SetHasGpuRasterizationTrigger(true); | 11045 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 11045 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11046 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 11046 host_impl_->CommitComplete(); | 11047 host_impl_->CommitComplete(); |
| 11047 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 11048 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
| 11048 host_impl_->gpu_rasterization_status()); | 11049 host_impl_->gpu_rasterization_status()); |
| 11049 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11050 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11050 | 11051 |
| 11051 // Ensure that with the msaa_is_slow cap we don't raster unsuitable content | 11052 // Ensure that with the msaa_is_slow cap we don't raster unsuitable content |
| 11052 // with msaa. | 11053 // with msaa. |
| 11053 CreateHostImplWithMsaaIsSlow(true); | 11054 CreateHostImplWithMsaaIsSlow(true); |
| 11054 host_impl_->SetHasGpuRasterizationTrigger(true); | 11055 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 11055 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11056 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 11056 host_impl_->CommitComplete(); | 11057 host_impl_->CommitComplete(); |
| 11057 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11058 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
| 11058 host_impl_->gpu_rasterization_status()); | 11059 host_impl_->gpu_rasterization_status()); |
| 11059 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11060 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11060 } | 11061 } |
| 11061 | 11062 |
| 11062 // A mock output surface which lets us detect calls to ForceReclaimResources. | 11063 // A mock output surface which lets us detect calls to ForceReclaimResources. |
| 11063 class MockReclaimResourcesOutputSurface : public FakeOutputSurface { | 11064 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { |
| 11064 public: | 11065 public: |
| 11065 MockReclaimResourcesOutputSurface() | 11066 MockReclaimResourcesCompositorFrameSink() |
| 11066 : FakeOutputSurface(TestContextProvider::Create(), | 11067 : FakeCompositorFrameSink(TestContextProvider::Create(), |
| 11067 TestContextProvider::CreateWorker(), | 11068 TestContextProvider::CreateWorker(), |
| 11068 true) {} | 11069 true) {} |
| 11069 | 11070 |
| 11070 MOCK_METHOD0(ForceReclaimResources, void()); | 11071 MOCK_METHOD0(ForceReclaimResources, void()); |
| 11071 }; | 11072 }; |
| 11072 | 11073 |
| 11073 // Display::Draw (and the planned Display Scheduler) currently rely on resources | 11074 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
| 11074 // being reclaimed to block drawing between BeginCommit / Swap. This test | 11075 // being reclaimed to block drawing between BeginCommit / Swap. This test |
| 11075 // ensures that BeginCommit triggers ForceReclaimResources. See | 11076 // ensures that BeginCommit triggers ForceReclaimResources. See |
| 11076 // crbug.com/489515. | 11077 // crbug.com/489515. |
| 11077 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | 11078 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
| 11078 auto output_surface = base::MakeUnique<MockReclaimResourcesOutputSurface>(); | 11079 auto compositor_frame_sink = |
| 11080 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>(); |
| 11079 // Hold an unowned pointer to the output surface to use for mock expectations. | 11081 // Hold an unowned pointer to the output surface to use for mock expectations. |
| 11080 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 11082 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink = |
| 11083 compositor_frame_sink.get(); |
| 11081 | 11084 |
| 11082 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 11085 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 11083 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 11086 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); |
| 11084 host_impl_->BeginCommit(); | 11087 host_impl_->BeginCommit(); |
| 11085 } | 11088 } |
| 11086 | 11089 |
| 11087 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11090 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
| 11088 // Check page scale factor update in property trees when an update is made | 11091 // Check page scale factor update in property trees when an update is made |
| 11089 // on the active tree. | 11092 // on the active tree. |
| 11090 host_impl_->CreatePendingTree(); | 11093 host_impl_->CreatePendingTree(); |
| 11091 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11094 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 11092 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11095 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 11093 gfx::Size(100, 100)); | 11096 gfx::Size(100, 100)); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11219 pending_tree->UpdateDrawProperties(false); | 11222 pending_tree->UpdateDrawProperties(false); |
| 11220 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); | 11223 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); |
| 11221 // There should not be any jitter measured till we hit the fixed point hits | 11224 // There should not be any jitter measured till we hit the fixed point hits |
| 11222 // threshold. | 11225 // threshold. |
| 11223 float expected_jitter = | 11226 float expected_jitter = |
| 11224 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 11227 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
| 11225 EXPECT_EQ(jitter, expected_jitter); | 11228 EXPECT_EQ(jitter, expected_jitter); |
| 11226 } | 11229 } |
| 11227 } | 11230 } |
| 11228 | 11231 |
| 11229 // Checks that if we lose a GPU raster enabled OutputSurface and replace it | 11232 // Checks that if we lose a GPU raster enabled CompositorFrameSink and replace |
| 11230 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU | 11233 // it |
| 11234 // with a software CompositorFrameSink, LayerTreeHostImpl correctly re-computes |
| 11235 // GPU |
| 11231 // rasterization status. | 11236 // rasterization status. |
| 11232 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) { | 11237 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnCompositorFrameSinkChange) { |
| 11233 host_impl_->ReleaseOutputSurface(); | 11238 host_impl_->ReleaseCompositorFrameSink(); |
| 11234 host_impl_ = nullptr; | 11239 host_impl_ = nullptr; |
| 11235 | 11240 |
| 11236 LayerTreeSettings settings = DefaultSettings(); | 11241 LayerTreeSettings settings = DefaultSettings(); |
| 11237 settings.gpu_rasterization_forced = true; | 11242 settings.gpu_rasterization_forced = true; |
| 11238 | 11243 |
| 11239 host_impl_ = LayerTreeHostImpl::Create( | 11244 host_impl_ = LayerTreeHostImpl::Create( |
| 11240 settings, this, &task_runner_provider_, &stats_instrumentation_, | 11245 settings, this, &task_runner_provider_, &stats_instrumentation_, |
| 11241 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 11246 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, |
| 11242 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 11247 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 11243 host_impl_->SetVisible(true); | 11248 host_impl_->SetVisible(true); |
| 11244 | 11249 |
| 11245 // InitializeRenderer with a gpu-raster enabled output surface. | 11250 // InitializeRenderer with a gpu-raster enabled output surface. |
| 11246 auto gpu_raster_output_surface = | 11251 auto gpu_raster_compositor_frame_sink = |
| 11247 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); | 11252 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); |
| 11248 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); | 11253 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); |
| 11249 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11254 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11250 | 11255 |
| 11251 // Re-initialize with a software output surface. | 11256 // Re-initialize with a software output surface. |
| 11252 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); | 11257 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11253 host_impl_->InitializeRenderer(output_surface_.get()); | 11258 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11254 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11259 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11255 } | 11260 } |
| 11256 | 11261 |
| 11257 } // namespace | 11262 } // namespace |
| 11258 } // namespace cc | 11263 } // namespace cc |
| OLD | NEW |