| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 void DidActivateSyncTree() override {} | 161 void DidActivateSyncTree() override {} |
| 162 void WillPrepareTiles() override {} | 162 void WillPrepareTiles() override {} |
| 163 void DidPrepareTiles() override {} | 163 void DidPrepareTiles() override {} |
| 164 void DidCompletePageScaleAnimationOnImplThread() override { | 164 void DidCompletePageScaleAnimationOnImplThread() override { |
| 165 did_complete_page_scale_animation_ = true; | 165 did_complete_page_scale_animation_ = true; |
| 166 } | 166 } |
| 167 void OnDrawForOutputSurface(bool resourceless_software_draw) override { | 167 void OnDrawForOutputSurface(bool resourceless_software_draw) override { |
| 168 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( | 168 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( |
| 169 new LayerTreeHostImpl::FrameData); | 169 new LayerTreeHostImpl::FrameData); |
| 170 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(frame.get())); | 170 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get())); |
| 171 last_on_draw_render_passes_.clear(); | 171 last_on_draw_render_passes_.clear(); |
| 172 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); | 172 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); |
| 173 if (!skip_draw_layers_in_on_draw_) | 173 if (!skip_draw_layers_in_on_draw_) |
| 174 host_impl_->DrawLayers(frame.get()); | 174 host_impl_->DrawLayers(frame.get()); |
| 175 host_impl_->DidDrawAllLayers(*frame); | 175 host_impl_->DidDrawAllLayers(*frame); |
| 176 host_impl_->SwapBuffers(*frame); | 176 host_impl_->SwapBuffers(*frame); |
| 177 last_on_draw_frame_ = std::move(frame); | 177 last_on_draw_frame_ = std::move(frame); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void set_reduce_memory_result(bool reduce_memory_result) { | 180 void set_reduce_memory_result(bool reduce_memory_result) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 contents->SetPosition(gfx::PointF()); | 332 contents->SetPosition(gfx::PointF()); |
| 333 | 333 |
| 334 outer_scroll->test_properties()->AddChild(std::move(contents)); | 334 outer_scroll->test_properties()->AddChild(std::move(contents)); |
| 335 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 335 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 336 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 336 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
| 337 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 337 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
| 338 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 338 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
| 339 root->test_properties()->AddChild(std::move(inner_clip)); | 339 root->test_properties()->AddChild(std::move(inner_clip)); |
| 340 | 340 |
| 341 layer_tree_impl->SetRootLayerForTesting(std::move(root)); | 341 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
| 342 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 342 layer_tree_impl->SetViewportLayersFromIds( | 343 layer_tree_impl->SetViewportLayersFromIds( |
| 343 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 344 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 344 kOuterViewportScrollLayerId); | 345 kOuterViewportScrollLayerId); |
| 345 | 346 |
| 346 layer_tree_impl->DidBecomeActive(); | 347 layer_tree_impl->DidBecomeActive(); |
| 347 return layer_tree_impl->InnerViewportScrollLayer(); | 348 return layer_tree_impl->InnerViewportScrollLayer(); |
| 348 } | 349 } |
| 349 | 350 |
| 350 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 351 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
| 351 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 352 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
| 352 host_impl_->active_tree(), content_size); | 353 host_impl_->active_tree(), content_size); |
| 353 SetNeedsRebuildPropertyTrees(); | |
| 354 RebuildPropertyTrees(); | |
| 355 host_impl_->active_tree()->DidBecomeActive(); | 354 host_impl_->active_tree()->DidBecomeActive(); |
| 356 return scroll_layer; | 355 return scroll_layer; |
| 357 } | 356 } |
| 358 | 357 |
| 359 // Sets up a typical virtual viewport setup with one child content layer. | 358 // Sets up a typical virtual viewport setup with one child content layer. |
| 360 // Returns a pointer to the content layer. | 359 // Returns a pointer to the content layer. |
| 361 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, | 360 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, |
| 362 const gfx::Size& content_size) { | 361 const gfx::Size& content_size) { |
| 363 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and | 362 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and |
| 364 // the inner a different size from the outer. We'll reuse its layer | 363 // the inner a different size from the outer. We'll reuse its layer |
| (...skipping 13 matching lines...) Expand all Loading... |
| 378 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer() | 377 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer() |
| 379 ->test_properties() | 378 ->test_properties() |
| 380 ->parent->test_properties() | 379 ->parent->test_properties() |
| 381 ->parent; | 380 ->parent; |
| 382 inner_clip_layer->SetBounds(viewport_size); | 381 inner_clip_layer->SetBounds(viewport_size); |
| 383 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 382 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
| 384 | 383 |
| 385 // Needs to happen before building property trees as the latter propagates | 384 // Needs to happen before building property trees as the latter propagates |
| 386 // these element ids to property tree nodes. | 385 // these element ids to property tree nodes. |
| 387 host_impl_->active_tree()->SetElementIdsForTesting(); | 386 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 388 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 387 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 389 | 388 |
| 390 host_impl_->SetViewportSize(viewport_size); | 389 host_impl_->SetViewportSize(viewport_size); |
| 391 host_impl_->active_tree()->DidBecomeActive(); | 390 host_impl_->active_tree()->DidBecomeActive(); |
| 392 | 391 |
| 393 return content_layer; | 392 return content_layer; |
| 394 } | 393 } |
| 395 | 394 |
| 396 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, | 395 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, |
| 397 const gfx::Size& size, | 396 const gfx::Size& size, |
| 398 LayerImpl* clip_layer) { | 397 LayerImpl* clip_layer) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 std::unique_ptr<ScrollState> EndState() { | 431 std::unique_ptr<ScrollState> EndState() { |
| 433 ScrollStateData scroll_state_data; | 432 ScrollStateData scroll_state_data; |
| 434 scroll_state_data.is_ending = true; | 433 scroll_state_data.is_ending = true; |
| 435 std::unique_ptr<ScrollState> scroll_state( | 434 std::unique_ptr<ScrollState> scroll_state( |
| 436 new ScrollState(scroll_state_data)); | 435 new ScrollState(scroll_state_data)); |
| 437 return scroll_state; | 436 return scroll_state; |
| 438 } | 437 } |
| 439 | 438 |
| 440 void DrawFrame() { | 439 void DrawFrame() { |
| 441 LayerTreeHostImpl::FrameData frame; | 440 LayerTreeHostImpl::FrameData frame; |
| 442 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 441 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 443 host_impl_->DrawLayers(&frame); | 442 host_impl_->DrawLayers(&frame); |
| 444 host_impl_->DidDrawAllLayers(frame); | 443 host_impl_->DidDrawAllLayers(frame); |
| 445 } | 444 } |
| 446 | 445 |
| 447 void SetNeedsRebuildPropertyTrees() { | |
| 448 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | |
| 449 } | |
| 450 | |
| 451 void RebuildPropertyTrees() { | |
| 452 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 453 } | |
| 454 | |
| 455 DrawResult PrepareToDrawFrame(LayerTreeHostImpl::FrameData* frame) { | |
| 456 // We need to build property trees here before drawing the frame as they are | |
| 457 // not built on the impl thread. | |
| 458 RebuildPropertyTrees(); | |
| 459 return host_impl_->PrepareToDraw(frame); | |
| 460 } | |
| 461 | |
| 462 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 446 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
| 463 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 447 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 464 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 448 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 465 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 449 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 466 float device_scale_factor); | 450 float device_scale_factor); |
| 467 | 451 |
| 468 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 452 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
| 469 | 453 |
| 470 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 454 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
| 471 | 455 |
| 472 protected: | 456 protected: |
| 473 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { | 457 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { |
| 474 return FakeOutputSurface::Create3d(); | 458 return FakeOutputSurface::Create3d(); |
| 475 } | 459 } |
| 476 | 460 |
| 477 void DrawOneFrame() { | 461 void DrawOneFrame() { |
| 478 LayerTreeHostImpl::FrameData frame_data; | 462 LayerTreeHostImpl::FrameData frame_data; |
| 479 PrepareToDrawFrame(&frame_data); | 463 host_impl_->PrepareToDraw(&frame_data); |
| 480 host_impl_->DidDrawAllLayers(frame_data); | 464 host_impl_->DidDrawAllLayers(frame_data); |
| 481 } | 465 } |
| 482 | 466 |
| 483 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 467 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
| 484 const gfx::Vector2dF& delta) { | 468 const gfx::Vector2dF& delta) { |
| 485 if (layer_impl->layer_tree_impl() | 469 if (layer_impl->layer_tree_impl() |
| 486 ->property_trees() | 470 ->property_trees() |
| 487 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), | 471 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), |
| 488 delta)) | 472 delta)) |
| 489 layer_impl->layer_tree_impl()->DidUpdateScrollOffset( | 473 layer_impl->layer_tree_impl()->DidUpdateScrollOffset( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 EXPECT_TRUE(host_impl_->CanDraw()); | 551 EXPECT_TRUE(host_impl_->CanDraw()); |
| 568 EXPECT_TRUE(on_can_draw_state_changed_called_); | 552 EXPECT_TRUE(on_can_draw_state_changed_called_); |
| 569 on_can_draw_state_changed_called_ = false; | 553 on_can_draw_state_changed_called_ = false; |
| 570 } | 554 } |
| 571 | 555 |
| 572 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { | 556 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { |
| 573 CreateHostImpl(DefaultSettings(), | 557 CreateHostImpl(DefaultSettings(), |
| 574 FakeOutputSurface::CreateSoftware( | 558 FakeOutputSurface::CreateSoftware( |
| 575 base::WrapUnique(new SoftwareOutputDevice()))); | 559 base::WrapUnique(new SoftwareOutputDevice()))); |
| 576 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 560 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 561 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 562 |
| 577 EXPECT_TRUE(host_impl_->CanDraw()); | 563 EXPECT_TRUE(host_impl_->CanDraw()); |
| 578 host_impl_->SetViewportSize(gfx::Size()); | 564 host_impl_->SetViewportSize(gfx::Size()); |
| 579 EXPECT_FALSE(host_impl_->CanDraw()); | 565 EXPECT_FALSE(host_impl_->CanDraw()); |
| 580 | 566 |
| 581 FakeOutputSurface* fake_output_surface = | 567 FakeOutputSurface* fake_output_surface = |
| 582 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 568 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 583 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); | 569 EXPECT_EQ(fake_output_surface->num_sent_frames(), 0u); |
| 584 gfx::Transform identity; | 570 gfx::Transform identity; |
| 585 gfx::Rect viewport(100, 100); | 571 gfx::Rect viewport(100, 100); |
| 586 const bool resourceless_software_draw = true; | 572 const bool resourceless_software_draw = true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 611 root->test_properties()->children[1]->test_properties()->AddChild( | 597 root->test_properties()->children[1]->test_properties()->AddChild( |
| 612 LayerImpl::Create(host_impl_->active_tree(), 5)); | 598 LayerImpl::Create(host_impl_->active_tree(), 5)); |
| 613 root->test_properties() | 599 root->test_properties() |
| 614 ->children[1] | 600 ->children[1] |
| 615 ->test_properties() | 601 ->test_properties() |
| 616 ->children[0] | 602 ->children[0] |
| 617 ->test_properties() | 603 ->test_properties() |
| 618 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); | 604 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); |
| 619 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 605 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 620 } | 606 } |
| 621 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 607 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 622 | 608 |
| 623 ExpectClearedScrollDeltasRecursive(root); | 609 ExpectClearedScrollDeltasRecursive(root); |
| 624 | 610 |
| 625 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 611 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 626 | 612 |
| 627 scroll_info = host_impl_->ProcessScrollDeltas(); | 613 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 628 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 614 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 629 ExpectClearedScrollDeltasRecursive(root); | 615 ExpectClearedScrollDeltasRecursive(root); |
| 630 | 616 |
| 631 scroll_info = host_impl_->ProcessScrollDeltas(); | 617 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 632 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 618 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 633 ExpectClearedScrollDeltasRecursive(root); | 619 ExpectClearedScrollDeltasRecursive(root); |
| 634 } | 620 } |
| 635 | 621 |
| 636 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 622 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
| 637 gfx::ScrollOffset scroll_offset(20, 30); | 623 gfx::ScrollOffset scroll_offset(20, 30); |
| 638 gfx::Vector2d scroll_delta(11, -15); | 624 gfx::Vector2d scroll_delta(11, -15); |
| 639 { | |
| 640 std::unique_ptr<LayerImpl> root_clip = | |
| 641 LayerImpl::Create(host_impl_->active_tree(), 2); | |
| 642 std::unique_ptr<LayerImpl> root = | |
| 643 LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 644 root_clip->SetBounds(gfx::Size(10, 10)); | |
| 645 LayerImpl* root_layer = root.get(); | |
| 646 root_clip->test_properties()->AddChild(std::move(root)); | |
| 647 root_layer->SetBounds(gfx::Size(110, 110)); | |
| 648 root_layer->SetScrollClipLayer(root_clip->id()); | |
| 649 root_layer->layer_tree_impl() | |
| 650 ->property_trees() | |
| 651 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), | |
| 652 scroll_offset); | |
| 653 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); | |
| 654 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 655 root_layer->ScrollBy(scroll_delta); | |
| 656 } | |
| 657 | 625 |
| 658 LayerImpl* root = host_impl_->active_tree() | 626 auto root_clip_owned = LayerImpl::Create(host_impl_->active_tree(), 2); |
| 659 ->root_layer_for_testing() | 627 auto* root_clip = root_clip_owned.get(); |
| 660 ->test_properties() | 628 auto root_owned = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 661 ->children[0]; | 629 auto* root = root_owned.get(); |
| 630 |
| 631 root_clip->SetBounds(gfx::Size(10, 10)); |
| 632 root_clip->test_properties()->AddChild(std::move(root_owned)); |
| 633 root->SetBounds(gfx::Size(110, 110)); |
| 634 root->SetScrollClipLayer(root_clip->id()); |
| 635 root->layer_tree_impl() |
| 636 ->property_trees() |
| 637 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root->id(), scroll_offset); |
| 638 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip_owned)); |
| 639 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 662 | 640 |
| 663 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 641 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 664 | 642 |
| 643 root->ScrollBy(scroll_delta); |
| 665 scroll_info = host_impl_->ProcessScrollDeltas(); | 644 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 666 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 645 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 667 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 646 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
| 668 | 647 |
| 669 gfx::Vector2d scroll_delta2(-5, 27); | 648 gfx::Vector2d scroll_delta2(-5, 27); |
| 670 root->ScrollBy(scroll_delta2); | 649 root->ScrollBy(scroll_delta2); |
| 671 scroll_info = host_impl_->ProcessScrollDeltas(); | 650 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 672 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 651 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 673 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 652 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
| 674 scroll_delta + scroll_delta2)); | 653 scroll_delta + scroll_delta2)); |
| 675 | 654 |
| 676 root->ScrollBy(gfx::Vector2d()); | 655 root->ScrollBy(gfx::Vector2d()); |
| 677 scroll_info = host_impl_->ProcessScrollDeltas(); | 656 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 678 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 657 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
| 679 scroll_delta + scroll_delta2)); | 658 scroll_delta + scroll_delta2)); |
| 680 } | 659 } |
| 681 | 660 |
| 682 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 661 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
| 683 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 662 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 663 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 664 |
| 684 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 665 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 685 DrawFrame(); | 666 DrawFrame(); |
| 686 | 667 |
| 687 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 668 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 688 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 669 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 689 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 670 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 690 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 671 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 691 status.main_thread_scrolling_reasons); | 672 status.main_thread_scrolling_reasons); |
| 692 | 673 |
| 693 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 674 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 694 InputHandler::WHEEL)); | 675 InputHandler::WHEEL)); |
| 695 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 676 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 696 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 677 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
| 697 InputHandler::WHEEL)); | 678 InputHandler::WHEEL)); |
| 698 host_impl_->ScrollEnd(EndState().get()); | 679 host_impl_->ScrollEnd(EndState().get()); |
| 699 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 680 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 700 InputHandler::WHEEL)); | 681 InputHandler::WHEEL)); |
| 701 EXPECT_TRUE(did_request_redraw_); | 682 EXPECT_TRUE(did_request_redraw_); |
| 702 EXPECT_TRUE(did_request_commit_); | 683 EXPECT_TRUE(did_request_commit_); |
| 703 } | 684 } |
| 704 | 685 |
| 705 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 686 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
| 706 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 687 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 688 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 689 |
| 707 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 690 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 708 DrawFrame(); | 691 DrawFrame(); |
| 709 | 692 |
| 710 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 693 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 711 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 694 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 712 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 695 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 713 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 696 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 714 status.main_thread_scrolling_reasons); | 697 status.main_thread_scrolling_reasons); |
| 715 | 698 |
| 716 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 699 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 788 |
| 806 LayerImpl* child = 0; | 789 LayerImpl* child = 0; |
| 807 { | 790 { |
| 808 std::unique_ptr<LayerImpl> child_layer = | 791 std::unique_ptr<LayerImpl> child_layer = |
| 809 LayerImpl::Create(host_impl_->active_tree(), 6); | 792 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 810 child = child_layer.get(); | 793 child = child_layer.get(); |
| 811 child_layer->SetDrawsContent(true); | 794 child_layer->SetDrawsContent(true); |
| 812 child_layer->SetPosition(gfx::PointF(0, 20)); | 795 child_layer->SetPosition(gfx::PointF(0, 20)); |
| 813 child_layer->SetBounds(gfx::Size(50, 50)); | 796 child_layer->SetBounds(gfx::Size(50, 50)); |
| 814 scroll->test_properties()->AddChild(std::move(child_layer)); | 797 scroll->test_properties()->AddChild(std::move(child_layer)); |
| 815 SetNeedsRebuildPropertyTrees(); | 798 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 816 RebuildPropertyTrees(); | |
| 817 } | 799 } |
| 818 | 800 |
| 819 // Touch handler regions determine whether touch events block scroll. | 801 // Touch handler regions determine whether touch events block scroll. |
| 820 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 802 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 821 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 803 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 822 | 804 |
| 823 // But they don't influence the actual handling of the scroll gestures. | 805 // But they don't influence the actual handling of the scroll gestures. |
| 824 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 806 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 825 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 807 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 826 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 808 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 status.main_thread_scrolling_reasons); | 867 status.main_thread_scrolling_reasons); |
| 886 } | 868 } |
| 887 | 869 |
| 888 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { | 870 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { |
| 889 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 871 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 890 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 872 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 891 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 873 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 892 | 874 |
| 893 root->set_main_thread_scrolling_reasons( | 875 root->set_main_thread_scrolling_reasons( |
| 894 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 876 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 877 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 895 | 878 |
| 896 SetNeedsRebuildPropertyTrees(); | |
| 897 DrawFrame(); | 879 DrawFrame(); |
| 898 | 880 |
| 899 // Start scrolling a layer | 881 // Start scrolling a layer |
| 900 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 882 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 901 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 883 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 902 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 884 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 903 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 885 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 904 status.main_thread_scrolling_reasons); | 886 status.main_thread_scrolling_reasons); |
| 905 | 887 |
| 906 // The fling should be ignored since there's no layer being scrolled impl-side | 888 // The fling should be ignored since there's no layer being scrolled impl-side |
| 907 status = host_impl_->FlingScrollBegin(); | 889 status = host_impl_->FlingScrollBegin(); |
| 908 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 890 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 909 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 891 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 910 status.main_thread_scrolling_reasons); | 892 status.main_thread_scrolling_reasons); |
| 911 } | 893 } |
| 912 | 894 |
| 913 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 895 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
| 914 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 896 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 915 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 897 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 916 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 898 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 917 | 899 |
| 918 root->set_main_thread_scrolling_reasons( | 900 root->set_main_thread_scrolling_reasons( |
| 919 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 901 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 920 SetNeedsRebuildPropertyTrees(); | 902 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 921 DrawFrame(); | 903 DrawFrame(); |
| 922 | 904 |
| 923 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 905 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 924 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 906 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 925 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 907 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 926 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 908 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 927 status.main_thread_scrolling_reasons); | 909 status.main_thread_scrolling_reasons); |
| 928 | 910 |
| 929 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 911 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 930 InputHandler::TOUCHSCREEN); | 912 InputHandler::TOUCHSCREEN); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 squash2->SetPosition(gfx::PointF(220, 300)); | 954 squash2->SetPosition(gfx::PointF(220, 300)); |
| 973 squash2->SetDrawsContent(true); | 955 squash2->SetDrawsContent(true); |
| 974 | 956 |
| 975 scroll->test_properties()->AddChild(std::move(squash2)); | 957 scroll->test_properties()->AddChild(std::move(squash2)); |
| 976 clip->test_properties()->AddChild(std::move(scroll)); | 958 clip->test_properties()->AddChild(std::move(scroll)); |
| 977 clip->test_properties()->AddChild(std::move(scrollbar)); | 959 clip->test_properties()->AddChild(std::move(scrollbar)); |
| 978 clip->test_properties()->AddChild(std::move(squash1)); | 960 clip->test_properties()->AddChild(std::move(squash1)); |
| 979 root->test_properties()->AddChild(std::move(clip)); | 961 root->test_properties()->AddChild(std::move(clip)); |
| 980 | 962 |
| 981 layer_tree_impl->SetRootLayerForTesting(std::move(root)); | 963 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
| 982 SetNeedsRebuildPropertyTrees(); | 964 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 983 RebuildPropertyTrees(); | |
| 984 layer_tree_impl->DidBecomeActive(); | 965 layer_tree_impl->DidBecomeActive(); |
| 985 | 966 |
| 986 // The point hits squash1 layer and also scroll layer, because scroll layer is | 967 // The point hits squash1 layer and also scroll layer, because scroll layer is |
| 987 // not an ancestor of squash1 layer, we cannot scroll on impl thread. | 968 // not an ancestor of squash1 layer, we cannot scroll on impl thread. |
| 988 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 969 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 989 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); | 970 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); |
| 990 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 971 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 991 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 972 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 992 status.main_thread_scrolling_reasons); | 973 status.main_thread_scrolling_reasons); |
| 993 | 974 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1005 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 986 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1006 } | 987 } |
| 1007 | 988 |
| 1008 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 989 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
| 1009 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 990 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1010 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 991 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1011 | 992 |
| 1012 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 993 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 1013 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 994 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 1014 | 995 |
| 1015 SetNeedsRebuildPropertyTrees(); | 996 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1016 DrawFrame(); | 997 DrawFrame(); |
| 1017 | 998 |
| 1018 // All scroll types inside the non-fast scrollable region should fail. | 999 // All scroll types inside the non-fast scrollable region should fail. |
| 1019 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1000 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 1020 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); | 1001 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); |
| 1021 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 1002 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 1022 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 1003 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
| 1023 status.main_thread_scrolling_reasons); | 1004 status.main_thread_scrolling_reasons); |
| 1024 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 1005 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
| 1025 InputHandler::WHEEL)); | 1006 InputHandler::WHEEL)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1039 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 1059 host_impl_->ScrollEnd(EndState().get()); | 1040 host_impl_->ScrollEnd(EndState().get()); |
| 1060 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1041 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 1061 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1042 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
| 1062 } | 1043 } |
| 1063 | 1044 |
| 1064 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 1045 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
| 1065 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1046 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1066 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1047 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1067 | 1048 |
| 1068 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1049 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1069 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1050 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 1070 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 1051 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
| 1071 root->SetDrawsContent(true); | 1052 root->SetDrawsContent(true); |
| 1072 | 1053 |
| 1073 SetNeedsRebuildPropertyTrees(); | 1054 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1074 DrawFrame(); | 1055 DrawFrame(); |
| 1075 | 1056 |
| 1076 // This point would fall into the non-fast scrollable region except that we've | 1057 // This point would fall into the non-fast scrollable region except that we've |
| 1077 // moved the layer down by 25 pixels. | 1058 // moved the layer down by 25 pixels. |
| 1078 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1059 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 1079 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); | 1060 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); |
| 1080 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1061 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1081 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1062 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1082 status.main_thread_scrolling_reasons); | 1063 status.main_thread_scrolling_reasons); |
| 1083 | 1064 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 | 1184 |
| 1204 DrawFrame(); | 1185 DrawFrame(); |
| 1205 | 1186 |
| 1206 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1187 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1207 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1188 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1208 InputHandler::WHEEL) | 1189 InputHandler::WHEEL) |
| 1209 .thread); | 1190 .thread); |
| 1210 | 1191 |
| 1211 // Trying to scroll if not user_scrollable_vertical will fail. | 1192 // Trying to scroll if not user_scrollable_vertical will fail. |
| 1212 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); | 1193 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); |
| 1213 SetNeedsRebuildPropertyTrees(); | 1194 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1214 DrawFrame(); | 1195 DrawFrame(); |
| 1215 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 1196 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
| 1216 gfx::Point(), SCROLL_FORWARD)); | 1197 gfx::Point(), SCROLL_FORWARD)); |
| 1217 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 1198 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
| 1218 gfx::Point(), SCROLL_BACKWARD)); | 1199 gfx::Point(), SCROLL_BACKWARD)); |
| 1219 | 1200 |
| 1220 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); | 1201 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); |
| 1221 SetNeedsRebuildPropertyTrees(); | 1202 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1222 DrawFrame(); | 1203 DrawFrame(); |
| 1223 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1204 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
| 1224 gfx::Point(), SCROLL_FORWARD)); | 1205 gfx::Point(), SCROLL_FORWARD)); |
| 1225 EXPECT_FLOAT_EQ(875.f, | 1206 EXPECT_FLOAT_EQ(875.f, |
| 1226 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | 1207 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); |
| 1227 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1208 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
| 1228 gfx::Point(), SCROLL_BACKWARD)); | 1209 gfx::Point(), SCROLL_BACKWARD)); |
| 1229 } | 1210 } |
| 1230 | 1211 |
| 1231 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1212 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1232 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1213 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1233 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1214 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1234 | 1215 |
| 1235 gfx::Size overflow_size(400, 400); | 1216 gfx::Size overflow_size(400, 400); |
| 1236 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1217 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1237 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1218 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1238 overflow->SetBounds(overflow_size); | 1219 overflow->SetBounds(overflow_size); |
| 1239 overflow->SetScrollClipLayer( | 1220 overflow->SetScrollClipLayer( |
| 1240 scroll_layer->test_properties()->parent->test_properties()->parent->id()); | 1221 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
| 1241 overflow->layer_tree_impl() | 1222 overflow->layer_tree_impl() |
| 1242 ->property_trees() | 1223 ->property_trees() |
| 1243 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1224 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
| 1244 gfx::ScrollOffset()); | 1225 gfx::ScrollOffset()); |
| 1245 overflow->SetPosition(gfx::PointF()); | 1226 overflow->SetPosition(gfx::PointF()); |
| 1227 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1246 | 1228 |
| 1247 SetNeedsRebuildPropertyTrees(); | |
| 1248 DrawFrame(); | 1229 DrawFrame(); |
| 1249 gfx::Point scroll_position(10, 10); | 1230 gfx::Point scroll_position(10, 10); |
| 1250 | 1231 |
| 1251 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1232 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1252 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1233 host_impl_->ScrollBegin(BeginState(scroll_position).get(), |
| 1253 InputHandler::WHEEL) | 1234 InputHandler::WHEEL) |
| 1254 .thread); | 1235 .thread); |
| 1255 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1236 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1256 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1237 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
| 1257 | 1238 |
| 1258 gfx::Vector2dF scroll_delta(10, 10); | 1239 gfx::Vector2dF scroll_delta(10, 10); |
| 1259 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1240 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1260 host_impl_->ScrollEnd(EndState().get()); | 1241 host_impl_->ScrollEnd(EndState().get()); |
| 1261 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1242 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1262 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1243 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1263 | 1244 |
| 1264 overflow->set_user_scrollable_horizontal(false); | 1245 overflow->set_user_scrollable_horizontal(false); |
| 1265 SetNeedsRebuildPropertyTrees(); | 1246 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1247 |
| 1266 DrawFrame(); | 1248 DrawFrame(); |
| 1267 | 1249 |
| 1268 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1250 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1269 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1251 host_impl_->ScrollBegin(BeginState(scroll_position).get(), |
| 1270 InputHandler::WHEEL) | 1252 InputHandler::WHEEL) |
| 1271 .thread); | 1253 .thread); |
| 1272 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1254 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1273 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1255 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1274 | 1256 |
| 1275 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1257 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1276 host_impl_->ScrollEnd(EndState().get()); | 1258 host_impl_->ScrollEnd(EndState().get()); |
| 1277 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1259 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1278 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1260 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1279 | 1261 |
| 1280 overflow->set_user_scrollable_vertical(false); | 1262 overflow->set_user_scrollable_vertical(false); |
| 1281 SetNeedsRebuildPropertyTrees(); | 1263 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1282 DrawFrame(); | 1264 DrawFrame(); |
| 1283 | 1265 |
| 1284 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1266 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1285 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1267 host_impl_->ScrollBegin(BeginState(scroll_position).get(), |
| 1286 InputHandler::WHEEL) | 1268 InputHandler::WHEEL) |
| 1287 .thread); | 1269 .thread); |
| 1288 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1270 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1289 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1271 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1290 | 1272 |
| 1291 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1273 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1292 host_impl_->ScrollEnd(EndState().get()); | 1274 host_impl_->ScrollEnd(EndState().get()); |
| 1293 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); | 1275 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); |
| 1294 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1276 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1295 } | 1277 } |
| 1296 | 1278 |
| 1297 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1279 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
| 1298 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1280 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 1299 | 1281 |
| 1300 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1282 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1301 | 1283 |
| 1302 host_impl_->CreatePendingTree(); | 1284 host_impl_->CreatePendingTree(); |
| 1303 host_impl_->pending_tree()->SetRootLayerForTesting( | 1285 auto root_owned = LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 1304 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1286 auto* root = root_owned.get(); |
| 1305 LayerImpl* root = host_impl_->pending_tree()->root_layer_for_testing(); | 1287 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(root_owned)); |
| 1306 root->SetBounds(gfx::Size(50, 50)); | 1288 root->SetBounds(gfx::Size(50, 50)); |
| 1307 root->test_properties()->force_render_surface = true; | 1289 root->test_properties()->force_render_surface = true; |
| 1308 | 1290 |
| 1309 root->test_properties()->AddChild( | 1291 root->test_properties()->AddChild( |
| 1310 LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1292 LayerImpl::Create(host_impl_->pending_tree(), 2)); |
| 1311 host_impl_->pending_tree()->BuildLayerListForTesting(); | |
| 1312 LayerImpl* child = root->test_properties()->children[0]; | 1293 LayerImpl* child = root->test_properties()->children[0]; |
| 1313 child->SetBounds(gfx::Size(10, 10)); | 1294 child->SetBounds(gfx::Size(10, 10)); |
| 1314 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1295 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1315 child->SetDrawsContent(true); | 1296 child->SetDrawsContent(true); |
| 1316 | 1297 |
| 1317 host_impl_->pending_tree()->SetElementIdsForTesting(); | 1298 host_impl_->pending_tree()->SetElementIdsForTesting(); |
| 1318 | 1299 |
| 1319 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, | 1300 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1320 3, 0); | 1301 3, 0); |
| 1321 | 1302 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1351 EXPECT_FALSE(did_request_commit_); | 1332 EXPECT_FALSE(did_request_commit_); |
| 1352 } | 1333 } |
| 1353 | 1334 |
| 1354 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1335 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
| 1355 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1336 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 1356 | 1337 |
| 1357 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1338 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1358 | 1339 |
| 1359 host_impl_->active_tree()->SetRootLayerForTesting( | 1340 host_impl_->active_tree()->SetRootLayerForTesting( |
| 1360 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1341 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1361 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1342 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1362 root->SetBounds(gfx::Size(50, 50)); | 1343 root->SetBounds(gfx::Size(50, 50)); |
| 1363 root->test_properties()->force_render_surface = true; | 1344 root->test_properties()->force_render_surface = true; |
| 1364 | 1345 |
| 1365 root->test_properties()->AddChild( | 1346 root->test_properties()->AddChild( |
| 1366 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1347 LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1367 LayerImpl* child = root->test_properties()->children[0]; | 1348 LayerImpl* child = root->test_properties()->children[0]; |
| 1368 child->SetBounds(gfx::Size(10, 10)); | 1349 child->SetBounds(gfx::Size(10, 10)); |
| 1369 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1350 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1370 child->SetDrawsContent(true); | 1351 child->SetDrawsContent(true); |
| 1371 | 1352 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 } | 1397 } |
| 1417 | 1398 |
| 1418 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { | 1399 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
| 1419 FakeImplTaskRunnerProvider provider(nullptr); | 1400 FakeImplTaskRunnerProvider provider(nullptr); |
| 1420 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), | 1401 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), |
| 1421 &provider); | 1402 &provider); |
| 1422 EXPECT_TRUE(host_impl_->CommitToActiveTree()); | 1403 EXPECT_TRUE(host_impl_->CommitToActiveTree()); |
| 1423 | 1404 |
| 1424 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1405 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1425 | 1406 |
| 1426 host_impl_->active_tree()->SetRootLayerForTesting( | 1407 auto root_owned = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1427 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1408 auto* root = root_owned.get(); |
| 1428 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1409 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_owned)); |
| 1429 root->SetBounds(gfx::Size(50, 50)); | 1410 root->SetBounds(gfx::Size(50, 50)); |
| 1430 root->SetHasRenderSurface(true); | 1411 root->SetHasRenderSurface(true); |
| 1431 | 1412 |
| 1432 root->test_properties()->AddChild( | 1413 auto child_owned = LayerImpl::Create(host_impl_->active_tree(), 2); |
| 1433 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1414 auto* child = child_owned.get(); |
| 1434 LayerImpl* child = root->test_properties()->children[0]; | 1415 root->test_properties()->AddChild(std::move(child_owned)); |
| 1435 child->SetBounds(gfx::Size(10, 10)); | 1416 child->SetBounds(gfx::Size(10, 10)); |
| 1436 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1417 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1437 child->SetDrawsContent(true); | 1418 child->SetDrawsContent(true); |
| 1438 | 1419 |
| 1439 host_impl_->active_tree()->SetElementIdsForTesting(); | 1420 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 1440 | 1421 |
| 1441 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, | 1422 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1442 3, 0); | 1423 3, 0); |
| 1443 | 1424 |
| 1444 // Set up the property trees so that UpdateDrawProperties will work in | 1425 // Set up the property trees so that UpdateDrawProperties will work in |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1462 | 1443 |
| 1463 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. | 1444 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
| 1464 host_impl_ = nullptr; | 1445 host_impl_ = nullptr; |
| 1465 } | 1446 } |
| 1466 | 1447 |
| 1467 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { | 1448 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
| 1468 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1449 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1469 | 1450 |
| 1470 host_impl_->active_tree()->SetRootLayerForTesting( | 1451 host_impl_->active_tree()->SetRootLayerForTesting( |
| 1471 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1452 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1472 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1453 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1473 root->SetBounds(gfx::Size(50, 50)); | 1454 root->SetBounds(gfx::Size(50, 50)); |
| 1474 | 1455 |
| 1475 root->test_properties()->AddChild( | 1456 root->test_properties()->AddChild( |
| 1476 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1457 LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1477 LayerImpl* child = root->test_properties()->children[0]; | 1458 LayerImpl* child = root->test_properties()->children[0]; |
| 1478 child->SetBounds(gfx::Size(10, 10)); | 1459 child->SetBounds(gfx::Size(10, 10)); |
| 1479 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1460 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1480 child->SetDrawsContent(true); | 1461 child->SetDrawsContent(true); |
| 1481 | 1462 |
| 1482 host_impl_->active_tree()->SetElementIdsForTesting(); | 1463 host_impl_->active_tree()->SetElementIdsForTesting(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 | 1518 |
| 1538 private: | 1519 private: |
| 1539 bool has_missing_tiles_; | 1520 bool has_missing_tiles_; |
| 1540 }; | 1521 }; |
| 1541 | 1522 |
| 1542 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { | 1523 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { |
| 1543 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1524 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1544 | 1525 |
| 1545 host_impl_->active_tree()->SetRootLayerForTesting( | 1526 host_impl_->active_tree()->SetRootLayerForTesting( |
| 1546 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1527 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1547 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1528 LayerImpl* root = *host_impl_->active_tree()->begin(); |
| 1548 root->SetBounds(gfx::Size(50, 50)); | 1529 root->SetBounds(gfx::Size(50, 50)); |
| 1549 root->SetHasRenderSurface(true); | 1530 root->SetHasRenderSurface(true); |
| 1550 | 1531 |
| 1551 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( | 1532 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( |
| 1552 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1533 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
| 1553 MissingTilesLayer* child = | 1534 MissingTilesLayer* child = |
| 1554 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); | 1535 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); |
| 1555 child->SetBounds(gfx::Size(10, 10)); | 1536 child->SetBounds(gfx::Size(10, 10)); |
| 1556 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1537 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1557 child->SetDrawsContent(true); | 1538 child->SetDrawsContent(true); |
| 1539 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1558 | 1540 |
| 1559 host_impl_->active_tree()->SetElementIdsForTesting(); | 1541 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 1560 | 1542 |
| 1561 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1543 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
| 1562 | 1544 |
| 1563 // Add a translate from 6,7 to 8,9. | 1545 // Add a translate from 6,7 to 8,9. |
| 1564 TransformOperations start; | 1546 TransformOperations start; |
| 1565 start.AppendTranslate(6.f, 7.f, 0.f); | 1547 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1566 TransformOperations end; | 1548 TransformOperations end; |
| 1567 end.AppendTranslate(8.f, 9.f, 0.f); | 1549 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1568 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1550 int animation_id = AddAnimatedTransformToElementWithPlayer( |
| 1569 child->element_id(), timeline(), 4.0, start, end); | 1551 child->element_id(), timeline(), 4.0, start, end); |
| 1570 | 1552 |
| 1571 base::TimeTicks now = base::TimeTicks::Now(); | 1553 base::TimeTicks now = base::TimeTicks::Now(); |
| 1572 host_impl_->WillBeginImplFrame( | 1554 host_impl_->WillBeginImplFrame( |
| 1573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1555 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
| 1574 | 1556 |
| 1575 host_impl_->ActivateAnimations(); | 1557 host_impl_->ActivateAnimations(); |
| 1576 host_impl_->Animate(); | 1558 host_impl_->Animate(); |
| 1577 | 1559 |
| 1578 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1560 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
| 1579 | 1561 |
| 1580 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | |
| 1581 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 1582 host_impl_->ResetRequiresHighResToDraw(); | 1562 host_impl_->ResetRequiresHighResToDraw(); |
| 1583 | 1563 |
| 1584 // Child layer has an animating transform but missing tiles. | 1564 // Child layer has an animating transform but missing tiles. |
| 1585 FakeLayerTreeHostImpl::FrameData frame; | 1565 FakeLayerTreeHostImpl::FrameData frame; |
| 1586 DrawResult result = host_impl_->PrepareToDraw(&frame); | 1566 DrawResult result = host_impl_->PrepareToDraw(&frame); |
| 1587 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1567 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
| 1588 host_impl_->DidDrawAllLayers(frame); | 1568 host_impl_->DidDrawAllLayers(frame); |
| 1589 | 1569 |
| 1590 child->set_has_missing_tiles(false); | 1570 child->set_has_missing_tiles(false); |
| 1591 | 1571 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1621 // Child layer doesn't have an animation, and was ready at least once since | 1601 // Child layer doesn't have an animation, and was ready at least once since |
| 1622 // the last time it animated. | 1602 // the last time it animated. |
| 1623 result = host_impl_->PrepareToDraw(&frame); | 1603 result = host_impl_->PrepareToDraw(&frame); |
| 1624 EXPECT_EQ(DRAW_SUCCESS, result); | 1604 EXPECT_EQ(DRAW_SUCCESS, result); |
| 1625 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1605 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
| 1626 host_impl_->DidDrawAllLayers(frame); | 1606 host_impl_->DidDrawAllLayers(frame); |
| 1627 } | 1607 } |
| 1628 | 1608 |
| 1629 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 1609 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| 1630 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1610 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1611 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1612 |
| 1631 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1613 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1632 DrawFrame(); | 1614 DrawFrame(); |
| 1633 | 1615 |
| 1634 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 1616 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
| 1635 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 1617 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
| 1636 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 1618 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
| 1637 | 1619 |
| 1638 float min_page_scale = 1.f, max_page_scale = 4.f; | 1620 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 1639 float page_scale_factor = 1.f; | 1621 float page_scale_factor = 1.f; |
| 1640 | 1622 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); | 1687 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); |
| 1706 | 1688 |
| 1707 const gfx::Size content_size(1000, 1000); | 1689 const gfx::Size content_size(1000, 1000); |
| 1708 const gfx::Size viewport_size(500, 500); | 1690 const gfx::Size viewport_size(500, 500); |
| 1709 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1691 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1710 | 1692 |
| 1711 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1693 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1712 outer_scroll_layer->SetDrawsContent(true); | 1694 outer_scroll_layer->SetDrawsContent(true); |
| 1713 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1695 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1714 inner_scroll_layer->SetDrawsContent(true); | 1696 inner_scroll_layer->SetDrawsContent(true); |
| 1697 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1715 | 1698 |
| 1716 EXPECT_VECTOR_EQ( | 1699 EXPECT_VECTOR_EQ( |
| 1717 gfx::Vector2dF(500, 500), | 1700 gfx::Vector2dF(500, 500), |
| 1718 outer_scroll_layer->MaxScrollOffset()); | 1701 outer_scroll_layer->MaxScrollOffset()); |
| 1719 | 1702 |
| 1720 RebuildPropertyTrees(); | |
| 1721 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1703 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1722 InputHandler::TOUCHSCREEN); | 1704 InputHandler::TOUCHSCREEN); |
| 1723 host_impl_->PinchGestureBegin(); | 1705 host_impl_->PinchGestureBegin(); |
| 1724 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1706 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 1725 host_impl_->PinchGestureEnd(); | 1707 host_impl_->PinchGestureEnd(); |
| 1726 host_impl_->ScrollEnd(EndState().get()); | 1708 host_impl_->ScrollEnd(EndState().get()); |
| 1727 | 1709 |
| 1728 // Sanity check - we're zoomed in, starting from the origin. | 1710 // Sanity check - we're zoomed in, starting from the origin. |
| 1729 EXPECT_VECTOR_EQ( | 1711 EXPECT_VECTOR_EQ( |
| 1730 gfx::Vector2dF(0, 0), | 1712 gfx::Vector2dF(0, 0), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1753 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1772 | 1754 |
| 1773 const gfx::Size content_size(1000, 1000); | 1755 const gfx::Size content_size(1000, 1000); |
| 1774 const gfx::Size viewport_size(500, 500); | 1756 const gfx::Size viewport_size(500, 500); |
| 1775 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1757 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1776 | 1758 |
| 1777 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1759 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1778 outer_scroll_layer->SetDrawsContent(true); | 1760 outer_scroll_layer->SetDrawsContent(true); |
| 1779 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1761 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1780 inner_scroll_layer->SetDrawsContent(true); | 1762 inner_scroll_layer->SetDrawsContent(true); |
| 1763 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1781 | 1764 |
| 1782 // Sanity checks. | 1765 // Sanity checks. |
| 1783 EXPECT_VECTOR_EQ( | 1766 EXPECT_VECTOR_EQ( |
| 1784 gfx::Vector2dF(500, 500), | 1767 gfx::Vector2dF(500, 500), |
| 1785 outer_scroll_layer->MaxScrollOffset()); | 1768 outer_scroll_layer->MaxScrollOffset()); |
| 1786 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 1769 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 1787 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); | 1770 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); |
| 1788 | 1771 |
| 1789 RebuildPropertyTrees(); | |
| 1790 | |
| 1791 // Scroll only the layout viewport. | 1772 // Scroll only the layout viewport. |
| 1792 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1773 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1793 InputHandler::TOUCHSCREEN); | 1774 InputHandler::TOUCHSCREEN); |
| 1794 host_impl_->ScrollBy( | 1775 host_impl_->ScrollBy( |
| 1795 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); | 1776 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); |
| 1796 EXPECT_VECTOR2DF_EQ( | 1777 EXPECT_VECTOR2DF_EQ( |
| 1797 gfx::Vector2dF(0.125f, 0.125f), | 1778 gfx::Vector2dF(0.125f, 0.125f), |
| 1798 outer_scroll_layer->CurrentScrollOffset()); | 1779 outer_scroll_layer->CurrentScrollOffset()); |
| 1799 EXPECT_VECTOR2DF_EQ( | 1780 EXPECT_VECTOR2DF_EQ( |
| 1800 gfx::Vector2dF(0, 0), | 1781 gfx::Vector2dF(0, 0), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1827 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1808 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1828 | 1809 |
| 1829 const gfx::Size content_size(1000, 1000); | 1810 const gfx::Size content_size(1000, 1000); |
| 1830 const gfx::Size viewport_size(500, 500); | 1811 const gfx::Size viewport_size(500, 500); |
| 1831 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1812 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1832 | 1813 |
| 1833 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1814 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1834 outer_scroll_layer->SetDrawsContent(true); | 1815 outer_scroll_layer->SetDrawsContent(true); |
| 1835 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1816 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1836 inner_scroll_layer->SetDrawsContent(true); | 1817 inner_scroll_layer->SetDrawsContent(true); |
| 1818 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1837 | 1819 |
| 1838 EXPECT_VECTOR_EQ( | 1820 EXPECT_VECTOR_EQ( |
| 1839 gfx::Vector2dF(500, 500), | 1821 gfx::Vector2dF(500, 500), |
| 1840 outer_scroll_layer->MaxScrollOffset()); | 1822 outer_scroll_layer->MaxScrollOffset()); |
| 1841 | 1823 |
| 1842 RebuildPropertyTrees(); | |
| 1843 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1824 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1844 InputHandler::TOUCHSCREEN); | 1825 InputHandler::TOUCHSCREEN); |
| 1845 host_impl_->PinchGestureBegin(); | 1826 host_impl_->PinchGestureBegin(); |
| 1846 | 1827 |
| 1847 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); | 1828 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); |
| 1848 EXPECT_VECTOR_EQ( | 1829 EXPECT_VECTOR_EQ( |
| 1849 gfx::Vector2dF(0, 0), | 1830 gfx::Vector2dF(0, 0), |
| 1850 outer_scroll_layer->CurrentScrollOffset()); | 1831 outer_scroll_layer->CurrentScrollOffset()); |
| 1851 EXPECT_VECTOR_EQ( | 1832 EXPECT_VECTOR_EQ( |
| 1852 gfx::Vector2dF(125, 125), | 1833 gfx::Vector2dF(125, 125), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 const gfx::Size content_size(1000, 1000); | 1872 const gfx::Size content_size(1000, 1000); |
| 1892 const gfx::Size viewport_size(500, 500); | 1873 const gfx::Size viewport_size(500, 500); |
| 1893 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1874 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1894 | 1875 |
| 1895 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; | 1876 int offsetFromEdge = Viewport::kPinchZoomSnapMarginDips - 5; |
| 1896 gfx::Point anchor(viewport_size.width() - offsetFromEdge, | 1877 gfx::Point anchor(viewport_size.width() - offsetFromEdge, |
| 1897 viewport_size.height() - offsetFromEdge); | 1878 viewport_size.height() - offsetFromEdge); |
| 1898 | 1879 |
| 1899 // Pinch in within the margins. The scroll should stay exactly locked to the | 1880 // Pinch in within the margins. The scroll should stay exactly locked to the |
| 1900 // bottom and right. | 1881 // bottom and right. |
| 1901 RebuildPropertyTrees(); | |
| 1902 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); | 1882 host_impl_->ScrollBegin(BeginState(anchor).get(), InputHandler::TOUCHSCREEN); |
| 1903 host_impl_->PinchGestureBegin(); | 1883 host_impl_->PinchGestureBegin(); |
| 1904 host_impl_->PinchGestureUpdate(2, anchor); | 1884 host_impl_->PinchGestureUpdate(2, anchor); |
| 1905 host_impl_->PinchGestureEnd(); | 1885 host_impl_->PinchGestureEnd(); |
| 1906 host_impl_->ScrollEnd(EndState().get()); | 1886 host_impl_->ScrollEnd(EndState().get()); |
| 1907 | 1887 |
| 1908 EXPECT_VECTOR_EQ( | 1888 EXPECT_VECTOR_EQ( |
| 1909 gfx::Vector2dF(250, 250), | 1889 gfx::Vector2dF(250, 250), |
| 1910 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 1890 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 1911 | 1891 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 const gfx::Size content_size(200, 200); | 1949 const gfx::Size content_size(200, 200); |
| 1970 const gfx::Size viewport_size(100, 100); | 1950 const gfx::Size viewport_size(100, 100); |
| 1971 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1951 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1972 | 1952 |
| 1973 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1953 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1974 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1954 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1975 | 1955 |
| 1976 // Zoom into the page by a 2X factor | 1956 // Zoom into the page by a 2X factor |
| 1977 float min_page_scale = 1.f, max_page_scale = 4.f; | 1957 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 1978 float page_scale_factor = 2.f; | 1958 float page_scale_factor = 2.f; |
| 1979 RebuildPropertyTrees(); | |
| 1980 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1959 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1981 page_scale_factor, min_page_scale, max_page_scale); | 1960 page_scale_factor, min_page_scale, max_page_scale); |
| 1982 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1961 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1983 | 1962 |
| 1984 // Scroll by a small amount, there should be no bubbling to the outer | 1963 // Scroll by a small amount, there should be no bubbling to the outer |
| 1985 // viewport. | 1964 // viewport. |
| 1986 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1965 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1987 InputHandler::WHEEL); | 1966 InputHandler::WHEEL); |
| 1988 host_impl_->ScrollBy( | 1967 host_impl_->ScrollBy( |
| 1989 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); | 1968 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 scroll_child_clip->test_properties()->AddChild(std::move(scroll_child)); | 2061 scroll_child_clip->test_properties()->AddChild(std::move(scroll_child)); |
| 2083 | 2062 |
| 2084 child_clip = scroll_child_clip.get(); | 2063 child_clip = scroll_child_clip.get(); |
| 2085 viewport_scroll->test_properties()->AddChild(std::move(scroll_child_clip)); | 2064 viewport_scroll->test_properties()->AddChild(std::move(scroll_child_clip)); |
| 2086 | 2065 |
| 2087 child_clip->test_properties()->scroll_parent = parent; | 2066 child_clip->test_properties()->scroll_parent = parent; |
| 2088 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 2067 std::unique_ptr<std::set<LayerImpl*>> scroll_children( |
| 2089 new std::set<LayerImpl*>); | 2068 new std::set<LayerImpl*>); |
| 2090 scroll_children->insert(child_clip); | 2069 scroll_children->insert(child_clip); |
| 2091 parent->test_properties()->scroll_children.reset(scroll_children.release()); | 2070 parent->test_properties()->scroll_children.reset(scroll_children.release()); |
| 2071 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2092 | 2072 |
| 2093 SetNeedsRebuildPropertyTrees(); | |
| 2094 DrawFrame(); | 2073 DrawFrame(); |
| 2095 | 2074 |
| 2096 { | 2075 { |
| 2097 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), | 2076 host_impl_->ScrollBegin(BeginState(gfx::Point(21, 21)).get(), |
| 2098 InputHandler::TOUCHSCREEN); | 2077 InputHandler::TOUCHSCREEN); |
| 2099 host_impl_->ScrollBy( | 2078 host_impl_->ScrollBy( |
| 2100 UpdateState(gfx::Point(21, 21), gfx::Vector2d(5, 5)).get()); | 2079 UpdateState(gfx::Point(21, 21), gfx::Vector2d(5, 5)).get()); |
| 2101 host_impl_->ScrollBy( | 2080 host_impl_->ScrollBy( |
| 2102 UpdateState(gfx::Point(21, 21), gfx::Vector2d(100, 100)).get()); | 2081 UpdateState(gfx::Point(21, 21), gfx::Vector2d(100, 100)).get()); |
| 2103 host_impl_->ScrollEnd(EndState().get()); | 2082 host_impl_->ScrollEnd(EndState().get()); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 ExpectNone(*scroll_info, scroll_layer->id()); | 2478 ExpectNone(*scroll_info, scroll_layer->id()); |
| 2500 } | 2479 } |
| 2501 } | 2480 } |
| 2502 | 2481 |
| 2503 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { | 2482 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
| 2504 host_impl_->CreatePendingTree(); | 2483 host_impl_->CreatePendingTree(); |
| 2505 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2484 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 2506 CreateScrollAndContentsLayers( | 2485 CreateScrollAndContentsLayers( |
| 2507 host_impl_->pending_tree(), | 2486 host_impl_->pending_tree(), |
| 2508 gfx::Size(100, 100)); | 2487 gfx::Size(100, 100)); |
| 2509 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2488 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 2510 host_impl_->ActivateSyncTree(); | 2489 host_impl_->ActivateSyncTree(); |
| 2511 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | |
| 2512 DrawFrame(); | 2490 DrawFrame(); |
| 2513 | 2491 |
| 2514 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2492 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2515 DCHECK(scroll_layer); | 2493 DCHECK(scroll_layer); |
| 2516 | 2494 |
| 2517 float min_page_scale = 0.5f; | 2495 float min_page_scale = 0.5f; |
| 2518 float max_page_scale = 4.f; | 2496 float max_page_scale = 4.f; |
| 2519 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2497 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2520 max_page_scale); | 2498 max_page_scale); |
| 2521 host_impl_->ActivateSyncTree(); | 2499 host_impl_->ActivateSyncTree(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 host_impl_->WillBeginImplFrame(begin_frame_args); | 2644 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2667 host_impl_->Animate(); | 2645 host_impl_->Animate(); |
| 2668 EXPECT_TRUE(did_complete_page_scale_animation_); | 2646 EXPECT_TRUE(did_complete_page_scale_animation_); |
| 2669 host_impl_->DidFinishImplFrame(); | 2647 host_impl_->DidFinishImplFrame(); |
| 2670 } | 2648 } |
| 2671 | 2649 |
| 2672 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { | 2650 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { |
| 2673 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2651 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2674 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2652 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2675 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2653 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 2676 SetNeedsRebuildPropertyTrees(); | 2654 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2677 DrawFrame(); | 2655 DrawFrame(); |
| 2678 | 2656 |
| 2679 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 2657 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 2680 LayerImpl* inner_container = inner_scroll->scroll_clip_layer(); | 2658 LayerImpl* inner_container = inner_scroll->scroll_clip_layer(); |
| 2681 DCHECK(inner_scroll); | 2659 DCHECK(inner_scroll); |
| 2682 DCHECK(inner_container); | 2660 DCHECK(inner_container); |
| 2683 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset()); | 2661 EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset()); |
| 2684 | 2662 |
| 2685 inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f)); | 2663 inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f)); |
| 2686 inner_scroll->SetBoundsDelta(gfx::Vector2dF(7.f, 7.f)); | 2664 inner_scroll->SetBoundsDelta(gfx::Vector2dF(7.f, 7.f)); |
| 2687 EXPECT_EQ(gfx::ScrollOffset(42, 42), inner_scroll->MaxScrollOffset()); | 2665 EXPECT_EQ(gfx::ScrollOffset(42, 42), inner_scroll->MaxScrollOffset()); |
| 2688 | 2666 |
| 2689 inner_container->SetBoundsDelta(gfx::Vector2dF()); | 2667 inner_container->SetBoundsDelta(gfx::Vector2dF()); |
| 2690 inner_scroll->SetBoundsDelta(gfx::Vector2dF()); | 2668 inner_scroll->SetBoundsDelta(gfx::Vector2dF()); |
| 2691 inner_scroll->SetBounds(gfx::Size()); | 2669 inner_scroll->SetBounds(gfx::Size()); |
| 2692 SetNeedsRebuildPropertyTrees(); | 2670 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2693 DrawFrame(); | 2671 DrawFrame(); |
| 2694 | 2672 |
| 2695 inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f)); | 2673 inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f)); |
| 2696 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset()); | 2674 EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset()); |
| 2697 } | 2675 } |
| 2698 | 2676 |
| 2699 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { | 2677 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
| 2700 public: | 2678 public: |
| 2701 LayerTreeHostImplOverridePhysicalTime( | 2679 LayerTreeHostImplOverridePhysicalTime( |
| 2702 const LayerTreeSettings& settings, | 2680 const LayerTreeSettings& settings, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2750 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2728 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 2751 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | 2729 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, |
| 2752 VERTICAL, 10, 0, false, true); | 2730 VERTICAL, 10, 0, false, true); |
| 2753 scrollbar->test_properties()->opacity = 0.f; | 2731 scrollbar->test_properties()->opacity = 0.f; |
| 2754 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); | 2732 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); |
| 2755 | 2733 |
| 2756 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | 2734 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2757 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | 2735 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2758 scrollbar->SetScrollLayerId(scroll->id()); | 2736 scrollbar->SetScrollLayerId(scroll->id()); |
| 2759 root->test_properties()->AddChild(std::move(scrollbar)); | 2737 root->test_properties()->AddChild(std::move(scrollbar)); |
| 2760 | 2738 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2761 host_impl_->active_tree()->DidBecomeActive(); | 2739 host_impl_->active_tree()->DidBecomeActive(); |
| 2762 SetNeedsRebuildPropertyTrees(); | |
| 2763 DrawFrame(); | 2740 DrawFrame(); |
| 2764 } | 2741 } |
| 2765 | 2742 |
| 2766 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2743 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2767 LayerTreeSettings settings = DefaultSettings(); | 2744 LayerTreeSettings settings = DefaultSettings(); |
| 2768 settings.scrollbar_animator = animator; | 2745 settings.scrollbar_animator = animator; |
| 2769 settings.scrollbar_fade_delay_ms = 20; | 2746 settings.scrollbar_fade_delay_ms = 20; |
| 2770 settings.scrollbar_fade_duration_ms = 20; | 2747 settings.scrollbar_fade_duration_ms = 20; |
| 2771 | 2748 |
| 2772 SetupLayers(settings); | 2749 SetupLayers(settings); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2935 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2912 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 2936 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 2913 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
| 2937 VERTICAL, 10, 0, false, true); | 2914 VERTICAL, 10, 0, false, true); |
| 2938 scrollbar->test_properties()->opacity = 0.f; | 2915 scrollbar->test_properties()->opacity = 0.f; |
| 2939 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 2916 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
| 2940 LayerImpl* container = | 2917 LayerImpl* container = |
| 2941 host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2918 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 2942 scrollbar->SetScrollLayerId(scroll->id()); | 2919 scrollbar->SetScrollLayerId(scroll->id()); |
| 2943 container->test_properties()->AddChild(std::move(scrollbar)); | 2920 container->test_properties()->AddChild(std::move(scrollbar)); |
| 2944 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2921 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 2945 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2922 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 2946 host_impl_->ActivateSyncTree(); | 2923 host_impl_->ActivateSyncTree(); |
| 2947 | 2924 |
| 2948 LayerImpl* active_scrollbar_layer = | 2925 LayerImpl* active_scrollbar_layer = |
| 2949 host_impl_->active_tree()->LayerById(400); | 2926 host_impl_->active_tree()->LayerById(400); |
| 2950 | 2927 |
| 2951 EffectNode* active_tree_node = | 2928 EffectNode* active_tree_node = |
| 2952 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 2929 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
| 2953 active_scrollbar_layer->effect_tree_index()); | 2930 active_scrollbar_layer->effect_tree_index()); |
| 2954 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), | 2931 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), |
| 2955 active_tree_node->data.opacity); | 2932 active_tree_node->data.opacity); |
| 2956 | 2933 |
| 2957 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) | 2934 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) |
| 2958 ->DidMouseMoveNear(0); | 2935 ->DidMouseMoveNear(0); |
| 2959 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2936 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2960 InputHandler::WHEEL); | 2937 InputHandler::WHEEL); |
| 2961 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2938 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
| 2962 host_impl_->ScrollEnd(EndState().get()); | 2939 host_impl_->ScrollEnd(EndState().get()); |
| 2963 host_impl_->CreatePendingTree(); | 2940 host_impl_->CreatePendingTree(); |
| 2964 // To test the case where the effect tree index of scrollbar layer changes, | 2941 // To test the case where the effect tree index of scrollbar layer changes, |
| 2965 // we force the container layer to create a render surface. | 2942 // we force the container layer to create a render surface. |
| 2966 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2943 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 2967 container->test_properties()->force_render_surface = true; | 2944 container->test_properties()->force_render_surface = true; |
| 2968 container->SetBounds(gfx::Size(10, 10)); | 2945 container->SetBounds(gfx::Size(10, 10)); |
| 2969 host_impl_->pending_tree()->property_trees()->needs_rebuild = true; | 2946 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 2970 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 2971 | 2947 |
| 2972 LayerImpl* pending_scrollbar_layer = | 2948 LayerImpl* pending_scrollbar_layer = |
| 2973 host_impl_->pending_tree()->LayerById(400); | 2949 host_impl_->pending_tree()->LayerById(400); |
| 2974 EffectNode* pending_tree_node = | 2950 EffectNode* pending_tree_node = |
| 2975 host_impl_->pending_tree()->property_trees()->effect_tree.Node( | 2951 host_impl_->pending_tree()->property_trees()->effect_tree.Node( |
| 2976 pending_scrollbar_layer->effect_tree_index()); | 2952 pending_scrollbar_layer->effect_tree_index()); |
| 2977 host_impl_->pending_tree() | 2953 host_impl_->pending_tree() |
| 2978 ->property_trees() | 2954 ->property_trees() |
| 2979 ->always_use_active_tree_opacity_effect_ids.push_back(400); | 2955 ->always_use_active_tree_opacity_effect_ids.push_back(400); |
| 2980 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); | 2956 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3178 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, | 3154 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, |
| 3179 VERTICAL, 5, 5, true, true); | 3155 VERTICAL, 5, 5, true, true); |
| 3180 scrollbar->SetScrollLayerId(root_scroll->id()); | 3156 scrollbar->SetScrollLayerId(root_scroll->id()); |
| 3181 scrollbar->SetDrawsContent(true); | 3157 scrollbar->SetDrawsContent(true); |
| 3182 scrollbar->SetBounds(scrollbar_size); | 3158 scrollbar->SetBounds(scrollbar_size); |
| 3183 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); | 3159 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); |
| 3184 host_impl_->active_tree() | 3160 host_impl_->active_tree() |
| 3185 ->InnerViewportContainerLayer() | 3161 ->InnerViewportContainerLayer() |
| 3186 ->test_properties() | 3162 ->test_properties() |
| 3187 ->AddChild(std::move(scrollbar)); | 3163 ->AddChild(std::move(scrollbar)); |
| 3164 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3188 host_impl_->active_tree()->DidBecomeActive(); | 3165 host_impl_->active_tree()->DidBecomeActive(); |
| 3189 | 3166 |
| 3190 DrawFrame(); | 3167 DrawFrame(); |
| 3191 host_impl_->active_tree()->UpdateDrawProperties(false); | 3168 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 3192 | 3169 |
| 3193 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 3170 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
| 3194 static_cast<ScrollbarAnimationControllerThinning*>( | 3171 static_cast<ScrollbarAnimationControllerThinning*>( |
| 3195 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 3172 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
| 3196 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 3173 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |
| 3197 | 3174 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3410 bool will_draw_called_; | 3387 bool will_draw_called_; |
| 3411 bool append_quads_called_; | 3388 bool append_quads_called_; |
| 3412 bool did_draw_called_; | 3389 bool did_draw_called_; |
| 3413 }; | 3390 }; |
| 3414 | 3391 |
| 3415 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 3392 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
| 3416 // The root layer is always drawn, so run this test on a child layer that | 3393 // The root layer is always drawn, so run this test on a child layer that |
| 3417 // will be masked out by the root layer's bounds. | 3394 // will be masked out by the root layer's bounds. |
| 3418 host_impl_->active_tree()->SetRootLayerForTesting( | 3395 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3419 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3396 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3420 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3397 DidDrawCheckLayer* root = |
| 3421 host_impl_->active_tree()->root_layer_for_testing()); | 3398 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 3422 | 3399 |
| 3423 root->test_properties()->AddChild( | 3400 root->test_properties()->AddChild( |
| 3424 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3401 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3425 root->test_properties()->force_render_surface = true; | 3402 root->test_properties()->force_render_surface = true; |
| 3426 DidDrawCheckLayer* layer = | 3403 DidDrawCheckLayer* layer = |
| 3427 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3404 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3405 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3428 | 3406 |
| 3429 { | 3407 { |
| 3430 LayerTreeHostImpl::FrameData frame; | 3408 LayerTreeHostImpl::FrameData frame; |
| 3431 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3409 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3432 host_impl_->DrawLayers(&frame); | 3410 host_impl_->DrawLayers(&frame); |
| 3433 host_impl_->DidDrawAllLayers(frame); | 3411 host_impl_->DidDrawAllLayers(frame); |
| 3434 | 3412 |
| 3435 EXPECT_TRUE(layer->will_draw_called()); | 3413 EXPECT_TRUE(layer->will_draw_called()); |
| 3436 EXPECT_TRUE(layer->append_quads_called()); | 3414 EXPECT_TRUE(layer->append_quads_called()); |
| 3437 EXPECT_TRUE(layer->did_draw_called()); | 3415 EXPECT_TRUE(layer->did_draw_called()); |
| 3438 } | 3416 } |
| 3439 | 3417 |
| 3440 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); | 3418 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); |
| 3441 | 3419 |
| 3442 { | 3420 { |
| 3443 LayerTreeHostImpl::FrameData frame; | 3421 LayerTreeHostImpl::FrameData frame; |
| 3444 | 3422 |
| 3445 layer->set_will_draw_returns_false(); | 3423 layer->set_will_draw_returns_false(); |
| 3446 layer->ClearDidDrawCheck(); | 3424 layer->ClearDidDrawCheck(); |
| 3447 | 3425 |
| 3448 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3426 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3449 host_impl_->DrawLayers(&frame); | 3427 host_impl_->DrawLayers(&frame); |
| 3450 host_impl_->DidDrawAllLayers(frame); | 3428 host_impl_->DidDrawAllLayers(frame); |
| 3451 | 3429 |
| 3452 EXPECT_TRUE(layer->will_draw_called()); | 3430 EXPECT_TRUE(layer->will_draw_called()); |
| 3453 EXPECT_FALSE(layer->append_quads_called()); | 3431 EXPECT_FALSE(layer->append_quads_called()); |
| 3454 EXPECT_FALSE(layer->did_draw_called()); | 3432 EXPECT_FALSE(layer->did_draw_called()); |
| 3455 } | 3433 } |
| 3456 } | 3434 } |
| 3457 | 3435 |
| 3458 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 3436 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 3459 // The root layer is always drawn, so run this test on a child layer that | 3437 // The root layer is always drawn, so run this test on a child layer that |
| 3460 // will be masked out by the root layer's bounds. | 3438 // will be masked out by the root layer's bounds. |
| 3461 host_impl_->active_tree()->SetRootLayerForTesting( | 3439 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3462 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3440 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3463 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3441 DidDrawCheckLayer* root = |
| 3464 host_impl_->active_tree()->root_layer_for_testing()); | 3442 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 3465 root->SetMasksToBounds(true); | 3443 root->SetMasksToBounds(true); |
| 3466 root->test_properties()->force_render_surface = true; | 3444 root->test_properties()->force_render_surface = true; |
| 3467 root->test_properties()->AddChild( | 3445 root->test_properties()->AddChild( |
| 3468 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3446 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3469 DidDrawCheckLayer* layer = | 3447 DidDrawCheckLayer* layer = |
| 3470 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3448 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3471 // Ensure visible_layer_rect for layer is empty. | 3449 // Ensure visible_layer_rect for layer is empty. |
| 3472 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 3450 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 3473 layer->SetBounds(gfx::Size(10, 10)); | 3451 layer->SetBounds(gfx::Size(10, 10)); |
| 3452 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3474 | 3453 |
| 3475 LayerTreeHostImpl::FrameData frame; | 3454 LayerTreeHostImpl::FrameData frame; |
| 3476 | 3455 |
| 3477 EXPECT_FALSE(layer->will_draw_called()); | 3456 EXPECT_FALSE(layer->will_draw_called()); |
| 3478 EXPECT_FALSE(layer->did_draw_called()); | 3457 EXPECT_FALSE(layer->did_draw_called()); |
| 3479 | 3458 |
| 3480 SetNeedsRebuildPropertyTrees(); | 3459 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3481 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 3482 host_impl_->DrawLayers(&frame); | 3460 host_impl_->DrawLayers(&frame); |
| 3483 host_impl_->DidDrawAllLayers(frame); | 3461 host_impl_->DidDrawAllLayers(frame); |
| 3484 | 3462 |
| 3485 EXPECT_FALSE(layer->will_draw_called()); | 3463 EXPECT_FALSE(layer->will_draw_called()); |
| 3486 EXPECT_FALSE(layer->did_draw_called()); | 3464 EXPECT_FALSE(layer->did_draw_called()); |
| 3487 | 3465 |
| 3488 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); | 3466 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); |
| 3489 | 3467 |
| 3490 // Ensure visible_layer_rect for layer is not empty | 3468 // Ensure visible_layer_rect for layer is not empty |
| 3491 layer->SetPosition(gfx::PointF()); | 3469 layer->SetPosition(gfx::PointF()); |
| 3492 layer->NoteLayerPropertyChanged(); | 3470 layer->NoteLayerPropertyChanged(); |
| 3471 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3493 | 3472 |
| 3494 EXPECT_FALSE(layer->will_draw_called()); | 3473 EXPECT_FALSE(layer->will_draw_called()); |
| 3495 EXPECT_FALSE(layer->did_draw_called()); | 3474 EXPECT_FALSE(layer->did_draw_called()); |
| 3496 | 3475 |
| 3497 SetNeedsRebuildPropertyTrees(); | 3476 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3498 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 3499 host_impl_->DrawLayers(&frame); | 3477 host_impl_->DrawLayers(&frame); |
| 3500 host_impl_->DidDrawAllLayers(frame); | 3478 host_impl_->DidDrawAllLayers(frame); |
| 3501 | 3479 |
| 3502 EXPECT_TRUE(layer->will_draw_called()); | 3480 EXPECT_TRUE(layer->will_draw_called()); |
| 3503 EXPECT_TRUE(layer->did_draw_called()); | 3481 EXPECT_TRUE(layer->did_draw_called()); |
| 3504 | 3482 |
| 3505 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); | 3483 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); |
| 3506 } | 3484 } |
| 3507 | 3485 |
| 3508 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 3486 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
| 3509 gfx::Size big_size(1000, 1000); | 3487 gfx::Size big_size(1000, 1000); |
| 3510 host_impl_->SetViewportSize(big_size); | 3488 host_impl_->SetViewportSize(big_size); |
| 3511 | 3489 |
| 3512 host_impl_->active_tree()->SetRootLayerForTesting( | 3490 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3513 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3491 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3514 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3492 DidDrawCheckLayer* root = |
| 3515 host_impl_->active_tree()->root_layer_for_testing()); | 3493 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 3516 | 3494 |
| 3517 root->test_properties()->AddChild( | 3495 root->test_properties()->AddChild( |
| 3518 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3496 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3519 DidDrawCheckLayer* occluded_layer = | 3497 DidDrawCheckLayer* occluded_layer = |
| 3520 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3498 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3521 | 3499 |
| 3522 root->test_properties()->AddChild( | 3500 root->test_properties()->AddChild( |
| 3523 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3501 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3524 root->test_properties()->force_render_surface = true; | 3502 root->test_properties()->force_render_surface = true; |
| 3525 DidDrawCheckLayer* top_layer = | 3503 DidDrawCheckLayer* top_layer = |
| 3526 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); | 3504 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); |
| 3527 // This layer covers the occluded_layer above. Make this layer large so it can | 3505 // This layer covers the occluded_layer above. Make this layer large so it can |
| 3528 // occlude. | 3506 // occlude. |
| 3529 top_layer->SetBounds(big_size); | 3507 top_layer->SetBounds(big_size); |
| 3530 top_layer->SetContentsOpaque(true); | 3508 top_layer->SetContentsOpaque(true); |
| 3509 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3531 | 3510 |
| 3532 LayerTreeHostImpl::FrameData frame; | 3511 LayerTreeHostImpl::FrameData frame; |
| 3533 | 3512 |
| 3534 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3513 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 3535 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3514 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 3536 EXPECT_FALSE(top_layer->will_draw_called()); | 3515 EXPECT_FALSE(top_layer->will_draw_called()); |
| 3537 EXPECT_FALSE(top_layer->did_draw_called()); | 3516 EXPECT_FALSE(top_layer->did_draw_called()); |
| 3538 | 3517 |
| 3539 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3518 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3540 host_impl_->DrawLayers(&frame); | 3519 host_impl_->DrawLayers(&frame); |
| 3541 host_impl_->DidDrawAllLayers(frame); | 3520 host_impl_->DidDrawAllLayers(frame); |
| 3542 | 3521 |
| 3543 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3522 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 3544 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3523 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 3545 EXPECT_TRUE(top_layer->will_draw_called()); | 3524 EXPECT_TRUE(top_layer->will_draw_called()); |
| 3546 EXPECT_TRUE(top_layer->did_draw_called()); | 3525 EXPECT_TRUE(top_layer->did_draw_called()); |
| 3547 } | 3526 } |
| 3548 | 3527 |
| 3549 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3528 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 3550 host_impl_->active_tree()->SetRootLayerForTesting( | 3529 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3551 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3530 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3552 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3531 DidDrawCheckLayer* root = |
| 3553 host_impl_->active_tree()->root_layer_for_testing()); | 3532 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 3554 | 3533 |
| 3555 root->test_properties()->AddChild( | 3534 root->test_properties()->AddChild( |
| 3556 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3535 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3557 root->test_properties()->force_render_surface = true; | 3536 root->test_properties()->force_render_surface = true; |
| 3558 DidDrawCheckLayer* layer1 = | 3537 DidDrawCheckLayer* layer1 = |
| 3559 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3538 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3560 | 3539 |
| 3561 layer1->test_properties()->AddChild( | 3540 layer1->test_properties()->AddChild( |
| 3562 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3541 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3563 DidDrawCheckLayer* layer2 = | 3542 DidDrawCheckLayer* layer2 = |
| 3564 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); | 3543 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); |
| 3565 | 3544 |
| 3566 layer1->test_properties()->force_render_surface = true; | 3545 layer1->test_properties()->force_render_surface = true; |
| 3567 layer1->test_properties()->should_flatten_transform = true; | 3546 layer1->test_properties()->should_flatten_transform = true; |
| 3547 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3568 | 3548 |
| 3569 EXPECT_FALSE(root->did_draw_called()); | 3549 EXPECT_FALSE(root->did_draw_called()); |
| 3570 EXPECT_FALSE(layer1->did_draw_called()); | 3550 EXPECT_FALSE(layer1->did_draw_called()); |
| 3571 EXPECT_FALSE(layer2->did_draw_called()); | 3551 EXPECT_FALSE(layer2->did_draw_called()); |
| 3572 | 3552 |
| 3573 LayerTreeHostImpl::FrameData frame; | 3553 LayerTreeHostImpl::FrameData frame; |
| 3574 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3554 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 3575 host_impl_->active_tree()->root_layer_for_testing()); | 3555 *host_impl_->active_tree()->begin()); |
| 3576 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3556 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3577 host_impl_->DrawLayers(&frame); | 3557 host_impl_->DrawLayers(&frame); |
| 3578 host_impl_->DidDrawAllLayers(frame); | 3558 host_impl_->DidDrawAllLayers(frame); |
| 3579 | 3559 |
| 3580 EXPECT_TRUE(root->did_draw_called()); | 3560 EXPECT_TRUE(root->did_draw_called()); |
| 3581 EXPECT_TRUE(layer1->did_draw_called()); | 3561 EXPECT_TRUE(layer1->did_draw_called()); |
| 3582 EXPECT_TRUE(layer2->did_draw_called()); | 3562 EXPECT_TRUE(layer2->did_draw_called()); |
| 3583 | 3563 |
| 3584 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 3564 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
| 3585 EXPECT_TRUE(layer1->render_surface()); | 3565 EXPECT_TRUE(layer1->render_surface()); |
| 3586 } | 3566 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3714 // 16. High res required is higher priority than animating missing tiles. | 3694 // 16. High res required is higher priority than animating missing tiles. |
| 3715 cases.push_back( | 3695 cases.push_back( |
| 3716 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); | 3696 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
| 3717 cases.back().high_res_required = true; | 3697 cases.back().high_res_required = true; |
| 3718 cases.back().layer_between.has_missing_tile = true; | 3698 cases.back().layer_between.has_missing_tile = true; |
| 3719 cases.back().layer_before.has_missing_tile = true; | 3699 cases.back().layer_before.has_missing_tile = true; |
| 3720 cases.back().layer_before.is_animating = true; | 3700 cases.back().layer_before.is_animating = true; |
| 3721 | 3701 |
| 3722 host_impl_->active_tree()->SetRootLayerForTesting( | 3702 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3723 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3703 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3724 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3704 DidDrawCheckLayer* root = |
| 3725 host_impl_->active_tree()->root_layer_for_testing()); | 3705 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 3726 root->test_properties()->force_render_surface = true; | 3706 root->test_properties()->force_render_surface = true; |
| 3707 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3727 | 3708 |
| 3728 LayerTreeHostImpl::FrameData frame; | 3709 LayerTreeHostImpl::FrameData frame; |
| 3729 SetNeedsRebuildPropertyTrees(); | 3710 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3730 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 3731 host_impl_->DrawLayers(&frame); | 3711 host_impl_->DrawLayers(&frame); |
| 3732 host_impl_->DidDrawAllLayers(frame); | 3712 host_impl_->DidDrawAllLayers(frame); |
| 3733 host_impl_->SwapBuffers(frame); | 3713 host_impl_->SwapBuffers(frame); |
| 3734 | 3714 |
| 3735 for (size_t i = 0; i < cases.size(); ++i) { | 3715 for (size_t i = 0; i < cases.size(); ++i) { |
| 3736 // Clean up host_impl_ state. | 3716 // Clean up host_impl_ state. |
| 3737 const auto& testcase = cases[i]; | 3717 const auto& testcase = cases[i]; |
| 3738 std::vector<LayerImpl*> to_remove; | 3718 std::vector<LayerImpl*> to_remove; |
| 3739 for (const auto& child : root->test_properties()->children) | 3719 for (const auto& child : root->test_properties()->children) |
| 3740 to_remove.push_back(child); | 3720 to_remove.push_back(child); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3768 | 3748 |
| 3769 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( | 3749 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( |
| 3770 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3750 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3771 testcase.layer_after.has_incomplete_tile, | 3751 testcase.layer_after.has_incomplete_tile, |
| 3772 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3752 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
| 3773 timeline())); | 3753 timeline())); |
| 3774 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( | 3754 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
| 3775 root->test_properties()->children.back()); | 3755 root->test_properties()->children.back()); |
| 3776 if (testcase.layer_after.has_copy_request) | 3756 if (testcase.layer_after.has_copy_request) |
| 3777 after->AddCopyRequest(); | 3757 after->AddCopyRequest(); |
| 3758 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3778 | 3759 |
| 3779 if (testcase.high_res_required) | 3760 if (testcase.high_res_required) |
| 3780 host_impl_->SetRequiresHighResToDraw(); | 3761 host_impl_->SetRequiresHighResToDraw(); |
| 3781 | 3762 |
| 3782 LayerTreeHostImpl::FrameData frame; | 3763 LayerTreeHostImpl::FrameData frame; |
| 3783 SetNeedsRebuildPropertyTrees(); | 3764 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
| 3784 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | |
| 3785 host_impl_->DrawLayers(&frame); | 3765 host_impl_->DrawLayers(&frame); |
| 3786 host_impl_->DidDrawAllLayers(frame); | 3766 host_impl_->DidDrawAllLayers(frame); |
| 3787 host_impl_->SwapBuffers(frame); | 3767 host_impl_->SwapBuffers(frame); |
| 3788 } | 3768 } |
| 3789 } | 3769 } |
| 3790 | 3770 |
| 3791 TEST_F(LayerTreeHostImplTest, | 3771 TEST_F(LayerTreeHostImplTest, |
| 3792 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3772 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
| 3793 CreateHostImpl(DefaultSettings(), | 3773 CreateHostImpl(DefaultSettings(), |
| 3794 FakeOutputSurface::CreateSoftware( | 3774 FakeOutputSurface::CreateSoftware( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3816 // 3. High res required with missing tile. | 3796 // 3. High res required with missing tile. |
| 3817 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3797 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
| 3818 cases.back().high_res_required = true; | 3798 cases.back().high_res_required = true; |
| 3819 cases.back().layer_between.has_missing_tile = true; | 3799 cases.back().layer_between.has_missing_tile = true; |
| 3820 | 3800 |
| 3821 host_impl_->active_tree()->SetRootLayerForTesting( | 3801 host_impl_->active_tree()->SetRootLayerForTesting( |
| 3822 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3802 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3823 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3803 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 3824 host_impl_->active_tree()->root_layer_for_testing()); | 3804 host_impl_->active_tree()->root_layer_for_testing()); |
| 3825 root->test_properties()->force_render_surface = true; | 3805 root->test_properties()->force_render_surface = true; |
| 3806 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3826 | 3807 |
| 3827 SetNeedsRebuildPropertyTrees(); | |
| 3828 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3808 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 3829 resourceless_software_draw); | 3809 resourceless_software_draw); |
| 3830 | 3810 |
| 3831 for (size_t i = 0; i < cases.size(); ++i) { | 3811 for (size_t i = 0; i < cases.size(); ++i) { |
| 3832 const auto& testcase = cases[i]; | 3812 const auto& testcase = cases[i]; |
| 3833 std::vector<LayerImpl*> to_remove; | 3813 std::vector<LayerImpl*> to_remove; |
| 3834 for (const auto& child : root->test_properties()->children) | 3814 for (const auto& child : root->test_properties()->children) |
| 3835 to_remove.push_back(child); | 3815 to_remove.push_back(child); |
| 3836 for (auto* child : to_remove) | 3816 for (auto* child : to_remove) |
| 3837 root->test_properties()->RemoveChild(child); | 3817 root->test_properties()->RemoveChild(child); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3862 | 3842 |
| 3863 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( | 3843 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( |
| 3864 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3844 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3865 testcase.layer_after.has_incomplete_tile, | 3845 testcase.layer_after.has_incomplete_tile, |
| 3866 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3846 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
| 3867 timeline())); | 3847 timeline())); |
| 3868 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( | 3848 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
| 3869 root->test_properties()->children.back()); | 3849 root->test_properties()->children.back()); |
| 3870 if (testcase.layer_after.has_copy_request) | 3850 if (testcase.layer_after.has_copy_request) |
| 3871 after->AddCopyRequest(); | 3851 after->AddCopyRequest(); |
| 3852 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3872 | 3853 |
| 3873 if (testcase.high_res_required) | 3854 if (testcase.high_res_required) |
| 3874 host_impl_->SetRequiresHighResToDraw(); | 3855 host_impl_->SetRequiresHighResToDraw(); |
| 3875 | 3856 |
| 3876 SetNeedsRebuildPropertyTrees(); | |
| 3877 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3857 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 3878 resourceless_software_draw); | 3858 resourceless_software_draw); |
| 3879 } | 3859 } |
| 3880 } | 3860 } |
| 3881 | 3861 |
| 3882 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3862 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 3883 std::unique_ptr<LayerImpl> root = | 3863 std::unique_ptr<LayerImpl> root = |
| 3884 LayerImpl::Create(host_impl_->active_tree(), 1); | 3864 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3885 root->SetScrollClipLayer(Layer::INVALID_ID); | 3865 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 3886 root->test_properties()->force_render_surface = true; | 3866 root->test_properties()->force_render_surface = true; |
| 3887 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 3867 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 3888 SetNeedsRebuildPropertyTrees(); | 3868 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3869 |
| 3889 DrawFrame(); | 3870 DrawFrame(); |
| 3890 | 3871 |
| 3891 // Scroll event is ignored because layer is not scrollable. | 3872 // Scroll event is ignored because layer is not scrollable. |
| 3892 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3873 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 3893 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3874 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 3894 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3875 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 3895 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 3876 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 3896 status.main_thread_scrolling_reasons); | 3877 status.main_thread_scrolling_reasons); |
| 3897 EXPECT_FALSE(did_request_redraw_); | 3878 EXPECT_FALSE(did_request_redraw_); |
| 3898 EXPECT_FALSE(did_request_commit_); | 3879 EXPECT_FALSE(did_request_commit_); |
| 3899 } | 3880 } |
| 3900 | 3881 |
| 3901 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { | 3882 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { |
| 3902 host_impl_->CreatePendingTree(); | 3883 host_impl_->CreatePendingTree(); |
| 3903 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3884 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3904 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 3885 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 3905 gfx::Size(100, 100)); | 3886 gfx::Size(100, 100)); |
| 3906 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 3887 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 3907 host_impl_->ActivateSyncTree(); | 3888 host_impl_->ActivateSyncTree(); |
| 3908 | 3889 |
| 3909 host_impl_->CreatePendingTree(); | 3890 host_impl_->CreatePendingTree(); |
| 3910 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); | 3891 const gfx::ScrollOffset pending_scroll = gfx::ScrollOffset(-100, -100); |
| 3911 LayerImpl* active_outer_layer = | 3892 LayerImpl* active_outer_layer = |
| 3912 host_impl_->active_tree()->OuterViewportScrollLayer(); | 3893 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 3913 LayerImpl* pending_outer_layer = | 3894 LayerImpl* pending_outer_layer = |
| 3914 host_impl_->pending_tree()->OuterViewportScrollLayer(); | 3895 host_impl_->pending_tree()->OuterViewportScrollLayer(); |
| 3915 pending_outer_layer->layer_tree_impl() | 3896 pending_outer_layer->layer_tree_impl() |
| 3916 ->property_trees() | 3897 ->property_trees() |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3996 | 3977 |
| 3997 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 3978 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
| 3998 root->test_properties()->AddChild(std::move(outer_clip)); | 3979 root->test_properties()->AddChild(std::move(outer_clip)); |
| 3999 page_scale->test_properties()->AddChild(std::move(root)); | 3980 page_scale->test_properties()->AddChild(std::move(root)); |
| 4000 root_clip->test_properties()->AddChild(std::move(page_scale)); | 3981 root_clip->test_properties()->AddChild(std::move(page_scale)); |
| 4001 | 3982 |
| 4002 tree_impl->SetRootLayerForTesting(std::move(root_clip)); | 3983 tree_impl->SetRootLayerForTesting(std::move(root_clip)); |
| 4003 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, | 3984 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, |
| 4004 inner_viewport_scroll_layer_id, | 3985 inner_viewport_scroll_layer_id, |
| 4005 outer_viewport_scroll_layer_id); | 3986 outer_viewport_scroll_layer_id); |
| 4006 tree_impl->BuildLayerListAndPropertyTreesForTesting(); | 3987 tree_impl->BuildPropertyTreesForTesting(); |
| 4007 | 3988 |
| 4008 host_impl_->SetViewportSize(inner_viewport_size); | 3989 host_impl_->SetViewportSize(inner_viewport_size); |
| 4009 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); | 3990 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); |
| 4010 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 3991 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
| 4011 } | 3992 } |
| 4012 | 3993 |
| 4013 protected: | 3994 protected: |
| 4014 gfx::Size layer_size_; | 3995 gfx::Size layer_size_; |
| 4015 gfx::Size clip_size_; | 3996 gfx::Size clip_size_; |
| 4016 gfx::Size viewport_size_; | 3997 gfx::Size viewport_size_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4031 | 4012 |
| 4032 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 4013 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 4033 | 4014 |
| 4034 // Create a content layer beneath the outer viewport scroll layer. | 4015 // Create a content layer beneath the outer viewport scroll layer. |
| 4035 int id = host_impl_->OuterViewportScrollLayer()->id(); | 4016 int id = host_impl_->OuterViewportScrollLayer()->id(); |
| 4036 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( | 4017 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( |
| 4037 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 4018 LayerImpl::Create(host_impl_->active_tree(), id + 2)); |
| 4038 LayerImpl* content = | 4019 LayerImpl* content = |
| 4039 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; | 4020 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; |
| 4040 content->SetBounds(gfx::Size(50, 50)); | 4021 content->SetBounds(gfx::Size(50, 50)); |
| 4022 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4041 | 4023 |
| 4042 SetNeedsRebuildPropertyTrees(); | |
| 4043 DrawFrame(); | 4024 DrawFrame(); |
| 4044 | 4025 |
| 4045 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 4026 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 4046 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 4027 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 4047 | 4028 |
| 4048 // The top controls should start off showing so the viewport should be shrunk. | 4029 // The top controls should start off showing so the viewport should be shrunk. |
| 4049 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 4030 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
| 4050 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); | 4031 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); |
| 4051 | 4032 |
| 4052 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); | 4033 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4333 child->SetBounds(sub_content_size); | 4314 child->SetBounds(sub_content_size); |
| 4334 child->SetPosition(gfx::PointF()); | 4315 child->SetPosition(gfx::PointF()); |
| 4335 child->SetDrawsContent(true); | 4316 child->SetDrawsContent(true); |
| 4336 child->test_properties()->is_container_for_fixed_position_layers = true; | 4317 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 4337 | 4318 |
| 4338 // scroll child to limit | 4319 // scroll child to limit |
| 4339 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); | 4320 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); |
| 4340 child_clip->test_properties()->AddChild(std::move(child)); | 4321 child_clip->test_properties()->AddChild(std::move(child)); |
| 4341 outer_viewport_scroll_layer->test_properties()->AddChild( | 4322 outer_viewport_scroll_layer->test_properties()->AddChild( |
| 4342 std::move(child_clip)); | 4323 std::move(child_clip)); |
| 4324 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4343 | 4325 |
| 4344 // Scroll 25px to hide top controls | 4326 // Scroll 25px to hide top controls |
| 4345 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4327 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4346 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | |
| 4347 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 4348 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4328 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4349 host_impl_ | 4329 host_impl_ |
| 4350 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4330 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4351 InputHandler::TOUCHSCREEN) | 4331 InputHandler::TOUCHSCREEN) |
| 4352 .thread); | 4332 .thread); |
| 4353 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4333 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4354 host_impl_->ScrollEnd(EndState().get()); | 4334 host_impl_->ScrollEnd(EndState().get()); |
| 4355 | 4335 |
| 4356 // Top controls should be hidden | 4336 // Top controls should be hidden |
| 4357 EXPECT_EQ(scroll_delta.y(), | 4337 EXPECT_EQ(scroll_delta.y(), |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4829 LayerImpl::Create(host_impl_->active_tree(), 2); | 4809 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 4830 scroll_layer->SetScrollClipLayer(3); | 4810 scroll_layer->SetScrollClipLayer(3); |
| 4831 scroll_layer->SetBounds(contents_size); | 4811 scroll_layer->SetBounds(contents_size); |
| 4832 scroll_layer->SetPosition(gfx::PointF()); | 4812 scroll_layer->SetPosition(gfx::PointF()); |
| 4833 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4813 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
| 4834 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4814 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
| 4835 | 4815 |
| 4836 scroll_clip_layer->test_properties()->force_render_surface = true; | 4816 scroll_clip_layer->test_properties()->force_render_surface = true; |
| 4837 host_impl_->active_tree()->SetRootLayerForTesting( | 4817 host_impl_->active_tree()->SetRootLayerForTesting( |
| 4838 std::move(scroll_clip_layer)); | 4818 std::move(scroll_clip_layer)); |
| 4819 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4820 |
| 4839 host_impl_->SetViewportSize(surface_size); | 4821 host_impl_->SetViewportSize(surface_size); |
| 4840 SetNeedsRebuildPropertyTrees(); | |
| 4841 DrawFrame(); | 4822 DrawFrame(); |
| 4842 | 4823 |
| 4843 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4824 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4844 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4825 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 4845 InputHandler::WHEEL) | 4826 InputHandler::WHEEL) |
| 4846 .thread); | 4827 .thread); |
| 4847 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4828 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4848 host_impl_->ScrollEnd(EndState().get()); | 4829 host_impl_->ScrollEnd(EndState().get()); |
| 4849 EXPECT_TRUE(did_request_redraw_); | 4830 EXPECT_TRUE(did_request_redraw_); |
| 4850 EXPECT_TRUE(did_request_commit_); | 4831 EXPECT_TRUE(did_request_commit_); |
| 4851 } | 4832 } |
| 4852 | 4833 |
| 4853 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4834 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 4854 gfx::Size surface_size(10, 10); | 4835 gfx::Size surface_size(10, 10); |
| 4855 gfx::Size contents_size(20, 20); | 4836 gfx::Size contents_size(20, 20); |
| 4856 std::unique_ptr<LayerImpl> root = | 4837 std::unique_ptr<LayerImpl> root = |
| 4857 LayerImpl::Create(host_impl_->active_tree(), 1); | 4838 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4858 root->SetBounds(surface_size); | 4839 root->SetBounds(surface_size); |
| 4859 root->test_properties()->AddChild( | 4840 root->test_properties()->AddChild( |
| 4860 CreateScrollableLayer(2, contents_size, root.get())); | 4841 CreateScrollableLayer(2, contents_size, root.get())); |
| 4861 root->test_properties()->force_render_surface = true; | 4842 root->test_properties()->force_render_surface = true; |
| 4862 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4843 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 4844 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4845 |
| 4863 host_impl_->SetViewportSize(surface_size); | 4846 host_impl_->SetViewportSize(surface_size); |
| 4864 SetNeedsRebuildPropertyTrees(); | |
| 4865 DrawFrame(); | 4847 DrawFrame(); |
| 4866 | 4848 |
| 4867 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4849 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4868 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4850 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 4869 InputHandler::WHEEL) | 4851 InputHandler::WHEEL) |
| 4870 .thread); | 4852 .thread); |
| 4871 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4853 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4872 host_impl_->ScrollEnd(EndState().get()); | 4854 host_impl_->ScrollEnd(EndState().get()); |
| 4873 EXPECT_TRUE(did_request_redraw_); | 4855 EXPECT_TRUE(did_request_redraw_); |
| 4874 EXPECT_TRUE(did_request_commit_); | 4856 EXPECT_TRUE(did_request_commit_); |
| 4875 } | 4857 } |
| 4876 | 4858 |
| 4877 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4859 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 4878 gfx::Size surface_size(10, 10); | 4860 gfx::Size surface_size(10, 10); |
| 4879 std::unique_ptr<LayerImpl> root = | 4861 std::unique_ptr<LayerImpl> root = |
| 4880 LayerImpl::Create(host_impl_->active_tree(), 1); | 4862 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4881 root->test_properties()->AddChild( | 4863 root->test_properties()->AddChild( |
| 4882 CreateScrollableLayer(2, surface_size, root.get())); | 4864 CreateScrollableLayer(2, surface_size, root.get())); |
| 4883 root->test_properties()->force_render_surface = true; | 4865 root->test_properties()->force_render_surface = true; |
| 4884 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4866 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 4867 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4868 |
| 4885 host_impl_->SetViewportSize(surface_size); | 4869 host_impl_->SetViewportSize(surface_size); |
| 4886 SetNeedsRebuildPropertyTrees(); | |
| 4887 DrawFrame(); | 4870 DrawFrame(); |
| 4888 | 4871 |
| 4889 // Scroll event is ignored because the input coordinate is outside the layer | 4872 // Scroll event is ignored because the input coordinate is outside the layer |
| 4890 // boundaries. | 4873 // boundaries. |
| 4891 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4874 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 4892 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4875 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
| 4893 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4876 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 4894 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4877 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 4895 status.main_thread_scrolling_reasons); | 4878 status.main_thread_scrolling_reasons); |
| 4896 | 4879 |
| 4897 EXPECT_FALSE(did_request_redraw_); | 4880 EXPECT_FALSE(did_request_redraw_); |
| 4898 EXPECT_FALSE(did_request_commit_); | 4881 EXPECT_FALSE(did_request_commit_); |
| 4899 } | 4882 } |
| 4900 | 4883 |
| 4901 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4884 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 4902 gfx::Size surface_size(10, 10); | 4885 gfx::Size surface_size(10, 10); |
| 4903 std::unique_ptr<LayerImpl> root = | 4886 std::unique_ptr<LayerImpl> root = |
| 4904 LayerImpl::Create(host_impl_->active_tree(), 1); | 4887 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4905 root->test_properties()->force_render_surface = true; | 4888 root->test_properties()->force_render_surface = true; |
| 4906 std::unique_ptr<LayerImpl> child = | 4889 std::unique_ptr<LayerImpl> child = |
| 4907 CreateScrollableLayer(2, surface_size, root.get()); | 4890 CreateScrollableLayer(2, surface_size, root.get()); |
| 4908 host_impl_->SetViewportSize(surface_size); | |
| 4909 | 4891 |
| 4910 gfx::Transform matrix; | 4892 gfx::Transform matrix; |
| 4911 matrix.RotateAboutXAxis(180.0); | 4893 matrix.RotateAboutXAxis(180.0); |
| 4912 child->SetTransform(matrix); | 4894 child->SetTransform(matrix); |
| 4913 child->test_properties()->double_sided = false; | 4895 child->test_properties()->double_sided = false; |
| 4914 | 4896 |
| 4915 root->test_properties()->AddChild(std::move(child)); | 4897 root->test_properties()->AddChild(std::move(child)); |
| 4916 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4898 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 4917 SetNeedsRebuildPropertyTrees(); | 4899 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4900 |
| 4901 host_impl_->SetViewportSize(surface_size); |
| 4918 DrawFrame(); | 4902 DrawFrame(); |
| 4919 | 4903 |
| 4920 // Scroll event is ignored because the scrollable layer is not facing the | 4904 // Scroll event is ignored because the scrollable layer is not facing the |
| 4921 // viewer and there is nothing scrollable behind it. | 4905 // viewer and there is nothing scrollable behind it. |
| 4922 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4906 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 4923 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4907 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
| 4924 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4908 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 4925 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4909 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 4926 status.main_thread_scrolling_reasons); | 4910 status.main_thread_scrolling_reasons); |
| 4927 | 4911 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4941 | 4925 |
| 4942 // Note: we can use the same clip layer for both since both calls to | 4926 // Note: we can use the same clip layer for both since both calls to |
| 4943 // CreateScrollableLayer() use the same surface size. | 4927 // CreateScrollableLayer() use the same surface size. |
| 4944 std::unique_ptr<LayerImpl> scroll_layer = | 4928 std::unique_ptr<LayerImpl> scroll_layer = |
| 4945 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4929 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 4946 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4930 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
| 4947 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4931 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
| 4948 clip_layer->test_properties()->force_render_surface = true; | 4932 clip_layer->test_properties()->force_render_surface = true; |
| 4949 | 4933 |
| 4950 host_impl_->active_tree()->SetRootLayerForTesting(std::move(clip_layer)); | 4934 host_impl_->active_tree()->SetRootLayerForTesting(std::move(clip_layer)); |
| 4935 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4936 |
| 4951 host_impl_->SetViewportSize(surface_size); | 4937 host_impl_->SetViewportSize(surface_size); |
| 4952 SetNeedsRebuildPropertyTrees(); | |
| 4953 DrawFrame(); | 4938 DrawFrame(); |
| 4954 | 4939 |
| 4955 // Scrolling fails because the content layer is asking to be scrolled on the | 4940 // Scrolling fails because the content layer is asking to be scrolled on the |
| 4956 // main thread. | 4941 // main thread. |
| 4957 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4942 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 4958 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4943 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
| 4959 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 4944 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 4960 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 4945 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
| 4961 status.main_thread_scrolling_reasons); | 4946 status.main_thread_scrolling_reasons); |
| 4962 } | 4947 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5016 SetupScrollAndContentsLayers(viewport_size); | 5001 SetupScrollAndContentsLayers(viewport_size); |
| 5017 | 5002 |
| 5018 // Setup the layers so that the outer viewport is scrollable. | 5003 // Setup the layers so that the outer viewport is scrollable. |
| 5019 host_impl_->active_tree() | 5004 host_impl_->active_tree() |
| 5020 ->InnerViewportScrollLayer() | 5005 ->InnerViewportScrollLayer() |
| 5021 ->test_properties() | 5006 ->test_properties() |
| 5022 ->parent->SetBounds(viewport_size); | 5007 ->parent->SetBounds(viewport_size); |
| 5023 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 5008 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 5024 gfx::Size(40, 40)); | 5009 gfx::Size(40, 40)); |
| 5025 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 5010 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 5011 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5012 |
| 5026 DrawFrame(); | 5013 DrawFrame(); |
| 5027 | 5014 |
| 5028 LayerImpl* root_scroll = | 5015 LayerImpl* root_scroll = |
| 5029 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5016 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 5030 LayerImpl* inner_scroll = | 5017 LayerImpl* inner_scroll = |
| 5031 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5018 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 5032 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5019 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| 5033 | 5020 |
| 5034 gfx::Vector2d scroll_delta(0, 10); | 5021 gfx::Vector2d scroll_delta(0, 10); |
| 5035 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5022 gfx::Vector2d expected_scroll_delta = scroll_delta; |
| 5036 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5023 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 5037 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5024 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5038 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5025 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5039 InputHandler::WHEEL) | 5026 InputHandler::WHEEL) |
| 5040 .thread); | 5027 .thread); |
| 5041 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5028 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5042 host_impl_->ScrollEnd(EndState().get()); | 5029 host_impl_->ScrollEnd(EndState().get()); |
| 5043 | 5030 |
| 5044 // Set new page scale on impl thread by pinching. | 5031 // Set new page scale on impl thread by pinching. |
| 5045 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5032 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5046 InputHandler::TOUCHSCREEN); | 5033 InputHandler::TOUCHSCREEN); |
| 5047 host_impl_->PinchGestureBegin(); | 5034 host_impl_->PinchGestureBegin(); |
| 5048 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 5035 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
| 5049 host_impl_->PinchGestureEnd(); | 5036 host_impl_->PinchGestureEnd(); |
| 5050 host_impl_->ScrollEnd(EndState().get()); | 5037 host_impl_->ScrollEnd(EndState().get()); |
| 5038 |
| 5051 DrawOneFrame(); | 5039 DrawOneFrame(); |
| 5052 | 5040 |
| 5053 // The scroll delta is not scaled because the main thread did not scale. | 5041 // The scroll delta is not scaled because the main thread did not scale. |
| 5054 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5042 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5055 host_impl_->ProcessScrollDeltas(); | 5043 host_impl_->ProcessScrollDeltas(); |
| 5056 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5044 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
| 5057 expected_scroll_delta)); | 5045 expected_scroll_delta)); |
| 5058 | 5046 |
| 5059 // The scroll range should also have been updated. | 5047 // The scroll range should also have been updated. |
| 5060 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 5048 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5083 | 5071 |
| 5084 std::unique_ptr<LayerImpl> scrollable_child_clip = | 5072 std::unique_ptr<LayerImpl> scrollable_child_clip = |
| 5085 LayerImpl::Create(host_impl_->active_tree(), 6); | 5073 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 5086 std::unique_ptr<LayerImpl> scrollable_child = | 5074 std::unique_ptr<LayerImpl> scrollable_child = |
| 5087 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 5075 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 5088 scrollable_child_clip->test_properties()->AddChild( | 5076 scrollable_child_clip->test_properties()->AddChild( |
| 5089 std::move(scrollable_child)); | 5077 std::move(scrollable_child)); |
| 5090 child->test_properties()->AddChild(std::move(scrollable_child_clip)); | 5078 child->test_properties()->AddChild(std::move(scrollable_child_clip)); |
| 5091 LayerImpl* grand_child = child->test_properties()->children[0]; | 5079 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 5092 grand_child->SetDrawsContent(true); | 5080 grand_child->SetDrawsContent(true); |
| 5081 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5093 | 5082 |
| 5094 // Set new page scale on impl thread by pinching. | 5083 // Set new page scale on impl thread by pinching. |
| 5095 SetNeedsRebuildPropertyTrees(); | |
| 5096 RebuildPropertyTrees(); | |
| 5097 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5084 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5098 InputHandler::TOUCHSCREEN); | 5085 InputHandler::TOUCHSCREEN); |
| 5099 host_impl_->PinchGestureBegin(); | 5086 host_impl_->PinchGestureBegin(); |
| 5100 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 5087 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
| 5101 host_impl_->PinchGestureEnd(); | 5088 host_impl_->PinchGestureEnd(); |
| 5102 host_impl_->ScrollEnd(EndState().get()); | 5089 host_impl_->ScrollEnd(EndState().get()); |
| 5103 DrawOneFrame(); | 5090 DrawOneFrame(); |
| 5104 | 5091 |
| 5105 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 5092 // Make sure all the layers are drawn with the page scale delta applied, i.e., |
| 5106 // the page scale delta on the root layer is applied hierarchically. | 5093 // the page scale delta on the root layer is applied hierarchically. |
| 5107 LayerTreeHostImpl::FrameData frame; | 5094 LayerTreeHostImpl::FrameData frame; |
| 5108 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5095 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5109 host_impl_->DrawLayers(&frame); | 5096 host_impl_->DrawLayers(&frame); |
| 5110 host_impl_->DidDrawAllLayers(frame); | 5097 host_impl_->DidDrawAllLayers(frame); |
| 5111 | 5098 |
| 5112 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0)); | 5099 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0)); |
| 5113 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1)); | 5100 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1)); |
| 5114 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0)); | 5101 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0)); |
| 5115 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1)); | 5102 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1)); |
| 5116 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0)); | 5103 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0)); |
| 5117 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1)); | 5104 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1)); |
| 5118 EXPECT_EQ(new_page_scale, | 5105 EXPECT_EQ(new_page_scale, |
| 5119 grand_child->DrawTransform().matrix().getDouble(0, 0)); | 5106 grand_child->DrawTransform().matrix().getDouble(0, 0)); |
| 5120 EXPECT_EQ(new_page_scale, | 5107 EXPECT_EQ(new_page_scale, |
| 5121 grand_child->DrawTransform().matrix().getDouble(1, 1)); | 5108 grand_child->DrawTransform().matrix().getDouble(1, 1)); |
| 5122 } | 5109 } |
| 5123 | 5110 |
| 5124 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 5111 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
| 5125 SetupScrollAndContentsLayers(gfx::Size(30, 30)); | 5112 SetupScrollAndContentsLayers(gfx::Size(30, 30)); |
| 5126 | 5113 |
| 5127 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 5114 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 5128 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 5115 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 5129 | 5116 |
| 5130 // Make the outer scroll layer scrollable. | 5117 // Make the outer scroll layer scrollable. |
| 5131 outer_scroll->SetBounds(gfx::Size(50, 50)); | 5118 outer_scroll->SetBounds(gfx::Size(50, 50)); |
| 5119 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5132 | 5120 |
| 5133 DrawFrame(); | 5121 DrawFrame(); |
| 5134 | 5122 |
| 5135 gfx::Vector2d scroll_delta(0, 10); | 5123 gfx::Vector2d scroll_delta(0, 10); |
| 5136 gfx::Vector2d expected_scroll_delta(scroll_delta); | 5124 gfx::Vector2d expected_scroll_delta(scroll_delta); |
| 5137 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); | 5125 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); |
| 5138 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5126 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5139 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5127 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5140 InputHandler::WHEEL) | 5128 InputHandler::WHEEL) |
| 5141 .thread); | 5129 .thread); |
| 5142 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5130 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5143 host_impl_->ScrollEnd(EndState().get()); | 5131 host_impl_->ScrollEnd(EndState().get()); |
| 5144 | 5132 |
| 5145 float page_scale = 2.f; | 5133 float page_scale = 2.f; |
| 5146 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 5134 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
| 5147 page_scale); | 5135 page_scale); |
| 5136 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5148 | 5137 |
| 5149 DrawOneFrame(); | 5138 DrawOneFrame(); |
| 5150 | 5139 |
| 5151 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5140 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5152 host_impl_->ProcessScrollDeltas(); | 5141 host_impl_->ProcessScrollDeltas(); |
| 5153 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5142 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
| 5154 expected_scroll_delta)); | 5143 expected_scroll_delta)); |
| 5155 | 5144 |
| 5156 // The scroll range should not have changed. | 5145 // The scroll range should not have changed. |
| 5157 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); | 5146 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5174 CreateScrollableLayer(3, content_size, root.get()); | 5163 CreateScrollableLayer(3, content_size, root.get()); |
| 5175 | 5164 |
| 5176 std::unique_ptr<LayerImpl> child = | 5165 std::unique_ptr<LayerImpl> child = |
| 5177 CreateScrollableLayer(2, content_size, root.get()); | 5166 CreateScrollableLayer(2, content_size, root.get()); |
| 5178 LayerImpl* grand_child_layer = grand_child.get(); | 5167 LayerImpl* grand_child_layer = grand_child.get(); |
| 5179 child->test_properties()->AddChild(std::move(grand_child)); | 5168 child->test_properties()->AddChild(std::move(grand_child)); |
| 5180 | 5169 |
| 5181 LayerImpl* child_layer = child.get(); | 5170 LayerImpl* child_layer = child.get(); |
| 5182 root->test_properties()->AddChild(std::move(child)); | 5171 root->test_properties()->AddChild(std::move(child)); |
| 5183 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 5172 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 5173 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5184 host_impl_->active_tree()->DidBecomeActive(); | 5174 host_impl_->active_tree()->DidBecomeActive(); |
| 5185 host_impl_->SetViewportSize(surface_size); | 5175 |
| 5186 grand_child_layer->layer_tree_impl() | 5176 grand_child_layer->layer_tree_impl() |
| 5187 ->property_trees() | 5177 ->property_trees() |
| 5188 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5178 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| 5189 gfx::ScrollOffset(0, 5)); | 5179 gfx::ScrollOffset(0, 5)); |
| 5190 child_layer->layer_tree_impl() | 5180 child_layer->layer_tree_impl() |
| 5191 ->property_trees() | 5181 ->property_trees() |
| 5192 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5182 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| 5193 gfx::ScrollOffset(3, 0)); | 5183 gfx::ScrollOffset(3, 0)); |
| 5194 | 5184 |
| 5195 SetNeedsRebuildPropertyTrees(); | 5185 host_impl_->SetViewportSize(surface_size); |
| 5196 DrawFrame(); | 5186 DrawFrame(); |
| 5197 { | 5187 { |
| 5198 gfx::Vector2d scroll_delta(-8, -7); | 5188 gfx::Vector2d scroll_delta(-8, -7); |
| 5199 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5189 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5200 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5190 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5201 InputHandler::WHEEL) | 5191 InputHandler::WHEEL) |
| 5202 .thread); | 5192 .thread); |
| 5203 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5193 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5204 host_impl_->ScrollEnd(EndState().get()); | 5194 host_impl_->ScrollEnd(EndState().get()); |
| 5205 | 5195 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5242 CreateScrollableLayer(4, surface_size, root_clip.get()); | 5232 CreateScrollableLayer(4, surface_size, root_clip.get()); |
| 5243 LayerImpl* grand_child_layer = grand_child.get(); | 5233 LayerImpl* grand_child_layer = grand_child.get(); |
| 5244 child->test_properties()->AddChild(std::move(grand_child)); | 5234 child->test_properties()->AddChild(std::move(grand_child)); |
| 5245 | 5235 |
| 5246 LayerImpl* child_layer = child.get(); | 5236 LayerImpl* child_layer = child.get(); |
| 5247 root_scrolling->test_properties()->AddChild(std::move(child)); | 5237 root_scrolling->test_properties()->AddChild(std::move(child)); |
| 5248 root_clip->test_properties()->AddChild(std::move(root_scrolling)); | 5238 root_clip->test_properties()->AddChild(std::move(root_scrolling)); |
| 5249 EXPECT_EQ(viewport_size, root_clip->bounds()); | 5239 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 5250 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5240 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 5251 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5241 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5242 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5252 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5243 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 5253 Layer::INVALID_ID); | 5244 Layer::INVALID_ID); |
| 5254 host_impl_->active_tree()->DidBecomeActive(); | 5245 host_impl_->active_tree()->DidBecomeActive(); |
| 5255 host_impl_->SetViewportSize(viewport_size); | 5246 host_impl_->SetViewportSize(viewport_size); |
| 5256 | 5247 |
| 5257 grand_child_layer->layer_tree_impl() | 5248 grand_child_layer->layer_tree_impl() |
| 5258 ->property_trees() | 5249 ->property_trees() |
| 5259 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5250 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| 5260 gfx::ScrollOffset(0, 2)); | 5251 gfx::ScrollOffset(0, 2)); |
| 5261 child_layer->layer_tree_impl() | 5252 child_layer->layer_tree_impl() |
| 5262 ->property_trees() | 5253 ->property_trees() |
| 5263 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5254 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| 5264 gfx::ScrollOffset(0, 3)); | 5255 gfx::ScrollOffset(0, 3)); |
| 5265 | 5256 |
| 5266 SetNeedsRebuildPropertyTrees(); | |
| 5267 DrawFrame(); | 5257 DrawFrame(); |
| 5268 { | 5258 { |
| 5269 gfx::Vector2d scroll_delta(0, -10); | 5259 gfx::Vector2d scroll_delta(0, -10); |
| 5270 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5260 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5271 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5261 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5272 InputHandler::NON_BUBBLING_GESTURE) | 5262 InputHandler::NON_BUBBLING_GESTURE) |
| 5273 .thread); | 5263 .thread); |
| 5274 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5264 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5275 host_impl_->ScrollEnd(EndState().get()); | 5265 host_impl_->ScrollEnd(EndState().get()); |
| 5276 | 5266 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5373 std::unique_ptr<LayerImpl> child = | 5363 std::unique_ptr<LayerImpl> child = |
| 5374 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5364 CreateScrollableLayer(2, content_size, root_scroll.get()); |
| 5375 child->test_properties()->is_container_for_fixed_position_layers = true; | 5365 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 5376 root_scroll->SetBounds(content_size); | 5366 root_scroll->SetBounds(content_size); |
| 5377 | 5367 |
| 5378 int root_scroll_id = root_scroll->id(); | 5368 int root_scroll_id = root_scroll->id(); |
| 5379 root_scroll->test_properties()->AddChild(std::move(child)); | 5369 root_scroll->test_properties()->AddChild(std::move(child)); |
| 5380 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5370 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 5381 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5371 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 5382 | 5372 |
| 5383 host_impl_->SetViewportSize(surface_size); | |
| 5384 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5373 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5385 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5374 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
| 5386 Layer::INVALID_ID); | 5375 Layer::INVALID_ID); |
| 5376 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5387 host_impl_->active_tree()->DidBecomeActive(); | 5377 host_impl_->active_tree()->DidBecomeActive(); |
| 5388 SetNeedsRebuildPropertyTrees(); | 5378 |
| 5379 host_impl_->SetViewportSize(surface_size); |
| 5389 DrawFrame(); | 5380 DrawFrame(); |
| 5390 { | 5381 { |
| 5391 gfx::Vector2d scroll_delta(0, 4); | 5382 gfx::Vector2d scroll_delta(0, 4); |
| 5392 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5383 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5393 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5384 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5394 InputHandler::WHEEL) | 5385 InputHandler::WHEEL) |
| 5395 .thread); | 5386 .thread); |
| 5396 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5387 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5397 host_impl_->ScrollEnd(EndState().get()); | 5388 host_impl_->ScrollEnd(EndState().get()); |
| 5398 | 5389 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5414 LayerImpl::Create(host_impl_->active_tree(), 2); | 5405 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5415 std::unique_ptr<LayerImpl> root_scroll = | 5406 std::unique_ptr<LayerImpl> root_scroll = |
| 5416 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5407 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 5417 root_clip->test_properties()->force_render_surface = true; | 5408 root_clip->test_properties()->force_render_surface = true; |
| 5418 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 5409 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
| 5419 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5410 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 5420 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5411 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 5421 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5412 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5422 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5413 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 5423 Layer::INVALID_ID); | 5414 Layer::INVALID_ID); |
| 5415 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5424 host_impl_->active_tree()->DidBecomeActive(); | 5416 host_impl_->active_tree()->DidBecomeActive(); |
| 5417 |
| 5425 host_impl_->SetViewportSize(surface_size); | 5418 host_impl_->SetViewportSize(surface_size); |
| 5426 | 5419 |
| 5427 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5420 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 5428 // synchronization. | 5421 // synchronization. |
| 5429 SetNeedsRebuildPropertyTrees(); | |
| 5430 DrawFrame(); | 5422 DrawFrame(); |
| 5423 |
| 5431 host_impl_->active_tree()->DetachLayers(); | 5424 host_impl_->active_tree()->DetachLayers(); |
| 5432 std::unique_ptr<LayerImpl> root_ptr2 = | 5425 std::unique_ptr<LayerImpl> root_ptr2 = |
| 5433 LayerImpl::Create(host_impl_->active_tree(), 4); | 5426 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5434 std::unique_ptr<LayerImpl> root_clip2 = | 5427 std::unique_ptr<LayerImpl> root_clip2 = |
| 5435 LayerImpl::Create(host_impl_->active_tree(), 5); | 5428 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 5436 std::unique_ptr<LayerImpl> root_scroll2 = | 5429 std::unique_ptr<LayerImpl> root_scroll2 = |
| 5437 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5430 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
| 5438 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5431 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
| 5439 true; | 5432 true; |
| 5440 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); | 5433 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); |
| 5441 root_clip2->test_properties()->force_render_surface = true; | 5434 root_clip2->test_properties()->force_render_surface = true; |
| 5442 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); | 5435 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); |
| 5443 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); | 5436 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
| 5437 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5444 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5438 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
| 5445 Layer::INVALID_ID); | 5439 Layer::INVALID_ID); |
| 5446 host_impl_->active_tree()->DidBecomeActive(); | 5440 host_impl_->active_tree()->DidBecomeActive(); |
| 5447 | 5441 |
| 5448 // Scrolling should still work even though we did not draw yet. | 5442 // Scrolling should still work even though we did not draw yet. |
| 5449 SetNeedsRebuildPropertyTrees(); | |
| 5450 RebuildPropertyTrees(); | |
| 5451 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5443 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5452 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5444 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5453 InputHandler::WHEEL) | 5445 InputHandler::WHEEL) |
| 5454 .thread); | 5446 .thread); |
| 5455 } | 5447 } |
| 5456 | 5448 |
| 5457 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5449 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
| 5458 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5450 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5459 scroll_layer->SetDrawsContent(true); | 5451 scroll_layer->SetDrawsContent(true); |
| 5460 | 5452 |
| 5461 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5453 // Rotate the root layer 90 degrees counter-clockwise about its center. |
| 5462 gfx::Transform rotate_transform; | 5454 gfx::Transform rotate_transform; |
| 5463 rotate_transform.Rotate(-90.0); | 5455 rotate_transform.Rotate(-90.0); |
| 5464 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( | 5456 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( |
| 5465 rotate_transform); | 5457 rotate_transform); |
| 5458 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5466 | 5459 |
| 5467 gfx::Size surface_size(50, 50); | 5460 gfx::Size surface_size(50, 50); |
| 5468 host_impl_->SetViewportSize(surface_size); | 5461 host_impl_->SetViewportSize(surface_size); |
| 5469 SetNeedsRebuildPropertyTrees(); | |
| 5470 DrawFrame(); | 5462 DrawFrame(); |
| 5471 | 5463 |
| 5472 // Scroll to the right in screen coordinates with a gesture. | 5464 // Scroll to the right in screen coordinates with a gesture. |
| 5473 gfx::Vector2d gesture_scroll_delta(10, 0); | 5465 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 5474 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5466 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5475 host_impl_ | 5467 host_impl_ |
| 5476 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5468 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5477 InputHandler::TOUCHSCREEN) | 5469 InputHandler::TOUCHSCREEN) |
| 5478 .thread); | 5470 .thread); |
| 5479 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5471 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5522 clip_layer->SetBounds( | 5514 clip_layer->SetBounds( |
| 5523 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 5515 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); |
| 5524 // The rotation depends on the layer's transform origin, and the child layer | 5516 // The rotation depends on the layer's transform origin, and the child layer |
| 5525 // is a different size than the clip, so make sure the clip layer's origin | 5517 // is a different size than the clip, so make sure the clip layer's origin |
| 5526 // lines up over the child. | 5518 // lines up over the child. |
| 5527 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5519 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
| 5528 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); | 5520 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); |
| 5529 LayerImpl* child_ptr = child.get(); | 5521 LayerImpl* child_ptr = child.get(); |
| 5530 clip_layer->test_properties()->AddChild(std::move(child)); | 5522 clip_layer->test_properties()->AddChild(std::move(child)); |
| 5531 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); | 5523 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); |
| 5524 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5532 | 5525 |
| 5533 gfx::Size surface_size(50, 50); | 5526 gfx::Size surface_size(50, 50); |
| 5534 host_impl_->SetViewportSize(surface_size); | 5527 host_impl_->SetViewportSize(surface_size); |
| 5535 SetNeedsRebuildPropertyTrees(); | |
| 5536 DrawFrame(); | 5528 DrawFrame(); |
| 5537 { | 5529 { |
| 5538 // Scroll down in screen coordinates with a gesture. | 5530 // Scroll down in screen coordinates with a gesture. |
| 5539 gfx::Vector2d gesture_scroll_delta(0, 10); | 5531 gfx::Vector2d gesture_scroll_delta(0, 10); |
| 5540 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5532 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5541 host_impl_ | 5533 host_impl_ |
| 5542 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5534 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
| 5543 InputHandler::TOUCHSCREEN) | 5535 InputHandler::TOUCHSCREEN) |
| 5544 .thread); | 5536 .thread); |
| 5545 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5537 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5607 | 5599 |
| 5608 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, | 5600 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, |
| 5609 child_ptr->bounds().height() / 2)); | 5601 child_ptr->bounds().height() / 2)); |
| 5610 // The transform depends on the layer's transform origin, and the child layer | 5602 // The transform depends on the layer's transform origin, and the child layer |
| 5611 // is a different size than the clip, so make sure the clip layer's origin | 5603 // is a different size than the clip, so make sure the clip layer's origin |
| 5612 // lines up over the child. | 5604 // lines up over the child. |
| 5613 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5605 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
| 5614 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); | 5606 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); |
| 5615 clip_layer->test_properties()->AddChild(std::move(child)); | 5607 clip_layer->test_properties()->AddChild(std::move(child)); |
| 5616 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); | 5608 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); |
| 5609 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5617 | 5610 |
| 5618 gfx::Size surface_size(50, 50); | 5611 gfx::Size surface_size(50, 50); |
| 5619 host_impl_->SetViewportSize(surface_size); | 5612 host_impl_->SetViewportSize(surface_size); |
| 5620 | 5613 |
| 5621 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 5614 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 5622 | 5615 |
| 5623 gfx::Vector2d gesture_scroll_deltas[4]; | 5616 gfx::Vector2d gesture_scroll_deltas[4]; |
| 5624 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); | 5617 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); |
| 5625 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); | 5618 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); |
| 5626 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); | 5619 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); |
| 5627 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); | 5620 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); |
| 5628 | 5621 |
| 5629 gfx::Vector2d expected_scroll_deltas[4]; | 5622 gfx::Vector2d expected_scroll_deltas[4]; |
| 5630 // Perspective affects the vertical delta by a different | 5623 // Perspective affects the vertical delta by a different |
| 5631 // amount depending on the vertical position of the |viewport_point|. | 5624 // amount depending on the vertical position of the |viewport_point|. |
| 5632 expected_scroll_deltas[0] = gfx::Vector2d(2, 8); | 5625 expected_scroll_deltas[0] = gfx::Vector2d(2, 8); |
| 5633 expected_scroll_deltas[1] = gfx::Vector2d(1, 4); | 5626 expected_scroll_deltas[1] = gfx::Vector2d(1, 4); |
| 5634 // Deltas which start with the same vertical position of the | 5627 // Deltas which start with the same vertical position of the |
| 5635 // |viewport_point| are subject to identical perspective effects. | 5628 // |viewport_point| are subject to identical perspective effects. |
| 5636 expected_scroll_deltas[2] = gfx::Vector2d(4, 0); | 5629 expected_scroll_deltas[2] = gfx::Vector2d(4, 0); |
| 5637 expected_scroll_deltas[3] = gfx::Vector2d(4, 0); | 5630 expected_scroll_deltas[3] = gfx::Vector2d(4, 0); |
| 5638 | 5631 |
| 5639 gfx::Point viewport_point(1, 1); | 5632 gfx::Point viewport_point(1, 1); |
| 5640 | 5633 |
| 5641 SetNeedsRebuildPropertyTrees(); | |
| 5642 // Scroll in screen coordinates with a gesture. Each scroll starts | 5634 // Scroll in screen coordinates with a gesture. Each scroll starts |
| 5643 // where the previous scroll ended, but the scroll position is reset | 5635 // where the previous scroll ended, but the scroll position is reset |
| 5644 // for each scroll. | 5636 // for each scroll. |
| 5645 for (int i = 0; i < 4; ++i) { | 5637 for (int i = 0; i < 4; ++i) { |
| 5646 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); | 5638 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); |
| 5647 DrawFrame(); | 5639 DrawFrame(); |
| 5648 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5640 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5649 host_impl_ | 5641 host_impl_ |
| 5650 ->ScrollBegin(BeginState(viewport_point).get(), | 5642 ->ScrollBegin(BeginState(viewport_point).get(), |
| 5651 InputHandler::TOUCHSCREEN) | 5643 InputHandler::TOUCHSCREEN) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5667 | 5659 |
| 5668 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5660 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
| 5669 LayerImpl* scroll_layer = | 5661 LayerImpl* scroll_layer = |
| 5670 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5662 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5671 | 5663 |
| 5672 // Scale the layer to twice its normal size. | 5664 // Scale the layer to twice its normal size. |
| 5673 int scale = 2; | 5665 int scale = 2; |
| 5674 gfx::Transform scale_transform; | 5666 gfx::Transform scale_transform; |
| 5675 scale_transform.Scale(scale, scale); | 5667 scale_transform.Scale(scale, scale); |
| 5676 scroll_layer->test_properties()->parent->SetTransform(scale_transform); | 5668 scroll_layer->test_properties()->parent->SetTransform(scale_transform); |
| 5669 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5677 | 5670 |
| 5678 gfx::Size surface_size(50, 50); | 5671 gfx::Size surface_size(50, 50); |
| 5679 host_impl_->SetViewportSize(surface_size); | 5672 host_impl_->SetViewportSize(surface_size); |
| 5680 SetNeedsRebuildPropertyTrees(); | |
| 5681 DrawFrame(); | 5673 DrawFrame(); |
| 5682 | 5674 |
| 5683 // Scroll down in screen coordinates with a gesture. | 5675 // Scroll down in screen coordinates with a gesture. |
| 5684 gfx::Vector2d scroll_delta(0, 10); | 5676 gfx::Vector2d scroll_delta(0, 10); |
| 5685 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5677 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5686 host_impl_ | 5678 host_impl_ |
| 5687 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5679 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5688 InputHandler::TOUCHSCREEN) | 5680 InputHandler::TOUCHSCREEN) |
| 5689 .thread); | 5681 .thread); |
| 5690 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5682 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5713 wheel_scroll_delta)); | 5705 wheel_scroll_delta)); |
| 5714 } | 5706 } |
| 5715 | 5707 |
| 5716 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 5708 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
| 5717 int width = 332; | 5709 int width = 332; |
| 5718 int height = 20; | 5710 int height = 20; |
| 5719 int scale = 3; | 5711 int scale = 3; |
| 5720 SetupScrollAndContentsLayers(gfx::Size(width, height)); | 5712 SetupScrollAndContentsLayers(gfx::Size(width, height)); |
| 5721 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 5713 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
| 5722 gfx::Size(width * scale - 1, height * scale)); | 5714 gfx::Size(width * scale - 1, height * scale)); |
| 5723 SetNeedsRebuildPropertyTrees(); | 5715 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5724 RebuildPropertyTrees(); | 5716 |
| 5725 host_impl_->active_tree()->SetDeviceScaleFactor(scale); | 5717 host_impl_->active_tree()->SetDeviceScaleFactor(scale); |
| 5726 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5718 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 5727 | 5719 |
| 5728 LayerImpl* inner_viewport_scroll_layer = | 5720 LayerImpl* inner_viewport_scroll_layer = |
| 5729 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5721 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 5730 EXPECT_EQ(gfx::ScrollOffset(0, 0), | 5722 EXPECT_EQ(gfx::ScrollOffset(0, 0), |
| 5731 inner_viewport_scroll_layer->MaxScrollOffset()); | 5723 inner_viewport_scroll_layer->MaxScrollOffset()); |
| 5732 } | 5724 } |
| 5733 | 5725 |
| 5734 class TestInputHandlerClient : public InputHandlerClient { | 5726 class TestInputHandlerClient : public InputHandlerClient { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5793 float min_page_scale_factor_; | 5785 float min_page_scale_factor_; |
| 5794 float max_page_scale_factor_; | 5786 float max_page_scale_factor_; |
| 5795 }; | 5787 }; |
| 5796 | 5788 |
| 5797 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 5789 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
| 5798 TestInputHandlerClient scroll_watcher; | 5790 TestInputHandlerClient scroll_watcher; |
| 5799 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5791 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 5800 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5792 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5801 LayerImpl* clip_layer = | 5793 LayerImpl* clip_layer = |
| 5802 scroll_layer->test_properties()->parent->test_properties()->parent; | 5794 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 5803 SetNeedsRebuildPropertyTrees(); | |
| 5804 clip_layer->SetBounds(gfx::Size(10, 20)); | 5795 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5805 RebuildPropertyTrees(); | 5796 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5806 | 5797 |
| 5807 host_impl_->BindToClient(&scroll_watcher); | 5798 host_impl_->BindToClient(&scroll_watcher); |
| 5808 | 5799 |
| 5809 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 5800 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
| 5810 scroll_layer->layer_tree_impl() | 5801 scroll_layer->layer_tree_impl() |
| 5811 ->property_trees() | 5802 ->property_trees() |
| 5812 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 5803 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 5813 gfx::ScrollOffset()); | 5804 gfx::ScrollOffset()); |
| 5814 SetScrollOffsetDelta(scroll_layer, initial_scroll_delta); | 5805 SetScrollOffsetDelta(scroll_layer, initial_scroll_delta); |
| 5815 | 5806 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5881 scroll_watcher.last_set_scroll_offset()); | 5872 scroll_watcher.last_set_scroll_offset()); |
| 5882 host_impl_->ScrollEnd(EndState().get()); | 5873 host_impl_->ScrollEnd(EndState().get()); |
| 5883 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset()); | 5874 host_impl_->SetSynchronousInputHandlerRootScrollOffset(gfx::ScrollOffset()); |
| 5884 | 5875 |
| 5885 // Forces a full tree synchronization and ensures that the scroll delegate | 5876 // Forces a full tree synchronization and ensures that the scroll delegate |
| 5886 // sees the correct size of the new tree. | 5877 // sees the correct size of the new tree. |
| 5887 gfx::Size new_size(42, 24); | 5878 gfx::Size new_size(42, 24); |
| 5888 host_impl_->CreatePendingTree(); | 5879 host_impl_->CreatePendingTree(); |
| 5889 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 5880 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 5890 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); | 5881 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); |
| 5891 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 5882 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 5892 host_impl_->ActivateSyncTree(); | 5883 host_impl_->ActivateSyncTree(); |
| 5893 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); | 5884 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); |
| 5894 | 5885 |
| 5895 // Tear down the LayerTreeHostImpl before the InputHandlerClient. | 5886 // Tear down the LayerTreeHostImpl before the InputHandlerClient. |
| 5896 host_impl_.reset(); | 5887 host_impl_.reset(); |
| 5897 } | 5888 } |
| 5898 | 5889 |
| 5899 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { | 5890 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
| 5900 const gfx::Transform target_space_transform = | 5891 const gfx::Transform target_space_transform = |
| 5901 layer->draw_properties().target_space_transform; | 5892 layer->draw_properties().target_space_transform; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5916 scroll_layer->SetDrawsContent(true); | 5907 scroll_layer->SetDrawsContent(true); |
| 5917 | 5908 |
| 5918 // Draw first frame to clear any pending draws and check scroll. | 5909 // Draw first frame to clear any pending draws and check scroll. |
| 5919 DrawFrame(); | 5910 DrawFrame(); |
| 5920 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); | 5911 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); |
| 5921 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 5912 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 5922 | 5913 |
| 5923 // Set external scroll delta on delegate and notify LayerTreeHost. | 5914 // Set external scroll delta on delegate and notify LayerTreeHost. |
| 5924 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 5915 gfx::ScrollOffset scroll_offset(10.f, 10.f); |
| 5925 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset); | 5916 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset); |
| 5917 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5926 | 5918 |
| 5927 // Check scroll delta reflected in layer. | 5919 // Check scroll delta reflected in layer. |
| 5928 LayerTreeHostImpl::FrameData frame; | 5920 LayerTreeHostImpl::FrameData frame; |
| 5929 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5921 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5930 host_impl_->DrawLayers(&frame); | 5922 host_impl_->DrawLayers(&frame); |
| 5931 host_impl_->DidDrawAllLayers(frame); | 5923 host_impl_->DidDrawAllLayers(frame); |
| 5932 EXPECT_FALSE(frame.has_no_damage); | 5924 EXPECT_FALSE(frame.has_no_damage); |
| 5933 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); | 5925 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); |
| 5934 } | 5926 } |
| 5935 | 5927 |
| 5936 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { | 5928 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
| 5937 InputHandlerScrollResult scroll_result; | 5929 InputHandlerScrollResult scroll_result; |
| 5938 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5930 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5931 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5932 |
| 5939 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 5933 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 5940 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5934 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 5941 DrawFrame(); | 5935 DrawFrame(); |
| 5942 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 5936 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 5943 | 5937 |
| 5944 // In-bounds scrolling does not affect overscroll. | 5938 // In-bounds scrolling does not affect overscroll. |
| 5945 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5939 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5946 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5940 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5947 InputHandler::WHEEL) | 5941 InputHandler::WHEEL) |
| 5948 .thread); | 5942 .thread); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6077 CreateScrollableLayer(3, surface_size, root_clip.get()); | 6071 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 6078 | 6072 |
| 6079 std::unique_ptr<LayerImpl> child = | 6073 std::unique_ptr<LayerImpl> child = |
| 6080 CreateScrollableLayer(2, surface_size, root_clip.get()); | 6074 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 6081 LayerImpl* grand_child_layer = grand_child.get(); | 6075 LayerImpl* grand_child_layer = grand_child.get(); |
| 6082 child->test_properties()->AddChild(std::move(grand_child)); | 6076 child->test_properties()->AddChild(std::move(grand_child)); |
| 6083 | 6077 |
| 6084 LayerImpl* child_layer = child.get(); | 6078 LayerImpl* child_layer = child.get(); |
| 6085 root->test_properties()->AddChild(std::move(child)); | 6079 root->test_properties()->AddChild(std::move(child)); |
| 6086 root_clip->test_properties()->AddChild(std::move(root)); | 6080 root_clip->test_properties()->AddChild(std::move(root)); |
| 6081 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
| 6082 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6083 host_impl_->active_tree()->DidBecomeActive(); |
| 6084 |
| 6087 child_layer->layer_tree_impl() | 6085 child_layer->layer_tree_impl() |
| 6088 ->property_trees() | 6086 ->property_trees() |
| 6089 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 6087 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| 6090 gfx::ScrollOffset(0, 3)); | 6088 gfx::ScrollOffset(0, 3)); |
| 6091 grand_child_layer->layer_tree_impl() | 6089 grand_child_layer->layer_tree_impl() |
| 6092 ->property_trees() | 6090 ->property_trees() |
| 6093 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 6091 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| 6094 gfx::ScrollOffset(0, 2)); | 6092 gfx::ScrollOffset(0, 2)); |
| 6095 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); | 6093 |
| 6096 host_impl_->active_tree()->DidBecomeActive(); | |
| 6097 host_impl_->SetViewportSize(surface_size); | 6094 host_impl_->SetViewportSize(surface_size); |
| 6098 SetNeedsRebuildPropertyTrees(); | |
| 6099 DrawFrame(); | 6095 DrawFrame(); |
| 6100 { | 6096 { |
| 6101 gfx::Vector2d scroll_delta(0, -10); | 6097 gfx::Vector2d scroll_delta(0, -10); |
| 6102 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6098 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6103 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6099 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 6104 InputHandler::NON_BUBBLING_GESTURE) | 6100 InputHandler::NON_BUBBLING_GESTURE) |
| 6105 .thread); | 6101 .thread); |
| 6106 scroll_result = | 6102 scroll_result = |
| 6107 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6103 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6108 EXPECT_TRUE(scroll_result.did_scroll); | 6104 EXPECT_TRUE(scroll_result.did_scroll); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6144 host_impl_->ScrollEnd(EndState().get()); | 6140 host_impl_->ScrollEnd(EndState().get()); |
| 6145 } | 6141 } |
| 6146 } | 6142 } |
| 6147 | 6143 |
| 6148 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 6144 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 6149 // When we try to scroll a non-scrollable child layer, the scroll delta | 6145 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 6150 // should be applied to one of its ancestors if possible. Overscroll should | 6146 // should be applied to one of its ancestors if possible. Overscroll should |
| 6151 // be reflected only when it has bubbled up to the root scrolling layer. | 6147 // be reflected only when it has bubbled up to the root scrolling layer. |
| 6152 InputHandlerScrollResult scroll_result; | 6148 InputHandlerScrollResult scroll_result; |
| 6153 SetupScrollAndContentsLayers(gfx::Size(20, 20)); | 6149 SetupScrollAndContentsLayers(gfx::Size(20, 20)); |
| 6150 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6151 |
| 6154 DrawFrame(); | 6152 DrawFrame(); |
| 6155 { | 6153 { |
| 6156 gfx::Vector2d scroll_delta(0, 8); | 6154 gfx::Vector2d scroll_delta(0, 8); |
| 6157 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6155 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6158 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6156 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6159 InputHandler::WHEEL) | 6157 InputHandler::WHEEL) |
| 6160 .thread); | 6158 .thread); |
| 6161 scroll_result = | 6159 scroll_result = |
| 6162 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6160 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6163 EXPECT_TRUE(scroll_result.did_scroll); | 6161 EXPECT_TRUE(scroll_result.did_scroll); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6178 } | 6176 } |
| 6179 | 6177 |
| 6180 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 6178 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 6181 InputHandlerScrollResult scroll_result; | 6179 InputHandlerScrollResult scroll_result; |
| 6182 LayerTreeSettings settings = DefaultSettings(); | 6180 LayerTreeSettings settings = DefaultSettings(); |
| 6183 CreateHostImpl(settings, CreateOutputSurface()); | 6181 CreateHostImpl(settings, CreateOutputSurface()); |
| 6184 | 6182 |
| 6185 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 6183 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 6186 LayerImpl* clip_layer = | 6184 LayerImpl* clip_layer = |
| 6187 scroll_layer->test_properties()->parent->test_properties()->parent; | 6185 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 6186 |
| 6188 clip_layer->SetBounds(gfx::Size(50, 50)); | 6187 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 6189 SetNeedsRebuildPropertyTrees(); | 6188 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6190 RebuildPropertyTrees(); | 6189 |
| 6191 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6190 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6192 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6191 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 6193 DrawFrame(); | 6192 DrawFrame(); |
| 6194 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6193 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6195 | 6194 |
| 6196 // Even though the layer can't scroll the overscroll still happens. | 6195 // Even though the layer can't scroll the overscroll still happens. |
| 6197 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6196 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6198 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6197 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 6199 InputHandler::WHEEL) | 6198 InputHandler::WHEEL) |
| 6200 .thread); | 6199 .thread); |
| 6201 scroll_result = host_impl_->ScrollBy( | 6200 scroll_result = host_impl_->ScrollBy( |
| 6202 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6201 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 6203 EXPECT_FALSE(scroll_result.did_scroll); | 6202 EXPECT_FALSE(scroll_result.did_scroll); |
| 6204 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6203 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| 6205 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 6204 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 6206 } | 6205 } |
| 6207 | 6206 |
| 6208 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 6207 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 6209 InputHandlerScrollResult scroll_result; | 6208 InputHandlerScrollResult scroll_result; |
| 6210 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 6209 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 6210 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6211 | 6211 |
| 6212 DrawFrame(); | 6212 DrawFrame(); |
| 6213 { | 6213 { |
| 6214 // Edge glow effect should be applicable only upon reaching Edges | 6214 // Edge glow effect should be applicable only upon reaching Edges |
| 6215 // of the content. unnecessary glow effect calls shouldn't be | 6215 // of the content. unnecessary glow effect calls shouldn't be |
| 6216 // called while scrolling up without reaching the edge of the content. | 6216 // called while scrolling up without reaching the edge of the content. |
| 6217 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6217 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6218 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6218 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 6219 InputHandler::WHEEL) | 6219 InputHandler::WHEEL) |
| 6220 .thread); | 6220 .thread); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6368 BlendStateCheckLayer* layer1 = | 6368 BlendStateCheckLayer* layer1 = |
| 6369 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); | 6369 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); |
| 6370 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 6370 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 6371 | 6371 |
| 6372 LayerTreeHostImpl::FrameData frame; | 6372 LayerTreeHostImpl::FrameData frame; |
| 6373 | 6373 |
| 6374 // Opaque layer, drawn without blending. | 6374 // Opaque layer, drawn without blending. |
| 6375 layer1->SetContentsOpaque(true); | 6375 layer1->SetContentsOpaque(true); |
| 6376 layer1->SetExpectation(false, false); | 6376 layer1->SetExpectation(false, false); |
| 6377 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6377 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6378 SetNeedsRebuildPropertyTrees(); | 6378 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6379 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6379 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6380 host_impl_->DrawLayers(&frame); | 6380 host_impl_->DrawLayers(&frame); |
| 6381 EXPECT_TRUE(layer1->quads_appended()); | 6381 EXPECT_TRUE(layer1->quads_appended()); |
| 6382 host_impl_->DidDrawAllLayers(frame); | 6382 host_impl_->DidDrawAllLayers(frame); |
| 6383 | 6383 |
| 6384 // Layer with translucent content and painting, so drawn with blending. | 6384 // Layer with translucent content and painting, so drawn with blending. |
| 6385 layer1->SetContentsOpaque(false); | 6385 layer1->SetContentsOpaque(false); |
| 6386 layer1->SetExpectation(true, false); | 6386 layer1->SetExpectation(true, false); |
| 6387 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6387 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6388 SetNeedsRebuildPropertyTrees(); | 6388 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6389 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6389 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6390 host_impl_->DrawLayers(&frame); | 6390 host_impl_->DrawLayers(&frame); |
| 6391 EXPECT_TRUE(layer1->quads_appended()); | 6391 EXPECT_TRUE(layer1->quads_appended()); |
| 6392 host_impl_->DidDrawAllLayers(frame); | 6392 host_impl_->DidDrawAllLayers(frame); |
| 6393 | 6393 |
| 6394 // Layer with translucent opacity, drawn with blending. | 6394 // Layer with translucent opacity, drawn with blending. |
| 6395 layer1->SetContentsOpaque(true); | 6395 layer1->SetContentsOpaque(true); |
| 6396 layer1->test_properties()->opacity = 0.5f; | 6396 layer1->test_properties()->opacity = 0.5f; |
| 6397 layer1->NoteLayerPropertyChanged(); | 6397 layer1->NoteLayerPropertyChanged(); |
| 6398 layer1->SetExpectation(true, false); | 6398 layer1->SetExpectation(true, false); |
| 6399 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6399 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6400 SetNeedsRebuildPropertyTrees(); | 6400 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6401 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6401 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6402 host_impl_->DrawLayers(&frame); | 6402 host_impl_->DrawLayers(&frame); |
| 6403 EXPECT_TRUE(layer1->quads_appended()); | 6403 EXPECT_TRUE(layer1->quads_appended()); |
| 6404 host_impl_->DidDrawAllLayers(frame); | 6404 host_impl_->DidDrawAllLayers(frame); |
| 6405 | 6405 |
| 6406 // Layer with translucent opacity and painting, drawn with blending. | 6406 // Layer with translucent opacity and painting, drawn with blending. |
| 6407 layer1->SetContentsOpaque(true); | 6407 layer1->SetContentsOpaque(true); |
| 6408 layer1->test_properties()->opacity = 0.5f; | 6408 layer1->test_properties()->opacity = 0.5f; |
| 6409 layer1->NoteLayerPropertyChanged(); | 6409 layer1->NoteLayerPropertyChanged(); |
| 6410 layer1->SetExpectation(true, false); | 6410 layer1->SetExpectation(true, false); |
| 6411 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6411 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6412 SetNeedsRebuildPropertyTrees(); | 6412 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6413 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6413 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6414 host_impl_->DrawLayers(&frame); | 6414 host_impl_->DrawLayers(&frame); |
| 6415 EXPECT_TRUE(layer1->quads_appended()); | 6415 EXPECT_TRUE(layer1->quads_appended()); |
| 6416 host_impl_->DidDrawAllLayers(frame); | 6416 host_impl_->DidDrawAllLayers(frame); |
| 6417 | 6417 |
| 6418 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( | 6418 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( |
| 6419 host_impl_->active_tree(), 3, host_impl_->resource_provider())); | 6419 host_impl_->active_tree(), 3, host_impl_->resource_provider())); |
| 6420 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( | 6420 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( |
| 6421 layer1->test_properties()->children[0]); | 6421 layer1->test_properties()->children[0]); |
| 6422 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 6422 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 6423 | 6423 |
| 6424 // 2 opaque layers, drawn without blending. | 6424 // 2 opaque layers, drawn without blending. |
| 6425 layer1->SetContentsOpaque(true); | 6425 layer1->SetContentsOpaque(true); |
| 6426 layer1->test_properties()->opacity = 1.f; | 6426 layer1->test_properties()->opacity = 1.f; |
| 6427 layer1->NoteLayerPropertyChanged(); | 6427 layer1->NoteLayerPropertyChanged(); |
| 6428 layer1->SetExpectation(false, false); | 6428 layer1->SetExpectation(false, false); |
| 6429 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6429 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6430 layer2->SetContentsOpaque(true); | 6430 layer2->SetContentsOpaque(true); |
| 6431 layer2->test_properties()->opacity = 1.f; | 6431 layer2->test_properties()->opacity = 1.f; |
| 6432 layer2->NoteLayerPropertyChanged(); | 6432 layer2->NoteLayerPropertyChanged(); |
| 6433 layer2->SetExpectation(false, false); | 6433 layer2->SetExpectation(false, false); |
| 6434 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6434 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6435 SetNeedsRebuildPropertyTrees(); | 6435 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6436 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6436 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6437 host_impl_->DrawLayers(&frame); | 6437 host_impl_->DrawLayers(&frame); |
| 6438 EXPECT_TRUE(layer1->quads_appended()); | 6438 EXPECT_TRUE(layer1->quads_appended()); |
| 6439 EXPECT_TRUE(layer2->quads_appended()); | 6439 EXPECT_TRUE(layer2->quads_appended()); |
| 6440 host_impl_->DidDrawAllLayers(frame); | 6440 host_impl_->DidDrawAllLayers(frame); |
| 6441 | 6441 |
| 6442 // Parent layer with translucent content, drawn with blending. | 6442 // Parent layer with translucent content, drawn with blending. |
| 6443 // Child layer with opaque content, drawn without blending. | 6443 // Child layer with opaque content, drawn without blending. |
| 6444 layer1->SetContentsOpaque(false); | 6444 layer1->SetContentsOpaque(false); |
| 6445 layer1->SetExpectation(true, false); | 6445 layer1->SetExpectation(true, false); |
| 6446 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6446 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6447 layer2->SetExpectation(false, false); | 6447 layer2->SetExpectation(false, false); |
| 6448 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6448 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6449 SetNeedsRebuildPropertyTrees(); | 6449 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6450 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6450 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6451 host_impl_->DrawLayers(&frame); | 6451 host_impl_->DrawLayers(&frame); |
| 6452 EXPECT_TRUE(layer1->quads_appended()); | 6452 EXPECT_TRUE(layer1->quads_appended()); |
| 6453 EXPECT_TRUE(layer2->quads_appended()); | 6453 EXPECT_TRUE(layer2->quads_appended()); |
| 6454 host_impl_->DidDrawAllLayers(frame); | 6454 host_impl_->DidDrawAllLayers(frame); |
| 6455 | 6455 |
| 6456 // Parent layer with translucent content but opaque painting, drawn without | 6456 // Parent layer with translucent content but opaque painting, drawn without |
| 6457 // blending. | 6457 // blending. |
| 6458 // Child layer with opaque content, drawn without blending. | 6458 // Child layer with opaque content, drawn without blending. |
| 6459 layer1->SetContentsOpaque(true); | 6459 layer1->SetContentsOpaque(true); |
| 6460 layer1->SetExpectation(false, false); | 6460 layer1->SetExpectation(false, false); |
| 6461 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6461 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6462 layer2->SetExpectation(false, false); | 6462 layer2->SetExpectation(false, false); |
| 6463 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6463 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6464 SetNeedsRebuildPropertyTrees(); | 6464 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6465 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6465 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6466 host_impl_->DrawLayers(&frame); | 6466 host_impl_->DrawLayers(&frame); |
| 6467 EXPECT_TRUE(layer1->quads_appended()); | 6467 EXPECT_TRUE(layer1->quads_appended()); |
| 6468 EXPECT_TRUE(layer2->quads_appended()); | 6468 EXPECT_TRUE(layer2->quads_appended()); |
| 6469 host_impl_->DidDrawAllLayers(frame); | 6469 host_impl_->DidDrawAllLayers(frame); |
| 6470 | 6470 |
| 6471 // Parent layer with translucent opacity and opaque content. Since it has a | 6471 // Parent layer with translucent opacity and opaque content. Since it has a |
| 6472 // drawing child, it's drawn to a render surface which carries the opacity, | 6472 // drawing child, it's drawn to a render surface which carries the opacity, |
| 6473 // so it's itself drawn without blending. | 6473 // so it's itself drawn without blending. |
| 6474 // Child layer with opaque content, drawn without blending (parent surface | 6474 // Child layer with opaque content, drawn without blending (parent surface |
| 6475 // carries the inherited opacity). | 6475 // carries the inherited opacity). |
| 6476 layer1->SetContentsOpaque(true); | 6476 layer1->SetContentsOpaque(true); |
| 6477 layer1->test_properties()->opacity = 0.5f; | 6477 layer1->test_properties()->opacity = 0.5f; |
| 6478 layer1->NoteLayerPropertyChanged(); | 6478 layer1->NoteLayerPropertyChanged(); |
| 6479 layer1->test_properties()->force_render_surface = true; | 6479 layer1->test_properties()->force_render_surface = true; |
| 6480 layer1->SetExpectation(false, true); | 6480 layer1->SetExpectation(false, true); |
| 6481 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6481 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6482 layer2->SetExpectation(false, false); | 6482 layer2->SetExpectation(false, false); |
| 6483 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6483 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6484 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 6484 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 6485 host_impl_->active_tree()->root_layer_for_testing()); | 6485 host_impl_->active_tree()->root_layer_for_testing()); |
| 6486 SetNeedsRebuildPropertyTrees(); | 6486 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6487 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6487 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6488 host_impl_->DrawLayers(&frame); | 6488 host_impl_->DrawLayers(&frame); |
| 6489 EXPECT_TRUE(layer1->quads_appended()); | 6489 EXPECT_TRUE(layer1->quads_appended()); |
| 6490 EXPECT_TRUE(layer2->quads_appended()); | 6490 EXPECT_TRUE(layer2->quads_appended()); |
| 6491 host_impl_->DidDrawAllLayers(frame); | 6491 host_impl_->DidDrawAllLayers(frame); |
| 6492 layer1->test_properties()->force_render_surface = false; | 6492 layer1->test_properties()->force_render_surface = false; |
| 6493 | 6493 |
| 6494 // Draw again, but with child non-opaque, to make sure | 6494 // Draw again, but with child non-opaque, to make sure |
| 6495 // layer1 not culled. | 6495 // layer1 not culled. |
| 6496 layer1->SetContentsOpaque(true); | 6496 layer1->SetContentsOpaque(true); |
| 6497 layer1->test_properties()->opacity = 1.f; | 6497 layer1->test_properties()->opacity = 1.f; |
| 6498 layer1->NoteLayerPropertyChanged(); | 6498 layer1->NoteLayerPropertyChanged(); |
| 6499 layer1->SetExpectation(false, false); | 6499 layer1->SetExpectation(false, false); |
| 6500 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6500 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6501 layer2->SetContentsOpaque(true); | 6501 layer2->SetContentsOpaque(true); |
| 6502 layer2->test_properties()->opacity = 0.5f; | 6502 layer2->test_properties()->opacity = 0.5f; |
| 6503 layer2->NoteLayerPropertyChanged(); | 6503 layer2->NoteLayerPropertyChanged(); |
| 6504 layer2->SetExpectation(true, false); | 6504 layer2->SetExpectation(true, false); |
| 6505 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6505 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6506 SetNeedsRebuildPropertyTrees(); | 6506 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6507 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6507 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6508 host_impl_->DrawLayers(&frame); | 6508 host_impl_->DrawLayers(&frame); |
| 6509 EXPECT_TRUE(layer1->quads_appended()); | 6509 EXPECT_TRUE(layer1->quads_appended()); |
| 6510 EXPECT_TRUE(layer2->quads_appended()); | 6510 EXPECT_TRUE(layer2->quads_appended()); |
| 6511 host_impl_->DidDrawAllLayers(frame); | 6511 host_impl_->DidDrawAllLayers(frame); |
| 6512 | 6512 |
| 6513 // A second way of making the child non-opaque. | 6513 // A second way of making the child non-opaque. |
| 6514 layer1->SetContentsOpaque(true); | 6514 layer1->SetContentsOpaque(true); |
| 6515 layer1->test_properties()->opacity = 1.f; | 6515 layer1->test_properties()->opacity = 1.f; |
| 6516 layer1->NoteLayerPropertyChanged(); | 6516 layer1->NoteLayerPropertyChanged(); |
| 6517 layer1->SetExpectation(false, false); | 6517 layer1->SetExpectation(false, false); |
| 6518 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6518 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6519 layer2->SetContentsOpaque(false); | 6519 layer2->SetContentsOpaque(false); |
| 6520 layer2->test_properties()->opacity = 1.f; | 6520 layer2->test_properties()->opacity = 1.f; |
| 6521 layer2->NoteLayerPropertyChanged(); | 6521 layer2->NoteLayerPropertyChanged(); |
| 6522 layer2->SetExpectation(true, false); | 6522 layer2->SetExpectation(true, false); |
| 6523 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6523 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6524 SetNeedsRebuildPropertyTrees(); | 6524 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6525 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6525 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6526 host_impl_->DrawLayers(&frame); | 6526 host_impl_->DrawLayers(&frame); |
| 6527 EXPECT_TRUE(layer1->quads_appended()); | 6527 EXPECT_TRUE(layer1->quads_appended()); |
| 6528 EXPECT_TRUE(layer2->quads_appended()); | 6528 EXPECT_TRUE(layer2->quads_appended()); |
| 6529 host_impl_->DidDrawAllLayers(frame); | 6529 host_impl_->DidDrawAllLayers(frame); |
| 6530 | 6530 |
| 6531 // And when the layer says its not opaque but is painted opaque, it is not | 6531 // And when the layer says its not opaque but is painted opaque, it is not |
| 6532 // blended. | 6532 // blended. |
| 6533 layer1->SetContentsOpaque(true); | 6533 layer1->SetContentsOpaque(true); |
| 6534 layer1->test_properties()->opacity = 1.f; | 6534 layer1->test_properties()->opacity = 1.f; |
| 6535 layer1->NoteLayerPropertyChanged(); | 6535 layer1->NoteLayerPropertyChanged(); |
| 6536 layer1->SetExpectation(false, false); | 6536 layer1->SetExpectation(false, false); |
| 6537 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6537 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6538 layer2->SetContentsOpaque(true); | 6538 layer2->SetContentsOpaque(true); |
| 6539 layer2->test_properties()->opacity = 1.f; | 6539 layer2->test_properties()->opacity = 1.f; |
| 6540 layer2->NoteLayerPropertyChanged(); | 6540 layer2->NoteLayerPropertyChanged(); |
| 6541 layer2->SetExpectation(false, false); | 6541 layer2->SetExpectation(false, false); |
| 6542 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6542 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6543 SetNeedsRebuildPropertyTrees(); | 6543 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6544 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6544 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6545 host_impl_->DrawLayers(&frame); | 6545 host_impl_->DrawLayers(&frame); |
| 6546 EXPECT_TRUE(layer1->quads_appended()); | 6546 EXPECT_TRUE(layer1->quads_appended()); |
| 6547 EXPECT_TRUE(layer2->quads_appended()); | 6547 EXPECT_TRUE(layer2->quads_appended()); |
| 6548 host_impl_->DidDrawAllLayers(frame); | 6548 host_impl_->DidDrawAllLayers(frame); |
| 6549 | 6549 |
| 6550 // Layer with partially opaque contents, drawn with blending. | 6550 // Layer with partially opaque contents, drawn with blending. |
| 6551 layer1->SetContentsOpaque(false); | 6551 layer1->SetContentsOpaque(false); |
| 6552 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6552 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 6553 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 6553 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 6554 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6554 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 6555 layer1->SetExpectation(true, false); | 6555 layer1->SetExpectation(true, false); |
| 6556 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6556 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6557 SetNeedsRebuildPropertyTrees(); | 6557 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6558 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6558 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6559 host_impl_->DrawLayers(&frame); | 6559 host_impl_->DrawLayers(&frame); |
| 6560 EXPECT_TRUE(layer1->quads_appended()); | 6560 EXPECT_TRUE(layer1->quads_appended()); |
| 6561 host_impl_->DidDrawAllLayers(frame); | 6561 host_impl_->DidDrawAllLayers(frame); |
| 6562 | 6562 |
| 6563 // Layer with partially opaque contents partially culled, drawn with blending. | 6563 // Layer with partially opaque contents partially culled, drawn with blending. |
| 6564 layer1->SetContentsOpaque(false); | 6564 layer1->SetContentsOpaque(false); |
| 6565 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6565 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 6566 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 6566 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 6567 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6567 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 6568 layer1->SetExpectation(true, false); | 6568 layer1->SetExpectation(true, false); |
| 6569 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6569 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6570 SetNeedsRebuildPropertyTrees(); | 6570 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6571 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6571 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6572 host_impl_->DrawLayers(&frame); | 6572 host_impl_->DrawLayers(&frame); |
| 6573 EXPECT_TRUE(layer1->quads_appended()); | 6573 EXPECT_TRUE(layer1->quads_appended()); |
| 6574 host_impl_->DidDrawAllLayers(frame); | 6574 host_impl_->DidDrawAllLayers(frame); |
| 6575 | 6575 |
| 6576 // Layer with partially opaque contents culled, drawn with blending. | 6576 // Layer with partially opaque contents culled, drawn with blending. |
| 6577 layer1->SetContentsOpaque(false); | 6577 layer1->SetContentsOpaque(false); |
| 6578 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6578 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 6579 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 6579 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 6580 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6580 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 6581 layer1->SetExpectation(true, false); | 6581 layer1->SetExpectation(true, false); |
| 6582 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6582 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6583 SetNeedsRebuildPropertyTrees(); | 6583 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6584 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6584 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6585 host_impl_->DrawLayers(&frame); | 6585 host_impl_->DrawLayers(&frame); |
| 6586 EXPECT_TRUE(layer1->quads_appended()); | 6586 EXPECT_TRUE(layer1->quads_appended()); |
| 6587 host_impl_->DidDrawAllLayers(frame); | 6587 host_impl_->DidDrawAllLayers(frame); |
| 6588 | 6588 |
| 6589 // Layer with partially opaque contents and translucent contents culled, drawn | 6589 // Layer with partially opaque contents and translucent contents culled, drawn |
| 6590 // without blending. | 6590 // without blending. |
| 6591 layer1->SetContentsOpaque(false); | 6591 layer1->SetContentsOpaque(false); |
| 6592 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6592 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 6593 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 6593 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 6594 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6594 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 6595 layer1->SetExpectation(false, false); | 6595 layer1->SetExpectation(false, false); |
| 6596 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6596 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6597 SetNeedsRebuildPropertyTrees(); | 6597 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6598 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6598 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6599 host_impl_->DrawLayers(&frame); | 6599 host_impl_->DrawLayers(&frame); |
| 6600 EXPECT_TRUE(layer1->quads_appended()); | 6600 EXPECT_TRUE(layer1->quads_appended()); |
| 6601 host_impl_->DidDrawAllLayers(frame); | 6601 host_impl_->DidDrawAllLayers(frame); |
| 6602 } | 6602 } |
| 6603 | 6603 |
| 6604 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6604 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 6605 protected: | 6605 protected: |
| 6606 LayerTreeHostImplViewportCoveredTest() : | 6606 LayerTreeHostImplViewportCoveredTest() : |
| 6607 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6607 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 6608 child_(NULL), | 6608 child_(NULL), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6637 child_->SetContentsOpaque(true); | 6637 child_->SetContentsOpaque(true); |
| 6638 } | 6638 } |
| 6639 | 6639 |
| 6640 // Expect no gutter rects. | 6640 // Expect no gutter rects. |
| 6641 void TestLayerCoversFullViewport() { | 6641 void TestLayerCoversFullViewport() { |
| 6642 gfx::Rect layer_rect(viewport_size_); | 6642 gfx::Rect layer_rect(viewport_size_); |
| 6643 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6643 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 6644 child_->SetBounds(layer_rect.size()); | 6644 child_->SetBounds(layer_rect.size()); |
| 6645 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6645 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 6646 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6646 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6647 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6647 | 6648 |
| 6648 LayerTreeHostImpl::FrameData frame; | 6649 LayerTreeHostImpl::FrameData frame; |
| 6649 SetNeedsRebuildPropertyTrees(); | 6650 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6650 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 6651 ASSERT_EQ(1u, frame.render_passes.size()); | 6651 ASSERT_EQ(1u, frame.render_passes.size()); |
| 6652 | 6652 |
| 6653 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 6653 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
| 6654 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 6654 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 6655 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 6655 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
| 6656 | 6656 |
| 6657 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 6657 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
| 6658 host_impl_->DidDrawAllLayers(frame); | 6658 host_impl_->DidDrawAllLayers(frame); |
| 6659 } | 6659 } |
| 6660 | 6660 |
| 6661 // Expect fullscreen gutter rect. | 6661 // Expect fullscreen gutter rect. |
| 6662 void SetUpEmptylayer() { | 6662 void SetUpEmptylayer() { |
| 6663 gfx::Rect layer_rect(0, 0, 0, 0); | 6663 gfx::Rect layer_rect(0, 0, 0, 0); |
| 6664 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6664 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 6665 child_->SetBounds(layer_rect.size()); | 6665 child_->SetBounds(layer_rect.size()); |
| 6666 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6666 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 6667 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6667 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6668 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6668 } | 6669 } |
| 6669 | 6670 |
| 6670 void VerifyEmptyLayerRenderPasses(const RenderPassList& render_passes) { | 6671 void VerifyEmptyLayerRenderPasses(const RenderPassList& render_passes) { |
| 6671 ASSERT_EQ(1u, render_passes.size()); | 6672 ASSERT_EQ(1u, render_passes.size()); |
| 6672 | 6673 |
| 6673 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list)); | 6674 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list)); |
| 6674 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); | 6675 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); |
| 6675 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6676 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
| 6676 | 6677 |
| 6677 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); | 6678 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); |
| 6678 } | 6679 } |
| 6679 | 6680 |
| 6680 void TestEmptyLayer() { | 6681 void TestEmptyLayer() { |
| 6681 SetUpEmptylayer(); | 6682 SetUpEmptylayer(); |
| 6682 LayerTreeHostImpl::FrameData frame; | 6683 LayerTreeHostImpl::FrameData frame; |
| 6683 SetNeedsRebuildPropertyTrees(); | 6684 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6684 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 6685 VerifyEmptyLayerRenderPasses(frame.render_passes); | 6685 VerifyEmptyLayerRenderPasses(frame.render_passes); |
| 6686 host_impl_->DidDrawAllLayers(frame); | 6686 host_impl_->DidDrawAllLayers(frame); |
| 6687 } | 6687 } |
| 6688 | 6688 |
| 6689 void TestEmptyLayerWithOnDraw() { | 6689 void TestEmptyLayerWithOnDraw() { |
| 6690 SetUpEmptylayer(); | 6690 SetUpEmptylayer(); |
| 6691 gfx::Transform identity; | 6691 gfx::Transform identity; |
| 6692 gfx::Rect viewport(viewport_size_); | 6692 gfx::Rect viewport(viewport_size_); |
| 6693 bool resourceless_software_draw = true; | 6693 bool resourceless_software_draw = true; |
| 6694 SetNeedsRebuildPropertyTrees(); | |
| 6695 host_impl_->OnDraw(identity, viewport, viewport, | 6694 host_impl_->OnDraw(identity, viewport, viewport, |
| 6696 resourceless_software_draw); | 6695 resourceless_software_draw); |
| 6697 VerifyEmptyLayerRenderPasses(last_on_draw_render_passes_); | 6696 VerifyEmptyLayerRenderPasses(last_on_draw_render_passes_); |
| 6698 } | 6697 } |
| 6699 | 6698 |
| 6700 // Expect four surrounding gutter rects. | 6699 // Expect four surrounding gutter rects. |
| 6701 void SetUpLayerInMiddleOfViewport() { | 6700 void SetUpLayerInMiddleOfViewport() { |
| 6702 gfx::Rect layer_rect(500, 500, 200, 200); | 6701 gfx::Rect layer_rect(500, 500, 200, 200); |
| 6703 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6702 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 6704 child_->SetBounds(layer_rect.size()); | 6703 child_->SetBounds(layer_rect.size()); |
| 6705 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6704 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 6706 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6705 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6706 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6707 } | 6707 } |
| 6708 | 6708 |
| 6709 void VerifyLayerInMiddleOfViewport(const RenderPassList& render_passes) { | 6709 void VerifyLayerInMiddleOfViewport(const RenderPassList& render_passes) { |
| 6710 ASSERT_EQ(1u, render_passes.size()); | 6710 ASSERT_EQ(1u, render_passes.size()); |
| 6711 | 6711 |
| 6712 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list)); | 6712 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list)); |
| 6713 EXPECT_EQ(5u, render_passes[0]->quad_list.size()); | 6713 EXPECT_EQ(5u, render_passes[0]->quad_list.size()); |
| 6714 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6714 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
| 6715 | 6715 |
| 6716 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); | 6716 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); |
| 6717 } | 6717 } |
| 6718 | 6718 |
| 6719 void TestLayerInMiddleOfViewport() { | 6719 void TestLayerInMiddleOfViewport() { |
| 6720 SetUpLayerInMiddleOfViewport(); | 6720 SetUpLayerInMiddleOfViewport(); |
| 6721 LayerTreeHostImpl::FrameData frame; | 6721 LayerTreeHostImpl::FrameData frame; |
| 6722 SetNeedsRebuildPropertyTrees(); | 6722 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6723 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 6724 VerifyLayerInMiddleOfViewport(frame.render_passes); | 6723 VerifyLayerInMiddleOfViewport(frame.render_passes); |
| 6725 host_impl_->DidDrawAllLayers(frame); | 6724 host_impl_->DidDrawAllLayers(frame); |
| 6726 } | 6725 } |
| 6727 | 6726 |
| 6728 void TestLayerInMiddleOfViewportWithOnDraw() { | 6727 void TestLayerInMiddleOfViewportWithOnDraw() { |
| 6729 SetUpLayerInMiddleOfViewport(); | 6728 SetUpLayerInMiddleOfViewport(); |
| 6730 gfx::Transform identity; | 6729 gfx::Transform identity; |
| 6731 gfx::Rect viewport(viewport_size_); | 6730 gfx::Rect viewport(viewport_size_); |
| 6732 bool resourceless_software_draw = true; | 6731 bool resourceless_software_draw = true; |
| 6733 SetNeedsRebuildPropertyTrees(); | |
| 6734 host_impl_->OnDraw(identity, viewport, viewport, | 6732 host_impl_->OnDraw(identity, viewport, viewport, |
| 6735 resourceless_software_draw); | 6733 resourceless_software_draw); |
| 6736 VerifyLayerInMiddleOfViewport(last_on_draw_render_passes_); | 6734 VerifyLayerInMiddleOfViewport(last_on_draw_render_passes_); |
| 6737 } | 6735 } |
| 6738 | 6736 |
| 6739 // Expect no gutter rects. | 6737 // Expect no gutter rects. |
| 6740 void SetUpLayerIsLargerThanViewport() { | 6738 void SetUpLayerIsLargerThanViewport() { |
| 6741 gfx::Rect layer_rect(viewport_size_.width() + 10, | 6739 gfx::Rect layer_rect(viewport_size_.width() + 10, |
| 6742 viewport_size_.height() + 10); | 6740 viewport_size_.height() + 10); |
| 6743 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6741 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 6744 child_->SetBounds(layer_rect.size()); | 6742 child_->SetBounds(layer_rect.size()); |
| 6745 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6743 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 6746 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6744 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6745 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6747 } | 6746 } |
| 6748 | 6747 |
| 6749 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) { | 6748 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) { |
| 6750 ASSERT_EQ(1u, render_passes.size()); | 6749 ASSERT_EQ(1u, render_passes.size()); |
| 6751 | 6750 |
| 6752 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list)); | 6751 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list)); |
| 6753 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); | 6752 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); |
| 6754 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6753 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
| 6755 } | 6754 } |
| 6756 | 6755 |
| 6757 void TestLayerIsLargerThanViewport() { | 6756 void TestLayerIsLargerThanViewport() { |
| 6758 SetUpLayerIsLargerThanViewport(); | 6757 SetUpLayerIsLargerThanViewport(); |
| 6759 LayerTreeHostImpl::FrameData frame; | 6758 LayerTreeHostImpl::FrameData frame; |
| 6760 SetNeedsRebuildPropertyTrees(); | 6759 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6761 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 6762 VerifyLayerIsLargerThanViewport(frame.render_passes); | 6760 VerifyLayerIsLargerThanViewport(frame.render_passes); |
| 6763 host_impl_->DidDrawAllLayers(frame); | 6761 host_impl_->DidDrawAllLayers(frame); |
| 6764 } | 6762 } |
| 6765 | 6763 |
| 6766 void TestLayerIsLargerThanViewportWithOnDraw() { | 6764 void TestLayerIsLargerThanViewportWithOnDraw() { |
| 6767 SetUpLayerIsLargerThanViewport(); | 6765 SetUpLayerIsLargerThanViewport(); |
| 6768 gfx::Transform identity; | 6766 gfx::Transform identity; |
| 6769 gfx::Rect viewport(viewport_size_); | 6767 gfx::Rect viewport(viewport_size_); |
| 6770 bool resourceless_software_draw = true; | 6768 bool resourceless_software_draw = true; |
| 6771 SetNeedsRebuildPropertyTrees(); | |
| 6772 host_impl_->OnDraw(identity, viewport, viewport, | 6769 host_impl_->OnDraw(identity, viewport, viewport, |
| 6773 resourceless_software_draw); | 6770 resourceless_software_draw); |
| 6774 VerifyLayerIsLargerThanViewport(last_on_draw_render_passes_); | 6771 VerifyLayerIsLargerThanViewport(last_on_draw_render_passes_); |
| 6775 } | 6772 } |
| 6776 | 6773 |
| 6777 void DidActivateSyncTree() override { did_activate_pending_tree_ = true; } | 6774 void DidActivateSyncTree() override { did_activate_pending_tree_ = true; } |
| 6778 | 6775 |
| 6779 void set_gutter_quad_material(DrawQuad::Material material) { | 6776 void set_gutter_quad_material(DrawQuad::Material material) { |
| 6780 gutter_quad_material_ = material; | 6777 gutter_quad_material_ = material; |
| 6781 } | 6778 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6924 std::unique_ptr<OutputSurface> output_surface( | 6921 std::unique_ptr<OutputSurface> output_surface( |
| 6925 FakeOutputSurface::Create3d(provider)); | 6922 FakeOutputSurface::Create3d(provider)); |
| 6926 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6923 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
| 6927 | 6924 |
| 6928 std::unique_ptr<LayerImpl> root = | 6925 std::unique_ptr<LayerImpl> root = |
| 6929 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6926 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 6930 root->SetBounds(gfx::Size(10, 10)); | 6927 root->SetBounds(gfx::Size(10, 10)); |
| 6931 root->SetDrawsContent(true); | 6928 root->SetDrawsContent(true); |
| 6932 root->test_properties()->force_render_surface = true; | 6929 root->test_properties()->force_render_surface = true; |
| 6933 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 6930 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 6931 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6932 |
| 6934 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 6933 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 6935 provider->TestContext3d()->clear_reshape_called(); | 6934 provider->TestContext3d()->clear_reshape_called(); |
| 6936 | 6935 |
| 6937 LayerTreeHostImpl::FrameData frame; | 6936 LayerTreeHostImpl::FrameData frame; |
| 6938 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6937 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 6939 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 6938 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
| 6940 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6939 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6941 host_impl_->DrawLayers(&frame); | 6940 host_impl_->DrawLayers(&frame); |
| 6942 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6941 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 6943 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 6942 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
| 6944 EXPECT_EQ(provider->TestContext3d()->height(), 10); | 6943 EXPECT_EQ(provider->TestContext3d()->height(), 10); |
| 6945 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 6944 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 6946 host_impl_->DidDrawAllLayers(frame); | 6945 host_impl_->DidDrawAllLayers(frame); |
| 6947 provider->TestContext3d()->clear_reshape_called(); | 6946 provider->TestContext3d()->clear_reshape_called(); |
| 6948 | 6947 |
| 6949 host_impl_->SetViewportSize(gfx::Size(20, 30)); | 6948 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
| 6950 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6949 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6951 host_impl_->DrawLayers(&frame); | 6950 host_impl_->DrawLayers(&frame); |
| 6952 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6951 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 6953 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 6952 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 6954 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 6953 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 6955 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 6954 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 6956 host_impl_->DidDrawAllLayers(frame); | 6955 host_impl_->DidDrawAllLayers(frame); |
| 6957 provider->TestContext3d()->clear_reshape_called(); | 6956 provider->TestContext3d()->clear_reshape_called(); |
| 6958 | 6957 |
| 6959 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); | 6958 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); |
| 6960 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6959 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6961 host_impl_->DrawLayers(&frame); | 6960 host_impl_->DrawLayers(&frame); |
| 6962 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6961 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 6963 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 6962 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 6964 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 6963 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 6965 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | 6964 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); |
| 6966 host_impl_->DidDrawAllLayers(frame); | 6965 host_impl_->DidDrawAllLayers(frame); |
| 6967 provider->TestContext3d()->clear_reshape_called(); | 6966 provider->TestContext3d()->clear_reshape_called(); |
| 6968 } | 6967 } |
| 6969 | 6968 |
| 6970 // Make sure damage tracking propagates all the way to the graphics context, | 6969 // Make sure damage tracking propagates all the way to the graphics context, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6999 root->test_properties()->force_render_surface = true; | 6998 root->test_properties()->force_render_surface = true; |
| 7000 std::unique_ptr<LayerImpl> child = | 6999 std::unique_ptr<LayerImpl> child = |
| 7001 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 7000 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 7002 child->SetPosition(gfx::PointF(12.f, 13.f)); | 7001 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 7003 child->SetBounds(gfx::Size(14, 15)); | 7002 child->SetBounds(gfx::Size(14, 15)); |
| 7004 child->SetDrawsContent(true); | 7003 child->SetDrawsContent(true); |
| 7005 root->SetBounds(gfx::Size(500, 500)); | 7004 root->SetBounds(gfx::Size(500, 500)); |
| 7006 root->SetDrawsContent(true); | 7005 root->SetDrawsContent(true); |
| 7007 root->test_properties()->AddChild(std::move(child)); | 7006 root->test_properties()->AddChild(std::move(child)); |
| 7008 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7007 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7008 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7009 | 7009 |
| 7010 LayerTreeHostImpl::FrameData frame; | 7010 LayerTreeHostImpl::FrameData frame; |
| 7011 | 7011 |
| 7012 // First frame, the entire screen should get swapped. | 7012 // First frame, the entire screen should get swapped. |
| 7013 layer_tree_host_impl->active_tree() | |
| 7014 ->BuildLayerListAndPropertyTreesForTesting(); | |
| 7015 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7013 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 7016 layer_tree_host_impl->DrawLayers(&frame); | 7014 layer_tree_host_impl->DrawLayers(&frame); |
| 7017 layer_tree_host_impl->DidDrawAllLayers(frame); | 7015 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 7018 layer_tree_host_impl->SwapBuffers(frame); | 7016 layer_tree_host_impl->SwapBuffers(frame); |
| 7019 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 7017 gfx::Rect expected_swap_rect(0, 0, 500, 500); |
| 7020 EXPECT_EQ(expected_swap_rect.ToString(), | 7018 EXPECT_EQ(expected_swap_rect.ToString(), |
| 7021 fake_output_surface->last_swap_rect().ToString()); | 7019 fake_output_surface->last_swap_rect().ToString()); |
| 7022 | 7020 |
| 7023 // Second frame, only the damaged area should get swapped. Damage should be | 7021 // Second frame, only the damaged area should get swapped. Damage should be |
| 7024 // the union of old and new child rects. | 7022 // the union of old and new child rects. |
| 7025 // expected damage rect: gfx::Rect(26, 28); | 7023 // expected damage rect: gfx::Rect(26, 28); |
| 7026 // expected swap rect: vertically flipped, with origin at bottom left corner. | 7024 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 7027 layer_tree_host_impl->active_tree() | 7025 layer_tree_host_impl->active_tree() |
| 7028 ->root_layer_for_testing() | 7026 ->root_layer_for_testing() |
| 7029 ->test_properties() | 7027 ->test_properties() |
| 7030 ->children[0] | 7028 ->children[0] |
| 7031 ->SetPosition(gfx::PointF()); | 7029 ->SetPosition(gfx::PointF()); |
| 7032 layer_tree_host_impl->active_tree() | 7030 layer_tree_host_impl->active_tree() |
| 7033 ->root_layer_for_testing() | 7031 ->root_layer_for_testing() |
| 7034 ->test_properties() | 7032 ->test_properties() |
| 7035 ->children[0] | 7033 ->children[0] |
| 7036 ->NoteLayerPropertyChanged(); | 7034 ->NoteLayerPropertyChanged(); |
| 7037 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; | 7035 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7038 layer_tree_host_impl->active_tree() | |
| 7039 ->BuildLayerListAndPropertyTreesForTesting(); | |
| 7040 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7036 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 7041 layer_tree_host_impl->DrawLayers(&frame); | 7037 layer_tree_host_impl->DrawLayers(&frame); |
| 7042 host_impl_->DidDrawAllLayers(frame); | 7038 host_impl_->DidDrawAllLayers(frame); |
| 7043 layer_tree_host_impl->SwapBuffers(frame); | 7039 layer_tree_host_impl->SwapBuffers(frame); |
| 7044 | 7040 |
| 7045 // Make sure that partial swap is constrained to the viewport dimensions | 7041 // Make sure that partial swap is constrained to the viewport dimensions |
| 7046 // expected damage rect: gfx::Rect(500, 500); | 7042 // expected damage rect: gfx::Rect(500, 500); |
| 7047 // expected swap rect: flipped damage rect, but also clamped to viewport | 7043 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 7048 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); | 7044 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); |
| 7049 EXPECT_EQ(expected_swap_rect.ToString(), | 7045 EXPECT_EQ(expected_swap_rect.ToString(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7070 std::unique_ptr<LayerImpl> child = | 7066 std::unique_ptr<LayerImpl> child = |
| 7071 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 7067 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 7072 child->SetBounds(gfx::Size(10, 10)); | 7068 child->SetBounds(gfx::Size(10, 10)); |
| 7073 child->SetDrawsContent(true); | 7069 child->SetDrawsContent(true); |
| 7074 root->SetBounds(gfx::Size(10, 10)); | 7070 root->SetBounds(gfx::Size(10, 10)); |
| 7075 root->SetDrawsContent(true); | 7071 root->SetDrawsContent(true); |
| 7076 root->test_properties()->force_render_surface = true; | 7072 root->test_properties()->force_render_surface = true; |
| 7077 root->test_properties()->AddChild(std::move(child)); | 7073 root->test_properties()->AddChild(std::move(child)); |
| 7078 | 7074 |
| 7079 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 7075 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7076 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7080 | 7077 |
| 7081 LayerTreeHostImpl::FrameData frame; | 7078 LayerTreeHostImpl::FrameData frame; |
| 7082 | 7079 |
| 7083 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7080 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7084 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 7081 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 7085 EXPECT_EQ(1u, frame.render_passes.size()); | 7082 EXPECT_EQ(1u, frame.render_passes.size()); |
| 7086 host_impl_->DidDrawAllLayers(frame); | 7083 host_impl_->DidDrawAllLayers(frame); |
| 7087 } | 7084 } |
| 7088 | 7085 |
| 7089 class FakeLayerWithQuads : public LayerImpl { | 7086 class FakeLayerWithQuads : public LayerImpl { |
| 7090 public: | 7087 public: |
| 7091 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 7088 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 7092 return base::WrapUnique(new FakeLayerWithQuads(tree_impl, id)); | 7089 return base::WrapUnique(new FakeLayerWithQuads(tree_impl, id)); |
| 7093 } | 7090 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7203 std::unique_ptr<MockContext> mock_context_owned(new MockContext); | 7200 std::unique_ptr<MockContext> mock_context_owned(new MockContext); |
| 7204 MockContext* mock_context = mock_context_owned.get(); | 7201 MockContext* mock_context = mock_context_owned.get(); |
| 7205 MockContextHarness harness(mock_context); | 7202 MockContextHarness harness(mock_context); |
| 7206 | 7203 |
| 7207 // Run test case | 7204 // Run test case |
| 7208 LayerTreeSettings settings = DefaultSettings(); | 7205 LayerTreeSettings settings = DefaultSettings(); |
| 7209 settings.renderer_settings.partial_swap_enabled = false; | 7206 settings.renderer_settings.partial_swap_enabled = false; |
| 7210 CreateHostImpl(settings, | 7207 CreateHostImpl(settings, |
| 7211 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7208 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
| 7212 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7209 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7210 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7213 | 7211 |
| 7214 // Without partial swap, and no clipping, no scissor is set. | 7212 // Without partial swap, and no clipping, no scissor is set. |
| 7215 harness.MustDrawSolidQuad(); | 7213 harness.MustDrawSolidQuad(); |
| 7216 harness.MustSetNoScissor(); | 7214 harness.MustSetNoScissor(); |
| 7217 { | 7215 { |
| 7218 LayerTreeHostImpl::FrameData frame; | 7216 LayerTreeHostImpl::FrameData frame; |
| 7219 SetNeedsRebuildPropertyTrees(); | 7217 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7220 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 7221 host_impl_->DrawLayers(&frame); | 7218 host_impl_->DrawLayers(&frame); |
| 7222 host_impl_->DidDrawAllLayers(frame); | 7219 host_impl_->DidDrawAllLayers(frame); |
| 7223 } | 7220 } |
| 7224 Mock::VerifyAndClearExpectations(&mock_context); | 7221 Mock::VerifyAndClearExpectations(&mock_context); |
| 7225 | 7222 |
| 7226 // Without partial swap, but a layer does clip its subtree, one scissor is | 7223 // Without partial swap, but a layer does clip its subtree, one scissor is |
| 7227 // set. | 7224 // set. |
| 7228 host_impl_->active_tree()->root_layer_for_testing()->SetMasksToBounds(true); | 7225 auto* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 7229 host_impl_->active_tree() | 7226 root->SetMasksToBounds(true); |
| 7230 ->root_layer_for_testing() | 7227 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7231 ->NoteLayerPropertyChanged(); | 7228 root->NoteLayerPropertyChanged(); |
| 7232 harness.MustDrawSolidQuad(); | 7229 harness.MustDrawSolidQuad(); |
| 7233 harness.MustSetScissor(0, 0, 10, 10); | 7230 harness.MustSetScissor(0, 0, 10, 10); |
| 7234 { | 7231 { |
| 7235 LayerTreeHostImpl::FrameData frame; | 7232 LayerTreeHostImpl::FrameData frame; |
| 7236 SetNeedsRebuildPropertyTrees(); | 7233 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7237 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
| 7238 host_impl_->DrawLayers(&frame); | 7234 host_impl_->DrawLayers(&frame); |
| 7239 host_impl_->DidDrawAllLayers(frame); | 7235 host_impl_->DidDrawAllLayers(frame); |
| 7240 } | 7236 } |
| 7241 Mock::VerifyAndClearExpectations(&mock_context); | 7237 Mock::VerifyAndClearExpectations(&mock_context); |
| 7242 } | 7238 } |
| 7243 | 7239 |
| 7244 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 7240 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
| 7245 std::unique_ptr<MockContext> context_owned(new MockContext); | 7241 std::unique_ptr<MockContext> context_owned(new MockContext); |
| 7246 MockContext* mock_context = context_owned.get(); | 7242 MockContext* mock_context = context_owned.get(); |
| 7247 MockContextHarness harness(mock_context); | 7243 MockContextHarness harness(mock_context); |
| 7248 | 7244 |
| 7249 LayerTreeSettings settings = DefaultSettings(); | 7245 LayerTreeSettings settings = DefaultSettings(); |
| 7250 settings.renderer_settings.partial_swap_enabled = true; | 7246 settings.renderer_settings.partial_swap_enabled = true; |
| 7251 CreateHostImpl(settings, | 7247 CreateHostImpl(settings, |
| 7252 FakeOutputSurface::Create3d(std::move(context_owned))); | 7248 FakeOutputSurface::Create3d(std::move(context_owned))); |
| 7253 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7249 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7250 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7254 | 7251 |
| 7255 // The first frame is not a partially-swapped one. No scissor should be set. | 7252 // The first frame is not a partially-swapped one. No scissor should be set. |
| 7256 harness.MustSetNoScissor(); | 7253 harness.MustSetNoScissor(); |
| 7257 harness.MustDrawSolidQuad(); | 7254 harness.MustDrawSolidQuad(); |
| 7258 { | 7255 { |
| 7259 LayerTreeHostImpl::FrameData frame; | 7256 LayerTreeHostImpl::FrameData frame; |
| 7260 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7257 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7261 host_impl_->DrawLayers(&frame); | 7258 host_impl_->DrawLayers(&frame); |
| 7262 host_impl_->DidDrawAllLayers(frame); | 7259 host_impl_->DidDrawAllLayers(frame); |
| 7263 } | 7260 } |
| 7264 Mock::VerifyAndClearExpectations(&mock_context); | 7261 Mock::VerifyAndClearExpectations(&mock_context); |
| 7265 | 7262 |
| 7266 // Damage a portion of the frame. | 7263 // Damage a portion of the frame. |
| 7267 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( | 7264 auto* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 7268 gfx::Rect(0, 0, 2, 3)); | 7265 root->SetUpdateRect(gfx::Rect(0, 0, 2, 3)); |
| 7266 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7269 | 7267 |
| 7270 // The second frame will be partially-swapped (the y coordinates are flipped). | 7268 // The second frame will be partially-swapped (the y coordinates are flipped). |
| 7271 harness.MustSetScissor(0, 7, 2, 3); | 7269 harness.MustSetScissor(0, 7, 2, 3); |
| 7272 harness.MustDrawSolidQuad(); | 7270 harness.MustDrawSolidQuad(); |
| 7273 { | 7271 { |
| 7274 LayerTreeHostImpl::FrameData frame; | 7272 LayerTreeHostImpl::FrameData frame; |
| 7275 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7273 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7276 host_impl_->DrawLayers(&frame); | 7274 host_impl_->DrawLayers(&frame); |
| 7277 host_impl_->DidDrawAllLayers(frame); | 7275 host_impl_->DidDrawAllLayers(frame); |
| 7278 } | 7276 } |
| 7279 Mock::VerifyAndClearExpectations(&mock_context); | 7277 Mock::VerifyAndClearExpectations(&mock_context); |
| 7280 } | 7278 } |
| 7281 | 7279 |
| 7282 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7280 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 7283 LayerTreeSettings settings, | 7281 LayerTreeSettings settings, |
| 7284 bool partial_swap, | 7282 bool partial_swap, |
| 7285 LayerTreeHostImplClient* client, | 7283 LayerTreeHostImplClient* client, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7343 | 7341 |
| 7344 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); | 7342 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); |
| 7345 grand_child->SetBounds(grand_child_rect.size()); | 7343 grand_child->SetBounds(grand_child_rect.size()); |
| 7346 grand_child->draw_properties().visible_layer_rect = grand_child_rect; | 7344 grand_child->draw_properties().visible_layer_rect = grand_child_rect; |
| 7347 grand_child->SetDrawsContent(true); | 7345 grand_child->SetDrawsContent(true); |
| 7348 | 7346 |
| 7349 child->test_properties()->AddChild(std::move(grand_child)); | 7347 child->test_properties()->AddChild(std::move(grand_child)); |
| 7350 root->test_properties()->AddChild(std::move(child)); | 7348 root->test_properties()->AddChild(std::move(child)); |
| 7351 | 7349 |
| 7352 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7350 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7353 my_host_impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 7351 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7354 return my_host_impl; | 7352 return my_host_impl; |
| 7355 } | 7353 } |
| 7356 | 7354 |
| 7357 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7355 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
| 7358 TestSharedBitmapManager shared_bitmap_manager; | 7356 TestSharedBitmapManager shared_bitmap_manager; |
| 7359 TestTaskGraphRunner task_graph_runner; | 7357 TestTaskGraphRunner task_graph_runner; |
| 7360 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7358 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 7361 provider->BindToCurrentThread(); | 7359 provider->BindToCurrentThread(); |
| 7362 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7360 provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 7363 std::unique_ptr<OutputSurface> output_surface( | 7361 std::unique_ptr<OutputSurface> output_surface( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7432 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7430 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 7433 FakeVideoFrameProvider provider; | 7431 FakeVideoFrameProvider provider; |
| 7434 provider.set_frame(softwareFrame); | 7432 provider.set_frame(softwareFrame); |
| 7435 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7433 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 7436 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7434 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 7437 video_layer->SetBounds(gfx::Size(10, 10)); | 7435 video_layer->SetBounds(gfx::Size(10, 10)); |
| 7438 video_layer->SetDrawsContent(true); | 7436 video_layer->SetDrawsContent(true); |
| 7439 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7437 root_layer->test_properties()->AddChild(std::move(video_layer)); |
| 7440 | 7438 |
| 7441 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); | 7439 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
| 7440 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7442 | 7441 |
| 7443 EXPECT_EQ(0u, context3d->NumTextures()); | 7442 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7444 | 7443 |
| 7445 LayerTreeHostImpl::FrameData frame; | 7444 LayerTreeHostImpl::FrameData frame; |
| 7446 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7445 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7447 host_impl_->DrawLayers(&frame); | 7446 host_impl_->DrawLayers(&frame); |
| 7448 host_impl_->DidDrawAllLayers(frame); | 7447 host_impl_->DidDrawAllLayers(frame); |
| 7449 host_impl_->SwapBuffers(frame); | 7448 host_impl_->SwapBuffers(frame); |
| 7450 | 7449 |
| 7451 EXPECT_GT(context3d->NumTextures(), 0u); | 7450 EXPECT_GT(context3d->NumTextures(), 0u); |
| 7452 | 7451 |
| 7453 // Kill the layer tree. | 7452 // Kill the layer tree. |
| 7454 host_impl_->active_tree()->DetachLayers(); | 7453 host_impl_->active_tree()->DetachLayers(); |
| 7455 // There should be no textures left in use after. | 7454 // There should be no textures left in use after. |
| 7456 EXPECT_EQ(0u, context3d->NumTextures()); | 7455 EXPECT_EQ(0u, context3d->NumTextures()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7469 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 7468 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
| 7470 new MockDrawQuadsToFillScreenContext); | 7469 new MockDrawQuadsToFillScreenContext); |
| 7471 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 7470 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
| 7472 | 7471 |
| 7473 // Run test case | 7472 // Run test case |
| 7474 LayerTreeSettings settings = DefaultSettings(); | 7473 LayerTreeSettings settings = DefaultSettings(); |
| 7475 settings.renderer_settings.partial_swap_enabled = false; | 7474 settings.renderer_settings.partial_swap_enabled = false; |
| 7476 CreateHostImpl(settings, | 7475 CreateHostImpl(settings, |
| 7477 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7476 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
| 7478 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7477 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 7478 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7479 |
| 7479 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7480 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 7480 | 7481 |
| 7481 // Verify one quad is drawn when transparent background set is not set. | 7482 // Verify one quad is drawn when transparent background set is not set. |
| 7482 host_impl_->active_tree()->set_has_transparent_background(false); | 7483 host_impl_->active_tree()->set_has_transparent_background(false); |
| 7483 EXPECT_CALL(*mock_context, useProgram(_)) | 7484 EXPECT_CALL(*mock_context, useProgram(_)) |
| 7484 .Times(1); | 7485 .Times(1); |
| 7485 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 7486 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
| 7486 .Times(1); | 7487 .Times(1); |
| 7487 LayerTreeHostImpl::FrameData frame; | 7488 LayerTreeHostImpl::FrameData frame; |
| 7488 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7489 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7489 host_impl_->DrawLayers(&frame); | 7490 host_impl_->DrawLayers(&frame); |
| 7490 host_impl_->DidDrawAllLayers(frame); | 7491 host_impl_->DidDrawAllLayers(frame); |
| 7491 Mock::VerifyAndClearExpectations(&mock_context); | 7492 Mock::VerifyAndClearExpectations(&mock_context); |
| 7492 | 7493 |
| 7493 // Verify no quads are drawn when transparent background is set. | 7494 // Verify no quads are drawn when transparent background is set. |
| 7494 host_impl_->active_tree()->set_has_transparent_background(true); | 7495 host_impl_->active_tree()->set_has_transparent_background(true); |
| 7495 host_impl_->SetFullRootLayerDamage(); | 7496 host_impl_->SetFullRootLayerDamage(); |
| 7496 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7497 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7497 host_impl_->DrawLayers(&frame); | 7498 host_impl_->DrawLayers(&frame); |
| 7498 host_impl_->DidDrawAllLayers(frame); | 7499 host_impl_->DidDrawAllLayers(frame); |
| 7499 Mock::VerifyAndClearExpectations(&mock_context); | 7500 Mock::VerifyAndClearExpectations(&mock_context); |
| 7500 } | 7501 } |
| 7501 | 7502 |
| 7502 class LayerTreeHostImplTestWithDelegatingRenderer | 7503 class LayerTreeHostImplTestWithDelegatingRenderer |
| 7503 : public LayerTreeHostImplTest { | 7504 : public LayerTreeHostImplTest { |
| 7504 protected: | 7505 protected: |
| 7505 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 7506 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 7506 return FakeOutputSurface::CreateDelegating3d(); | 7507 return FakeOutputSurface::CreateDelegating3d(); |
| 7507 } | 7508 } |
| 7508 | 7509 |
| 7509 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { | 7510 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { |
| 7510 bool expect_to_draw = !expected_damage.IsEmpty(); | 7511 bool expect_to_draw = !expected_damage.IsEmpty(); |
| 7511 | 7512 |
| 7512 LayerTreeHostImpl::FrameData frame; | 7513 LayerTreeHostImpl::FrameData frame; |
| 7513 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7514 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7514 | 7515 |
| 7515 if (!expect_to_draw) { | 7516 if (!expect_to_draw) { |
| 7516 // With no damage, we don't draw, and no quads are created. | 7517 // With no damage, we don't draw, and no quads are created. |
| 7517 ASSERT_EQ(0u, frame.render_passes.size()); | 7518 ASSERT_EQ(0u, frame.render_passes.size()); |
| 7518 } else { | 7519 } else { |
| 7519 ASSERT_EQ(1u, frame.render_passes.size()); | 7520 ASSERT_EQ(1u, frame.render_passes.size()); |
| 7520 | 7521 |
| 7521 // Verify the damage rect for the root render pass. | 7522 // Verify the damage rect for the root render pass. |
| 7522 const RenderPass* root_render_pass = frame.render_passes.back().get(); | 7523 const RenderPass* root_render_pass = frame.render_passes.back().get(); |
| 7523 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); | 7524 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7556 | 7557 |
| 7557 // Child layer is in the bottom right corner. | 7558 // Child layer is in the bottom right corner. |
| 7558 std::unique_ptr<SolidColorLayerImpl> child = | 7559 std::unique_ptr<SolidColorLayerImpl> child = |
| 7559 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7560 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 7560 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7561 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 7561 child->SetBounds(gfx::Size(1, 1)); | 7562 child->SetBounds(gfx::Size(1, 1)); |
| 7562 child->SetDrawsContent(true); | 7563 child->SetDrawsContent(true); |
| 7563 root->test_properties()->AddChild(std::move(child)); | 7564 root->test_properties()->AddChild(std::move(child)); |
| 7564 | 7565 |
| 7565 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 7566 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7567 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7566 | 7568 |
| 7567 // Draw a frame. In the first frame, the entire viewport should be damaged. | 7569 // Draw a frame. In the first frame, the entire viewport should be damaged. |
| 7568 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7570 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 7569 DrawFrameAndTestDamage(full_frame_damage); | 7571 DrawFrameAndTestDamage(full_frame_damage); |
| 7570 | 7572 |
| 7571 // The second frame has damage that doesn't touch the child layer. Its quads | 7573 // The second frame has damage that doesn't touch the child layer. Its quads |
| 7572 // should still be generated. | 7574 // should still be generated. |
| 7573 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); | 7575 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); |
| 7574 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( | 7576 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( |
| 7575 small_damage); | 7577 small_damage); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7628 3, raster_source); | 7630 3, raster_source); |
| 7629 LayerImpl* content_layer = scoped_content_layer.get(); | 7631 LayerImpl* content_layer = scoped_content_layer.get(); |
| 7630 scrolling_layer->test_properties()->AddChild(std::move(scoped_content_layer)); | 7632 scrolling_layer->test_properties()->AddChild(std::move(scoped_content_layer)); |
| 7631 content_layer->SetBounds(content_layer_bounds); | 7633 content_layer->SetBounds(content_layer_bounds); |
| 7632 content_layer->SetDrawsContent(true); | 7634 content_layer->SetDrawsContent(true); |
| 7633 | 7635 |
| 7634 root->SetBounds(root_size); | 7636 root->SetBounds(root_size); |
| 7635 | 7637 |
| 7636 gfx::ScrollOffset scroll_offset(100000, 0); | 7638 gfx::ScrollOffset scroll_offset(100000, 0); |
| 7637 scrolling_layer->SetScrollClipLayer(root->id()); | 7639 scrolling_layer->SetScrollClipLayer(root->id()); |
| 7640 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 7641 |
| 7638 scrolling_layer->layer_tree_impl() | 7642 scrolling_layer->layer_tree_impl() |
| 7639 ->property_trees() | 7643 ->property_trees() |
| 7640 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), | 7644 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), |
| 7641 scroll_offset); | 7645 scroll_offset); |
| 7642 | |
| 7643 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 7644 host_impl_->ActivateSyncTree(); | 7646 host_impl_->ActivateSyncTree(); |
| 7645 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | |
| 7646 | 7647 |
| 7647 bool update_lcd_text = false; | 7648 bool update_lcd_text = false; |
| 7648 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 7649 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 7649 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 7650 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
| 7650 | 7651 |
| 7651 LayerTreeHostImpl::FrameData frame; | 7652 LayerTreeHostImpl::FrameData frame; |
| 7652 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7653 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7653 | 7654 |
| 7654 ASSERT_EQ(1u, frame.render_passes.size()); | 7655 ASSERT_EQ(1u, frame.render_passes.size()); |
| 7655 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 7656 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 7656 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); | 7657 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); |
| 7657 | 7658 |
| 7658 bool clipped = false, force_aa = false; | 7659 bool clipped = false, force_aa = false; |
| 7659 gfx::QuadF device_layer_quad = MathUtil::MapQuad( | 7660 gfx::QuadF device_layer_quad = MathUtil::MapQuad( |
| 7660 quad->shared_quad_state->quad_to_target_transform, | 7661 quad->shared_quad_state->quad_to_target_transform, |
| 7661 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)), | 7662 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)), |
| 7662 &clipped); | 7663 &clipped); |
| 7663 EXPECT_FALSE(clipped); | 7664 EXPECT_FALSE(clipped); |
| 7664 bool antialiased = | 7665 bool antialiased = |
| 7665 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( | 7666 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( |
| 7666 device_layer_quad, clipped, force_aa); | 7667 device_layer_quad, clipped, force_aa); |
| 7667 EXPECT_FALSE(antialiased); | 7668 EXPECT_FALSE(antialiased); |
| 7668 | 7669 |
| 7669 host_impl_->DrawLayers(&frame); | 7670 host_impl_->DrawLayers(&frame); |
| 7670 host_impl_->DidDrawAllLayers(frame); | 7671 host_impl_->DidDrawAllLayers(frame); |
| 7671 } | 7672 } |
| 7672 | 7673 |
| 7673 | |
| 7674 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 7674 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
| 7675 public: | 7675 public: |
| 7676 CompositorFrameMetadataTest() | 7676 CompositorFrameMetadataTest() |
| 7677 : swap_buffers_complete_(0) {} | 7677 : swap_buffers_complete_(0) {} |
| 7678 | 7678 |
| 7679 void DidSwapBuffersCompleteOnImplThread() override { | 7679 void DidSwapBuffersCompleteOnImplThread() override { |
| 7680 swap_buffers_complete_++; | 7680 swap_buffers_complete_++; |
| 7681 } | 7681 } |
| 7682 | 7682 |
| 7683 int swap_buffers_complete_; | 7683 int swap_buffers_complete_; |
| 7684 }; | 7684 }; |
| 7685 | 7685 |
| 7686 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 7686 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
| 7687 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7687 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7688 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7688 { | 7689 { |
| 7689 LayerTreeHostImpl::FrameData frame; | 7690 LayerTreeHostImpl::FrameData frame; |
| 7690 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7691 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7691 host_impl_->DrawLayers(&frame); | 7692 host_impl_->DrawLayers(&frame); |
| 7692 host_impl_->DidDrawAllLayers(frame); | 7693 host_impl_->DidDrawAllLayers(frame); |
| 7693 } | 7694 } |
| 7694 CompositorFrameAck ack; | 7695 CompositorFrameAck ack; |
| 7695 host_impl_->ReclaimResources(&ack); | 7696 host_impl_->ReclaimResources(&ack); |
| 7696 host_impl_->DidSwapBuffersComplete(); | 7697 host_impl_->DidSwapBuffersComplete(); |
| 7697 EXPECT_EQ(swap_buffers_complete_, 1); | 7698 EXPECT_EQ(swap_buffers_complete_, 1); |
| 7698 } | 7699 } |
| 7699 | 7700 |
| 7700 class CountingSoftwareDevice : public SoftwareOutputDevice { | 7701 class CountingSoftwareDevice : public SoftwareOutputDevice { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7765 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7766 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7766 | 7767 |
| 7767 // VideoLayerImpl will not be drawn. | 7768 // VideoLayerImpl will not be drawn. |
| 7768 FakeVideoFrameProvider provider; | 7769 FakeVideoFrameProvider provider; |
| 7769 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7770 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 7770 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 7771 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
| 7771 video_layer->SetBounds(gfx::Size(10, 10)); | 7772 video_layer->SetBounds(gfx::Size(10, 10)); |
| 7772 video_layer->SetDrawsContent(true); | 7773 video_layer->SetDrawsContent(true); |
| 7773 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7774 root_layer->test_properties()->AddChild(std::move(video_layer)); |
| 7774 SetupRootLayerImpl(std::move(root_layer)); | 7775 SetupRootLayerImpl(std::move(root_layer)); |
| 7776 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7775 | 7777 |
| 7776 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7778 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 7777 resourceless_software_draw); | 7779 resourceless_software_draw); |
| 7778 | 7780 |
| 7779 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7781 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
| 7780 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), | 7782 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), |
| 7781 last_on_draw_frame_->will_draw_layers[0]); | 7783 last_on_draw_frame_->will_draw_layers[0]); |
| 7782 } | 7784 } |
| 7783 | 7785 |
| 7784 // Checks that we have a non-0 default allocation if we pass a context that | 7786 // Checks that we have a non-0 default allocation if we pass a context that |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7948 | 7950 |
| 7949 CreateHostImpl(DefaultSettings(), | 7951 CreateHostImpl(DefaultSettings(), |
| 7950 FakeOutputSurface::Create3d(context_provider)); | 7952 FakeOutputSurface::Create3d(context_provider)); |
| 7951 | 7953 |
| 7952 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7954 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 7953 | 7955 |
| 7954 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 7956 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 7955 root->test_properties()->copy_requests.push_back( | 7957 root->test_properties()->copy_requests.push_back( |
| 7956 CopyOutputRequest::CreateRequest( | 7958 CopyOutputRequest::CreateRequest( |
| 7957 base::Bind(&ShutdownReleasesContext_Callback))); | 7959 base::Bind(&ShutdownReleasesContext_Callback))); |
| 7960 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7958 | 7961 |
| 7959 LayerTreeHostImpl::FrameData frame; | 7962 LayerTreeHostImpl::FrameData frame; |
| 7960 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7963 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7961 host_impl_->DrawLayers(&frame); | 7964 host_impl_->DrawLayers(&frame); |
| 7962 host_impl_->DidDrawAllLayers(frame); | 7965 host_impl_->DidDrawAllLayers(frame); |
| 7963 | 7966 |
| 7964 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 7967 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
| 7965 // texture in a texture mailbox. | 7968 // texture in a texture mailbox. |
| 7966 EXPECT_FALSE(context_provider->HasOneRef()); | 7969 EXPECT_FALSE(context_provider->HasOneRef()); |
| 7967 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 7970 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
| 7968 | 7971 |
| 7969 host_impl_ = nullptr; | 7972 host_impl_ = nullptr; |
| 7970 | 7973 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7993 | 7996 |
| 7994 root_scroll->test_properties()->AddChild(std::move(child)); | 7997 root_scroll->test_properties()->AddChild(std::move(child)); |
| 7995 int root_id = root_scroll->id(); | 7998 int root_id = root_scroll->id(); |
| 7996 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 7999 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 7997 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 8000 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
| 7998 | 8001 |
| 7999 host_impl_->SetViewportSize(surface_size); | 8002 host_impl_->SetViewportSize(surface_size); |
| 8000 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 8003 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 8001 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 8004 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, |
| 8002 Layer::INVALID_ID); | 8005 Layer::INVALID_ID); |
| 8006 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8003 host_impl_->active_tree()->DidBecomeActive(); | 8007 host_impl_->active_tree()->DidBecomeActive(); |
| 8004 SetNeedsRebuildPropertyTrees(); | |
| 8005 DrawFrame(); | 8008 DrawFrame(); |
| 8006 { | 8009 { |
| 8007 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8010 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8008 host_impl_ | 8011 host_impl_ |
| 8009 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8012 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8010 InputHandler::TOUCHSCREEN) | 8013 InputHandler::TOUCHSCREEN) |
| 8011 .thread); | 8014 .thread); |
| 8012 | 8015 |
| 8013 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8016 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8014 host_impl_->FlingScrollBegin().thread); | 8017 host_impl_->FlingScrollBegin().thread); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8028 } | 8031 } |
| 8029 } | 8032 } |
| 8030 | 8033 |
| 8031 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 8034 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
| 8032 // Scroll a child layer beyond its maximum scroll range and make sure the | 8035 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 8033 // the scroll doesn't bubble up to the parent layer. | 8036 // the scroll doesn't bubble up to the parent layer. |
| 8034 gfx::Size surface_size(10, 10); | 8037 gfx::Size surface_size(10, 10); |
| 8035 std::unique_ptr<LayerImpl> root = | 8038 std::unique_ptr<LayerImpl> root = |
| 8036 LayerImpl::Create(host_impl_->active_tree(), 1); | 8039 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 8037 root->test_properties()->force_render_surface = true; | 8040 root->test_properties()->force_render_surface = true; |
| 8038 std::unique_ptr<LayerImpl> root_scrolling = | 8041 |
| 8042 std::unique_ptr<LayerImpl> root_scrolling_owned = |
| 8039 CreateScrollableLayer(2, surface_size, root.get()); | 8043 CreateScrollableLayer(2, surface_size, root.get()); |
| 8044 auto* root_scrolling = root_scrolling_owned.get(); |
| 8045 root->test_properties()->AddChild(std::move(root_scrolling_owned)); |
| 8040 | 8046 |
| 8041 std::unique_ptr<LayerImpl> grand_child = | 8047 std::unique_ptr<LayerImpl> child_owned = |
| 8048 CreateScrollableLayer(3, surface_size, root.get()); |
| 8049 auto* child = child_owned.get(); |
| 8050 root_scrolling->test_properties()->AddChild(std::move(child_owned)); |
| 8051 |
| 8052 std::unique_ptr<LayerImpl> grand_child_owned = |
| 8042 CreateScrollableLayer(4, surface_size, root.get()); | 8053 CreateScrollableLayer(4, surface_size, root.get()); |
| 8054 auto* grand_child = grand_child_owned.get(); |
| 8055 child->test_properties()->AddChild(std::move(grand_child_owned)); |
| 8056 |
| 8057 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8058 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8059 host_impl_->active_tree()->DidBecomeActive(); |
| 8060 |
| 8061 child->layer_tree_impl() |
| 8062 ->property_trees() |
| 8063 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), |
| 8064 gfx::ScrollOffset(0, 4)); |
| 8043 grand_child->layer_tree_impl() | 8065 grand_child->layer_tree_impl() |
| 8044 ->property_trees() | 8066 ->property_trees() |
| 8045 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), | 8067 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), |
| 8046 gfx::ScrollOffset(0, 2)); | 8068 gfx::ScrollOffset(0, 2)); |
| 8047 | 8069 |
| 8048 std::unique_ptr<LayerImpl> child = | |
| 8049 CreateScrollableLayer(3, surface_size, root.get()); | |
| 8050 child->layer_tree_impl() | |
| 8051 ->property_trees() | |
| 8052 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), | |
| 8053 gfx::ScrollOffset(0, 4)); | |
| 8054 child->test_properties()->AddChild(std::move(grand_child)); | |
| 8055 | |
| 8056 root_scrolling->test_properties()->AddChild(std::move(child)); | |
| 8057 root->test_properties()->AddChild(std::move(root_scrolling)); | |
| 8058 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | |
| 8059 host_impl_->active_tree()->DidBecomeActive(); | |
| 8060 host_impl_->SetViewportSize(surface_size); | 8070 host_impl_->SetViewportSize(surface_size); |
| 8061 SetNeedsRebuildPropertyTrees(); | |
| 8062 DrawFrame(); | 8071 DrawFrame(); |
| 8063 { | 8072 { |
| 8064 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 8073 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 8065 LayerImpl* child = host_impl_->active_tree() | 8074 LayerImpl* child = host_impl_->active_tree() |
| 8066 ->root_layer_for_testing() | 8075 ->root_layer_for_testing() |
| 8067 ->test_properties() | 8076 ->test_properties() |
| 8068 ->children[0] | 8077 ->children[0] |
| 8069 ->test_properties() | 8078 ->test_properties() |
| 8070 ->children[0]; | 8079 ->children[0]; |
| 8071 LayerImpl* grand_child = child->test_properties()->children[0]; | 8080 LayerImpl* grand_child = child->test_properties()->children[0]; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8130 root_clip->test_properties()->force_render_surface = true; | 8139 root_clip->test_properties()->force_render_surface = true; |
| 8131 std::unique_ptr<LayerImpl> root_scroll = | 8140 std::unique_ptr<LayerImpl> root_scroll = |
| 8132 CreateScrollableLayer(1, content_size, root_clip.get()); | 8141 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 8133 int root_scroll_id = root_scroll->id(); | 8142 int root_scroll_id = root_scroll->id(); |
| 8134 std::unique_ptr<LayerImpl> child = | 8143 std::unique_ptr<LayerImpl> child = |
| 8135 CreateScrollableLayer(2, content_size, root_clip.get()); | 8144 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 8136 | 8145 |
| 8137 root_scroll->test_properties()->AddChild(std::move(child)); | 8146 root_scroll->test_properties()->AddChild(std::move(child)); |
| 8138 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8147 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 8139 | 8148 |
| 8149 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
| 8150 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8151 host_impl_->active_tree()->DidBecomeActive(); |
| 8152 |
| 8140 host_impl_->SetViewportSize(surface_size); | 8153 host_impl_->SetViewportSize(surface_size); |
| 8141 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); | |
| 8142 host_impl_->active_tree()->DidBecomeActive(); | |
| 8143 SetNeedsRebuildPropertyTrees(); | |
| 8144 DrawFrame(); | 8154 DrawFrame(); |
| 8145 { | 8155 { |
| 8146 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8156 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8147 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8157 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8148 InputHandler::WHEEL) | 8158 InputHandler::WHEEL) |
| 8149 .thread); | 8159 .thread); |
| 8150 | 8160 |
| 8151 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8161 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8152 host_impl_->FlingScrollBegin().thread); | 8162 host_impl_->FlingScrollBegin().thread); |
| 8153 | 8163 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 8183 | 8193 |
| 8184 int occluder_layer_id = 6; | 8194 int occluder_layer_id = 6; |
| 8185 std::unique_ptr<LayerImpl> occluder_layer = | 8195 std::unique_ptr<LayerImpl> occluder_layer = |
| 8186 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 8196 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
| 8187 occluder_layer->SetDrawsContent(true); | 8197 occluder_layer->SetDrawsContent(true); |
| 8188 occluder_layer->SetBounds(content_size); | 8198 occluder_layer->SetBounds(content_size); |
| 8189 occluder_layer->SetPosition(gfx::PointF()); | 8199 occluder_layer->SetPosition(gfx::PointF()); |
| 8190 | 8200 |
| 8191 // The parent of the occluder is *above* the scroller. | 8201 // The parent of the occluder is *above* the scroller. |
| 8192 page_scale_layer->test_properties()->AddChild(std::move(occluder_layer)); | 8202 page_scale_layer->test_properties()->AddChild(std::move(occluder_layer)); |
| 8203 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8193 | 8204 |
| 8194 SetNeedsRebuildPropertyTrees(); | |
| 8195 DrawFrame(); | 8205 DrawFrame(); |
| 8196 | 8206 |
| 8197 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 8207 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 8198 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 8208 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 8199 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 8209 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 8200 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 8210 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 8201 status.main_thread_scrolling_reasons); | 8211 status.main_thread_scrolling_reasons); |
| 8202 } | 8212 } |
| 8203 | 8213 |
| 8204 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { | 8214 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 8226 | 8236 |
| 8227 int child_scroll_layer_id = 8; | 8237 int child_scroll_layer_id = 8; |
| 8228 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 8238 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
| 8229 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 8239 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
| 8230 | 8240 |
| 8231 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 8241 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
| 8232 | 8242 |
| 8233 child_scroll->test_properties()->AddChild(std::move(occluder_layer)); | 8243 child_scroll->test_properties()->AddChild(std::move(occluder_layer)); |
| 8234 child_scroll_clip->test_properties()->AddChild(std::move(child_scroll)); | 8244 child_scroll_clip->test_properties()->AddChild(std::move(child_scroll)); |
| 8235 scroll_layer->test_properties()->AddChild(std::move(child_scroll_clip)); | 8245 scroll_layer->test_properties()->AddChild(std::move(child_scroll_clip)); |
| 8246 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8236 | 8247 |
| 8237 SetNeedsRebuildPropertyTrees(); | |
| 8238 DrawFrame(); | 8248 DrawFrame(); |
| 8239 | 8249 |
| 8240 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 8250 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 8241 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 8251 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 8242 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 8252 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
| 8243 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 8253 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
| 8244 status.main_thread_scrolling_reasons); | 8254 status.main_thread_scrolling_reasons); |
| 8245 } | 8255 } |
| 8246 | 8256 |
| 8247 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { | 8257 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { |
| 8248 gfx::Size content_size(100, 100); | 8258 gfx::Size content_size(100, 100); |
| 8249 SetupScrollAndContentsLayers(content_size); | 8259 SetupScrollAndContentsLayers(content_size); |
| 8250 | 8260 |
| 8251 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8261 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 8252 | 8262 |
| 8253 int scroll_layer_id = 2; | 8263 int scroll_layer_id = 2; |
| 8254 LayerImpl* scroll_layer = | 8264 LayerImpl* scroll_layer = |
| 8255 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8265 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 8256 | 8266 |
| 8257 int child_scroll_layer_id = 7; | 8267 int child_scroll_layer_id = 7; |
| 8258 std::unique_ptr<LayerImpl> child_scroll = | 8268 std::unique_ptr<LayerImpl> child_scroll = |
| 8259 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 8269 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
| 8260 child_scroll->SetDrawsContent(false); | 8270 child_scroll->SetDrawsContent(false); |
| 8261 | 8271 |
| 8262 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); | 8272 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); |
| 8273 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8263 | 8274 |
| 8264 SetNeedsRebuildPropertyTrees(); | |
| 8265 DrawFrame(); | 8275 DrawFrame(); |
| 8266 | 8276 |
| 8267 // We should not have scrolled |child_scroll| even though we technically "hit" | 8277 // We should not have scrolled |child_scroll| even though we technically "hit" |
| 8268 // it. The reason for this is that if the scrolling the scroll would not move | 8278 // it. The reason for this is that if the scrolling the scroll would not move |
| 8269 // any layer that is a drawn RSLL member, then we can ignore the hit. | 8279 // any layer that is a drawn RSLL member, then we can ignore the hit. |
| 8270 // | 8280 // |
| 8271 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 8281 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
| 8272 // started scrolling the inner viewport. | 8282 // started scrolling the inner viewport. |
| 8273 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8283 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8274 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8284 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8297 LayerImpl::Create(host_impl_->active_tree(), 9); | 8307 LayerImpl::Create(host_impl_->active_tree(), 9); |
| 8298 grand_child_layer->SetDrawsContent(true); | 8308 grand_child_layer->SetDrawsContent(true); |
| 8299 grand_child_layer->SetBounds(content_size); | 8309 grand_child_layer->SetBounds(content_size); |
| 8300 // Move the grand child so it's not hit by our test point. | 8310 // Move the grand child so it's not hit by our test point. |
| 8301 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 8311 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
| 8302 | 8312 |
| 8303 child_layer->test_properties()->AddChild(std::move(grand_child_layer)); | 8313 child_layer->test_properties()->AddChild(std::move(grand_child_layer)); |
| 8304 invisible_scroll_layer->test_properties()->AddChild(std::move(child_layer)); | 8314 invisible_scroll_layer->test_properties()->AddChild(std::move(child_layer)); |
| 8305 root_scroll_layer->test_properties()->AddChild( | 8315 root_scroll_layer->test_properties()->AddChild( |
| 8306 std::move(invisible_scroll_layer)); | 8316 std::move(invisible_scroll_layer)); |
| 8317 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8307 | 8318 |
| 8308 SetNeedsRebuildPropertyTrees(); | |
| 8309 DrawFrame(); | 8319 DrawFrame(); |
| 8310 | 8320 |
| 8311 // We should have scrolled |invisible_scroll_layer| as it was hit and it has | 8321 // We should have scrolled |invisible_scroll_layer| as it was hit and it has |
| 8312 // a descendant which is a drawn RSLL member. | 8322 // a descendant which is a drawn RSLL member. |
| 8313 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8323 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8314 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8324 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8315 InputHandler::WHEEL) | 8325 InputHandler::WHEEL) |
| 8316 .thread); | 8326 .thread); |
| 8317 | 8327 |
| 8318 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8328 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8354 scroll_children->insert(scroll_child.get()); | 8364 scroll_children->insert(scroll_child.get()); |
| 8355 invisible_scroll->test_properties()->scroll_children.reset( | 8365 invisible_scroll->test_properties()->scroll_children.reset( |
| 8356 scroll_children.release()); | 8366 scroll_children.release()); |
| 8357 | 8367 |
| 8358 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); | 8368 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); |
| 8359 | 8369 |
| 8360 container->test_properties()->AddChild(std::move(invisible_scroll)); | 8370 container->test_properties()->AddChild(std::move(invisible_scroll)); |
| 8361 container->test_properties()->AddChild(std::move(scroll_child)); | 8371 container->test_properties()->AddChild(std::move(scroll_child)); |
| 8362 | 8372 |
| 8363 scroll_layer->test_properties()->AddChild(std::move(container)); | 8373 scroll_layer->test_properties()->AddChild(std::move(container)); |
| 8374 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8364 | 8375 |
| 8365 SetNeedsRebuildPropertyTrees(); | |
| 8366 DrawFrame(); | 8376 DrawFrame(); |
| 8367 | 8377 |
| 8368 // We should have scrolled |child_scroll| even though it is invisible. | 8378 // We should have scrolled |child_scroll| even though it is invisible. |
| 8369 // The reason for this is that if the scrolling the scroll would move a layer | 8379 // The reason for this is that if the scrolling the scroll would move a layer |
| 8370 // that is a drawn RSLL member, then we should accept this hit. | 8380 // that is a drawn RSLL member, then we should accept this hit. |
| 8371 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8381 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8372 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8382 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8373 InputHandler::WHEEL) | 8383 InputHandler::WHEEL) |
| 8374 .thread); | 8384 .thread); |
| 8375 | 8385 |
| 8376 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8386 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| 8377 } | 8387 } |
| 8378 | 8388 |
| 8379 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8389 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 8380 // to CompositorFrameMetadata after SwapBuffers(); | 8390 // to CompositorFrameMetadata after SwapBuffers(); |
| 8381 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8391 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 8382 std::unique_ptr<SolidColorLayerImpl> root = | 8392 std::unique_ptr<SolidColorLayerImpl> root = |
| 8383 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8393 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 8384 root->SetPosition(gfx::PointF()); | 8394 root->SetPosition(gfx::PointF()); |
| 8385 root->SetBounds(gfx::Size(10, 10)); | 8395 root->SetBounds(gfx::Size(10, 10)); |
| 8386 root->SetDrawsContent(true); | 8396 root->SetDrawsContent(true); |
| 8387 root->test_properties()->force_render_surface = true; | 8397 root->test_properties()->force_render_surface = true; |
| 8388 | 8398 |
| 8389 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8399 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8400 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8390 | 8401 |
| 8391 FakeOutputSurface* fake_output_surface = | 8402 FakeOutputSurface* fake_output_surface = |
| 8392 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8403 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 8393 | 8404 |
| 8394 ui::LatencyInfo latency_info; | 8405 ui::LatencyInfo latency_info; |
| 8395 latency_info.AddLatencyNumber( | 8406 latency_info.AddLatencyNumber( |
| 8396 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8407 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
| 8397 std::unique_ptr<SwapPromise> swap_promise( | 8408 std::unique_ptr<SwapPromise> swap_promise( |
| 8398 new LatencyInfoSwapPromise(latency_info)); | 8409 new LatencyInfoSwapPromise(latency_info)); |
| 8399 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8410 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
| 8400 host_impl_->SetNeedsRedraw(); | |
| 8401 | 8411 |
| 8402 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8412 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 8403 LayerTreeHostImpl::FrameData frame; | 8413 LayerTreeHostImpl::FrameData frame; |
| 8404 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8414 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8405 host_impl_->DrawLayers(&frame); | 8415 host_impl_->DrawLayers(&frame); |
| 8406 host_impl_->DidDrawAllLayers(frame); | 8416 host_impl_->DidDrawAllLayers(frame); |
| 8407 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8417 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 8408 | 8418 |
| 8409 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 8419 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
| 8410 fake_output_surface->last_sent_frame()->metadata.latency_info; | 8420 fake_output_surface->last_sent_frame()->metadata.latency_info; |
| 8411 EXPECT_EQ(1u, metadata_latency_after.size()); | 8421 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 8412 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8422 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 8413 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8423 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 8414 } | 8424 } |
| 8415 | 8425 |
| 8416 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8426 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 8417 int root_layer_id = 1; | 8427 int root_layer_id = 1; |
| 8418 std::unique_ptr<SolidColorLayerImpl> root = | 8428 std::unique_ptr<SolidColorLayerImpl> root = |
| 8419 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8429 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 8420 root->SetPosition(gfx::PointF()); | 8430 root->SetPosition(gfx::PointF()); |
| 8421 root->SetBounds(gfx::Size(10, 10)); | 8431 root->SetBounds(gfx::Size(10, 10)); |
| 8422 root->SetDrawsContent(true); | 8432 root->SetDrawsContent(true); |
| 8423 root->test_properties()->force_render_surface = true; | 8433 root->test_properties()->force_render_surface = true; |
| 8424 | 8434 |
| 8425 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8435 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8436 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8426 | 8437 |
| 8427 // Ensure the default frame selection bounds are empty. | 8438 // Ensure the default frame selection bounds are empty. |
| 8428 FakeOutputSurface* fake_output_surface = | 8439 FakeOutputSurface* fake_output_surface = |
| 8429 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8440 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 8430 | 8441 |
| 8431 // Plumb the layer-local selection bounds. | 8442 // Plumb the layer-local selection bounds. |
| 8432 gfx::Point selection_top(5, 0); | 8443 gfx::Point selection_top(5, 0); |
| 8433 gfx::Point selection_bottom(5, 5); | 8444 gfx::Point selection_bottom(5, 5); |
| 8434 LayerSelection selection; | 8445 LayerSelection selection; |
| 8435 selection.start.type = gfx::SelectionBound::CENTER; | 8446 selection.start.type = gfx::SelectionBound::CENTER; |
| 8436 selection.start.layer_id = root_layer_id; | 8447 selection.start.layer_id = root_layer_id; |
| 8437 selection.start.edge_bottom = selection_bottom; | 8448 selection.start.edge_bottom = selection_bottom; |
| 8438 selection.start.edge_top = selection_top; | 8449 selection.start.edge_top = selection_top; |
| 8439 selection.end = selection.start; | 8450 selection.end = selection.start; |
| 8440 host_impl_->active_tree()->RegisterSelection(selection); | 8451 host_impl_->active_tree()->RegisterSelection(selection); |
| 8441 | 8452 |
| 8442 // Trigger a draw-swap sequence. | 8453 // Trigger a draw-swap sequence. |
| 8443 host_impl_->SetNeedsRedraw(); | 8454 host_impl_->SetNeedsRedraw(); |
| 8444 | 8455 |
| 8445 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8456 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 8446 LayerTreeHostImpl::FrameData frame; | 8457 LayerTreeHostImpl::FrameData frame; |
| 8447 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8458 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8448 host_impl_->DrawLayers(&frame); | 8459 host_impl_->DrawLayers(&frame); |
| 8449 host_impl_->DidDrawAllLayers(frame); | 8460 host_impl_->DidDrawAllLayers(frame); |
| 8450 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8461 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 8451 | 8462 |
| 8452 // Ensure the selection bounds have propagated to the frame metadata. | 8463 // Ensure the selection bounds have propagated to the frame metadata. |
| 8453 const Selection<gfx::SelectionBound>& selection_after = | 8464 const Selection<gfx::SelectionBound>& selection_after = |
| 8454 fake_output_surface->last_sent_frame()->metadata.selection; | 8465 fake_output_surface->last_sent_frame()->metadata.selection; |
| 8455 EXPECT_EQ(selection.start.type, selection_after.start.type()); | 8466 EXPECT_EQ(selection.start.type, selection_after.start.type()); |
| 8456 EXPECT_EQ(selection.end.type, selection_after.end.type()); | 8467 EXPECT_EQ(selection.end.type, selection_after.end.type()); |
| 8457 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); | 8468 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8642 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8653 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 8643 gfx::ScrollOffset(0, 10)); | 8654 gfx::ScrollOffset(0, 10)); |
| 8644 host_impl_->DidChangeTopControlsPosition(); | 8655 host_impl_->DidChangeTopControlsPosition(); |
| 8645 EXPECT_TRUE(did_request_next_frame_); | 8656 EXPECT_TRUE(did_request_next_frame_); |
| 8646 EXPECT_TRUE(did_request_redraw_); | 8657 EXPECT_TRUE(did_request_redraw_); |
| 8647 } | 8658 } |
| 8648 | 8659 |
| 8649 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 8660 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
| 8650 InputHandlerScrollResult result; | 8661 InputHandlerScrollResult result; |
| 8651 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8662 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8663 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8664 |
| 8652 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8665 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8653 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8666 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8654 BOTH, SHOWN, false); | 8667 BOTH, SHOWN, false); |
| 8655 DrawFrame(); | 8668 DrawFrame(); |
| 8656 | 8669 |
| 8657 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8670 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8658 host_impl_ | 8671 host_impl_ |
| 8659 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8672 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8660 InputHandler::TOUCHSCREEN) | 8673 InputHandler::TOUCHSCREEN) |
| 8661 .thread); | 8674 .thread); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8752 host_impl_->ScrollBy( | 8765 host_impl_->ScrollBy( |
| 8753 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 8766 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
| 8754 .did_scroll); | 8767 .did_scroll); |
| 8755 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8768 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8756 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), | 8769 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), |
| 8757 viewport_layer->CurrentScrollOffset()); | 8770 viewport_layer->CurrentScrollOffset()); |
| 8758 } | 8771 } |
| 8759 | 8772 |
| 8760 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 8773 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
| 8761 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8774 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8775 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8776 |
| 8762 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 8777 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
| 8763 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8778 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8764 BOTH, SHOWN, false); | 8779 BOTH, SHOWN, false); |
| 8765 DrawFrame(); | 8780 DrawFrame(); |
| 8766 | 8781 |
| 8767 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8782 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8768 host_impl_ | 8783 host_impl_ |
| 8769 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8784 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8770 InputHandler::TOUCHSCREEN) | 8785 InputHandler::TOUCHSCREEN) |
| 8771 .thread); | 8786 .thread); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8828 EXPECT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 8843 EXPECT_TRUE(host_impl_->top_controls_manager()->has_animation()); |
| 8829 EXPECT_TRUE(did_request_next_frame_); | 8844 EXPECT_TRUE(did_request_next_frame_); |
| 8830 } | 8845 } |
| 8831 host_impl_->DidFinishImplFrame(); | 8846 host_impl_->DidFinishImplFrame(); |
| 8832 } | 8847 } |
| 8833 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8848 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
| 8834 } | 8849 } |
| 8835 | 8850 |
| 8836 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 8851 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
| 8837 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8852 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8853 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8854 |
| 8838 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8855 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8839 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8856 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 8840 BOTH, SHOWN, false); | 8857 BOTH, SHOWN, false); |
| 8841 float initial_scroll_offset = 50; | 8858 float initial_scroll_offset = 50; |
| 8842 scroll_layer->layer_tree_impl() | 8859 scroll_layer->layer_tree_impl() |
| 8843 ->property_trees() | 8860 ->property_trees() |
| 8844 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 8861 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 8845 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 8862 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
| 8846 DrawFrame(); | 8863 DrawFrame(); |
| 8847 | 8864 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8902 host_impl_->DidFinishImplFrame(); | 8919 host_impl_->DidFinishImplFrame(); |
| 8903 } | 8920 } |
| 8904 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8921 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
| 8905 EXPECT_EQ(-top_controls_height_, | 8922 EXPECT_EQ(-top_controls_height_, |
| 8906 host_impl_->top_controls_manager()->ControlsTopOffset()); | 8923 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8907 } | 8924 } |
| 8908 | 8925 |
| 8909 TEST_F(LayerTreeHostImplWithTopControlsTest, | 8926 TEST_F(LayerTreeHostImplWithTopControlsTest, |
| 8910 TopControlsAnimationAfterMainThreadFlingStopped) { | 8927 TopControlsAnimationAfterMainThreadFlingStopped) { |
| 8911 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8928 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8929 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8930 |
| 8912 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8931 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8913 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 8932 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
| 8914 false); | 8933 false); |
| 8915 float initial_scroll_offset = 50; | 8934 float initial_scroll_offset = 50; |
| 8916 scroll_layer->layer_tree_impl() | 8935 scroll_layer->layer_tree_impl() |
| 8917 ->property_trees() | 8936 ->property_trees() |
| 8918 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 8937 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 8919 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 8938 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
| 8920 DrawFrame(); | 8939 DrawFrame(); |
| 8921 | 8940 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8975 } | 8994 } |
| 8976 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8995 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
| 8977 EXPECT_EQ(-top_controls_height_, | 8996 EXPECT_EQ(-top_controls_height_, |
| 8978 host_impl_->top_controls_manager()->ControlsTopOffset()); | 8997 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 8979 } | 8998 } |
| 8980 | 8999 |
| 8981 TEST_F(LayerTreeHostImplWithTopControlsTest, | 9000 TEST_F(LayerTreeHostImplWithTopControlsTest, |
| 8982 TopControlsScrollDeltaInOverScroll) { | 9001 TopControlsScrollDeltaInOverScroll) { |
| 8983 // Verifies that the overscroll delta should not have accumulated in | 9002 // Verifies that the overscroll delta should not have accumulated in |
| 8984 // the top controls if we do a hide and show without releasing finger. | 9003 // the top controls if we do a hide and show without releasing finger. |
| 9004 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9005 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8985 | 9006 |
| 8986 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | |
| 8987 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 9007 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8988 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 9008 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
| 8989 false); | 9009 false); |
| 8990 DrawFrame(); | 9010 DrawFrame(); |
| 8991 | 9011 |
| 8992 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9012 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8993 host_impl_ | 9013 host_impl_ |
| 8994 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9014 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8995 InputHandler::TOUCHSCREEN) | 9015 InputHandler::TOUCHSCREEN) |
| 8996 .thread); | 9016 .thread); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9113 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 9133 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
| 9114 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 9134 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
| 9115 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 9135 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
| 9116 | 9136 |
| 9117 inner_clip->test_properties()->force_render_surface = true; | 9137 inner_clip->test_properties()->force_render_surface = true; |
| 9118 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); | 9138 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); |
| 9119 layer_tree_impl->SetViewportLayersFromIds( | 9139 layer_tree_impl->SetViewportLayersFromIds( |
| 9120 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 9140 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 9121 kOuterViewportScrollLayerId); | 9141 kOuterViewportScrollLayerId); |
| 9122 | 9142 |
| 9143 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9123 host_impl_->active_tree()->DidBecomeActive(); | 9144 host_impl_->active_tree()->DidBecomeActive(); |
| 9124 } | 9145 } |
| 9125 }; | 9146 }; |
| 9126 | 9147 |
| 9127 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 9148 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
| 9128 gfx::Size content_size = gfx::Size(100, 160); | 9149 gfx::Size content_size = gfx::Size(100, 160); |
| 9129 gfx::Size outer_viewport = gfx::Size(50, 80); | 9150 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9130 gfx::Size inner_viewport = gfx::Size(25, 40); | 9151 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 9131 | 9152 |
| 9132 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9153 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9133 | 9154 |
| 9134 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9155 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9135 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9156 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9136 SetNeedsRebuildPropertyTrees(); | 9157 |
| 9137 DrawFrame(); | 9158 DrawFrame(); |
| 9138 { | 9159 { |
| 9139 gfx::ScrollOffset inner_expected; | 9160 gfx::ScrollOffset inner_expected; |
| 9140 gfx::ScrollOffset outer_expected; | 9161 gfx::ScrollOffset outer_expected; |
| 9141 EXPECT_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9162 EXPECT_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9142 EXPECT_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9163 EXPECT_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9143 | 9164 |
| 9144 gfx::ScrollOffset current_offset(70.f, 100.f); | 9165 gfx::ScrollOffset current_offset(70.f, 100.f); |
| 9145 | 9166 |
| 9146 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); | 9167 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 9158 | 9179 |
| 9159 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 9180 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
| 9160 gfx::Size content_size = gfx::Size(200, 320); | 9181 gfx::Size content_size = gfx::Size(200, 320); |
| 9161 gfx::Size outer_viewport = gfx::Size(100, 160); | 9182 gfx::Size outer_viewport = gfx::Size(100, 160); |
| 9162 gfx::Size inner_viewport = gfx::Size(50, 80); | 9183 gfx::Size inner_viewport = gfx::Size(50, 80); |
| 9163 | 9184 |
| 9164 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9185 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9165 | 9186 |
| 9166 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9187 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9167 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9188 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9168 SetNeedsRebuildPropertyTrees(); | 9189 |
| 9169 DrawFrame(); | 9190 DrawFrame(); |
| 9170 { | 9191 { |
| 9171 gfx::Vector2dF inner_expected; | 9192 gfx::Vector2dF inner_expected; |
| 9172 gfx::Vector2dF outer_expected; | 9193 gfx::Vector2dF outer_expected; |
| 9173 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9194 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9174 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9195 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9175 | 9196 |
| 9176 // Scrolling the viewport always sets the outer scroll layer as the | 9197 // Scrolling the viewport always sets the outer scroll layer as the |
| 9177 // currently scrolling layer. | 9198 // currently scrolling layer. |
| 9178 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9199 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9227 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9248 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9228 DiagonalScrollBubblesPerfectlyToInner) { | 9249 DiagonalScrollBubblesPerfectlyToInner) { |
| 9229 gfx::Size content_size = gfx::Size(200, 320); | 9250 gfx::Size content_size = gfx::Size(200, 320); |
| 9230 gfx::Size outer_viewport = gfx::Size(100, 160); | 9251 gfx::Size outer_viewport = gfx::Size(100, 160); |
| 9231 gfx::Size inner_viewport = gfx::Size(50, 80); | 9252 gfx::Size inner_viewport = gfx::Size(50, 80); |
| 9232 | 9253 |
| 9233 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9254 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9234 | 9255 |
| 9235 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9256 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9236 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9257 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9237 SetNeedsRebuildPropertyTrees(); | 9258 |
| 9238 DrawFrame(); | 9259 DrawFrame(); |
| 9239 { | 9260 { |
| 9240 gfx::Vector2dF inner_expected; | 9261 gfx::Vector2dF inner_expected; |
| 9241 gfx::Vector2dF outer_expected; | 9262 gfx::Vector2dF outer_expected; |
| 9242 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9263 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9243 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9264 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9244 | 9265 |
| 9245 // Make sure the scroll goes to the inner viewport first. | 9266 // Make sure the scroll goes to the inner viewport first. |
| 9246 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9267 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9247 host_impl_ | 9268 host_impl_ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9291 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9312 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9292 | 9313 |
| 9293 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9314 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9294 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9315 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9295 | 9316 |
| 9296 std::unique_ptr<LayerImpl> child = | 9317 std::unique_ptr<LayerImpl> child = |
| 9297 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9318 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 9298 LayerImpl* child_scroll = child.get(); | 9319 LayerImpl* child_scroll = child.get(); |
| 9299 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( | 9320 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( |
| 9300 std::move(child)); | 9321 std::move(child)); |
| 9322 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9301 | 9323 |
| 9302 SetNeedsRebuildPropertyTrees(); | |
| 9303 DrawFrame(); | 9324 DrawFrame(); |
| 9304 { | 9325 { |
| 9305 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 9326 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 9306 | 9327 |
| 9307 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 9328 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
| 9308 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9329 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9309 host_impl_ | 9330 host_impl_ |
| 9310 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9331 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9311 InputHandler::TOUCHSCREEN) | 9332 InputHandler::TOUCHSCREEN) |
| 9312 .thread); | 9333 .thread); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9360 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9381 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9361 | 9382 |
| 9362 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9383 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9363 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9384 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9364 | 9385 |
| 9365 std::unique_ptr<LayerImpl> child = | 9386 std::unique_ptr<LayerImpl> child = |
| 9366 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9387 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 9367 LayerImpl* child_scroll = child.get(); | 9388 LayerImpl* child_scroll = child.get(); |
| 9368 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( | 9389 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( |
| 9369 std::move(child)); | 9390 std::move(child)); |
| 9391 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9370 | 9392 |
| 9371 SetNeedsRebuildPropertyTrees(); | |
| 9372 DrawFrame(); | 9393 DrawFrame(); |
| 9373 | 9394 |
| 9374 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9395 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9375 host_impl_ | 9396 host_impl_ |
| 9376 ->RootScrollBegin(BeginState(gfx::Point()).get(), | 9397 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
| 9377 InputHandler::TOUCHSCREEN) | 9398 InputHandler::TOUCHSCREEN) |
| 9378 .thread); | 9399 .thread); |
| 9379 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 9400 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 9380 host_impl_->ScrollEnd(EndState().get()); | 9401 host_impl_->ScrollEnd(EndState().get()); |
| 9381 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9402 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9382 host_impl_ | 9403 host_impl_ |
| 9383 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9404 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9384 InputHandler::TOUCHSCREEN) | 9405 InputHandler::TOUCHSCREEN) |
| 9385 .thread); | 9406 .thread); |
| 9386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9407 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 9387 host_impl_->ScrollEnd(EndState().get()); | 9408 host_impl_->ScrollEnd(EndState().get()); |
| 9388 } | 9409 } |
| 9389 | 9410 |
| 9390 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9411 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9391 NoOverscrollWhenInnerViewportCantScroll) { | 9412 NoOverscrollWhenInnerViewportCantScroll) { |
| 9392 InputHandlerScrollResult scroll_result; | 9413 InputHandlerScrollResult scroll_result; |
| 9393 gfx::Size content_size = gfx::Size(100, 160); | 9414 gfx::Size content_size = gfx::Size(100, 160); |
| 9394 gfx::Size outer_viewport = gfx::Size(50, 80); | 9415 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9395 gfx::Size inner_viewport = gfx::Size(25, 40); | 9416 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 9396 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9417 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9397 // Make inner viewport unscrollable. | 9418 // Make inner viewport unscrollable. |
| 9398 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9419 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9399 inner_scroll->set_user_scrollable_horizontal(false); | 9420 inner_scroll->set_user_scrollable_horizontal(false); |
| 9400 inner_scroll->set_user_scrollable_vertical(false); | 9421 inner_scroll->set_user_scrollable_vertical(false); |
| 9401 SetNeedsRebuildPropertyTrees(); | 9422 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9423 |
| 9402 DrawFrame(); | 9424 DrawFrame(); |
| 9403 | 9425 |
| 9404 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). | 9426 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). |
| 9405 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); | 9427 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); |
| 9406 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9428 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9407 host_impl_ | 9429 host_impl_ |
| 9408 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9430 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9409 InputHandler::TOUCHSCREEN) | 9431 InputHandler::TOUCHSCREEN) |
| 9410 .thread); | 9432 .thread); |
| 9411 scroll_result = host_impl_->ScrollBy( | 9433 scroll_result = host_impl_->ScrollBy( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9459 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 9481 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 9460 external_transform); | 9482 external_transform); |
| 9461 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9483 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 9462 resourceless_software_draw); | 9484 resourceless_software_draw); |
| 9463 EXPECT_TRANSFORMATION_MATRIX_EQ( | 9485 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 9464 external_transform, layer->draw_properties().target_space_transform); | 9486 external_transform, layer->draw_properties().target_space_transform); |
| 9465 } | 9487 } |
| 9466 | 9488 |
| 9467 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { | 9489 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { |
| 9468 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9490 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9491 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9469 | 9492 |
| 9470 const gfx::Size viewport_size(100, 100); | 9493 const gfx::Size viewport_size(100, 100); |
| 9471 host_impl_->SetViewportSize(viewport_size); | 9494 host_impl_->SetViewportSize(viewport_size); |
| 9472 | 9495 |
| 9473 const gfx::Transform transform_for_tile_priority; | 9496 const gfx::Transform transform_for_tile_priority; |
| 9474 const gfx::Transform draw_transform; | 9497 const gfx::Transform draw_transform; |
| 9475 const gfx::Rect viewport_for_tile_priority1(viewport_size); | 9498 const gfx::Rect viewport_for_tile_priority1(viewport_size); |
| 9476 const gfx::Rect viewport_for_tile_priority2(50, 50); | 9499 const gfx::Rect viewport_for_tile_priority2(50, 50); |
| 9477 const gfx::Rect draw_viewport(viewport_size); | 9500 const gfx::Rect draw_viewport(viewport_size); |
| 9478 const gfx::Rect clip(viewport_size); | 9501 const gfx::Rect clip(viewport_size); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 9490 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, | 9513 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, |
| 9491 transform_for_tile_priority); | 9514 transform_for_tile_priority); |
| 9492 EXPECT_TRUE(did_request_redraw_); | 9515 EXPECT_TRUE(did_request_redraw_); |
| 9493 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9516 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
| 9494 resourceless_software_draw); | 9517 resourceless_software_draw); |
| 9495 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9518 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
| 9496 } | 9519 } |
| 9497 | 9520 |
| 9498 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { | 9521 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { |
| 9499 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9522 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9523 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9500 | 9524 |
| 9501 const gfx::Size viewport_size(100, 100); | 9525 const gfx::Size viewport_size(100, 100); |
| 9502 host_impl_->SetViewportSize(viewport_size); | 9526 host_impl_->SetViewportSize(viewport_size); |
| 9503 | 9527 |
| 9504 const gfx::Transform draw_transform; | 9528 const gfx::Transform draw_transform; |
| 9505 const gfx::Rect draw_viewport1(viewport_size); | 9529 const gfx::Rect draw_viewport1(viewport_size); |
| 9506 const gfx::Rect draw_viewport2(50, 50); | 9530 const gfx::Rect draw_viewport2(50, 50); |
| 9507 const gfx::Rect clip(viewport_size); | 9531 const gfx::Rect clip(viewport_size); |
| 9508 bool resourceless_software_draw = false; | 9532 bool resourceless_software_draw = false; |
| 9509 | 9533 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 9531 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 9555 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| 9532 protected: | 9556 protected: |
| 9533 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 9557 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 9534 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); | 9558 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); |
| 9535 } | 9559 } |
| 9536 }; | 9560 }; |
| 9537 | 9561 |
| 9538 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9562 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
| 9539 ResourcelessSoftwareSetNeedsRedraw) { | 9563 ResourcelessSoftwareSetNeedsRedraw) { |
| 9540 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9564 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9565 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9541 | 9566 |
| 9542 const gfx::Size viewport_size(100, 100); | 9567 const gfx::Size viewport_size(100, 100); |
| 9543 host_impl_->SetViewportSize(viewport_size); | 9568 host_impl_->SetViewportSize(viewport_size); |
| 9544 | 9569 |
| 9545 const gfx::Transform draw_transform; | 9570 const gfx::Transform draw_transform; |
| 9546 const gfx::Rect draw_viewport(viewport_size); | 9571 const gfx::Rect draw_viewport(viewport_size); |
| 9547 const gfx::Rect clip(viewport_size); | 9572 const gfx::Rect clip(viewport_size); |
| 9548 bool resourceless_software_draw = false; | 9573 bool resourceless_software_draw = false; |
| 9549 | 9574 |
| 9550 // Clear any damage. | 9575 // Clear any damage. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 9574 host_impl_->CreatePendingTree(); | 9599 host_impl_->CreatePendingTree(); |
| 9575 scoped_refptr<FakeRasterSource> raster_source( | 9600 scoped_refptr<FakeRasterSource> raster_source( |
| 9576 FakeRasterSource::CreateFilled(viewport_size)); | 9601 FakeRasterSource::CreateFilled(viewport_size)); |
| 9577 std::unique_ptr<FakePictureLayerImpl> layer( | 9602 std::unique_ptr<FakePictureLayerImpl> layer( |
| 9578 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 9603 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
| 9579 11, raster_source)); | 9604 11, raster_source)); |
| 9580 layer->SetBounds(viewport_size); | 9605 layer->SetBounds(viewport_size); |
| 9581 layer->SetDrawsContent(true); | 9606 layer->SetDrawsContent(true); |
| 9582 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); | 9607 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); |
| 9583 | 9608 |
| 9584 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9609 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 9585 host_impl_->ActivateSyncTree(); | 9610 host_impl_->ActivateSyncTree(); |
| 9586 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | |
| 9587 | 9611 |
| 9588 const gfx::Transform draw_transform; | 9612 const gfx::Transform draw_transform; |
| 9589 const gfx::Rect draw_viewport(viewport_size); | 9613 const gfx::Rect draw_viewport(viewport_size); |
| 9590 const gfx::Rect clip(viewport_size); | 9614 const gfx::Rect clip(viewport_size); |
| 9591 bool resourceless_software_draw = false; | 9615 bool resourceless_software_draw = false; |
| 9592 | 9616 |
| 9593 // Regular draw causes UpdateTiles. | 9617 // Regular draw causes UpdateTiles. |
| 9594 did_request_prepare_tiles_ = false; | 9618 did_request_prepare_tiles_ = false; |
| 9595 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9619 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
| 9596 resourceless_software_draw); | 9620 resourceless_software_draw); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9609 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { | 9633 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { |
| 9610 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 9634 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 9611 const gfx::Size layer_size(100, 100); | 9635 const gfx::Size layer_size(100, 100); |
| 9612 host_impl_->SetViewportSize(layer_size); | 9636 host_impl_->SetViewportSize(layer_size); |
| 9613 bool update_lcd_text = false; | 9637 bool update_lcd_text = false; |
| 9614 | 9638 |
| 9615 // Set up active and pending tree. | 9639 // Set up active and pending tree. |
| 9616 host_impl_->CreatePendingTree(); | 9640 host_impl_->CreatePendingTree(); |
| 9617 host_impl_->pending_tree()->SetRootLayerForTesting( | 9641 host_impl_->pending_tree()->SetRootLayerForTesting( |
| 9618 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 9642 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
| 9619 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9643 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 9620 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9644 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 9621 | 9645 |
| 9622 host_impl_->ActivateSyncTree(); | 9646 host_impl_->ActivateSyncTree(); |
| 9623 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | 9647 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
| 9624 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9648 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9625 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9649 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9626 | 9650 |
| 9627 host_impl_->CreatePendingTree(); | 9651 host_impl_->CreatePendingTree(); |
| 9628 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9652 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 9629 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9653 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9630 | 9654 |
| 9631 EXPECT_FALSE(host_impl_->pending_tree()->needs_update_draw_properties()); | 9655 EXPECT_FALSE(host_impl_->pending_tree()->needs_update_draw_properties()); |
| 9632 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 9656 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 9633 | 9657 |
| 9634 // Update external constraints should set_needs_update_draw_properties on | 9658 // Update external constraints should set_needs_update_draw_properties on |
| 9635 // both trees. | 9659 // both trees. |
| 9636 gfx::Transform external_transform; | 9660 gfx::Transform external_transform; |
| 9637 gfx::Rect external_viewport(10, 20); | 9661 gfx::Rect external_viewport(10, 20); |
| 9638 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 9662 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 9639 external_transform); | 9663 external_transform); |
| 9640 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties()); | 9664 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties()); |
| 9641 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); | 9665 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 9642 } | 9666 } |
| 9643 | 9667 |
| 9644 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { | 9668 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { |
| 9645 const gfx::Size layer_size(100, 100); | 9669 const gfx::Size layer_size(100, 100); |
| 9646 SetupScrollAndContentsLayers(layer_size); | 9670 SetupScrollAndContentsLayers(layer_size); |
| 9647 LayerImpl* content_layer = host_impl_->active_tree() | 9671 LayerImpl* content_layer = host_impl_->active_tree() |
| 9648 ->OuterViewportScrollLayer() | 9672 ->OuterViewportScrollLayer() |
| 9649 ->test_properties() | 9673 ->test_properties() |
| 9650 ->children[0]; | 9674 ->children[0]; |
| 9651 SetNeedsRebuildPropertyTrees(); | |
| 9652 RebuildPropertyTrees(); | |
| 9653 | 9675 |
| 9654 bool update_lcd_text = false; | 9676 bool update_lcd_text = false; |
| 9655 | 9677 |
| 9656 host_impl_->SetViewportSize(gfx::Size(90, 90)); | 9678 host_impl_->SetViewportSize(gfx::Size(90, 90)); |
| 9657 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9679 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9658 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 9680 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 9659 | 9681 |
| 9660 gfx::Transform external_transform; | 9682 gfx::Transform external_transform; |
| 9661 gfx::Rect external_viewport(10, 20); | 9683 gfx::Rect external_viewport(10, 20); |
| 9662 gfx::Rect external_clip(layer_size); | 9684 gfx::Rect external_clip(layer_size); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9677 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 9699 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 9678 } | 9700 } |
| 9679 | 9701 |
| 9680 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { | 9702 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { |
| 9681 const gfx::Size layer_size(100, 100); | 9703 const gfx::Size layer_size(100, 100); |
| 9682 SetupScrollAndContentsLayers(layer_size); | 9704 SetupScrollAndContentsLayers(layer_size); |
| 9683 LayerImpl* content_layer = host_impl_->active_tree() | 9705 LayerImpl* content_layer = host_impl_->active_tree() |
| 9684 ->OuterViewportScrollLayer() | 9706 ->OuterViewportScrollLayer() |
| 9685 ->test_properties() | 9707 ->test_properties() |
| 9686 ->children[0]; | 9708 ->children[0]; |
| 9687 SetNeedsRebuildPropertyTrees(); | |
| 9688 RebuildPropertyTrees(); | |
| 9689 | 9709 |
| 9690 bool update_lcd_text = false; | 9710 bool update_lcd_text = false; |
| 9691 | 9711 |
| 9692 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9712 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 9693 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9713 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9694 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9714 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 9695 | 9715 |
| 9696 gfx::Transform external_transform; | 9716 gfx::Transform external_transform; |
| 9697 external_transform.Translate(10, 10); | 9717 external_transform.Translate(10, 10); |
| 9698 external_transform.Scale(2, 2); | 9718 external_transform.Scale(2, 2); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 9727 ->children[0]; | 9747 ->children[0]; |
| 9728 content_layer->test_properties()->AddChild( | 9748 content_layer->test_properties()->AddChild( |
| 9729 LayerImpl::Create(host_impl_->active_tree(), 100)); | 9749 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 9730 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9750 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
| 9731 test_layer->test_properties()->force_render_surface = true; | 9751 test_layer->test_properties()->force_render_surface = true; |
| 9732 test_layer->SetDrawsContent(true); | 9752 test_layer->SetDrawsContent(true); |
| 9733 test_layer->SetBounds(layer_size); | 9753 test_layer->SetBounds(layer_size); |
| 9734 gfx::Transform perspective_transform; | 9754 gfx::Transform perspective_transform; |
| 9735 perspective_transform.ApplyPerspectiveDepth(2); | 9755 perspective_transform.ApplyPerspectiveDepth(2); |
| 9736 test_layer->SetTransform(perspective_transform); | 9756 test_layer->SetTransform(perspective_transform); |
| 9757 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9737 | 9758 |
| 9738 SetNeedsRebuildPropertyTrees(); | |
| 9739 RebuildPropertyTrees(); | |
| 9740 bool update_lcd_text = false; | 9759 bool update_lcd_text = false; |
| 9741 | 9760 |
| 9742 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9761 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 9743 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9762 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9744 TransformNode* node = | 9763 TransformNode* node = |
| 9745 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9764 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 9746 test_layer->transform_tree_index()); | 9765 test_layer->transform_tree_index()); |
| 9747 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 9766 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9748 | 9767 |
| 9749 gfx::Transform external_transform; | 9768 gfx::Transform external_transform; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 9772 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9791 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 9773 test_layer->transform_tree_index()); | 9792 test_layer->transform_tree_index()); |
| 9774 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 9793 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9775 } | 9794 } |
| 9776 | 9795 |
| 9777 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { | 9796 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { |
| 9778 const gfx::Size content_size(1000, 1000); | 9797 const gfx::Size content_size(1000, 1000); |
| 9779 const gfx::Size viewport_size(50, 100); | 9798 const gfx::Size viewport_size(50, 100); |
| 9780 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9799 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 9781 | 9800 |
| 9782 SetNeedsRebuildPropertyTrees(); | |
| 9783 DrawFrame(); | 9801 DrawFrame(); |
| 9784 | 9802 |
| 9785 base::TimeTicks start_time = | 9803 base::TimeTicks start_time = |
| 9786 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 9804 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 9787 | 9805 |
| 9788 BeginFrameArgs begin_frame_args = | 9806 BeginFrameArgs begin_frame_args = |
| 9789 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 9807 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 9790 | 9808 |
| 9791 EXPECT_EQ( | 9809 EXPECT_EQ( |
| 9792 InputHandler::SCROLL_ON_IMPL_THREAD, | 9810 InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9966 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9984 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9967 host_impl_->DidFinishImplFrame(); | 9985 host_impl_->DidFinishImplFrame(); |
| 9968 } | 9986 } |
| 9969 | 9987 |
| 9970 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9988 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
| 9971 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9989 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
| 9972 const gfx::Size content_size(1000, 1000); | 9990 const gfx::Size content_size(1000, 1000); |
| 9973 const gfx::Size viewport_size(500, 500); | 9991 const gfx::Size viewport_size(500, 500); |
| 9974 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9992 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 9975 | 9993 |
| 9976 SetNeedsRebuildPropertyTrees(); | |
| 9977 DrawFrame(); | 9994 DrawFrame(); |
| 9978 | 9995 |
| 9979 base::TimeTicks start_time = | 9996 base::TimeTicks start_time = |
| 9980 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 9997 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 9981 | 9998 |
| 9982 BeginFrameArgs begin_frame_args = | 9999 BeginFrameArgs begin_frame_args = |
| 9983 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10000 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 9984 | 10001 |
| 9985 EXPECT_EQ( | 10002 EXPECT_EQ( |
| 9986 InputHandler::SCROLL_ON_IMPL_THREAD, | 10003 InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10032 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10049 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 10033 host_impl_->DidFinishImplFrame(); | 10050 host_impl_->DidFinishImplFrame(); |
| 10034 } | 10051 } |
| 10035 | 10052 |
| 10036 // Test that the scroll delta for an animated scroll is distributed correctly | 10053 // Test that the scroll delta for an animated scroll is distributed correctly |
| 10037 // between the inner and outer viewport. | 10054 // between the inner and outer viewport. |
| 10038 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimated) { | 10055 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimated) { |
| 10039 const gfx::Size content_size(200, 200); | 10056 const gfx::Size content_size(200, 200); |
| 10040 const gfx::Size viewport_size(100, 100); | 10057 const gfx::Size viewport_size(100, 100); |
| 10041 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10058 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10059 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10042 | 10060 |
| 10043 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 10061 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 10044 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 10062 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 10045 | 10063 |
| 10046 // Zoom into the page by a 2X factor | 10064 // Zoom into the page by a 2X factor |
| 10047 float min_page_scale = 1.f, max_page_scale = 4.f; | 10065 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 10048 float page_scale_factor = 2.f; | 10066 float page_scale_factor = 2.f; |
| 10049 RebuildPropertyTrees(); | |
| 10050 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10067 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 10051 page_scale_factor, min_page_scale, max_page_scale); | 10068 page_scale_factor, min_page_scale, max_page_scale); |
| 10052 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10069 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 10053 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 10054 | 10070 |
| 10055 // Scroll by a small amount, there should be no bubbling to the outer | 10071 // Scroll by a small amount, there should be no bubbling to the outer |
| 10056 // viewport. | 10072 // viewport. |
| 10057 base::TimeTicks start_time = | 10073 base::TimeTicks start_time = |
| 10058 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10074 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
| 10059 BeginFrameArgs begin_frame_args = | 10075 BeginFrameArgs begin_frame_args = |
| 10060 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10076 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10061 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10077 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10062 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 10078 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
| 10063 .thread); | 10079 .thread); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10130 const gfx::Size content_size(200, 200); | 10146 const gfx::Size content_size(200, 200); |
| 10131 const gfx::Size viewport_size(100, 100); | 10147 const gfx::Size viewport_size(100, 100); |
| 10132 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10148 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10133 | 10149 |
| 10134 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 10150 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 10135 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 10151 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 10136 | 10152 |
| 10137 // Zoom into the page by a 2X factor | 10153 // Zoom into the page by a 2X factor |
| 10138 float min_page_scale = 1.f, max_page_scale = 4.f; | 10154 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 10139 float page_scale_factor = 2.f; | 10155 float page_scale_factor = 2.f; |
| 10140 RebuildPropertyTrees(); | |
| 10141 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10156 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 10142 page_scale_factor, min_page_scale, max_page_scale); | 10157 page_scale_factor, min_page_scale, max_page_scale); |
| 10143 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10158 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 10144 | 10159 |
| 10145 // Scroll the inner viewport. | 10160 // Scroll the inner viewport. |
| 10146 base::TimeTicks start_time = | 10161 base::TimeTicks start_time = |
| 10147 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10162 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
| 10148 BeginFrameArgs begin_frame_args = | 10163 BeginFrameArgs begin_frame_args = |
| 10149 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10164 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10150 EXPECT_EQ( | 10165 EXPECT_EQ( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10183 | 10198 |
| 10184 // Test that smooth scroll offset animation doesn't happen for non user | 10199 // Test that smooth scroll offset animation doesn't happen for non user |
| 10185 // scrollable layers. | 10200 // scrollable layers. |
| 10186 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { | 10201 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { |
| 10187 const gfx::Size content_size(1000, 1000); | 10202 const gfx::Size content_size(1000, 1000); |
| 10188 const gfx::Size viewport_size(500, 500); | 10203 const gfx::Size viewport_size(500, 500); |
| 10189 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10204 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10190 | 10205 |
| 10191 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); | 10206 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); |
| 10192 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); | 10207 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); |
| 10208 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10193 | 10209 |
| 10194 SetNeedsRebuildPropertyTrees(); | |
| 10195 DrawFrame(); | 10210 DrawFrame(); |
| 10196 | 10211 |
| 10197 base::TimeTicks start_time = | 10212 base::TimeTicks start_time = |
| 10198 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10213 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10199 | 10214 |
| 10200 BeginFrameArgs begin_frame_args = | 10215 BeginFrameArgs begin_frame_args = |
| 10201 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10216 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10202 | 10217 |
| 10203 EXPECT_EQ( | 10218 EXPECT_EQ( |
| 10204 InputHandler::SCROLL_ON_IMPL_THREAD, | 10219 InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10254 } | 10269 } |
| 10255 | 10270 |
| 10256 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10271 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
| 10257 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10272 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
| 10258 const gfx::Size old_content_size(1000, 1000); | 10273 const gfx::Size old_content_size(1000, 1000); |
| 10259 const gfx::Size new_content_size(750, 750); | 10274 const gfx::Size new_content_size(750, 750); |
| 10260 const gfx::Size viewport_size(500, 500); | 10275 const gfx::Size viewport_size(500, 500); |
| 10261 | 10276 |
| 10262 LayerImpl* content_layer = | 10277 LayerImpl* content_layer = |
| 10263 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10278 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
| 10264 SetNeedsRebuildPropertyTrees(); | 10279 |
| 10265 DrawFrame(); | 10280 DrawFrame(); |
| 10266 | 10281 |
| 10267 base::TimeTicks start_time = | 10282 base::TimeTicks start_time = |
| 10268 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10283 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10269 BeginFrameArgs begin_frame_args = | 10284 BeginFrameArgs begin_frame_args = |
| 10270 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10285 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10271 | 10286 |
| 10272 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10287 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
| 10273 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10288 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10274 | 10289 |
| 10275 begin_frame_args.frame_time = start_time; | 10290 begin_frame_args.frame_time = start_time; |
| 10276 host_impl_->WillBeginImplFrame(begin_frame_args); | 10291 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10277 host_impl_->Animate(); | 10292 host_impl_->Animate(); |
| 10278 host_impl_->UpdateAnimationState(true); | 10293 host_impl_->UpdateAnimationState(true); |
| 10279 host_impl_->DidFinishImplFrame(); | 10294 host_impl_->DidFinishImplFrame(); |
| 10280 | 10295 |
| 10281 content_layer->SetBounds(new_content_size); | 10296 content_layer->SetBounds(new_content_size); |
| 10282 scrolling_layer->SetBounds(new_content_size); | 10297 scrolling_layer->SetBounds(new_content_size); |
| 10283 SetNeedsRebuildPropertyTrees(); | 10298 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10299 |
| 10284 DrawFrame(); | 10300 DrawFrame(); |
| 10285 | 10301 |
| 10286 begin_frame_args.frame_time = | 10302 begin_frame_args.frame_time = |
| 10287 start_time + base::TimeDelta::FromMilliseconds(200); | 10303 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10288 host_impl_->WillBeginImplFrame(begin_frame_args); | 10304 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10289 host_impl_->Animate(); | 10305 host_impl_->Animate(); |
| 10290 host_impl_->UpdateAnimationState(true); | 10306 host_impl_->UpdateAnimationState(true); |
| 10291 host_impl_->DidFinishImplFrame(); | 10307 host_impl_->DidFinishImplFrame(); |
| 10292 | 10308 |
| 10293 EXPECT_EQ(gfx::ScrollOffset(250, 250), | 10309 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10336 host_impl_->CreatePendingTree(); | 10352 host_impl_->CreatePendingTree(); |
| 10337 host_impl_->ActivateSyncTree(); | 10353 host_impl_->ActivateSyncTree(); |
| 10338 host_impl_->CreatePendingTree(); | 10354 host_impl_->CreatePendingTree(); |
| 10339 | 10355 |
| 10340 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 10356 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 10341 | 10357 |
| 10342 std::unique_ptr<FakePictureLayerImpl> pending_layer = | 10358 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 10343 FakePictureLayerImpl::Create(pending_tree, 10); | 10359 FakePictureLayerImpl::Create(pending_tree, 10); |
| 10344 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); | 10360 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); |
| 10345 pending_tree->SetRootLayerForTesting(std::move(pending_layer)); | 10361 pending_tree->SetRootLayerForTesting(std::move(pending_layer)); |
| 10346 pending_tree->BuildLayerListForTesting(); | |
| 10347 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer_for_testing()); | 10362 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer_for_testing()); |
| 10348 | 10363 |
| 10349 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); | 10364 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); |
| 10350 pending_tree->DidBecomeActive(); | 10365 pending_tree->DidBecomeActive(); |
| 10351 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 10366 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
| 10352 | 10367 |
| 10353 std::unique_ptr<FakePictureLayerImpl> mask_layer = | 10368 std::unique_ptr<FakePictureLayerImpl> mask_layer = |
| 10354 FakePictureLayerImpl::Create(pending_tree, 11); | 10369 FakePictureLayerImpl::Create(pending_tree, 11); |
| 10355 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); | 10370 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); |
| 10356 raw_pending_layer->test_properties()->SetMaskLayer(std::move(mask_layer)); | 10371 raw_pending_layer->test_properties()->SetMaskLayer(std::move(mask_layer)); |
| 10357 ASSERT_EQ(raw_mask_layer, raw_pending_layer->test_properties()->mask_layer); | 10372 ASSERT_EQ(raw_mask_layer, raw_pending_layer->test_properties()->mask_layer); |
| 10358 pending_tree->BuildLayerListAndPropertyTreesForTesting(); | 10373 pending_tree->BuildPropertyTreesForTesting(); |
| 10359 | 10374 |
| 10360 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 10375 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
| 10361 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); | 10376 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); |
| 10362 pending_tree->DidBecomeActive(); | 10377 pending_tree->DidBecomeActive(); |
| 10363 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 10378 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
| 10364 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 10379 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
| 10365 | 10380 |
| 10366 std::unique_ptr<FakePictureLayerImpl> replica_layer = | 10381 std::unique_ptr<FakePictureLayerImpl> replica_layer = |
| 10367 FakePictureLayerImpl::Create(pending_tree, 12); | 10382 FakePictureLayerImpl::Create(pending_tree, 12); |
| 10368 std::unique_ptr<FakePictureLayerImpl> replica_mask_layer = | 10383 std::unique_ptr<FakePictureLayerImpl> replica_mask_layer = |
| 10369 FakePictureLayerImpl::Create(pending_tree, 13); | 10384 FakePictureLayerImpl::Create(pending_tree, 13); |
| 10370 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); | 10385 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); |
| 10371 replica_layer->test_properties()->SetMaskLayer(std::move(replica_mask_layer)); | 10386 replica_layer->test_properties()->SetMaskLayer(std::move(replica_mask_layer)); |
| 10372 raw_pending_layer->test_properties()->SetReplicaLayer( | 10387 raw_pending_layer->test_properties()->SetReplicaLayer( |
| 10373 std::move(replica_layer)); | 10388 std::move(replica_layer)); |
| 10374 ASSERT_EQ(raw_replica_mask_layer, raw_pending_layer->test_properties() | 10389 ASSERT_EQ(raw_replica_mask_layer, raw_pending_layer->test_properties() |
| 10375 ->replica_layer->test_properties() | 10390 ->replica_layer->test_properties() |
| 10376 ->mask_layer); | 10391 ->mask_layer); |
| 10377 pending_tree->property_trees()->needs_rebuild = true; | 10392 pending_tree->BuildPropertyTreesForTesting(); |
| 10378 pending_tree->BuildLayerListAndPropertyTreesForTesting(); | |
| 10379 | 10393 |
| 10380 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 10394 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
| 10381 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 10395 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
| 10382 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); | 10396 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); |
| 10383 pending_tree->DidBecomeActive(); | 10397 pending_tree->DidBecomeActive(); |
| 10384 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); | 10398 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); |
| 10385 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); | 10399 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); |
| 10386 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); | 10400 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); |
| 10387 } | 10401 } |
| 10388 | 10402 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10773 host_impl_->BeginCommit(); | 10787 host_impl_->BeginCommit(); |
| 10774 } | 10788 } |
| 10775 | 10789 |
| 10776 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 10790 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
| 10777 // Check page scale factor update in property trees when an update is made | 10791 // Check page scale factor update in property trees when an update is made |
| 10778 // on the active tree. | 10792 // on the active tree. |
| 10779 host_impl_->CreatePendingTree(); | 10793 host_impl_->CreatePendingTree(); |
| 10780 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10794 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 10781 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 10795 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 10782 gfx::Size(100, 100)); | 10796 gfx::Size(100, 100)); |
| 10783 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 10797 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 10784 host_impl_->ActivateSyncTree(); | 10798 host_impl_->ActivateSyncTree(); |
| 10785 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | 10799 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
| 10786 DrawFrame(); | 10800 DrawFrame(); |
| 10787 | 10801 |
| 10788 host_impl_->CreatePendingTree(); | 10802 host_impl_->CreatePendingTree(); |
| 10789 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 10803 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 10790 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10804 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
| 10791 | 10805 |
| 10792 TransformNode* active_tree_node = | 10806 TransformNode* active_tree_node = |
| 10793 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10807 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 10822 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10836 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 10823 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); | 10837 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); |
| 10824 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10838 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
| 10825 page_scale_layer->test_properties()->AddChild( | 10839 page_scale_layer->test_properties()->AddChild( |
| 10826 LayerImpl::Create(host_impl_->active_tree(), 100)); | 10840 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 10827 | 10841 |
| 10828 LayerImpl* in_subtree_of_page_scale_layer = | 10842 LayerImpl* in_subtree_of_page_scale_layer = |
| 10829 host_impl_->active_tree()->LayerById(100); | 10843 host_impl_->active_tree()->LayerById(100); |
| 10830 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = | 10844 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = |
| 10831 true; | 10845 true; |
| 10832 SetNeedsRebuildPropertyTrees(); | 10846 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10833 RebuildPropertyTrees(); | 10847 |
| 10834 DrawFrame(); | 10848 DrawFrame(); |
| 10849 |
| 10835 TransformNode* node = | 10850 TransformNode* node = |
| 10836 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10851 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 10837 in_subtree_of_page_scale_layer->transform_tree_index()); | 10852 in_subtree_of_page_scale_layer->transform_tree_index()); |
| 10838 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 10853 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 10839 | 10854 |
| 10840 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 10855 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 10856 |
| 10841 DrawFrame(); | 10857 DrawFrame(); |
| 10858 |
| 10842 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); | 10859 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); |
| 10843 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10860 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 10844 in_subtree_of_page_scale_layer->transform_tree_index()); | 10861 in_subtree_of_page_scale_layer->transform_tree_index()); |
| 10845 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); | 10862 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 10846 } | 10863 } |
| 10847 | 10864 |
| 10848 TEST_F(LayerTreeHostImplTest, JitterTest) { | 10865 TEST_F(LayerTreeHostImplTest, JitterTest) { |
| 10849 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 10866 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 10850 | 10867 |
| 10851 host_impl_->CreatePendingTree(); | 10868 host_impl_->CreatePendingTree(); |
| 10852 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 10869 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 10853 gfx::Size(100, 100)); | 10870 gfx::Size(100, 100)); |
| 10871 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 10854 | 10872 |
| 10855 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 10873 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 10856 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
| 10857 const int scroll = 5; | 10874 const int scroll = 5; |
| 10858 int accumulated_scroll = 0; | 10875 int accumulated_scroll = 0; |
| 10859 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1; | 10876 for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1; |
| 10860 ++i) { | 10877 ++i) { |
| 10861 host_impl_->ActivateSyncTree(); | 10878 host_impl_->ActivateSyncTree(); |
| 10862 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 10879 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 10863 InputHandler::TOUCHSCREEN); | 10880 InputHandler::TOUCHSCREEN); |
| 10864 host_impl_->ScrollBy( | 10881 host_impl_->ScrollBy( |
| 10865 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); | 10882 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); |
| 10866 accumulated_scroll += scroll; | 10883 accumulated_scroll += scroll; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 10889 // layer->CurrentScrollOffset()). | 10906 // layer->CurrentScrollOffset()). |
| 10890 // However, layer_impl does not store scroll_offset, so it is using scroll | 10907 // However, layer_impl does not store scroll_offset, so it is using scroll |
| 10891 // tree's scroll offset to initialize itself. Usually this approach works | 10908 // tree's scroll offset to initialize itself. Usually this approach works |
| 10892 // because this is a simple assignment. However if scroll_offset's pending | 10909 // because this is a simple assignment. However if scroll_offset's pending |
| 10893 // delta is not zero, the delta would be counted twice. | 10910 // delta is not zero, the delta would be counted twice. |
| 10894 // This hacking here is to restore the damaged scroll offset. | 10911 // This hacking here is to restore the damaged scroll offset. |
| 10895 gfx::ScrollOffset pending_base = | 10912 gfx::ScrollOffset pending_base = |
| 10896 pending_tree->property_trees() | 10913 pending_tree->property_trees() |
| 10897 ->scroll_tree.GetScrollOffsetBaseForTesting( | 10914 ->scroll_tree.GetScrollOffsetBaseForTesting( |
| 10898 last_scrolled_layer->id()); | 10915 last_scrolled_layer->id()); |
| 10899 pending_tree->property_trees()->needs_rebuild = true; | 10916 pending_tree->BuildPropertyTreesForTesting(); |
| 10900 pending_tree->BuildLayerListAndPropertyTreesForTesting(); | |
| 10901 pending_tree->property_trees() | 10917 pending_tree->property_trees() |
| 10902 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 10918 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 10903 last_scrolled_layer->id(), pending_base); | 10919 last_scrolled_layer->id(), pending_base); |
| 10904 pending_tree->LayerById(content_layer->id())->SetNeedsPushProperties(); | 10920 pending_tree->LayerById(content_layer->id())->SetNeedsPushProperties(); |
| 10905 | 10921 |
| 10906 pending_tree->set_needs_update_draw_properties(); | 10922 pending_tree->set_needs_update_draw_properties(); |
| 10907 pending_tree->UpdateDrawProperties(false); | 10923 pending_tree->UpdateDrawProperties(false); |
| 10908 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); | 10924 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); |
| 10909 // There should not be any jitter measured till we hit the fixed point hits | 10925 // There should not be any jitter measured till we hit the fixed point hits |
| 10910 // threshold. | 10926 // threshold. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10935 | 10951 |
| 10936 // Re-initialize with a software output surface. | 10952 // Re-initialize with a software output surface. |
| 10937 output_surface_ = FakeOutputSurface::CreateSoftware( | 10953 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10938 base::WrapUnique(new SoftwareOutputDevice)); | 10954 base::WrapUnique(new SoftwareOutputDevice)); |
| 10939 host_impl_->InitializeRenderer(output_surface_.get()); | 10955 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10940 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10956 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10941 } | 10957 } |
| 10942 | 10958 |
| 10943 } // namespace | 10959 } // namespace |
| 10944 } // namespace cc | 10960 } // namespace cc |
| OLD | NEW |