| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 145 void NotifyReadyToDraw() override {} | 145 void NotifyReadyToDraw() override {} |
| 146 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } | 146 void SetNeedsRedrawOnImplThread() override { did_request_redraw_ = true; } |
| 147 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) override { | |
| 148 did_request_redraw_ = true; | |
| 149 } | |
| 150 void SetNeedsOneBeginImplFrameOnImplThread() override { | 147 void SetNeedsOneBeginImplFrameOnImplThread() override { |
| 151 did_request_next_frame_ = true; | 148 did_request_next_frame_ = true; |
| 152 } | 149 } |
| 153 void SetNeedsPrepareTilesOnImplThread() override { | 150 void SetNeedsPrepareTilesOnImplThread() override { |
| 154 did_request_prepare_tiles_ = true; | 151 did_request_prepare_tiles_ = true; |
| 155 } | 152 } |
| 156 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } | 153 void SetNeedsCommitOnImplThread() override { did_request_commit_ = true; } |
| 157 void SetVideoNeedsBeginFrames(bool needs_begin_frames) override {} | 154 void SetVideoNeedsBeginFrames(bool needs_begin_frames) override {} |
| 158 void PostAnimationEventsToMainThreadOnImplThread( | 155 void PostAnimationEventsToMainThreadOnImplThread( |
| 159 std::unique_ptr<AnimationEvents> events) override {} | 156 std::unique_ptr<AnimationEvents> events) override {} |
| (...skipping 8496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8656 host_impl_->SetNeedsRedraw(); | 8653 host_impl_->SetNeedsRedraw(); |
| 8657 EXPECT_EQ(0, set_needs_commit_count); | 8654 EXPECT_EQ(0, set_needs_commit_count); |
| 8658 EXPECT_EQ(1, set_needs_redraw_count); | 8655 EXPECT_EQ(1, set_needs_redraw_count); |
| 8659 EXPECT_EQ(0, forward_to_main_count); | 8656 EXPECT_EQ(0, forward_to_main_count); |
| 8660 | 8657 |
| 8661 { | 8658 { |
| 8662 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8659 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
| 8663 new SimpleSwapPromiseMonitor( | 8660 new SimpleSwapPromiseMonitor( |
| 8664 NULL, host_impl_.get(), &set_needs_commit_count, | 8661 NULL, host_impl_.get(), &set_needs_commit_count, |
| 8665 &set_needs_redraw_count, &forward_to_main_count)); | 8662 &set_needs_redraw_count, &forward_to_main_count)); |
| 8666 host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10)); | 8663 // Redraw with damage. |
| 8664 host_impl_->SetFullViewportDamage(); |
| 8665 host_impl_->SetNeedsRedraw(); |
| 8667 EXPECT_EQ(0, set_needs_commit_count); | 8666 EXPECT_EQ(0, set_needs_commit_count); |
| 8668 EXPECT_EQ(2, set_needs_redraw_count); | 8667 EXPECT_EQ(2, set_needs_redraw_count); |
| 8669 EXPECT_EQ(0, forward_to_main_count); | 8668 EXPECT_EQ(0, forward_to_main_count); |
| 8670 } | 8669 } |
| 8671 | 8670 |
| 8672 { | 8671 { |
| 8673 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8672 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
| 8674 new SimpleSwapPromiseMonitor( | 8673 new SimpleSwapPromiseMonitor( |
| 8675 NULL, host_impl_.get(), &set_needs_commit_count, | 8674 NULL, host_impl_.get(), &set_needs_commit_count, |
| 8676 &set_needs_redraw_count, &forward_to_main_count)); | 8675 &set_needs_redraw_count, &forward_to_main_count)); |
| 8677 // Empty damage rect won't signal the monitor. | 8676 // Redraw without damage. |
| 8678 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 8677 host_impl_->SetNeedsRedraw(); |
| 8679 EXPECT_EQ(0, set_needs_commit_count); | 8678 EXPECT_EQ(0, set_needs_commit_count); |
| 8680 EXPECT_EQ(2, set_needs_redraw_count); | 8679 EXPECT_EQ(3, set_needs_redraw_count); |
| 8681 EXPECT_EQ(0, forward_to_main_count); | 8680 EXPECT_EQ(0, forward_to_main_count); |
| 8682 } | 8681 } |
| 8683 | 8682 |
| 8683 set_needs_commit_count = 0; |
| 8684 set_needs_redraw_count = 0; |
| 8685 forward_to_main_count = 0; |
| 8686 |
| 8684 { | 8687 { |
| 8685 set_needs_commit_count = 0; | |
| 8686 set_needs_redraw_count = 0; | |
| 8687 forward_to_main_count = 0; | |
| 8688 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 8688 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
| 8689 new SimpleSwapPromiseMonitor( | 8689 new SimpleSwapPromiseMonitor( |
| 8690 NULL, host_impl_.get(), &set_needs_commit_count, | 8690 NULL, host_impl_.get(), &set_needs_commit_count, |
| 8691 &set_needs_redraw_count, &forward_to_main_count)); | 8691 &set_needs_redraw_count, &forward_to_main_count)); |
| 8692 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8692 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8693 | 8693 |
| 8694 // Scrolling normally should not trigger any forwarding. | 8694 // Scrolling normally should not trigger any forwarding. |
| 8695 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8695 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8696 host_impl_ | 8696 host_impl_ |
| 8697 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8697 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| (...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11060 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11060 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
| 11061 host_impl_->gpu_rasterization_status()); | 11061 host_impl_->gpu_rasterization_status()); |
| 11062 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11062 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11063 } | 11063 } |
| 11064 | 11064 |
| 11065 // A mock output surface which lets us detect calls to ForceReclaimResources. | 11065 // A mock output surface which lets us detect calls to ForceReclaimResources. |
| 11066 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { | 11066 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { |
| 11067 public: | 11067 public: |
| 11068 MockReclaimResourcesCompositorFrameSink() | 11068 MockReclaimResourcesCompositorFrameSink() |
| 11069 : FakeCompositorFrameSink(TestContextProvider::Create(), | 11069 : FakeCompositorFrameSink(TestContextProvider::Create(), |
| 11070 TestContextProvider::CreateWorker(), | 11070 TestContextProvider::CreateWorker()) {} |
| 11071 true) {} | |
| 11072 | 11071 |
| 11073 MOCK_METHOD0(ForceReclaimResources, void()); | 11072 MOCK_METHOD0(ForceReclaimResources, void()); |
| 11074 }; | 11073 }; |
| 11075 | 11074 |
| 11076 // Display::Draw (and the planned Display Scheduler) currently rely on resources | 11075 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
| 11077 // being reclaimed to block drawing between BeginCommit / Swap. This test | 11076 // being reclaimed to block drawing between BeginCommit / Swap. This test |
| 11078 // ensures that BeginCommit triggers ForceReclaimResources. See | 11077 // ensures that BeginCommit triggers ForceReclaimResources. See |
| 11079 // crbug.com/489515. | 11078 // crbug.com/489515. |
| 11080 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | 11079 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
| 11081 auto compositor_frame_sink = | 11080 auto compositor_frame_sink = |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11256 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11255 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11257 | 11256 |
| 11258 // Re-initialize with a software output surface. | 11257 // Re-initialize with a software output surface. |
| 11259 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11258 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11260 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11259 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11261 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11260 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11262 } | 11261 } |
| 11263 | 11262 |
| 11264 } // namespace | 11263 } // namespace |
| 11265 } // namespace cc | 11264 } // namespace cc |
| OLD | NEW |