| 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(); |
| 541 EXPECT_FALSE(host_impl_->CanDraw()); | 542 EXPECT_FALSE(host_impl_->CanDraw()); |
| 542 EXPECT_TRUE(on_can_draw_state_changed_called_); | 543 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 543 on_can_draw_state_changed_called_ = false; | 544 on_can_draw_state_changed_called_ = false; |
| 544 | 545 |
| 545 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 546 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 546 EXPECT_TRUE(host_impl_->CanDraw()); | 547 EXPECT_TRUE(host_impl_->CanDraw()); |
| 547 EXPECT_TRUE(on_can_draw_state_changed_called_); | 548 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 548 on_can_draw_state_changed_called_ = false; | 549 on_can_draw_state_changed_called_ = false; |
| 549 | 550 |
| 550 // Toggle the device viewport size to make sure it toggles can_draw. | 551 // 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... |
| 734 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 735 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
| 735 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 736 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 736 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 737 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 737 DrawFrame(); | 738 DrawFrame(); |
| 738 | 739 |
| 739 // We should not crash if the tree is replaced while we are scrolling. | 740 // We should not crash if the tree is replaced while we are scrolling. |
| 740 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 741 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 741 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 742 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 742 InputHandler::WHEEL) | 743 InputHandler::WHEEL) |
| 743 .thread); | 744 .thread); |
| 744 host_impl_->active_tree()->ClearLayers(); | 745 host_impl_->active_tree()->DetachLayers(); |
| 745 | 746 |
| 746 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 747 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 747 | 748 |
| 748 // We should still be scrolling, because the scrolled layer also exists in the | 749 // We should still be scrolling, because the scrolled layer also exists in the |
| 749 // new tree. | 750 // new tree. |
| 750 gfx::Vector2d scroll_delta(0, 10); | 751 gfx::Vector2d scroll_delta(0, 10); |
| 751 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 752 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 752 host_impl_->ScrollEnd(EndState().get()); | 753 host_impl_->ScrollEnd(EndState().get()); |
| 753 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 754 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 754 host_impl_->ProcessScrollDeltas(); | 755 host_impl_->ProcessScrollDeltas(); |
| (...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5337 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5338 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
| 5338 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5339 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 5339 Layer::INVALID_ID); | 5340 Layer::INVALID_ID); |
| 5340 host_impl_->active_tree()->DidBecomeActive(); | 5341 host_impl_->active_tree()->DidBecomeActive(); |
| 5341 host_impl_->SetViewportSize(surface_size); | 5342 host_impl_->SetViewportSize(surface_size); |
| 5342 | 5343 |
| 5343 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5344 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 5344 // synchronization. | 5345 // synchronization. |
| 5345 SetNeedsRebuildPropertyTrees(); | 5346 SetNeedsRebuildPropertyTrees(); |
| 5346 DrawFrame(); | 5347 DrawFrame(); |
| 5347 host_impl_->active_tree()->ClearLayers(); | 5348 host_impl_->active_tree()->DetachLayers(); |
| 5348 std::unique_ptr<LayerImpl> root_ptr2 = | 5349 std::unique_ptr<LayerImpl> root_ptr2 = |
| 5349 LayerImpl::Create(host_impl_->active_tree(), 4); | 5350 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5350 std::unique_ptr<LayerImpl> root_clip2 = | 5351 std::unique_ptr<LayerImpl> root_clip2 = |
| 5351 LayerImpl::Create(host_impl_->active_tree(), 5); | 5352 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 5352 std::unique_ptr<LayerImpl> root_scroll2 = | 5353 std::unique_ptr<LayerImpl> root_scroll2 = |
| 5353 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5354 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
| 5354 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5355 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
| 5355 true; | 5356 true; |
| 5356 root_clip2->AddChild(std::move(root_scroll2)); | 5357 root_clip2->AddChild(std::move(root_scroll2)); |
| 5357 root_clip2->test_properties()->force_render_surface = true; | 5358 root_clip2->test_properties()->force_render_surface = true; |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7348 | 7349 |
| 7349 LayerTreeHostImpl::FrameData frame; | 7350 LayerTreeHostImpl::FrameData frame; |
| 7350 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7351 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 7351 host_impl_->DrawLayers(&frame); | 7352 host_impl_->DrawLayers(&frame); |
| 7352 host_impl_->DidDrawAllLayers(frame); | 7353 host_impl_->DidDrawAllLayers(frame); |
| 7353 host_impl_->SwapBuffers(frame); | 7354 host_impl_->SwapBuffers(frame); |
| 7354 | 7355 |
| 7355 EXPECT_GT(context3d->NumTextures(), 0u); | 7356 EXPECT_GT(context3d->NumTextures(), 0u); |
| 7356 | 7357 |
| 7357 // Kill the layer tree. | 7358 // Kill the layer tree. |
| 7358 host_impl_->active_tree()->SetRootLayer( | 7359 host_impl_->active_tree()->DetachLayers(); |
| 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 |