| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 on_can_draw_state_changed_called_ = false; | 531 on_can_draw_state_changed_called_ = false; |
| 532 | 532 |
| 533 // Set up the root layer, which allows us to draw. | 533 // Set up the root layer, which allows us to draw. |
| 534 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 534 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 535 EXPECT_TRUE(host_impl_->CanDraw()); | 535 EXPECT_TRUE(host_impl_->CanDraw()); |
| 536 EXPECT_TRUE(on_can_draw_state_changed_called_); | 536 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 537 on_can_draw_state_changed_called_ = false; | 537 on_can_draw_state_changed_called_ = false; |
| 538 | 538 |
| 539 // Toggle the root layer to make sure it toggles can_draw | 539 // Toggle the root layer to make sure it toggles can_draw |
| 540 host_impl_->active_tree()->SetRootLayer(nullptr); | 540 host_impl_->active_tree()->SetRootLayer(nullptr); |
| 541 host_impl_->active_tree()->DetachLayers(); | |
| 542 EXPECT_FALSE(host_impl_->CanDraw()); | 541 EXPECT_FALSE(host_impl_->CanDraw()); |
| 543 EXPECT_TRUE(on_can_draw_state_changed_called_); | 542 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 544 on_can_draw_state_changed_called_ = false; | 543 on_can_draw_state_changed_called_ = false; |
| 545 | 544 |
| 546 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 545 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 547 EXPECT_TRUE(host_impl_->CanDraw()); | 546 EXPECT_TRUE(host_impl_->CanDraw()); |
| 548 EXPECT_TRUE(on_can_draw_state_changed_called_); | 547 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 549 on_can_draw_state_changed_called_ = false; | 548 on_can_draw_state_changed_called_ = false; |
| 550 | 549 |
| 551 // Toggle the device viewport size to make sure it toggles can_draw. | 550 // Toggle the device viewport size to make sure it toggles can_draw. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 734 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
| 736 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 735 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 737 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 736 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 738 DrawFrame(); | 737 DrawFrame(); |
| 739 | 738 |
| 740 // We should not crash if the tree is replaced while we are scrolling. | 739 // We should not crash if the tree is replaced while we are scrolling. |
| 741 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 740 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 742 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 741 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 743 InputHandler::WHEEL) | 742 InputHandler::WHEEL) |
| 744 .thread); | 743 .thread); |
| 745 host_impl_->active_tree()->DetachLayers(); | 744 host_impl_->active_tree()->ClearLayers(); |
| 746 | 745 |
| 747 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 746 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 748 | 747 |
| 749 // We should still be scrolling, because the scrolled layer also exists in the | 748 // We should still be scrolling, because the scrolled layer also exists in the |
| 750 // new tree. | 749 // new tree. |
| 751 gfx::Vector2d scroll_delta(0, 10); | 750 gfx::Vector2d scroll_delta(0, 10); |
| 752 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 751 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 753 host_impl_->ScrollEnd(EndState().get()); | 752 host_impl_->ScrollEnd(EndState().get()); |
| 754 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 753 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 755 host_impl_->ProcessScrollDeltas(); | 754 host_impl_->ProcessScrollDeltas(); |
| (...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5338 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5337 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
| 5339 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5338 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 5340 Layer::INVALID_ID); | 5339 Layer::INVALID_ID); |
| 5341 host_impl_->active_tree()->DidBecomeActive(); | 5340 host_impl_->active_tree()->DidBecomeActive(); |
| 5342 host_impl_->SetViewportSize(surface_size); | 5341 host_impl_->SetViewportSize(surface_size); |
| 5343 | 5342 |
| 5344 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5343 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 5345 // synchronization. | 5344 // synchronization. |
| 5346 SetNeedsRebuildPropertyTrees(); | 5345 SetNeedsRebuildPropertyTrees(); |
| 5347 DrawFrame(); | 5346 DrawFrame(); |
| 5348 host_impl_->active_tree()->DetachLayers(); | 5347 host_impl_->active_tree()->ClearLayers(); |
| 5349 std::unique_ptr<LayerImpl> root_ptr2 = | 5348 std::unique_ptr<LayerImpl> root_ptr2 = |
| 5350 LayerImpl::Create(host_impl_->active_tree(), 4); | 5349 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5351 std::unique_ptr<LayerImpl> root_clip2 = | 5350 std::unique_ptr<LayerImpl> root_clip2 = |
| 5352 LayerImpl::Create(host_impl_->active_tree(), 5); | 5351 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 5353 std::unique_ptr<LayerImpl> root_scroll2 = | 5352 std::unique_ptr<LayerImpl> root_scroll2 = |
| 5354 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5353 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
| 5355 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5354 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
| 5356 true; | 5355 true; |
| 5357 root_clip2->AddChild(std::move(root_scroll2)); | 5356 root_clip2->AddChild(std::move(root_scroll2)); |
| 5358 root_clip2->test_properties()->force_render_surface = true; | 5357 root_clip2->test_properties()->force_render_surface = true; |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7349 | 7348 |
| 7350 LayerTreeHostImpl::FrameData frame; | 7349 LayerTreeHostImpl::FrameData frame; |
| 7351 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7350 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 7352 host_impl_->DrawLayers(&frame); | 7351 host_impl_->DrawLayers(&frame); |
| 7353 host_impl_->DidDrawAllLayers(frame); | 7352 host_impl_->DidDrawAllLayers(frame); |
| 7354 host_impl_->SwapBuffers(frame); | 7353 host_impl_->SwapBuffers(frame); |
| 7355 | 7354 |
| 7356 EXPECT_GT(context3d->NumTextures(), 0u); | 7355 EXPECT_GT(context3d->NumTextures(), 0u); |
| 7357 | 7356 |
| 7358 // Kill the layer tree. | 7357 // Kill the layer tree. |
| 7359 host_impl_->active_tree()->DetachLayers(); | 7358 host_impl_->active_tree()->SetRootLayer( |
| 7359 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 7360 // There should be no textures left in use after. | 7360 // There should be no textures left in use after. |
| 7361 EXPECT_EQ(0u, context3d->NumTextures()); | 7361 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7362 } | 7362 } |
| 7363 | 7363 |
| 7364 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7364 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
| 7365 public: | 7365 public: |
| 7366 MOCK_METHOD1(useProgram, void(GLuint program)); | 7366 MOCK_METHOD1(useProgram, void(GLuint program)); |
| 7367 MOCK_METHOD4(drawElements, void(GLenum mode, | 7367 MOCK_METHOD4(drawElements, void(GLenum mode, |
| 7368 GLsizei count, | 7368 GLsizei count, |
| 7369 GLenum type, | 7369 GLenum type, |
| (...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10815 | 10815 |
| 10816 // Re-initialize with a software output surface. | 10816 // Re-initialize with a software output surface. |
| 10817 output_surface_ = FakeOutputSurface::CreateSoftware( | 10817 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10818 base::WrapUnique(new SoftwareOutputDevice)); | 10818 base::WrapUnique(new SoftwareOutputDevice)); |
| 10819 host_impl_->InitializeRenderer(output_surface_.get()); | 10819 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10820 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10820 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10821 } | 10821 } |
| 10822 | 10822 |
| 10823 } // namespace | 10823 } // namespace |
| 10824 } // namespace cc | 10824 } // namespace cc |
| OLD | NEW |