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->BuildLayerListAndPropertyTreesForTesting(); |
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 67 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 23 matching lines...) Expand all Loading... |
610 LayerImpl::Create(host_impl_->active_tree(), 4)); | 596 LayerImpl::Create(host_impl_->active_tree(), 4)); |
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)); |
| 606 host_impl_->active_tree()->BuildLayerListForTesting(); |
620 } | 607 } |
621 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 608 LayerImpl* root = *host_impl_->active_tree()->begin(); |
622 | 609 |
623 ExpectClearedScrollDeltasRecursive(root); | 610 ExpectClearedScrollDeltasRecursive(root); |
624 | 611 |
625 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 612 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
626 | 613 |
627 scroll_info = host_impl_->ProcessScrollDeltas(); | 614 scroll_info = host_impl_->ProcessScrollDeltas(); |
628 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 615 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
629 ExpectClearedScrollDeltasRecursive(root); | 616 ExpectClearedScrollDeltasRecursive(root); |
630 | 617 |
631 scroll_info = host_impl_->ProcessScrollDeltas(); | 618 scroll_info = host_impl_->ProcessScrollDeltas(); |
632 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 619 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
633 ExpectClearedScrollDeltasRecursive(root); | 620 ExpectClearedScrollDeltasRecursive(root); |
634 } | 621 } |
635 | 622 |
636 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 623 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
637 gfx::ScrollOffset scroll_offset(20, 30); | 624 gfx::ScrollOffset scroll_offset(20, 30); |
638 gfx::Vector2d scroll_delta(11, -15); | 625 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 | 626 |
658 LayerImpl* root = host_impl_->active_tree() | 627 auto root_clip_owned = LayerImpl::Create(host_impl_->active_tree(), 2); |
659 ->root_layer_for_testing() | 628 auto* root_clip = root_clip_owned.get(); |
660 ->test_properties() | 629 auto root_owned = LayerImpl::Create(host_impl_->active_tree(), 1); |
661 ->children[0]; | 630 auto* root = root_owned.get(); |
| 631 |
| 632 root_clip->SetBounds(gfx::Size(10, 10)); |
| 633 root_clip->test_properties()->AddChild(std::move(root_owned)); |
| 634 root->SetBounds(gfx::Size(110, 110)); |
| 635 root->SetScrollClipLayer(root_clip->id()); |
| 636 root->layer_tree_impl() |
| 637 ->property_trees() |
| 638 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root->id(), scroll_offset); |
| 639 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip_owned)); |
| 640 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
662 | 641 |
663 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 642 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
664 | 643 |
| 644 root->ScrollBy(scroll_delta); |
665 scroll_info = host_impl_->ProcessScrollDeltas(); | 645 scroll_info = host_impl_->ProcessScrollDeltas(); |
666 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 646 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
667 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 647 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
668 | 648 |
669 gfx::Vector2d scroll_delta2(-5, 27); | 649 gfx::Vector2d scroll_delta2(-5, 27); |
670 root->ScrollBy(scroll_delta2); | 650 root->ScrollBy(scroll_delta2); |
671 scroll_info = host_impl_->ProcessScrollDeltas(); | 651 scroll_info = host_impl_->ProcessScrollDeltas(); |
672 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 652 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
673 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 653 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
674 scroll_delta + scroll_delta2)); | 654 scroll_delta + scroll_delta2)); |
675 | 655 |
676 root->ScrollBy(gfx::Vector2d()); | 656 root->ScrollBy(gfx::Vector2d()); |
677 scroll_info = host_impl_->ProcessScrollDeltas(); | 657 scroll_info = host_impl_->ProcessScrollDeltas(); |
678 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 658 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
679 scroll_delta + scroll_delta2)); | 659 scroll_delta + scroll_delta2)); |
680 } | 660 } |
681 | 661 |
682 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 662 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
683 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 663 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 664 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 665 |
684 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 666 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
685 DrawFrame(); | 667 DrawFrame(); |
686 | 668 |
687 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 669 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
688 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 670 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
689 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 671 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
690 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 672 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
691 status.main_thread_scrolling_reasons); | 673 status.main_thread_scrolling_reasons); |
692 | 674 |
693 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 675 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
694 InputHandler::WHEEL)); | 676 InputHandler::WHEEL)); |
695 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 677 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
696 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 678 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
697 InputHandler::WHEEL)); | 679 InputHandler::WHEEL)); |
698 host_impl_->ScrollEnd(EndState().get()); | 680 host_impl_->ScrollEnd(EndState().get()); |
699 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 681 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
700 InputHandler::WHEEL)); | 682 InputHandler::WHEEL)); |
701 EXPECT_TRUE(did_request_redraw_); | 683 EXPECT_TRUE(did_request_redraw_); |
702 EXPECT_TRUE(did_request_commit_); | 684 EXPECT_TRUE(did_request_commit_); |
703 } | 685 } |
704 | 686 |
705 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 687 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
706 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 688 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 689 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 690 |
707 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 691 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
708 DrawFrame(); | 692 DrawFrame(); |
709 | 693 |
710 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 694 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
711 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 695 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
712 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 696 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
713 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 697 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
714 status.main_thread_scrolling_reasons); | 698 status.main_thread_scrolling_reasons); |
715 | 699 |
716 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 700 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 789 |
806 LayerImpl* child = 0; | 790 LayerImpl* child = 0; |
807 { | 791 { |
808 std::unique_ptr<LayerImpl> child_layer = | 792 std::unique_ptr<LayerImpl> child_layer = |
809 LayerImpl::Create(host_impl_->active_tree(), 6); | 793 LayerImpl::Create(host_impl_->active_tree(), 6); |
810 child = child_layer.get(); | 794 child = child_layer.get(); |
811 child_layer->SetDrawsContent(true); | 795 child_layer->SetDrawsContent(true); |
812 child_layer->SetPosition(gfx::PointF(0, 20)); | 796 child_layer->SetPosition(gfx::PointF(0, 20)); |
813 child_layer->SetBounds(gfx::Size(50, 50)); | 797 child_layer->SetBounds(gfx::Size(50, 50)); |
814 scroll->test_properties()->AddChild(std::move(child_layer)); | 798 scroll->test_properties()->AddChild(std::move(child_layer)); |
815 SetNeedsRebuildPropertyTrees(); | 799 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
816 RebuildPropertyTrees(); | |
817 } | 800 } |
818 | 801 |
819 // Touch handler regions determine whether touch events block scroll. | 802 // Touch handler regions determine whether touch events block scroll. |
820 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 803 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
821 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 804 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
822 | 805 |
823 // But they don't influence the actual handling of the scroll gestures. | 806 // But they don't influence the actual handling of the scroll gestures. |
824 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 807 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
825 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 808 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
826 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 809 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 } | 869 } |
887 | 870 |
888 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { | 871 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { |
889 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 872 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
890 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 873 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
891 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 874 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
892 | 875 |
893 root->set_main_thread_scrolling_reasons( | 876 root->set_main_thread_scrolling_reasons( |
894 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 877 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
895 | 878 |
896 SetNeedsRebuildPropertyTrees(); | 879 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
897 DrawFrame(); | 880 DrawFrame(); |
898 | 881 |
899 // Start scrolling a layer | 882 // Start scrolling a layer |
900 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 883 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
901 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 884 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
902 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 885 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
903 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 886 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
904 status.main_thread_scrolling_reasons); | 887 status.main_thread_scrolling_reasons); |
905 | 888 |
906 // The fling should be ignored since there's no layer being scrolled impl-side | 889 // The fling should be ignored since there's no layer being scrolled impl-side |
907 status = host_impl_->FlingScrollBegin(); | 890 status = host_impl_->FlingScrollBegin(); |
908 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 891 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
909 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 892 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
910 status.main_thread_scrolling_reasons); | 893 status.main_thread_scrolling_reasons); |
911 } | 894 } |
912 | 895 |
913 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 896 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
914 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 897 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
915 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 898 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
916 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 899 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
917 | 900 |
918 root->set_main_thread_scrolling_reasons( | 901 root->set_main_thread_scrolling_reasons( |
919 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 902 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
920 SetNeedsRebuildPropertyTrees(); | 903 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
921 DrawFrame(); | 904 DrawFrame(); |
922 | 905 |
923 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 906 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
924 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 907 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
925 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 908 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
926 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 909 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
927 status.main_thread_scrolling_reasons); | 910 status.main_thread_scrolling_reasons); |
928 | 911 |
929 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 912 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
930 InputHandler::TOUCHSCREEN); | 913 InputHandler::TOUCHSCREEN); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 squash2->SetPosition(gfx::PointF(220, 300)); | 955 squash2->SetPosition(gfx::PointF(220, 300)); |
973 squash2->SetDrawsContent(true); | 956 squash2->SetDrawsContent(true); |
974 | 957 |
975 scroll->test_properties()->AddChild(std::move(squash2)); | 958 scroll->test_properties()->AddChild(std::move(squash2)); |
976 clip->test_properties()->AddChild(std::move(scroll)); | 959 clip->test_properties()->AddChild(std::move(scroll)); |
977 clip->test_properties()->AddChild(std::move(scrollbar)); | 960 clip->test_properties()->AddChild(std::move(scrollbar)); |
978 clip->test_properties()->AddChild(std::move(squash1)); | 961 clip->test_properties()->AddChild(std::move(squash1)); |
979 root->test_properties()->AddChild(std::move(clip)); | 962 root->test_properties()->AddChild(std::move(clip)); |
980 | 963 |
981 layer_tree_impl->SetRootLayerForTesting(std::move(root)); | 964 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
982 SetNeedsRebuildPropertyTrees(); | 965 layer_tree_impl->BuildLayerListAndPropertyTreesForTesting(); |
983 RebuildPropertyTrees(); | |
984 layer_tree_impl->DidBecomeActive(); | 966 layer_tree_impl->DidBecomeActive(); |
985 | 967 |
986 // The point hits squash1 layer and also scroll layer, because scroll layer is | 968 // 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. | 969 // not an ancestor of squash1 layer, we cannot scroll on impl thread. |
988 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 970 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
989 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); | 971 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); |
990 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 972 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
991 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 973 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
992 status.main_thread_scrolling_reasons); | 974 status.main_thread_scrolling_reasons); |
993 | 975 |
(...skipping 11 matching lines...) Expand all Loading... |
1005 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 987 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
1006 } | 988 } |
1007 | 989 |
1008 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 990 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
1009 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 991 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1010 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 992 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1011 | 993 |
1012 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 994 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1013 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 995 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
1014 | 996 |
1015 SetNeedsRebuildPropertyTrees(); | 997 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1016 DrawFrame(); | 998 DrawFrame(); |
1017 | 999 |
1018 // All scroll types inside the non-fast scrollable region should fail. | 1000 // All scroll types inside the non-fast scrollable region should fail. |
1019 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1001 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
1020 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); | 1002 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); |
1021 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 1003 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
1022 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 1004 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
1023 status.main_thread_scrolling_reasons); | 1005 status.main_thread_scrolling_reasons); |
1024 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 1006 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
1025 InputHandler::WHEEL)); | 1007 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()); | 1040 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
1059 host_impl_->ScrollEnd(EndState().get()); | 1041 host_impl_->ScrollEnd(EndState().get()); |
1060 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1042 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
1061 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1043 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
1062 } | 1044 } |
1063 | 1045 |
1064 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 1046 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
1065 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1047 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1066 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1048 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1067 | 1049 |
1068 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 1050 LayerImpl* root = *host_impl_->active_tree()->begin(); |
1069 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1051 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
1070 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 1052 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
1071 root->SetDrawsContent(true); | 1053 root->SetDrawsContent(true); |
1072 | 1054 |
1073 SetNeedsRebuildPropertyTrees(); | 1055 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1074 DrawFrame(); | 1056 DrawFrame(); |
1075 | 1057 |
1076 // This point would fall into the non-fast scrollable region except that we've | 1058 // This point would fall into the non-fast scrollable region except that we've |
1077 // moved the layer down by 25 pixels. | 1059 // moved the layer down by 25 pixels. |
1078 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1060 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
1079 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); | 1061 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); |
1080 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1062 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
1081 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1063 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
1082 status.main_thread_scrolling_reasons); | 1064 status.main_thread_scrolling_reasons); |
1083 | 1065 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 | 1185 |
1204 DrawFrame(); | 1186 DrawFrame(); |
1205 | 1187 |
1206 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1188 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
1207 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1189 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
1208 InputHandler::WHEEL) | 1190 InputHandler::WHEEL) |
1209 .thread); | 1191 .thread); |
1210 | 1192 |
1211 // Trying to scroll if not user_scrollable_vertical will fail. | 1193 // Trying to scroll if not user_scrollable_vertical will fail. |
1212 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); | 1194 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); |
1213 SetNeedsRebuildPropertyTrees(); | 1195 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1214 DrawFrame(); | 1196 DrawFrame(); |
1215 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 1197 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
1216 gfx::Point(), SCROLL_FORWARD)); | 1198 gfx::Point(), SCROLL_FORWARD)); |
1217 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 1199 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
1218 gfx::Point(), SCROLL_BACKWARD)); | 1200 gfx::Point(), SCROLL_BACKWARD)); |
1219 | 1201 |
1220 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); | 1202 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); |
1221 SetNeedsRebuildPropertyTrees(); | 1203 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1222 DrawFrame(); | 1204 DrawFrame(); |
1223 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1205 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
1224 gfx::Point(), SCROLL_FORWARD)); | 1206 gfx::Point(), SCROLL_FORWARD)); |
1225 EXPECT_FLOAT_EQ(875.f, | 1207 EXPECT_FLOAT_EQ(875.f, |
1226 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | 1208 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); |
1227 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1209 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
1228 gfx::Point(), SCROLL_BACKWARD)); | 1210 gfx::Point(), SCROLL_BACKWARD)); |
1229 } | 1211 } |
1230 | 1212 |
1231 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1213 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
1232 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1214 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1233 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1215 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1234 | 1216 |
1235 gfx::Size overflow_size(400, 400); | 1217 gfx::Size overflow_size(400, 400); |
1236 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1218 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
1237 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1219 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
1238 overflow->SetBounds(overflow_size); | 1220 overflow->SetBounds(overflow_size); |
1239 overflow->SetScrollClipLayer( | 1221 overflow->SetScrollClipLayer( |
1240 scroll_layer->test_properties()->parent->test_properties()->parent->id()); | 1222 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
1241 overflow->layer_tree_impl() | 1223 overflow->layer_tree_impl() |
1242 ->property_trees() | 1224 ->property_trees() |
1243 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1225 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
1244 gfx::ScrollOffset()); | 1226 gfx::ScrollOffset()); |
1245 overflow->SetPosition(gfx::PointF()); | 1227 overflow->SetPosition(gfx::PointF()); |
1246 | 1228 |
1247 SetNeedsRebuildPropertyTrees(); | 1229 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
1248 DrawFrame(); | 1230 DrawFrame(); |
1249 gfx::Point scroll_position(10, 10); | 1231 gfx::Point scroll_position(10, 10); |
1250 | 1232 |
1251 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1233 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
1252 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1234 host_impl_->ScrollBegin(BeginState(scroll_position).get(), |
1253 InputHandler::WHEEL) | 1235 InputHandler::WHEEL) |
1254 .thread); | 1236 .thread); |
1255 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1237 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1256 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1238 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
1257 | 1239 |
1258 gfx::Vector2dF scroll_delta(10, 10); | 1240 gfx::Vector2dF scroll_delta(10, 10); |
1259 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1241 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
1260 host_impl_->ScrollEnd(EndState().get()); | 1242 host_impl_->ScrollEnd(EndState().get()); |
1261 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1243 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1262 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1244 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
1263 | 1245 |
1264 overflow->set_user_scrollable_horizontal(false); | 1246 overflow->set_user_scrollable_horizontal(false); |
1265 SetNeedsRebuildPropertyTrees(); | 1247 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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); |
(...skipping 12 matching lines...) Expand all Loading... |
1570 | 1551 |
1571 base::TimeTicks now = base::TimeTicks::Now(); | 1552 base::TimeTicks now = base::TimeTicks::Now(); |
1572 host_impl_->WillBeginImplFrame( | 1553 host_impl_->WillBeginImplFrame( |
1573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1554 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1574 | 1555 |
1575 host_impl_->ActivateAnimations(); | 1556 host_impl_->ActivateAnimations(); |
1576 host_impl_->Animate(); | 1557 host_impl_->Animate(); |
1577 | 1558 |
1578 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1559 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1579 | 1560 |
1580 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | |
1581 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1561 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); |
(...skipping 30 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()->BuildLayerListAndPropertyTreesForTesting(); |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()); |
2092 | 2071 |
2093 SetNeedsRebuildPropertyTrees(); | 2072 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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()->BuildLayerListAndPropertyTreesForTesting(); |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
2761 host_impl_->active_tree()->DidBecomeActive(); | 2739 host_impl_->active_tree()->DidBecomeActive(); |
2762 SetNeedsRebuildPropertyTrees(); | 2740 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
2763 DrawFrame(); | 2741 DrawFrame(); |
2764 } | 2742 } |
2765 | 2743 |
2766 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2744 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
2767 LayerTreeSettings settings = DefaultSettings(); | 2745 LayerTreeSettings settings = DefaultSettings(); |
2768 settings.scrollbar_animator = animator; | 2746 settings.scrollbar_animator = animator; |
2769 settings.scrollbar_fade_delay_ms = 20; | 2747 settings.scrollbar_fade_delay_ms = 20; |
2770 settings.scrollbar_fade_duration_ms = 20; | 2748 settings.scrollbar_fade_duration_ms = 20; |
2771 | 2749 |
2772 SetupLayers(settings); | 2750 SetupLayers(settings); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2959 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2937 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2960 InputHandler::WHEEL); | 2938 InputHandler::WHEEL); |
2961 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2939 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
2962 host_impl_->ScrollEnd(EndState().get()); | 2940 host_impl_->ScrollEnd(EndState().get()); |
2963 host_impl_->CreatePendingTree(); | 2941 host_impl_->CreatePendingTree(); |
2964 // To test the case where the effect tree index of scrollbar layer changes, | 2942 // To test the case where the effect tree index of scrollbar layer changes, |
2965 // we force the container layer to create a render surface. | 2943 // we force the container layer to create a render surface. |
2966 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2944 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); |
2967 container->test_properties()->force_render_surface = true; | 2945 container->test_properties()->force_render_surface = true; |
2968 container->SetBounds(gfx::Size(10, 10)); | 2946 container->SetBounds(gfx::Size(10, 10)); |
2969 host_impl_->pending_tree()->property_trees()->needs_rebuild = true; | |
2970 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2947 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
2971 | 2948 |
2972 LayerImpl* pending_scrollbar_layer = | 2949 LayerImpl* pending_scrollbar_layer = |
2973 host_impl_->pending_tree()->LayerById(400); | 2950 host_impl_->pending_tree()->LayerById(400); |
2974 EffectNode* pending_tree_node = | 2951 EffectNode* pending_tree_node = |
2975 host_impl_->pending_tree()->property_trees()->effect_tree.Node( | 2952 host_impl_->pending_tree()->property_trees()->effect_tree.Node( |
2976 pending_scrollbar_layer->effect_tree_index()); | 2953 pending_scrollbar_layer->effect_tree_index()); |
2977 host_impl_->pending_tree() | 2954 host_impl_->pending_tree() |
2978 ->property_trees() | 2955 ->property_trees() |
2979 ->always_use_active_tree_opacity_effect_ids.push_back(400); | 2956 ->always_use_active_tree_opacity_effect_ids.push_back(400); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, | 3155 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, |
3179 VERTICAL, 5, 5, true, true); | 3156 VERTICAL, 5, 5, true, true); |
3180 scrollbar->SetScrollLayerId(root_scroll->id()); | 3157 scrollbar->SetScrollLayerId(root_scroll->id()); |
3181 scrollbar->SetDrawsContent(true); | 3158 scrollbar->SetDrawsContent(true); |
3182 scrollbar->SetBounds(scrollbar_size); | 3159 scrollbar->SetBounds(scrollbar_size); |
3183 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); | 3160 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); |
3184 host_impl_->active_tree() | 3161 host_impl_->active_tree() |
3185 ->InnerViewportContainerLayer() | 3162 ->InnerViewportContainerLayer() |
3186 ->test_properties() | 3163 ->test_properties() |
3187 ->AddChild(std::move(scrollbar)); | 3164 ->AddChild(std::move(scrollbar)); |
| 3165 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3188 host_impl_->active_tree()->DidBecomeActive(); | 3166 host_impl_->active_tree()->DidBecomeActive(); |
3189 | 3167 |
3190 DrawFrame(); | 3168 DrawFrame(); |
3191 host_impl_->active_tree()->UpdateDrawProperties(false); | 3169 host_impl_->active_tree()->UpdateDrawProperties(false); |
3192 | 3170 |
3193 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 3171 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
3194 static_cast<ScrollbarAnimationControllerThinning*>( | 3172 static_cast<ScrollbarAnimationControllerThinning*>( |
3195 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 3173 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
3196 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 3174 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |
3197 | 3175 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3410 bool will_draw_called_; | 3388 bool will_draw_called_; |
3411 bool append_quads_called_; | 3389 bool append_quads_called_; |
3412 bool did_draw_called_; | 3390 bool did_draw_called_; |
3413 }; | 3391 }; |
3414 | 3392 |
3415 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 3393 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
3416 // The root layer is always drawn, so run this test on a child layer that | 3394 // 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. | 3395 // will be masked out by the root layer's bounds. |
3418 host_impl_->active_tree()->SetRootLayerForTesting( | 3396 host_impl_->active_tree()->SetRootLayerForTesting( |
3419 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3397 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3420 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3398 DidDrawCheckLayer* root = |
3421 host_impl_->active_tree()->root_layer_for_testing()); | 3399 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
3422 | 3400 |
3423 root->test_properties()->AddChild( | 3401 root->test_properties()->AddChild( |
3424 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3402 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3425 root->test_properties()->force_render_surface = true; | 3403 root->test_properties()->force_render_surface = true; |
3426 DidDrawCheckLayer* layer = | 3404 DidDrawCheckLayer* layer = |
3427 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3405 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3406 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3428 | 3407 |
3429 { | 3408 { |
3430 LayerTreeHostImpl::FrameData frame; | 3409 LayerTreeHostImpl::FrameData frame; |
3431 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3410 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3432 host_impl_->DrawLayers(&frame); | 3411 host_impl_->DrawLayers(&frame); |
3433 host_impl_->DidDrawAllLayers(frame); | 3412 host_impl_->DidDrawAllLayers(frame); |
3434 | 3413 |
3435 EXPECT_TRUE(layer->will_draw_called()); | 3414 EXPECT_TRUE(layer->will_draw_called()); |
3436 EXPECT_TRUE(layer->append_quads_called()); | 3415 EXPECT_TRUE(layer->append_quads_called()); |
3437 EXPECT_TRUE(layer->did_draw_called()); | 3416 EXPECT_TRUE(layer->did_draw_called()); |
3438 } | 3417 } |
3439 | 3418 |
3440 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); | 3419 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); |
3441 | 3420 |
3442 { | 3421 { |
3443 LayerTreeHostImpl::FrameData frame; | 3422 LayerTreeHostImpl::FrameData frame; |
3444 | 3423 |
3445 layer->set_will_draw_returns_false(); | 3424 layer->set_will_draw_returns_false(); |
3446 layer->ClearDidDrawCheck(); | 3425 layer->ClearDidDrawCheck(); |
3447 | 3426 |
3448 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3427 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3449 host_impl_->DrawLayers(&frame); | 3428 host_impl_->DrawLayers(&frame); |
3450 host_impl_->DidDrawAllLayers(frame); | 3429 host_impl_->DidDrawAllLayers(frame); |
3451 | 3430 |
3452 EXPECT_TRUE(layer->will_draw_called()); | 3431 EXPECT_TRUE(layer->will_draw_called()); |
3453 EXPECT_FALSE(layer->append_quads_called()); | 3432 EXPECT_FALSE(layer->append_quads_called()); |
3454 EXPECT_FALSE(layer->did_draw_called()); | 3433 EXPECT_FALSE(layer->did_draw_called()); |
3455 } | 3434 } |
3456 } | 3435 } |
3457 | 3436 |
3458 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 3437 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
3459 // The root layer is always drawn, so run this test on a child layer that | 3438 // 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. | 3439 // will be masked out by the root layer's bounds. |
3461 host_impl_->active_tree()->SetRootLayerForTesting( | 3440 host_impl_->active_tree()->SetRootLayerForTesting( |
3462 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3441 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3463 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3442 DidDrawCheckLayer* root = |
3464 host_impl_->active_tree()->root_layer_for_testing()); | 3443 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
3465 root->SetMasksToBounds(true); | 3444 root->SetMasksToBounds(true); |
3466 root->test_properties()->force_render_surface = true; | 3445 root->test_properties()->force_render_surface = true; |
3467 root->test_properties()->AddChild( | 3446 root->test_properties()->AddChild( |
3468 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3447 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3469 DidDrawCheckLayer* layer = | 3448 DidDrawCheckLayer* layer = |
3470 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3449 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3471 // Ensure visible_layer_rect for layer is empty. | 3450 // Ensure visible_layer_rect for layer is empty. |
3472 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 3451 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
3473 layer->SetBounds(gfx::Size(10, 10)); | 3452 layer->SetBounds(gfx::Size(10, 10)); |
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 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3481 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3460 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3482 host_impl_->DrawLayers(&frame); | 3461 host_impl_->DrawLayers(&frame); |
3483 host_impl_->DidDrawAllLayers(frame); | 3462 host_impl_->DidDrawAllLayers(frame); |
3484 | 3463 |
3485 EXPECT_FALSE(layer->will_draw_called()); | 3464 EXPECT_FALSE(layer->will_draw_called()); |
3486 EXPECT_FALSE(layer->did_draw_called()); | 3465 EXPECT_FALSE(layer->did_draw_called()); |
3487 | 3466 |
3488 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); | 3467 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); |
3489 | 3468 |
3490 // Ensure visible_layer_rect for layer is not empty | 3469 // Ensure visible_layer_rect for layer is not empty |
3491 layer->SetPosition(gfx::PointF()); | 3470 layer->SetPosition(gfx::PointF()); |
3492 layer->NoteLayerPropertyChanged(); | 3471 layer->NoteLayerPropertyChanged(); |
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 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3498 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3477 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3499 host_impl_->DrawLayers(&frame); | 3478 host_impl_->DrawLayers(&frame); |
3500 host_impl_->DidDrawAllLayers(frame); | 3479 host_impl_->DidDrawAllLayers(frame); |
3501 | 3480 |
3502 EXPECT_TRUE(layer->will_draw_called()); | 3481 EXPECT_TRUE(layer->will_draw_called()); |
3503 EXPECT_TRUE(layer->did_draw_called()); | 3482 EXPECT_TRUE(layer->did_draw_called()); |
3504 | 3483 |
3505 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); | 3484 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); |
3506 } | 3485 } |
3507 | 3486 |
3508 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 3487 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
3509 gfx::Size big_size(1000, 1000); | 3488 gfx::Size big_size(1000, 1000); |
3510 host_impl_->SetViewportSize(big_size); | 3489 host_impl_->SetViewportSize(big_size); |
3511 | 3490 |
3512 host_impl_->active_tree()->SetRootLayerForTesting( | 3491 host_impl_->active_tree()->SetRootLayerForTesting( |
3513 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3492 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3514 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3493 DidDrawCheckLayer* root = |
3515 host_impl_->active_tree()->root_layer_for_testing()); | 3494 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
3516 | 3495 |
3517 root->test_properties()->AddChild( | 3496 root->test_properties()->AddChild( |
3518 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3497 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3519 DidDrawCheckLayer* occluded_layer = | 3498 DidDrawCheckLayer* occluded_layer = |
3520 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3499 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3521 | 3500 |
3522 root->test_properties()->AddChild( | 3501 root->test_properties()->AddChild( |
3523 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3502 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3524 root->test_properties()->force_render_surface = true; | 3503 root->test_properties()->force_render_surface = true; |
3525 DidDrawCheckLayer* top_layer = | 3504 DidDrawCheckLayer* top_layer = |
3526 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); | 3505 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); |
3527 // This layer covers the occluded_layer above. Make this layer large so it can | 3506 // This layer covers the occluded_layer above. Make this layer large so it can |
3528 // occlude. | 3507 // occlude. |
3529 top_layer->SetBounds(big_size); | 3508 top_layer->SetBounds(big_size); |
3530 top_layer->SetContentsOpaque(true); | 3509 top_layer->SetContentsOpaque(true); |
| 3510 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3531 | 3511 |
3532 LayerTreeHostImpl::FrameData frame; | 3512 LayerTreeHostImpl::FrameData frame; |
3533 | 3513 |
3534 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3514 EXPECT_FALSE(occluded_layer->will_draw_called()); |
3535 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3515 EXPECT_FALSE(occluded_layer->did_draw_called()); |
3536 EXPECT_FALSE(top_layer->will_draw_called()); | 3516 EXPECT_FALSE(top_layer->will_draw_called()); |
3537 EXPECT_FALSE(top_layer->did_draw_called()); | 3517 EXPECT_FALSE(top_layer->did_draw_called()); |
3538 | 3518 |
3539 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3519 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3540 host_impl_->DrawLayers(&frame); | 3520 host_impl_->DrawLayers(&frame); |
3541 host_impl_->DidDrawAllLayers(frame); | 3521 host_impl_->DidDrawAllLayers(frame); |
3542 | 3522 |
3543 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3523 EXPECT_FALSE(occluded_layer->will_draw_called()); |
3544 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3524 EXPECT_FALSE(occluded_layer->did_draw_called()); |
3545 EXPECT_TRUE(top_layer->will_draw_called()); | 3525 EXPECT_TRUE(top_layer->will_draw_called()); |
3546 EXPECT_TRUE(top_layer->did_draw_called()); | 3526 EXPECT_TRUE(top_layer->did_draw_called()); |
3547 } | 3527 } |
3548 | 3528 |
3549 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3529 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
3550 host_impl_->active_tree()->SetRootLayerForTesting( | 3530 host_impl_->active_tree()->SetRootLayerForTesting( |
3551 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3531 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3552 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3532 DidDrawCheckLayer* root = |
3553 host_impl_->active_tree()->root_layer_for_testing()); | 3533 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
3554 | 3534 |
3555 root->test_properties()->AddChild( | 3535 root->test_properties()->AddChild( |
3556 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3536 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3557 root->test_properties()->force_render_surface = true; | 3537 root->test_properties()->force_render_surface = true; |
3558 DidDrawCheckLayer* layer1 = | 3538 DidDrawCheckLayer* layer1 = |
3559 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3539 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3560 | 3540 |
3561 layer1->test_properties()->AddChild( | 3541 layer1->test_properties()->AddChild( |
3562 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3542 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3563 DidDrawCheckLayer* layer2 = | 3543 DidDrawCheckLayer* layer2 = |
3564 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); | 3544 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); |
3565 | 3545 |
3566 layer1->test_properties()->force_render_surface = true; | 3546 layer1->test_properties()->force_render_surface = true; |
3567 layer1->test_properties()->should_flatten_transform = true; | 3547 layer1->test_properties()->should_flatten_transform = true; |
| 3548 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3568 | 3549 |
3569 EXPECT_FALSE(root->did_draw_called()); | 3550 EXPECT_FALSE(root->did_draw_called()); |
3570 EXPECT_FALSE(layer1->did_draw_called()); | 3551 EXPECT_FALSE(layer1->did_draw_called()); |
3571 EXPECT_FALSE(layer2->did_draw_called()); | 3552 EXPECT_FALSE(layer2->did_draw_called()); |
3572 | 3553 |
3573 LayerTreeHostImpl::FrameData frame; | 3554 LayerTreeHostImpl::FrameData frame; |
3574 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3555 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
3575 host_impl_->active_tree()->root_layer_for_testing()); | 3556 *host_impl_->active_tree()->begin()); |
3576 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3557 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3577 host_impl_->DrawLayers(&frame); | 3558 host_impl_->DrawLayers(&frame); |
3578 host_impl_->DidDrawAllLayers(frame); | 3559 host_impl_->DidDrawAllLayers(frame); |
3579 | 3560 |
3580 EXPECT_TRUE(root->did_draw_called()); | 3561 EXPECT_TRUE(root->did_draw_called()); |
3581 EXPECT_TRUE(layer1->did_draw_called()); | 3562 EXPECT_TRUE(layer1->did_draw_called()); |
3582 EXPECT_TRUE(layer2->did_draw_called()); | 3563 EXPECT_TRUE(layer2->did_draw_called()); |
3583 | 3564 |
3584 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 3565 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
3585 EXPECT_TRUE(layer1->render_surface()); | 3566 EXPECT_TRUE(layer1->render_surface()); |
3586 } | 3567 } |
(...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. | 3695 // 16. High res required is higher priority than animating missing tiles. |
3715 cases.push_back( | 3696 cases.push_back( |
3716 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); | 3697 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
3717 cases.back().high_res_required = true; | 3698 cases.back().high_res_required = true; |
3718 cases.back().layer_between.has_missing_tile = true; | 3699 cases.back().layer_between.has_missing_tile = true; |
3719 cases.back().layer_before.has_missing_tile = true; | 3700 cases.back().layer_before.has_missing_tile = true; |
3720 cases.back().layer_before.is_animating = true; | 3701 cases.back().layer_before.is_animating = true; |
3721 | 3702 |
3722 host_impl_->active_tree()->SetRootLayerForTesting( | 3703 host_impl_->active_tree()->SetRootLayerForTesting( |
3723 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3704 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3724 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3705 DidDrawCheckLayer* root = |
3725 host_impl_->active_tree()->root_layer_for_testing()); | 3706 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
3726 root->test_properties()->force_render_surface = true; | 3707 root->test_properties()->force_render_surface = true; |
3727 | 3708 |
3728 LayerTreeHostImpl::FrameData frame; | 3709 LayerTreeHostImpl::FrameData frame; |
3729 SetNeedsRebuildPropertyTrees(); | 3710 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3730 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3711 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3731 host_impl_->DrawLayers(&frame); | 3712 host_impl_->DrawLayers(&frame); |
3732 host_impl_->DidDrawAllLayers(frame); | 3713 host_impl_->DidDrawAllLayers(frame); |
3733 host_impl_->SwapBuffers(frame); | 3714 host_impl_->SwapBuffers(frame); |
3734 | 3715 |
3735 for (size_t i = 0; i < cases.size(); ++i) { | 3716 for (size_t i = 0; i < cases.size(); ++i) { |
3736 // Clean up host_impl_ state. | 3717 // Clean up host_impl_ state. |
3737 const auto& testcase = cases[i]; | 3718 const auto& testcase = cases[i]; |
3738 std::vector<LayerImpl*> to_remove; | 3719 std::vector<LayerImpl*> to_remove; |
3739 for (const auto& child : root->test_properties()->children) | 3720 for (const auto& child : root->test_properties()->children) |
3740 to_remove.push_back(child); | 3721 to_remove.push_back(child); |
(...skipping 27 matching lines...) Expand all Loading... |
3768 | 3749 |
3769 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( | 3750 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( |
3770 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3751 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
3771 testcase.layer_after.has_incomplete_tile, | 3752 testcase.layer_after.has_incomplete_tile, |
3772 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3753 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
3773 timeline())); | 3754 timeline())); |
3774 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( | 3755 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
3775 root->test_properties()->children.back()); | 3756 root->test_properties()->children.back()); |
3776 if (testcase.layer_after.has_copy_request) | 3757 if (testcase.layer_after.has_copy_request) |
3777 after->AddCopyRequest(); | 3758 after->AddCopyRequest(); |
| 3759 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3778 | 3760 |
3779 if (testcase.high_res_required) | 3761 if (testcase.high_res_required) |
3780 host_impl_->SetRequiresHighResToDraw(); | 3762 host_impl_->SetRequiresHighResToDraw(); |
3781 | 3763 |
3782 LayerTreeHostImpl::FrameData frame; | 3764 LayerTreeHostImpl::FrameData frame; |
3783 SetNeedsRebuildPropertyTrees(); | 3765 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
3784 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | |
3785 host_impl_->DrawLayers(&frame); | 3766 host_impl_->DrawLayers(&frame); |
3786 host_impl_->DidDrawAllLayers(frame); | 3767 host_impl_->DidDrawAllLayers(frame); |
3787 host_impl_->SwapBuffers(frame); | 3768 host_impl_->SwapBuffers(frame); |
3788 } | 3769 } |
3789 } | 3770 } |
3790 | 3771 |
3791 TEST_F(LayerTreeHostImplTest, | 3772 TEST_F(LayerTreeHostImplTest, |
3792 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3773 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
3793 CreateHostImpl(DefaultSettings(), | 3774 CreateHostImpl(DefaultSettings(), |
3794 FakeOutputSurface::CreateSoftware( | 3775 FakeOutputSurface::CreateSoftware( |
(...skipping 21 matching lines...) Expand all Loading... |
3816 // 3. High res required with missing tile. | 3797 // 3. High res required with missing tile. |
3817 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3798 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
3818 cases.back().high_res_required = true; | 3799 cases.back().high_res_required = true; |
3819 cases.back().layer_between.has_missing_tile = true; | 3800 cases.back().layer_between.has_missing_tile = true; |
3820 | 3801 |
3821 host_impl_->active_tree()->SetRootLayerForTesting( | 3802 host_impl_->active_tree()->SetRootLayerForTesting( |
3822 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3803 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3823 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3804 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3824 host_impl_->active_tree()->root_layer_for_testing()); | 3805 host_impl_->active_tree()->root_layer_for_testing()); |
3825 root->test_properties()->force_render_surface = true; | 3806 root->test_properties()->force_render_surface = true; |
| 3807 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3826 | 3808 |
3827 SetNeedsRebuildPropertyTrees(); | |
3828 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3809 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3829 resourceless_software_draw); | 3810 resourceless_software_draw); |
3830 | 3811 |
3831 for (size_t i = 0; i < cases.size(); ++i) { | 3812 for (size_t i = 0; i < cases.size(); ++i) { |
3832 const auto& testcase = cases[i]; | 3813 const auto& testcase = cases[i]; |
3833 std::vector<LayerImpl*> to_remove; | 3814 std::vector<LayerImpl*> to_remove; |
3834 for (const auto& child : root->test_properties()->children) | 3815 for (const auto& child : root->test_properties()->children) |
3835 to_remove.push_back(child); | 3816 to_remove.push_back(child); |
3836 for (auto* child : to_remove) | 3817 for (auto* child : to_remove) |
3837 root->test_properties()->RemoveChild(child); | 3818 root->test_properties()->RemoveChild(child); |
(...skipping 24 matching lines...) Expand all Loading... |
3862 | 3843 |
3863 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( | 3844 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create( |
3864 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3845 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
3865 testcase.layer_after.has_incomplete_tile, | 3846 testcase.layer_after.has_incomplete_tile, |
3866 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3847 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
3867 timeline())); | 3848 timeline())); |
3868 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( | 3849 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
3869 root->test_properties()->children.back()); | 3850 root->test_properties()->children.back()); |
3870 if (testcase.layer_after.has_copy_request) | 3851 if (testcase.layer_after.has_copy_request) |
3871 after->AddCopyRequest(); | 3852 after->AddCopyRequest(); |
| 3853 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3872 | 3854 |
3873 if (testcase.high_res_required) | 3855 if (testcase.high_res_required) |
3874 host_impl_->SetRequiresHighResToDraw(); | 3856 host_impl_->SetRequiresHighResToDraw(); |
3875 | 3857 |
3876 SetNeedsRebuildPropertyTrees(); | |
3877 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3858 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3878 resourceless_software_draw); | 3859 resourceless_software_draw); |
3879 } | 3860 } |
3880 } | 3861 } |
3881 | 3862 |
3882 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3863 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
3883 std::unique_ptr<LayerImpl> root = | 3864 std::unique_ptr<LayerImpl> root = |
3884 LayerImpl::Create(host_impl_->active_tree(), 1); | 3865 LayerImpl::Create(host_impl_->active_tree(), 1); |
3885 root->SetScrollClipLayer(Layer::INVALID_ID); | 3866 root->SetScrollClipLayer(Layer::INVALID_ID); |
3886 root->test_properties()->force_render_surface = true; | 3867 root->test_properties()->force_render_surface = true; |
3887 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 3868 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
3888 SetNeedsRebuildPropertyTrees(); | 3869 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 3870 |
3889 DrawFrame(); | 3871 DrawFrame(); |
3890 | 3872 |
3891 // Scroll event is ignored because layer is not scrollable. | 3873 // Scroll event is ignored because layer is not scrollable. |
3892 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3874 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
3893 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3875 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
3894 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3876 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
3895 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 3877 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
3896 status.main_thread_scrolling_reasons); | 3878 status.main_thread_scrolling_reasons); |
3897 EXPECT_FALSE(did_request_redraw_); | 3879 EXPECT_FALSE(did_request_redraw_); |
3898 EXPECT_FALSE(did_request_commit_); | 3880 EXPECT_FALSE(did_request_commit_); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 | 4013 |
4032 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 4014 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
4033 | 4015 |
4034 // Create a content layer beneath the outer viewport scroll layer. | 4016 // Create a content layer beneath the outer viewport scroll layer. |
4035 int id = host_impl_->OuterViewportScrollLayer()->id(); | 4017 int id = host_impl_->OuterViewportScrollLayer()->id(); |
4036 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( | 4018 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( |
4037 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 4019 LayerImpl::Create(host_impl_->active_tree(), id + 2)); |
4038 LayerImpl* content = | 4020 LayerImpl* content = |
4039 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; | 4021 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; |
4040 content->SetBounds(gfx::Size(50, 50)); | 4022 content->SetBounds(gfx::Size(50, 50)); |
| 4023 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
4041 | 4024 |
4042 SetNeedsRebuildPropertyTrees(); | |
4043 DrawFrame(); | 4025 DrawFrame(); |
4044 | 4026 |
4045 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 4027 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
4046 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 4028 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
4047 | 4029 |
4048 // The top controls should start off showing so the viewport should be shrunk. | 4030 // The top controls should start off showing so the viewport should be shrunk. |
4049 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 4031 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
4050 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); | 4032 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); |
4051 | 4033 |
4052 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); | 4034 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4336 child->test_properties()->is_container_for_fixed_position_layers = true; | 4318 child->test_properties()->is_container_for_fixed_position_layers = true; |
4337 | 4319 |
4338 // scroll child to limit | 4320 // scroll child to limit |
4339 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); | 4321 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); |
4340 child_clip->test_properties()->AddChild(std::move(child)); | 4322 child_clip->test_properties()->AddChild(std::move(child)); |
4341 outer_viewport_scroll_layer->test_properties()->AddChild( | 4323 outer_viewport_scroll_layer->test_properties()->AddChild( |
4342 std::move(child_clip)); | 4324 std::move(child_clip)); |
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(); | 4328 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
4348 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4329 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4349 host_impl_ | 4330 host_impl_ |
4350 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4331 ->ScrollBegin(BeginState(gfx::Point()).get(), |
4351 InputHandler::TOUCHSCREEN) | 4332 InputHandler::TOUCHSCREEN) |
4352 .thread); | 4333 .thread); |
4353 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4334 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
4354 host_impl_->ScrollEnd(EndState().get()); | 4335 host_impl_->ScrollEnd(EndState().get()); |
4355 | 4336 |
4356 // Top controls should be hidden | 4337 // Top controls should be hidden |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4829 LayerImpl::Create(host_impl_->active_tree(), 2); | 4810 LayerImpl::Create(host_impl_->active_tree(), 2); |
4830 scroll_layer->SetScrollClipLayer(3); | 4811 scroll_layer->SetScrollClipLayer(3); |
4831 scroll_layer->SetBounds(contents_size); | 4812 scroll_layer->SetBounds(contents_size); |
4832 scroll_layer->SetPosition(gfx::PointF()); | 4813 scroll_layer->SetPosition(gfx::PointF()); |
4833 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4814 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
4834 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4815 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
4835 | 4816 |
4836 scroll_clip_layer->test_properties()->force_render_surface = true; | 4817 scroll_clip_layer->test_properties()->force_render_surface = true; |
4837 host_impl_->active_tree()->SetRootLayerForTesting( | 4818 host_impl_->active_tree()->SetRootLayerForTesting( |
4838 std::move(scroll_clip_layer)); | 4819 std::move(scroll_clip_layer)); |
| 4820 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4821 |
4839 host_impl_->SetViewportSize(surface_size); | 4822 host_impl_->SetViewportSize(surface_size); |
4840 SetNeedsRebuildPropertyTrees(); | |
4841 DrawFrame(); | 4823 DrawFrame(); |
4842 | 4824 |
4843 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4825 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4844 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4826 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4845 InputHandler::WHEEL) | 4827 InputHandler::WHEEL) |
4846 .thread); | 4828 .thread); |
4847 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4829 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4848 host_impl_->ScrollEnd(EndState().get()); | 4830 host_impl_->ScrollEnd(EndState().get()); |
4849 EXPECT_TRUE(did_request_redraw_); | 4831 EXPECT_TRUE(did_request_redraw_); |
4850 EXPECT_TRUE(did_request_commit_); | 4832 EXPECT_TRUE(did_request_commit_); |
4851 } | 4833 } |
4852 | 4834 |
4853 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4835 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4854 gfx::Size surface_size(10, 10); | 4836 gfx::Size surface_size(10, 10); |
4855 gfx::Size contents_size(20, 20); | 4837 gfx::Size contents_size(20, 20); |
4856 std::unique_ptr<LayerImpl> root = | 4838 std::unique_ptr<LayerImpl> root = |
4857 LayerImpl::Create(host_impl_->active_tree(), 1); | 4839 LayerImpl::Create(host_impl_->active_tree(), 1); |
4858 root->SetBounds(surface_size); | 4840 root->SetBounds(surface_size); |
4859 root->test_properties()->AddChild( | 4841 root->test_properties()->AddChild( |
4860 CreateScrollableLayer(2, contents_size, root.get())); | 4842 CreateScrollableLayer(2, contents_size, root.get())); |
4861 root->test_properties()->force_render_surface = true; | 4843 root->test_properties()->force_render_surface = true; |
4862 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4844 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 4845 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4846 |
4863 host_impl_->SetViewportSize(surface_size); | 4847 host_impl_->SetViewportSize(surface_size); |
4864 SetNeedsRebuildPropertyTrees(); | |
4865 DrawFrame(); | 4848 DrawFrame(); |
4866 | 4849 |
4867 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4850 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4868 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4851 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4869 InputHandler::WHEEL) | 4852 InputHandler::WHEEL) |
4870 .thread); | 4853 .thread); |
4871 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4854 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4872 host_impl_->ScrollEnd(EndState().get()); | 4855 host_impl_->ScrollEnd(EndState().get()); |
4873 EXPECT_TRUE(did_request_redraw_); | 4856 EXPECT_TRUE(did_request_redraw_); |
4874 EXPECT_TRUE(did_request_commit_); | 4857 EXPECT_TRUE(did_request_commit_); |
4875 } | 4858 } |
4876 | 4859 |
4877 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4860 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4878 gfx::Size surface_size(10, 10); | 4861 gfx::Size surface_size(10, 10); |
4879 std::unique_ptr<LayerImpl> root = | 4862 std::unique_ptr<LayerImpl> root = |
4880 LayerImpl::Create(host_impl_->active_tree(), 1); | 4863 LayerImpl::Create(host_impl_->active_tree(), 1); |
4881 root->test_properties()->AddChild( | 4864 root->test_properties()->AddChild( |
4882 CreateScrollableLayer(2, surface_size, root.get())); | 4865 CreateScrollableLayer(2, surface_size, root.get())); |
4883 root->test_properties()->force_render_surface = true; | 4866 root->test_properties()->force_render_surface = true; |
4884 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4867 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 4868 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4869 |
4885 host_impl_->SetViewportSize(surface_size); | 4870 host_impl_->SetViewportSize(surface_size); |
4886 SetNeedsRebuildPropertyTrees(); | |
4887 DrawFrame(); | 4871 DrawFrame(); |
4888 | 4872 |
4889 // Scroll event is ignored because the input coordinate is outside the layer | 4873 // Scroll event is ignored because the input coordinate is outside the layer |
4890 // boundaries. | 4874 // boundaries. |
4891 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4875 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4892 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4876 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
4893 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4877 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4894 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4878 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4895 status.main_thread_scrolling_reasons); | 4879 status.main_thread_scrolling_reasons); |
4896 | 4880 |
4897 EXPECT_FALSE(did_request_redraw_); | 4881 EXPECT_FALSE(did_request_redraw_); |
4898 EXPECT_FALSE(did_request_commit_); | 4882 EXPECT_FALSE(did_request_commit_); |
4899 } | 4883 } |
4900 | 4884 |
4901 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4885 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
4902 gfx::Size surface_size(10, 10); | 4886 gfx::Size surface_size(10, 10); |
4903 std::unique_ptr<LayerImpl> root = | 4887 std::unique_ptr<LayerImpl> root = |
4904 LayerImpl::Create(host_impl_->active_tree(), 1); | 4888 LayerImpl::Create(host_impl_->active_tree(), 1); |
4905 root->test_properties()->force_render_surface = true; | 4889 root->test_properties()->force_render_surface = true; |
4906 std::unique_ptr<LayerImpl> child = | 4890 std::unique_ptr<LayerImpl> child = |
4907 CreateScrollableLayer(2, surface_size, root.get()); | 4891 CreateScrollableLayer(2, surface_size, root.get()); |
4908 host_impl_->SetViewportSize(surface_size); | |
4909 | 4892 |
4910 gfx::Transform matrix; | 4893 gfx::Transform matrix; |
4911 matrix.RotateAboutXAxis(180.0); | 4894 matrix.RotateAboutXAxis(180.0); |
4912 child->SetTransform(matrix); | 4895 child->SetTransform(matrix); |
4913 child->test_properties()->double_sided = false; | 4896 child->test_properties()->double_sided = false; |
4914 | 4897 |
4915 root->test_properties()->AddChild(std::move(child)); | 4898 root->test_properties()->AddChild(std::move(child)); |
4916 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 4899 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
4917 SetNeedsRebuildPropertyTrees(); | 4900 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4901 |
| 4902 host_impl_->SetViewportSize(surface_size); |
4918 DrawFrame(); | 4903 DrawFrame(); |
4919 | 4904 |
4920 // Scroll event is ignored because the scrollable layer is not facing the | 4905 // Scroll event is ignored because the scrollable layer is not facing the |
4921 // viewer and there is nothing scrollable behind it. | 4906 // viewer and there is nothing scrollable behind it. |
4922 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4907 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4923 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4908 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
4924 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4909 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4925 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4910 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4926 status.main_thread_scrolling_reasons); | 4911 status.main_thread_scrolling_reasons); |
4927 | 4912 |
(...skipping 13 matching lines...) Expand all Loading... |
4941 | 4926 |
4942 // Note: we can use the same clip layer for both since both calls to | 4927 // Note: we can use the same clip layer for both since both calls to |
4943 // CreateScrollableLayer() use the same surface size. | 4928 // CreateScrollableLayer() use the same surface size. |
4944 std::unique_ptr<LayerImpl> scroll_layer = | 4929 std::unique_ptr<LayerImpl> scroll_layer = |
4945 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4930 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
4946 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4931 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
4947 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4932 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
4948 clip_layer->test_properties()->force_render_surface = true; | 4933 clip_layer->test_properties()->force_render_surface = true; |
4949 | 4934 |
4950 host_impl_->active_tree()->SetRootLayerForTesting(std::move(clip_layer)); | 4935 host_impl_->active_tree()->SetRootLayerForTesting(std::move(clip_layer)); |
| 4936 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4937 |
4951 host_impl_->SetViewportSize(surface_size); | 4938 host_impl_->SetViewportSize(surface_size); |
4952 SetNeedsRebuildPropertyTrees(); | |
4953 DrawFrame(); | 4939 DrawFrame(); |
4954 | 4940 |
4955 // Scrolling fails because the content layer is asking to be scrolled on the | 4941 // Scrolling fails because the content layer is asking to be scrolled on the |
4956 // main thread. | 4942 // main thread. |
4957 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4943 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4958 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4944 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
4959 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 4945 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
4960 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 4946 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
4961 status.main_thread_scrolling_reasons); | 4947 status.main_thread_scrolling_reasons); |
4962 } | 4948 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5016 SetupScrollAndContentsLayers(viewport_size); | 5002 SetupScrollAndContentsLayers(viewport_size); |
5017 | 5003 |
5018 // Setup the layers so that the outer viewport is scrollable. | 5004 // Setup the layers so that the outer viewport is scrollable. |
5019 host_impl_->active_tree() | 5005 host_impl_->active_tree() |
5020 ->InnerViewportScrollLayer() | 5006 ->InnerViewportScrollLayer() |
5021 ->test_properties() | 5007 ->test_properties() |
5022 ->parent->SetBounds(viewport_size); | 5008 ->parent->SetBounds(viewport_size); |
5023 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 5009 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
5024 gfx::Size(40, 40)); | 5010 gfx::Size(40, 40)); |
5025 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 5011 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 5012 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 5013 |
5026 DrawFrame(); | 5014 DrawFrame(); |
5027 | 5015 |
5028 LayerImpl* root_scroll = | 5016 LayerImpl* root_scroll = |
5029 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5017 host_impl_->active_tree()->OuterViewportScrollLayer(); |
5030 LayerImpl* inner_scroll = | 5018 LayerImpl* inner_scroll = |
5031 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5019 host_impl_->active_tree()->InnerViewportScrollLayer(); |
5032 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5020 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
5033 | 5021 |
5034 gfx::Vector2d scroll_delta(0, 10); | 5022 gfx::Vector2d scroll_delta(0, 10); |
5035 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5023 gfx::Vector2d expected_scroll_delta = scroll_delta; |
5036 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5024 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
5037 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5025 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5038 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5026 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5039 InputHandler::WHEEL) | 5027 InputHandler::WHEEL) |
5040 .thread); | 5028 .thread); |
5041 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5029 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5042 host_impl_->ScrollEnd(EndState().get()); | 5030 host_impl_->ScrollEnd(EndState().get()); |
5043 | 5031 |
5044 // Set new page scale on impl thread by pinching. | 5032 // Set new page scale on impl thread by pinching. |
5045 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5033 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5046 InputHandler::TOUCHSCREEN); | 5034 InputHandler::TOUCHSCREEN); |
5047 host_impl_->PinchGestureBegin(); | 5035 host_impl_->PinchGestureBegin(); |
5048 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 5036 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
5049 host_impl_->PinchGestureEnd(); | 5037 host_impl_->PinchGestureEnd(); |
5050 host_impl_->ScrollEnd(EndState().get()); | 5038 host_impl_->ScrollEnd(EndState().get()); |
| 5039 |
5051 DrawOneFrame(); | 5040 DrawOneFrame(); |
5052 | 5041 |
5053 // The scroll delta is not scaled because the main thread did not scale. | 5042 // The scroll delta is not scaled because the main thread did not scale. |
5054 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5043 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5055 host_impl_->ProcessScrollDeltas(); | 5044 host_impl_->ProcessScrollDeltas(); |
5056 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5045 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
5057 expected_scroll_delta)); | 5046 expected_scroll_delta)); |
5058 | 5047 |
5059 // The scroll range should also have been updated. | 5048 // The scroll range should also have been updated. |
5060 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); | 5049 EXPECT_EQ(expected_max_scroll, root_scroll->MaxScrollOffset()); |
(...skipping 22 matching lines...) Expand all Loading... |
5083 | 5072 |
5084 std::unique_ptr<LayerImpl> scrollable_child_clip = | 5073 std::unique_ptr<LayerImpl> scrollable_child_clip = |
5085 LayerImpl::Create(host_impl_->active_tree(), 6); | 5074 LayerImpl::Create(host_impl_->active_tree(), 6); |
5086 std::unique_ptr<LayerImpl> scrollable_child = | 5075 std::unique_ptr<LayerImpl> scrollable_child = |
5087 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 5076 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
5088 scrollable_child_clip->test_properties()->AddChild( | 5077 scrollable_child_clip->test_properties()->AddChild( |
5089 std::move(scrollable_child)); | 5078 std::move(scrollable_child)); |
5090 child->test_properties()->AddChild(std::move(scrollable_child_clip)); | 5079 child->test_properties()->AddChild(std::move(scrollable_child_clip)); |
5091 LayerImpl* grand_child = child->test_properties()->children[0]; | 5080 LayerImpl* grand_child = child->test_properties()->children[0]; |
5092 grand_child->SetDrawsContent(true); | 5081 grand_child->SetDrawsContent(true); |
| 5082 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5093 | 5083 |
5094 // Set new page scale on impl thread by pinching. | 5084 // Set new page scale on impl thread by pinching. |
5095 SetNeedsRebuildPropertyTrees(); | |
5096 RebuildPropertyTrees(); | |
5097 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5085 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5098 InputHandler::TOUCHSCREEN); | 5086 InputHandler::TOUCHSCREEN); |
5099 host_impl_->PinchGestureBegin(); | 5087 host_impl_->PinchGestureBegin(); |
5100 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 5088 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
5101 host_impl_->PinchGestureEnd(); | 5089 host_impl_->PinchGestureEnd(); |
5102 host_impl_->ScrollEnd(EndState().get()); | 5090 host_impl_->ScrollEnd(EndState().get()); |
5103 DrawOneFrame(); | 5091 DrawOneFrame(); |
5104 | 5092 |
5105 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 5093 // 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. | 5094 // the page scale delta on the root layer is applied hierarchically. |
5107 LayerTreeHostImpl::FrameData frame; | 5095 LayerTreeHostImpl::FrameData frame; |
5108 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5096 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5109 host_impl_->DrawLayers(&frame); | 5097 host_impl_->DrawLayers(&frame); |
5110 host_impl_->DidDrawAllLayers(frame); | 5098 host_impl_->DidDrawAllLayers(frame); |
5111 | 5099 |
5112 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0)); | 5100 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0)); |
5113 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1)); | 5101 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1)); |
5114 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0)); | 5102 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0)); |
5115 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1)); | 5103 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1)); |
5116 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0)); | 5104 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0)); |
5117 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1)); | 5105 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1)); |
5118 EXPECT_EQ(new_page_scale, | 5106 EXPECT_EQ(new_page_scale, |
5119 grand_child->DrawTransform().matrix().getDouble(0, 0)); | 5107 grand_child->DrawTransform().matrix().getDouble(0, 0)); |
5120 EXPECT_EQ(new_page_scale, | 5108 EXPECT_EQ(new_page_scale, |
5121 grand_child->DrawTransform().matrix().getDouble(1, 1)); | 5109 grand_child->DrawTransform().matrix().getDouble(1, 1)); |
5122 } | 5110 } |
5123 | 5111 |
5124 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 5112 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
5125 SetupScrollAndContentsLayers(gfx::Size(30, 30)); | 5113 SetupScrollAndContentsLayers(gfx::Size(30, 30)); |
5126 | 5114 |
5127 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 5115 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
5128 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 5116 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
5129 | 5117 |
5130 // Make the outer scroll layer scrollable. | 5118 // Make the outer scroll layer scrollable. |
5131 outer_scroll->SetBounds(gfx::Size(50, 50)); | 5119 outer_scroll->SetBounds(gfx::Size(50, 50)); |
| 5120 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5132 | 5121 |
5133 DrawFrame(); | 5122 DrawFrame(); |
5134 | 5123 |
5135 gfx::Vector2d scroll_delta(0, 10); | 5124 gfx::Vector2d scroll_delta(0, 10); |
5136 gfx::Vector2d expected_scroll_delta(scroll_delta); | 5125 gfx::Vector2d expected_scroll_delta(scroll_delta); |
5137 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); | 5126 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); |
5138 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5139 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5128 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5140 InputHandler::WHEEL) | 5129 InputHandler::WHEEL) |
5141 .thread); | 5130 .thread); |
5142 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5131 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5143 host_impl_->ScrollEnd(EndState().get()); | 5132 host_impl_->ScrollEnd(EndState().get()); |
5144 | 5133 |
5145 float page_scale = 2.f; | 5134 float page_scale = 2.f; |
5146 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 5135 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
5147 page_scale); | 5136 page_scale); |
| 5137 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5148 | 5138 |
5149 DrawOneFrame(); | 5139 DrawOneFrame(); |
5150 | 5140 |
5151 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5141 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5152 host_impl_->ProcessScrollDeltas(); | 5142 host_impl_->ProcessScrollDeltas(); |
5153 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5143 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
5154 expected_scroll_delta)); | 5144 expected_scroll_delta)); |
5155 | 5145 |
5156 // The scroll range should not have changed. | 5146 // The scroll range should not have changed. |
5157 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); | 5147 EXPECT_EQ(outer_scroll->MaxScrollOffset(), expected_max_scroll); |
(...skipping 16 matching lines...) Expand all Loading... |
5174 CreateScrollableLayer(3, content_size, root.get()); | 5164 CreateScrollableLayer(3, content_size, root.get()); |
5175 | 5165 |
5176 std::unique_ptr<LayerImpl> child = | 5166 std::unique_ptr<LayerImpl> child = |
5177 CreateScrollableLayer(2, content_size, root.get()); | 5167 CreateScrollableLayer(2, content_size, root.get()); |
5178 LayerImpl* grand_child_layer = grand_child.get(); | 5168 LayerImpl* grand_child_layer = grand_child.get(); |
5179 child->test_properties()->AddChild(std::move(grand_child)); | 5169 child->test_properties()->AddChild(std::move(grand_child)); |
5180 | 5170 |
5181 LayerImpl* child_layer = child.get(); | 5171 LayerImpl* child_layer = child.get(); |
5182 root->test_properties()->AddChild(std::move(child)); | 5172 root->test_properties()->AddChild(std::move(child)); |
5183 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 5173 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 5174 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5184 host_impl_->active_tree()->DidBecomeActive(); | 5175 host_impl_->active_tree()->DidBecomeActive(); |
5185 host_impl_->SetViewportSize(surface_size); | 5176 |
5186 grand_child_layer->layer_tree_impl() | 5177 grand_child_layer->layer_tree_impl() |
5187 ->property_trees() | 5178 ->property_trees() |
5188 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5179 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
5189 gfx::ScrollOffset(0, 5)); | 5180 gfx::ScrollOffset(0, 5)); |
5190 child_layer->layer_tree_impl() | 5181 child_layer->layer_tree_impl() |
5191 ->property_trees() | 5182 ->property_trees() |
5192 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5183 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
5193 gfx::ScrollOffset(3, 0)); | 5184 gfx::ScrollOffset(3, 0)); |
5194 | 5185 |
5195 SetNeedsRebuildPropertyTrees(); | 5186 host_impl_->SetViewportSize(surface_size); |
5196 DrawFrame(); | 5187 DrawFrame(); |
5197 { | 5188 { |
5198 gfx::Vector2d scroll_delta(-8, -7); | 5189 gfx::Vector2d scroll_delta(-8, -7); |
5199 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5190 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5200 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5191 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5201 InputHandler::WHEEL) | 5192 InputHandler::WHEEL) |
5202 .thread); | 5193 .thread); |
5203 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5194 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5204 host_impl_->ScrollEnd(EndState().get()); | 5195 host_impl_->ScrollEnd(EndState().get()); |
5205 | 5196 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 CreateScrollableLayer(4, surface_size, root_clip.get()); | 5233 CreateScrollableLayer(4, surface_size, root_clip.get()); |
5243 LayerImpl* grand_child_layer = grand_child.get(); | 5234 LayerImpl* grand_child_layer = grand_child.get(); |
5244 child->test_properties()->AddChild(std::move(grand_child)); | 5235 child->test_properties()->AddChild(std::move(grand_child)); |
5245 | 5236 |
5246 LayerImpl* child_layer = child.get(); | 5237 LayerImpl* child_layer = child.get(); |
5247 root_scrolling->test_properties()->AddChild(std::move(child)); | 5238 root_scrolling->test_properties()->AddChild(std::move(child)); |
5248 root_clip->test_properties()->AddChild(std::move(root_scrolling)); | 5239 root_clip->test_properties()->AddChild(std::move(root_scrolling)); |
5249 EXPECT_EQ(viewport_size, root_clip->bounds()); | 5240 EXPECT_EQ(viewport_size, root_clip->bounds()); |
5250 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5241 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5251 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5242 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
| 5243 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5252 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5244 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5253 Layer::INVALID_ID); | 5245 Layer::INVALID_ID); |
5254 host_impl_->active_tree()->DidBecomeActive(); | 5246 host_impl_->active_tree()->DidBecomeActive(); |
5255 host_impl_->SetViewportSize(viewport_size); | 5247 host_impl_->SetViewportSize(viewport_size); |
5256 | 5248 |
5257 grand_child_layer->layer_tree_impl() | 5249 grand_child_layer->layer_tree_impl() |
5258 ->property_trees() | 5250 ->property_trees() |
5259 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5251 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
5260 gfx::ScrollOffset(0, 2)); | 5252 gfx::ScrollOffset(0, 2)); |
5261 child_layer->layer_tree_impl() | 5253 child_layer->layer_tree_impl() |
5262 ->property_trees() | 5254 ->property_trees() |
5263 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5255 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
5264 gfx::ScrollOffset(0, 3)); | 5256 gfx::ScrollOffset(0, 3)); |
5265 | 5257 |
5266 SetNeedsRebuildPropertyTrees(); | |
5267 DrawFrame(); | 5258 DrawFrame(); |
5268 { | 5259 { |
5269 gfx::Vector2d scroll_delta(0, -10); | 5260 gfx::Vector2d scroll_delta(0, -10); |
5270 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5261 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5271 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5262 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5272 InputHandler::NON_BUBBLING_GESTURE) | 5263 InputHandler::NON_BUBBLING_GESTURE) |
5273 .thread); | 5264 .thread); |
5274 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5265 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5275 host_impl_->ScrollEnd(EndState().get()); | 5266 host_impl_->ScrollEnd(EndState().get()); |
5276 | 5267 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5373 std::unique_ptr<LayerImpl> child = | 5364 std::unique_ptr<LayerImpl> child = |
5374 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5365 CreateScrollableLayer(2, content_size, root_scroll.get()); |
5375 child->test_properties()->is_container_for_fixed_position_layers = true; | 5366 child->test_properties()->is_container_for_fixed_position_layers = true; |
5376 root_scroll->SetBounds(content_size); | 5367 root_scroll->SetBounds(content_size); |
5377 | 5368 |
5378 int root_scroll_id = root_scroll->id(); | 5369 int root_scroll_id = root_scroll->id(); |
5379 root_scroll->test_properties()->AddChild(std::move(child)); | 5370 root_scroll->test_properties()->AddChild(std::move(child)); |
5380 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5371 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
5381 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5372 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5382 | 5373 |
5383 host_impl_->SetViewportSize(surface_size); | |
5384 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5374 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5385 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5375 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
5386 Layer::INVALID_ID); | 5376 Layer::INVALID_ID); |
| 5377 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5387 host_impl_->active_tree()->DidBecomeActive(); | 5378 host_impl_->active_tree()->DidBecomeActive(); |
5388 SetNeedsRebuildPropertyTrees(); | 5379 |
| 5380 host_impl_->SetViewportSize(surface_size); |
5389 DrawFrame(); | 5381 DrawFrame(); |
5390 { | 5382 { |
5391 gfx::Vector2d scroll_delta(0, 4); | 5383 gfx::Vector2d scroll_delta(0, 4); |
5392 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5384 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5393 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5385 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5394 InputHandler::WHEEL) | 5386 InputHandler::WHEEL) |
5395 .thread); | 5387 .thread); |
5396 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5388 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5397 host_impl_->ScrollEnd(EndState().get()); | 5389 host_impl_->ScrollEnd(EndState().get()); |
5398 | 5390 |
(...skipping 15 matching lines...) Expand all Loading... |
5414 LayerImpl::Create(host_impl_->active_tree(), 2); | 5406 LayerImpl::Create(host_impl_->active_tree(), 2); |
5415 std::unique_ptr<LayerImpl> root_scroll = | 5407 std::unique_ptr<LayerImpl> root_scroll = |
5416 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5408 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5417 root_clip->test_properties()->force_render_surface = true; | 5409 root_clip->test_properties()->force_render_surface = true; |
5418 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 5410 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
5419 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5411 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
5420 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5412 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5421 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5413 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5422 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5414 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5423 Layer::INVALID_ID); | 5415 Layer::INVALID_ID); |
| 5416 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5424 host_impl_->active_tree()->DidBecomeActive(); | 5417 host_impl_->active_tree()->DidBecomeActive(); |
| 5418 |
5425 host_impl_->SetViewportSize(surface_size); | 5419 host_impl_->SetViewportSize(surface_size); |
5426 | 5420 |
5427 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5421 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
5428 // synchronization. | 5422 // synchronization. |
5429 SetNeedsRebuildPropertyTrees(); | |
5430 DrawFrame(); | 5423 DrawFrame(); |
| 5424 |
5431 host_impl_->active_tree()->DetachLayers(); | 5425 host_impl_->active_tree()->DetachLayers(); |
5432 std::unique_ptr<LayerImpl> root_ptr2 = | 5426 std::unique_ptr<LayerImpl> root_ptr2 = |
5433 LayerImpl::Create(host_impl_->active_tree(), 4); | 5427 LayerImpl::Create(host_impl_->active_tree(), 4); |
5434 std::unique_ptr<LayerImpl> root_clip2 = | 5428 std::unique_ptr<LayerImpl> root_clip2 = |
5435 LayerImpl::Create(host_impl_->active_tree(), 5); | 5429 LayerImpl::Create(host_impl_->active_tree(), 5); |
5436 std::unique_ptr<LayerImpl> root_scroll2 = | 5430 std::unique_ptr<LayerImpl> root_scroll2 = |
5437 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5431 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
5438 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5432 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
5439 true; | 5433 true; |
5440 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); | 5434 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); |
5441 root_clip2->test_properties()->force_render_surface = true; | 5435 root_clip2->test_properties()->force_render_surface = true; |
5442 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); | 5436 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); |
5443 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); | 5437 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
| 5438 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5444 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5439 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
5445 Layer::INVALID_ID); | 5440 Layer::INVALID_ID); |
5446 host_impl_->active_tree()->DidBecomeActive(); | 5441 host_impl_->active_tree()->DidBecomeActive(); |
5447 | 5442 |
5448 // Scrolling should still work even though we did not draw yet. | 5443 // Scrolling should still work even though we did not draw yet. |
5449 SetNeedsRebuildPropertyTrees(); | |
5450 RebuildPropertyTrees(); | |
5451 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5444 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5452 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5445 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5453 InputHandler::WHEEL) | 5446 InputHandler::WHEEL) |
5454 .thread); | 5447 .thread); |
5455 } | 5448 } |
5456 | 5449 |
5457 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5450 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
5458 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5451 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5459 scroll_layer->SetDrawsContent(true); | 5452 scroll_layer->SetDrawsContent(true); |
5460 | 5453 |
5461 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5454 // Rotate the root layer 90 degrees counter-clockwise about its center. |
5462 gfx::Transform rotate_transform; | 5455 gfx::Transform rotate_transform; |
5463 rotate_transform.Rotate(-90.0); | 5456 rotate_transform.Rotate(-90.0); |
5464 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( | 5457 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( |
5465 rotate_transform); | 5458 rotate_transform); |
| 5459 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5466 | 5460 |
5467 gfx::Size surface_size(50, 50); | 5461 gfx::Size surface_size(50, 50); |
5468 host_impl_->SetViewportSize(surface_size); | 5462 host_impl_->SetViewportSize(surface_size); |
5469 SetNeedsRebuildPropertyTrees(); | |
5470 DrawFrame(); | 5463 DrawFrame(); |
5471 | 5464 |
5472 // Scroll to the right in screen coordinates with a gesture. | 5465 // Scroll to the right in screen coordinates with a gesture. |
5473 gfx::Vector2d gesture_scroll_delta(10, 0); | 5466 gfx::Vector2d gesture_scroll_delta(10, 0); |
5474 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5467 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5475 host_impl_ | 5468 host_impl_ |
5476 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5469 ->ScrollBegin(BeginState(gfx::Point()).get(), |
5477 InputHandler::TOUCHSCREEN) | 5470 InputHandler::TOUCHSCREEN) |
5478 .thread); | 5471 .thread); |
5479 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5472 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( | 5515 clip_layer->SetBounds( |
5523 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 5516 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); |
5524 // The rotation depends on the layer's transform origin, and the child layer | 5517 // 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 | 5518 // is a different size than the clip, so make sure the clip layer's origin |
5526 // lines up over the child. | 5519 // lines up over the child. |
5527 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5520 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
5528 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); | 5521 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); |
5529 LayerImpl* child_ptr = child.get(); | 5522 LayerImpl* child_ptr = child.get(); |
5530 clip_layer->test_properties()->AddChild(std::move(child)); | 5523 clip_layer->test_properties()->AddChild(std::move(child)); |
5531 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); | 5524 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); |
| 5525 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5532 | 5526 |
5533 gfx::Size surface_size(50, 50); | 5527 gfx::Size surface_size(50, 50); |
5534 host_impl_->SetViewportSize(surface_size); | 5528 host_impl_->SetViewportSize(surface_size); |
5535 SetNeedsRebuildPropertyTrees(); | |
5536 DrawFrame(); | 5529 DrawFrame(); |
5537 { | 5530 { |
5538 // Scroll down in screen coordinates with a gesture. | 5531 // Scroll down in screen coordinates with a gesture. |
5539 gfx::Vector2d gesture_scroll_delta(0, 10); | 5532 gfx::Vector2d gesture_scroll_delta(0, 10); |
5540 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5533 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5541 host_impl_ | 5534 host_impl_ |
5542 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5535 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
5543 InputHandler::TOUCHSCREEN) | 5536 InputHandler::TOUCHSCREEN) |
5544 .thread); | 5537 .thread); |
5545 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); | 5538 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5607 | 5600 |
5608 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, | 5601 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, |
5609 child_ptr->bounds().height() / 2)); | 5602 child_ptr->bounds().height() / 2)); |
5610 // The transform depends on the layer's transform origin, and the child layer | 5603 // 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 | 5604 // is a different size than the clip, so make sure the clip layer's origin |
5612 // lines up over the child. | 5605 // lines up over the child. |
5613 clip_layer->test_properties()->transform_origin = gfx::Point3F( | 5606 clip_layer->test_properties()->transform_origin = gfx::Point3F( |
5614 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); | 5607 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); |
5615 clip_layer->test_properties()->AddChild(std::move(child)); | 5608 clip_layer->test_properties()->AddChild(std::move(child)); |
5616 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); | 5609 scroll_layer->test_properties()->AddChild(std::move(clip_layer)); |
| 5610 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5617 | 5611 |
5618 gfx::Size surface_size(50, 50); | 5612 gfx::Size surface_size(50, 50); |
5619 host_impl_->SetViewportSize(surface_size); | 5613 host_impl_->SetViewportSize(surface_size); |
5620 | 5614 |
5621 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 5615 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
5622 | 5616 |
5623 gfx::Vector2d gesture_scroll_deltas[4]; | 5617 gfx::Vector2d gesture_scroll_deltas[4]; |
5624 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); | 5618 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); |
5625 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); | 5619 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); |
5626 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); | 5620 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); |
5627 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); | 5621 gesture_scroll_deltas[3] = gfx::Vector2d(10, 0); |
5628 | 5622 |
5629 gfx::Vector2d expected_scroll_deltas[4]; | 5623 gfx::Vector2d expected_scroll_deltas[4]; |
5630 // Perspective affects the vertical delta by a different | 5624 // Perspective affects the vertical delta by a different |
5631 // amount depending on the vertical position of the |viewport_point|. | 5625 // amount depending on the vertical position of the |viewport_point|. |
5632 expected_scroll_deltas[0] = gfx::Vector2d(2, 8); | 5626 expected_scroll_deltas[0] = gfx::Vector2d(2, 8); |
5633 expected_scroll_deltas[1] = gfx::Vector2d(1, 4); | 5627 expected_scroll_deltas[1] = gfx::Vector2d(1, 4); |
5634 // Deltas which start with the same vertical position of the | 5628 // Deltas which start with the same vertical position of the |
5635 // |viewport_point| are subject to identical perspective effects. | 5629 // |viewport_point| are subject to identical perspective effects. |
5636 expected_scroll_deltas[2] = gfx::Vector2d(4, 0); | 5630 expected_scroll_deltas[2] = gfx::Vector2d(4, 0); |
5637 expected_scroll_deltas[3] = gfx::Vector2d(4, 0); | 5631 expected_scroll_deltas[3] = gfx::Vector2d(4, 0); |
5638 | 5632 |
5639 gfx::Point viewport_point(1, 1); | 5633 gfx::Point viewport_point(1, 1); |
5640 | 5634 |
5641 SetNeedsRebuildPropertyTrees(); | |
5642 // Scroll in screen coordinates with a gesture. Each scroll starts | 5635 // Scroll in screen coordinates with a gesture. Each scroll starts |
5643 // where the previous scroll ended, but the scroll position is reset | 5636 // where the previous scroll ended, but the scroll position is reset |
5644 // for each scroll. | 5637 // for each scroll. |
5645 for (int i = 0; i < 4; ++i) { | 5638 for (int i = 0; i < 4; ++i) { |
5646 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); | 5639 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); |
5647 DrawFrame(); | 5640 DrawFrame(); |
5648 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5641 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5649 host_impl_ | 5642 host_impl_ |
5650 ->ScrollBegin(BeginState(viewport_point).get(), | 5643 ->ScrollBegin(BeginState(viewport_point).get(), |
5651 InputHandler::TOUCHSCREEN) | 5644 InputHandler::TOUCHSCREEN) |
(...skipping 15 matching lines...) Expand all Loading... |
5667 | 5660 |
5668 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5661 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
5669 LayerImpl* scroll_layer = | 5662 LayerImpl* scroll_layer = |
5670 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5663 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5671 | 5664 |
5672 // Scale the layer to twice its normal size. | 5665 // Scale the layer to twice its normal size. |
5673 int scale = 2; | 5666 int scale = 2; |
5674 gfx::Transform scale_transform; | 5667 gfx::Transform scale_transform; |
5675 scale_transform.Scale(scale, scale); | 5668 scale_transform.Scale(scale, scale); |
5676 scroll_layer->test_properties()->parent->SetTransform(scale_transform); | 5669 scroll_layer->test_properties()->parent->SetTransform(scale_transform); |
| 5670 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5677 | 5671 |
5678 gfx::Size surface_size(50, 50); | 5672 gfx::Size surface_size(50, 50); |
5679 host_impl_->SetViewportSize(surface_size); | 5673 host_impl_->SetViewportSize(surface_size); |
5680 SetNeedsRebuildPropertyTrees(); | |
5681 DrawFrame(); | 5674 DrawFrame(); |
5682 | 5675 |
5683 // Scroll down in screen coordinates with a gesture. | 5676 // Scroll down in screen coordinates with a gesture. |
5684 gfx::Vector2d scroll_delta(0, 10); | 5677 gfx::Vector2d scroll_delta(0, 10); |
5685 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5678 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5686 host_impl_ | 5679 host_impl_ |
5687 ->ScrollBegin(BeginState(gfx::Point()).get(), | 5680 ->ScrollBegin(BeginState(gfx::Point()).get(), |
5688 InputHandler::TOUCHSCREEN) | 5681 InputHandler::TOUCHSCREEN) |
5689 .thread); | 5682 .thread); |
5690 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5683 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
(...skipping 22 matching lines...) Expand all Loading... |
5713 wheel_scroll_delta)); | 5706 wheel_scroll_delta)); |
5714 } | 5707 } |
5715 | 5708 |
5716 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 5709 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
5717 int width = 332; | 5710 int width = 332; |
5718 int height = 20; | 5711 int height = 20; |
5719 int scale = 3; | 5712 int scale = 3; |
5720 SetupScrollAndContentsLayers(gfx::Size(width, height)); | 5713 SetupScrollAndContentsLayers(gfx::Size(width, height)); |
5721 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 5714 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
5722 gfx::Size(width * scale - 1, height * scale)); | 5715 gfx::Size(width * scale - 1, height * scale)); |
5723 SetNeedsRebuildPropertyTrees(); | 5716 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5724 RebuildPropertyTrees(); | 5717 |
5725 host_impl_->active_tree()->SetDeviceScaleFactor(scale); | 5718 host_impl_->active_tree()->SetDeviceScaleFactor(scale); |
5726 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5719 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
5727 | 5720 |
5728 LayerImpl* inner_viewport_scroll_layer = | 5721 LayerImpl* inner_viewport_scroll_layer = |
5729 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5722 host_impl_->active_tree()->InnerViewportScrollLayer(); |
5730 EXPECT_EQ(gfx::ScrollOffset(0, 0), | 5723 EXPECT_EQ(gfx::ScrollOffset(0, 0), |
5731 inner_viewport_scroll_layer->MaxScrollOffset()); | 5724 inner_viewport_scroll_layer->MaxScrollOffset()); |
5732 } | 5725 } |
5733 | 5726 |
5734 class TestInputHandlerClient : public InputHandlerClient { | 5727 class TestInputHandlerClient : public InputHandlerClient { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5793 float min_page_scale_factor_; | 5786 float min_page_scale_factor_; |
5794 float max_page_scale_factor_; | 5787 float max_page_scale_factor_; |
5795 }; | 5788 }; |
5796 | 5789 |
5797 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 5790 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
5798 TestInputHandlerClient scroll_watcher; | 5791 TestInputHandlerClient scroll_watcher; |
5799 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5792 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
5800 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5793 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5801 LayerImpl* clip_layer = | 5794 LayerImpl* clip_layer = |
5802 scroll_layer->test_properties()->parent->test_properties()->parent; | 5795 scroll_layer->test_properties()->parent->test_properties()->parent; |
5803 SetNeedsRebuildPropertyTrees(); | |
5804 clip_layer->SetBounds(gfx::Size(10, 20)); | 5796 clip_layer->SetBounds(gfx::Size(10, 20)); |
5805 RebuildPropertyTrees(); | 5797 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5806 | 5798 |
5807 host_impl_->BindToClient(&scroll_watcher); | 5799 host_impl_->BindToClient(&scroll_watcher); |
5808 | 5800 |
5809 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 5801 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
5810 scroll_layer->layer_tree_impl() | 5802 scroll_layer->layer_tree_impl() |
5811 ->property_trees() | 5803 ->property_trees() |
5812 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 5804 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
5813 gfx::ScrollOffset()); | 5805 gfx::ScrollOffset()); |
5814 SetScrollOffsetDelta(scroll_layer, initial_scroll_delta); | 5806 SetScrollOffsetDelta(scroll_layer, initial_scroll_delta); |
5815 | 5807 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5916 scroll_layer->SetDrawsContent(true); | 5908 scroll_layer->SetDrawsContent(true); |
5917 | 5909 |
5918 // Draw first frame to clear any pending draws and check scroll. | 5910 // Draw first frame to clear any pending draws and check scroll. |
5919 DrawFrame(); | 5911 DrawFrame(); |
5920 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); | 5912 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); |
5921 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 5913 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
5922 | 5914 |
5923 // Set external scroll delta on delegate and notify LayerTreeHost. | 5915 // Set external scroll delta on delegate and notify LayerTreeHost. |
5924 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 5916 gfx::ScrollOffset scroll_offset(10.f, 10.f); |
5925 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset); | 5917 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset); |
| 5918 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5926 | 5919 |
5927 // Check scroll delta reflected in layer. | 5920 // Check scroll delta reflected in layer. |
5928 LayerTreeHostImpl::FrameData frame; | 5921 LayerTreeHostImpl::FrameData frame; |
5929 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5922 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5930 host_impl_->DrawLayers(&frame); | 5923 host_impl_->DrawLayers(&frame); |
5931 host_impl_->DidDrawAllLayers(frame); | 5924 host_impl_->DidDrawAllLayers(frame); |
5932 EXPECT_FALSE(frame.has_no_damage); | 5925 EXPECT_FALSE(frame.has_no_damage); |
5933 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); | 5926 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); |
5934 } | 5927 } |
5935 | 5928 |
5936 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { | 5929 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
5937 InputHandlerScrollResult scroll_result; | 5930 InputHandlerScrollResult scroll_result; |
5938 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5931 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5932 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5933 |
5939 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 5934 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
5940 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5935 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
5941 DrawFrame(); | 5936 DrawFrame(); |
5942 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 5937 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
5943 | 5938 |
5944 // In-bounds scrolling does not affect overscroll. | 5939 // In-bounds scrolling does not affect overscroll. |
5945 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5940 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5946 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5941 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5947 InputHandler::WHEEL) | 5942 InputHandler::WHEEL) |
5948 .thread); | 5943 .thread); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 CreateScrollableLayer(3, surface_size, root_clip.get()); | 6072 CreateScrollableLayer(3, surface_size, root_clip.get()); |
6078 | 6073 |
6079 std::unique_ptr<LayerImpl> child = | 6074 std::unique_ptr<LayerImpl> child = |
6080 CreateScrollableLayer(2, surface_size, root_clip.get()); | 6075 CreateScrollableLayer(2, surface_size, root_clip.get()); |
6081 LayerImpl* grand_child_layer = grand_child.get(); | 6076 LayerImpl* grand_child_layer = grand_child.get(); |
6082 child->test_properties()->AddChild(std::move(grand_child)); | 6077 child->test_properties()->AddChild(std::move(grand_child)); |
6083 | 6078 |
6084 LayerImpl* child_layer = child.get(); | 6079 LayerImpl* child_layer = child.get(); |
6085 root->test_properties()->AddChild(std::move(child)); | 6080 root->test_properties()->AddChild(std::move(child)); |
6086 root_clip->test_properties()->AddChild(std::move(root)); | 6081 root_clip->test_properties()->AddChild(std::move(root)); |
| 6082 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
| 6083 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6084 host_impl_->active_tree()->DidBecomeActive(); |
| 6085 |
6087 child_layer->layer_tree_impl() | 6086 child_layer->layer_tree_impl() |
6088 ->property_trees() | 6087 ->property_trees() |
6089 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 6088 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
6090 gfx::ScrollOffset(0, 3)); | 6089 gfx::ScrollOffset(0, 3)); |
6091 grand_child_layer->layer_tree_impl() | 6090 grand_child_layer->layer_tree_impl() |
6092 ->property_trees() | 6091 ->property_trees() |
6093 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 6092 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
6094 gfx::ScrollOffset(0, 2)); | 6093 gfx::ScrollOffset(0, 2)); |
6095 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); | 6094 |
6096 host_impl_->active_tree()->DidBecomeActive(); | |
6097 host_impl_->SetViewportSize(surface_size); | 6095 host_impl_->SetViewportSize(surface_size); |
6098 SetNeedsRebuildPropertyTrees(); | |
6099 DrawFrame(); | 6096 DrawFrame(); |
6100 { | 6097 { |
6101 gfx::Vector2d scroll_delta(0, -10); | 6098 gfx::Vector2d scroll_delta(0, -10); |
6102 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6099 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6103 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6100 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
6104 InputHandler::NON_BUBBLING_GESTURE) | 6101 InputHandler::NON_BUBBLING_GESTURE) |
6105 .thread); | 6102 .thread); |
6106 scroll_result = | 6103 scroll_result = |
6107 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6104 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6108 EXPECT_TRUE(scroll_result.did_scroll); | 6105 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()); | 6141 host_impl_->ScrollEnd(EndState().get()); |
6145 } | 6142 } |
6146 } | 6143 } |
6147 | 6144 |
6148 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 6145 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
6149 // When we try to scroll a non-scrollable child layer, the scroll delta | 6146 // 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 | 6147 // 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. | 6148 // be reflected only when it has bubbled up to the root scrolling layer. |
6152 InputHandlerScrollResult scroll_result; | 6149 InputHandlerScrollResult scroll_result; |
6153 SetupScrollAndContentsLayers(gfx::Size(20, 20)); | 6150 SetupScrollAndContentsLayers(gfx::Size(20, 20)); |
| 6151 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6152 |
6154 DrawFrame(); | 6153 DrawFrame(); |
6155 { | 6154 { |
6156 gfx::Vector2d scroll_delta(0, 8); | 6155 gfx::Vector2d scroll_delta(0, 8); |
6157 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6156 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6158 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6157 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
6159 InputHandler::WHEEL) | 6158 InputHandler::WHEEL) |
6160 .thread); | 6159 .thread); |
6161 scroll_result = | 6160 scroll_result = |
6162 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6161 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6163 EXPECT_TRUE(scroll_result.did_scroll); | 6162 EXPECT_TRUE(scroll_result.did_scroll); |
(...skipping 14 matching lines...) Expand all Loading... |
6178 } | 6177 } |
6179 | 6178 |
6180 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 6179 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
6181 InputHandlerScrollResult scroll_result; | 6180 InputHandlerScrollResult scroll_result; |
6182 LayerTreeSettings settings = DefaultSettings(); | 6181 LayerTreeSettings settings = DefaultSettings(); |
6183 CreateHostImpl(settings, CreateOutputSurface()); | 6182 CreateHostImpl(settings, CreateOutputSurface()); |
6184 | 6183 |
6185 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 6184 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
6186 LayerImpl* clip_layer = | 6185 LayerImpl* clip_layer = |
6187 scroll_layer->test_properties()->parent->test_properties()->parent; | 6186 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 6187 |
6188 clip_layer->SetBounds(gfx::Size(50, 50)); | 6188 clip_layer->SetBounds(gfx::Size(50, 50)); |
6189 SetNeedsRebuildPropertyTrees(); | 6189 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6190 RebuildPropertyTrees(); | 6190 |
6191 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6191 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
6192 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6192 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
6193 DrawFrame(); | 6193 DrawFrame(); |
6194 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6194 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6195 | 6195 |
6196 // Even though the layer can't scroll the overscroll still happens. | 6196 // Even though the layer can't scroll the overscroll still happens. |
6197 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6197 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6198 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6198 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
6199 InputHandler::WHEEL) | 6199 InputHandler::WHEEL) |
6200 .thread); | 6200 .thread); |
6201 scroll_result = host_impl_->ScrollBy( | 6201 scroll_result = host_impl_->ScrollBy( |
6202 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6202 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
6203 EXPECT_FALSE(scroll_result.did_scroll); | 6203 EXPECT_FALSE(scroll_result.did_scroll); |
6204 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6204 EXPECT_TRUE(scroll_result.did_overscroll_root); |
6205 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 6205 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
6206 } | 6206 } |
6207 | 6207 |
6208 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 6208 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
6209 InputHandlerScrollResult scroll_result; | 6209 InputHandlerScrollResult scroll_result; |
6210 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 6210 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 6211 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6211 | 6212 |
6212 DrawFrame(); | 6213 DrawFrame(); |
6213 { | 6214 { |
6214 // Edge glow effect should be applicable only upon reaching Edges | 6215 // Edge glow effect should be applicable only upon reaching Edges |
6215 // of the content. unnecessary glow effect calls shouldn't be | 6216 // of the content. unnecessary glow effect calls shouldn't be |
6216 // called while scrolling up without reaching the edge of the content. | 6217 // called while scrolling up without reaching the edge of the content. |
6217 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6218 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6218 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6219 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
6219 InputHandler::WHEEL) | 6220 InputHandler::WHEEL) |
6220 .thread); | 6221 .thread); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6368 BlendStateCheckLayer* layer1 = | 6369 BlendStateCheckLayer* layer1 = |
6369 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); | 6370 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); |
6370 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 6371 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
6371 | 6372 |
6372 LayerTreeHostImpl::FrameData frame; | 6373 LayerTreeHostImpl::FrameData frame; |
6373 | 6374 |
6374 // Opaque layer, drawn without blending. | 6375 // Opaque layer, drawn without blending. |
6375 layer1->SetContentsOpaque(true); | 6376 layer1->SetContentsOpaque(true); |
6376 layer1->SetExpectation(false, false); | 6377 layer1->SetExpectation(false, false); |
6377 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6378 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6378 SetNeedsRebuildPropertyTrees(); | 6379 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6379 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6380 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6380 host_impl_->DrawLayers(&frame); | 6381 host_impl_->DrawLayers(&frame); |
6381 EXPECT_TRUE(layer1->quads_appended()); | 6382 EXPECT_TRUE(layer1->quads_appended()); |
6382 host_impl_->DidDrawAllLayers(frame); | 6383 host_impl_->DidDrawAllLayers(frame); |
6383 | 6384 |
6384 // Layer with translucent content and painting, so drawn with blending. | 6385 // Layer with translucent content and painting, so drawn with blending. |
6385 layer1->SetContentsOpaque(false); | 6386 layer1->SetContentsOpaque(false); |
6386 layer1->SetExpectation(true, false); | 6387 layer1->SetExpectation(true, false); |
6387 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6388 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6388 SetNeedsRebuildPropertyTrees(); | 6389 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6389 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6390 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6390 host_impl_->DrawLayers(&frame); | 6391 host_impl_->DrawLayers(&frame); |
6391 EXPECT_TRUE(layer1->quads_appended()); | 6392 EXPECT_TRUE(layer1->quads_appended()); |
6392 host_impl_->DidDrawAllLayers(frame); | 6393 host_impl_->DidDrawAllLayers(frame); |
6393 | 6394 |
6394 // Layer with translucent opacity, drawn with blending. | 6395 // Layer with translucent opacity, drawn with blending. |
6395 layer1->SetContentsOpaque(true); | 6396 layer1->SetContentsOpaque(true); |
6396 layer1->test_properties()->opacity = 0.5f; | 6397 layer1->test_properties()->opacity = 0.5f; |
6397 layer1->NoteLayerPropertyChanged(); | 6398 layer1->NoteLayerPropertyChanged(); |
6398 layer1->SetExpectation(true, false); | 6399 layer1->SetExpectation(true, false); |
6399 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6400 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6400 SetNeedsRebuildPropertyTrees(); | 6401 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6401 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6402 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6402 host_impl_->DrawLayers(&frame); | 6403 host_impl_->DrawLayers(&frame); |
6403 EXPECT_TRUE(layer1->quads_appended()); | 6404 EXPECT_TRUE(layer1->quads_appended()); |
6404 host_impl_->DidDrawAllLayers(frame); | 6405 host_impl_->DidDrawAllLayers(frame); |
6405 | 6406 |
6406 // Layer with translucent opacity and painting, drawn with blending. | 6407 // Layer with translucent opacity and painting, drawn with blending. |
6407 layer1->SetContentsOpaque(true); | 6408 layer1->SetContentsOpaque(true); |
6408 layer1->test_properties()->opacity = 0.5f; | 6409 layer1->test_properties()->opacity = 0.5f; |
6409 layer1->NoteLayerPropertyChanged(); | 6410 layer1->NoteLayerPropertyChanged(); |
6410 layer1->SetExpectation(true, false); | 6411 layer1->SetExpectation(true, false); |
6411 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6412 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6412 SetNeedsRebuildPropertyTrees(); | 6413 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6413 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6414 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6414 host_impl_->DrawLayers(&frame); | 6415 host_impl_->DrawLayers(&frame); |
6415 EXPECT_TRUE(layer1->quads_appended()); | 6416 EXPECT_TRUE(layer1->quads_appended()); |
6416 host_impl_->DidDrawAllLayers(frame); | 6417 host_impl_->DidDrawAllLayers(frame); |
6417 | 6418 |
6418 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( | 6419 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( |
6419 host_impl_->active_tree(), 3, host_impl_->resource_provider())); | 6420 host_impl_->active_tree(), 3, host_impl_->resource_provider())); |
6420 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( | 6421 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( |
6421 layer1->test_properties()->children[0]); | 6422 layer1->test_properties()->children[0]); |
6422 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 6423 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
6423 | 6424 |
6424 // 2 opaque layers, drawn without blending. | 6425 // 2 opaque layers, drawn without blending. |
6425 layer1->SetContentsOpaque(true); | 6426 layer1->SetContentsOpaque(true); |
6426 layer1->test_properties()->opacity = 1.f; | 6427 layer1->test_properties()->opacity = 1.f; |
6427 layer1->NoteLayerPropertyChanged(); | 6428 layer1->NoteLayerPropertyChanged(); |
6428 layer1->SetExpectation(false, false); | 6429 layer1->SetExpectation(false, false); |
6429 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6430 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6430 layer2->SetContentsOpaque(true); | 6431 layer2->SetContentsOpaque(true); |
6431 layer2->test_properties()->opacity = 1.f; | 6432 layer2->test_properties()->opacity = 1.f; |
6432 layer2->NoteLayerPropertyChanged(); | 6433 layer2->NoteLayerPropertyChanged(); |
6433 layer2->SetExpectation(false, false); | 6434 layer2->SetExpectation(false, false); |
6434 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6435 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6435 SetNeedsRebuildPropertyTrees(); | 6436 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6436 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6437 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6437 host_impl_->DrawLayers(&frame); | 6438 host_impl_->DrawLayers(&frame); |
6438 EXPECT_TRUE(layer1->quads_appended()); | 6439 EXPECT_TRUE(layer1->quads_appended()); |
6439 EXPECT_TRUE(layer2->quads_appended()); | 6440 EXPECT_TRUE(layer2->quads_appended()); |
6440 host_impl_->DidDrawAllLayers(frame); | 6441 host_impl_->DidDrawAllLayers(frame); |
6441 | 6442 |
6442 // Parent layer with translucent content, drawn with blending. | 6443 // Parent layer with translucent content, drawn with blending. |
6443 // Child layer with opaque content, drawn without blending. | 6444 // Child layer with opaque content, drawn without blending. |
6444 layer1->SetContentsOpaque(false); | 6445 layer1->SetContentsOpaque(false); |
6445 layer1->SetExpectation(true, false); | 6446 layer1->SetExpectation(true, false); |
6446 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6447 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6447 layer2->SetExpectation(false, false); | 6448 layer2->SetExpectation(false, false); |
6448 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6449 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6449 SetNeedsRebuildPropertyTrees(); | 6450 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6450 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6451 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6451 host_impl_->DrawLayers(&frame); | 6452 host_impl_->DrawLayers(&frame); |
6452 EXPECT_TRUE(layer1->quads_appended()); | 6453 EXPECT_TRUE(layer1->quads_appended()); |
6453 EXPECT_TRUE(layer2->quads_appended()); | 6454 EXPECT_TRUE(layer2->quads_appended()); |
6454 host_impl_->DidDrawAllLayers(frame); | 6455 host_impl_->DidDrawAllLayers(frame); |
6455 | 6456 |
6456 // Parent layer with translucent content but opaque painting, drawn without | 6457 // Parent layer with translucent content but opaque painting, drawn without |
6457 // blending. | 6458 // blending. |
6458 // Child layer with opaque content, drawn without blending. | 6459 // Child layer with opaque content, drawn without blending. |
6459 layer1->SetContentsOpaque(true); | 6460 layer1->SetContentsOpaque(true); |
6460 layer1->SetExpectation(false, false); | 6461 layer1->SetExpectation(false, false); |
6461 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6462 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6462 layer2->SetExpectation(false, false); | 6463 layer2->SetExpectation(false, false); |
6463 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6464 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6464 SetNeedsRebuildPropertyTrees(); | 6465 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6465 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6466 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6466 host_impl_->DrawLayers(&frame); | 6467 host_impl_->DrawLayers(&frame); |
6467 EXPECT_TRUE(layer1->quads_appended()); | 6468 EXPECT_TRUE(layer1->quads_appended()); |
6468 EXPECT_TRUE(layer2->quads_appended()); | 6469 EXPECT_TRUE(layer2->quads_appended()); |
6469 host_impl_->DidDrawAllLayers(frame); | 6470 host_impl_->DidDrawAllLayers(frame); |
6470 | 6471 |
6471 // Parent layer with translucent opacity and opaque content. Since it has a | 6472 // 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, | 6473 // drawing child, it's drawn to a render surface which carries the opacity, |
6473 // so it's itself drawn without blending. | 6474 // so it's itself drawn without blending. |
6474 // Child layer with opaque content, drawn without blending (parent surface | 6475 // Child layer with opaque content, drawn without blending (parent surface |
6475 // carries the inherited opacity). | 6476 // carries the inherited opacity). |
6476 layer1->SetContentsOpaque(true); | 6477 layer1->SetContentsOpaque(true); |
6477 layer1->test_properties()->opacity = 0.5f; | 6478 layer1->test_properties()->opacity = 0.5f; |
6478 layer1->NoteLayerPropertyChanged(); | 6479 layer1->NoteLayerPropertyChanged(); |
6479 layer1->test_properties()->force_render_surface = true; | 6480 layer1->test_properties()->force_render_surface = true; |
6480 layer1->SetExpectation(false, true); | 6481 layer1->SetExpectation(false, true); |
6481 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6482 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6482 layer2->SetExpectation(false, false); | 6483 layer2->SetExpectation(false, false); |
6483 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6484 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6484 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 6485 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
6485 host_impl_->active_tree()->root_layer_for_testing()); | 6486 host_impl_->active_tree()->root_layer_for_testing()); |
6486 SetNeedsRebuildPropertyTrees(); | 6487 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6487 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6488 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6488 host_impl_->DrawLayers(&frame); | 6489 host_impl_->DrawLayers(&frame); |
6489 EXPECT_TRUE(layer1->quads_appended()); | 6490 EXPECT_TRUE(layer1->quads_appended()); |
6490 EXPECT_TRUE(layer2->quads_appended()); | 6491 EXPECT_TRUE(layer2->quads_appended()); |
6491 host_impl_->DidDrawAllLayers(frame); | 6492 host_impl_->DidDrawAllLayers(frame); |
6492 layer1->test_properties()->force_render_surface = false; | 6493 layer1->test_properties()->force_render_surface = false; |
6493 | 6494 |
6494 // Draw again, but with child non-opaque, to make sure | 6495 // Draw again, but with child non-opaque, to make sure |
6495 // layer1 not culled. | 6496 // layer1 not culled. |
6496 layer1->SetContentsOpaque(true); | 6497 layer1->SetContentsOpaque(true); |
6497 layer1->test_properties()->opacity = 1.f; | 6498 layer1->test_properties()->opacity = 1.f; |
6498 layer1->NoteLayerPropertyChanged(); | 6499 layer1->NoteLayerPropertyChanged(); |
6499 layer1->SetExpectation(false, false); | 6500 layer1->SetExpectation(false, false); |
6500 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6501 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6501 layer2->SetContentsOpaque(true); | 6502 layer2->SetContentsOpaque(true); |
6502 layer2->test_properties()->opacity = 0.5f; | 6503 layer2->test_properties()->opacity = 0.5f; |
6503 layer2->NoteLayerPropertyChanged(); | 6504 layer2->NoteLayerPropertyChanged(); |
6504 layer2->SetExpectation(true, false); | 6505 layer2->SetExpectation(true, false); |
6505 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6506 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6506 SetNeedsRebuildPropertyTrees(); | 6507 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6507 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6508 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6508 host_impl_->DrawLayers(&frame); | 6509 host_impl_->DrawLayers(&frame); |
6509 EXPECT_TRUE(layer1->quads_appended()); | 6510 EXPECT_TRUE(layer1->quads_appended()); |
6510 EXPECT_TRUE(layer2->quads_appended()); | 6511 EXPECT_TRUE(layer2->quads_appended()); |
6511 host_impl_->DidDrawAllLayers(frame); | 6512 host_impl_->DidDrawAllLayers(frame); |
6512 | 6513 |
6513 // A second way of making the child non-opaque. | 6514 // A second way of making the child non-opaque. |
6514 layer1->SetContentsOpaque(true); | 6515 layer1->SetContentsOpaque(true); |
6515 layer1->test_properties()->opacity = 1.f; | 6516 layer1->test_properties()->opacity = 1.f; |
6516 layer1->NoteLayerPropertyChanged(); | 6517 layer1->NoteLayerPropertyChanged(); |
6517 layer1->SetExpectation(false, false); | 6518 layer1->SetExpectation(false, false); |
6518 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6519 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6519 layer2->SetContentsOpaque(false); | 6520 layer2->SetContentsOpaque(false); |
6520 layer2->test_properties()->opacity = 1.f; | 6521 layer2->test_properties()->opacity = 1.f; |
6521 layer2->NoteLayerPropertyChanged(); | 6522 layer2->NoteLayerPropertyChanged(); |
6522 layer2->SetExpectation(true, false); | 6523 layer2->SetExpectation(true, false); |
6523 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6524 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6524 SetNeedsRebuildPropertyTrees(); | 6525 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6525 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6526 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6526 host_impl_->DrawLayers(&frame); | 6527 host_impl_->DrawLayers(&frame); |
6527 EXPECT_TRUE(layer1->quads_appended()); | 6528 EXPECT_TRUE(layer1->quads_appended()); |
6528 EXPECT_TRUE(layer2->quads_appended()); | 6529 EXPECT_TRUE(layer2->quads_appended()); |
6529 host_impl_->DidDrawAllLayers(frame); | 6530 host_impl_->DidDrawAllLayers(frame); |
6530 | 6531 |
6531 // And when the layer says its not opaque but is painted opaque, it is not | 6532 // And when the layer says its not opaque but is painted opaque, it is not |
6532 // blended. | 6533 // blended. |
6533 layer1->SetContentsOpaque(true); | 6534 layer1->SetContentsOpaque(true); |
6534 layer1->test_properties()->opacity = 1.f; | 6535 layer1->test_properties()->opacity = 1.f; |
6535 layer1->NoteLayerPropertyChanged(); | 6536 layer1->NoteLayerPropertyChanged(); |
6536 layer1->SetExpectation(false, false); | 6537 layer1->SetExpectation(false, false); |
6537 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6538 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6538 layer2->SetContentsOpaque(true); | 6539 layer2->SetContentsOpaque(true); |
6539 layer2->test_properties()->opacity = 1.f; | 6540 layer2->test_properties()->opacity = 1.f; |
6540 layer2->NoteLayerPropertyChanged(); | 6541 layer2->NoteLayerPropertyChanged(); |
6541 layer2->SetExpectation(false, false); | 6542 layer2->SetExpectation(false, false); |
6542 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6543 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6543 SetNeedsRebuildPropertyTrees(); | 6544 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6544 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6545 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6545 host_impl_->DrawLayers(&frame); | 6546 host_impl_->DrawLayers(&frame); |
6546 EXPECT_TRUE(layer1->quads_appended()); | 6547 EXPECT_TRUE(layer1->quads_appended()); |
6547 EXPECT_TRUE(layer2->quads_appended()); | 6548 EXPECT_TRUE(layer2->quads_appended()); |
6548 host_impl_->DidDrawAllLayers(frame); | 6549 host_impl_->DidDrawAllLayers(frame); |
6549 | 6550 |
6550 // Layer with partially opaque contents, drawn with blending. | 6551 // Layer with partially opaque contents, drawn with blending. |
6551 layer1->SetContentsOpaque(false); | 6552 layer1->SetContentsOpaque(false); |
6552 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6553 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6553 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 6554 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
6554 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6555 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6555 layer1->SetExpectation(true, false); | 6556 layer1->SetExpectation(true, false); |
6556 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6557 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6557 SetNeedsRebuildPropertyTrees(); | 6558 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6558 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6559 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6559 host_impl_->DrawLayers(&frame); | 6560 host_impl_->DrawLayers(&frame); |
6560 EXPECT_TRUE(layer1->quads_appended()); | 6561 EXPECT_TRUE(layer1->quads_appended()); |
6561 host_impl_->DidDrawAllLayers(frame); | 6562 host_impl_->DidDrawAllLayers(frame); |
6562 | 6563 |
6563 // Layer with partially opaque contents partially culled, drawn with blending. | 6564 // Layer with partially opaque contents partially culled, drawn with blending. |
6564 layer1->SetContentsOpaque(false); | 6565 layer1->SetContentsOpaque(false); |
6565 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6566 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6566 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 6567 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
6567 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6568 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6568 layer1->SetExpectation(true, false); | 6569 layer1->SetExpectation(true, false); |
6569 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6570 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6570 SetNeedsRebuildPropertyTrees(); | 6571 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6571 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6572 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6572 host_impl_->DrawLayers(&frame); | 6573 host_impl_->DrawLayers(&frame); |
6573 EXPECT_TRUE(layer1->quads_appended()); | 6574 EXPECT_TRUE(layer1->quads_appended()); |
6574 host_impl_->DidDrawAllLayers(frame); | 6575 host_impl_->DidDrawAllLayers(frame); |
6575 | 6576 |
6576 // Layer with partially opaque contents culled, drawn with blending. | 6577 // Layer with partially opaque contents culled, drawn with blending. |
6577 layer1->SetContentsOpaque(false); | 6578 layer1->SetContentsOpaque(false); |
6578 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6579 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6579 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 6580 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
6580 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6581 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6581 layer1->SetExpectation(true, false); | 6582 layer1->SetExpectation(true, false); |
6582 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6583 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6583 SetNeedsRebuildPropertyTrees(); | 6584 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6584 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6585 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6585 host_impl_->DrawLayers(&frame); | 6586 host_impl_->DrawLayers(&frame); |
6586 EXPECT_TRUE(layer1->quads_appended()); | 6587 EXPECT_TRUE(layer1->quads_appended()); |
6587 host_impl_->DidDrawAllLayers(frame); | 6588 host_impl_->DidDrawAllLayers(frame); |
6588 | 6589 |
6589 // Layer with partially opaque contents and translucent contents culled, drawn | 6590 // Layer with partially opaque contents and translucent contents culled, drawn |
6590 // without blending. | 6591 // without blending. |
6591 layer1->SetContentsOpaque(false); | 6592 layer1->SetContentsOpaque(false); |
6592 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6593 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6593 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 6594 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
6594 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6595 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6595 layer1->SetExpectation(false, false); | 6596 layer1->SetExpectation(false, false); |
6596 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6597 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6597 SetNeedsRebuildPropertyTrees(); | 6598 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6598 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6599 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6599 host_impl_->DrawLayers(&frame); | 6600 host_impl_->DrawLayers(&frame); |
6600 EXPECT_TRUE(layer1->quads_appended()); | 6601 EXPECT_TRUE(layer1->quads_appended()); |
6601 host_impl_->DidDrawAllLayers(frame); | 6602 host_impl_->DidDrawAllLayers(frame); |
6602 } | 6603 } |
6603 | 6604 |
6604 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6605 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
6605 protected: | 6606 protected: |
6606 LayerTreeHostImplViewportCoveredTest() : | 6607 LayerTreeHostImplViewportCoveredTest() : |
6607 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6608 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
6608 child_(NULL), | 6609 child_(NULL), |
(...skipping 28 matching lines...) Expand all Loading... |
6637 child_->SetContentsOpaque(true); | 6638 child_->SetContentsOpaque(true); |
6638 } | 6639 } |
6639 | 6640 |
6640 // Expect no gutter rects. | 6641 // Expect no gutter rects. |
6641 void TestLayerCoversFullViewport() { | 6642 void TestLayerCoversFullViewport() { |
6642 gfx::Rect layer_rect(viewport_size_); | 6643 gfx::Rect layer_rect(viewport_size_); |
6643 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6644 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
6644 child_->SetBounds(layer_rect.size()); | 6645 child_->SetBounds(layer_rect.size()); |
6645 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6646 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
6646 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6647 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6648 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6647 | 6649 |
6648 LayerTreeHostImpl::FrameData frame; | 6650 LayerTreeHostImpl::FrameData frame; |
6649 SetNeedsRebuildPropertyTrees(); | 6651 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6650 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
6651 ASSERT_EQ(1u, frame.render_passes.size()); | 6652 ASSERT_EQ(1u, frame.render_passes.size()); |
6652 | 6653 |
6653 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 6654 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
6654 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 6655 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
6655 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 6656 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
6656 | 6657 |
6657 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 6658 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
6658 host_impl_->DidDrawAllLayers(frame); | 6659 host_impl_->DidDrawAllLayers(frame); |
6659 } | 6660 } |
6660 | 6661 |
6661 // Expect fullscreen gutter rect. | 6662 // Expect fullscreen gutter rect. |
6662 void SetUpEmptylayer() { | 6663 void SetUpEmptylayer() { |
6663 gfx::Rect layer_rect(0, 0, 0, 0); | 6664 gfx::Rect layer_rect(0, 0, 0, 0); |
6664 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6665 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
6665 child_->SetBounds(layer_rect.size()); | 6666 child_->SetBounds(layer_rect.size()); |
6666 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6667 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
6667 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6668 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6669 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6668 } | 6670 } |
6669 | 6671 |
6670 void VerifyEmptyLayerRenderPasses(const RenderPassList& render_passes) { | 6672 void VerifyEmptyLayerRenderPasses(const RenderPassList& render_passes) { |
6671 ASSERT_EQ(1u, render_passes.size()); | 6673 ASSERT_EQ(1u, render_passes.size()); |
6672 | 6674 |
6673 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list)); | 6675 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list)); |
6674 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); | 6676 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); |
6675 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6677 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
6676 | 6678 |
6677 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); | 6679 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); |
6678 } | 6680 } |
6679 | 6681 |
6680 void TestEmptyLayer() { | 6682 void TestEmptyLayer() { |
6681 SetUpEmptylayer(); | 6683 SetUpEmptylayer(); |
6682 LayerTreeHostImpl::FrameData frame; | 6684 LayerTreeHostImpl::FrameData frame; |
6683 SetNeedsRebuildPropertyTrees(); | 6685 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6684 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
6685 VerifyEmptyLayerRenderPasses(frame.render_passes); | 6686 VerifyEmptyLayerRenderPasses(frame.render_passes); |
6686 host_impl_->DidDrawAllLayers(frame); | 6687 host_impl_->DidDrawAllLayers(frame); |
6687 } | 6688 } |
6688 | 6689 |
6689 void TestEmptyLayerWithOnDraw() { | 6690 void TestEmptyLayerWithOnDraw() { |
6690 SetUpEmptylayer(); | 6691 SetUpEmptylayer(); |
6691 gfx::Transform identity; | 6692 gfx::Transform identity; |
6692 gfx::Rect viewport(viewport_size_); | 6693 gfx::Rect viewport(viewport_size_); |
6693 bool resourceless_software_draw = true; | 6694 bool resourceless_software_draw = true; |
6694 SetNeedsRebuildPropertyTrees(); | |
6695 host_impl_->OnDraw(identity, viewport, viewport, | 6695 host_impl_->OnDraw(identity, viewport, viewport, |
6696 resourceless_software_draw); | 6696 resourceless_software_draw); |
6697 VerifyEmptyLayerRenderPasses(last_on_draw_render_passes_); | 6697 VerifyEmptyLayerRenderPasses(last_on_draw_render_passes_); |
6698 } | 6698 } |
6699 | 6699 |
6700 // Expect four surrounding gutter rects. | 6700 // Expect four surrounding gutter rects. |
6701 void SetUpLayerInMiddleOfViewport() { | 6701 void SetUpLayerInMiddleOfViewport() { |
6702 gfx::Rect layer_rect(500, 500, 200, 200); | 6702 gfx::Rect layer_rect(500, 500, 200, 200); |
6703 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6703 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
6704 child_->SetBounds(layer_rect.size()); | 6704 child_->SetBounds(layer_rect.size()); |
6705 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6705 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
6706 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6706 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6707 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6707 } | 6708 } |
6708 | 6709 |
6709 void VerifyLayerInMiddleOfViewport(const RenderPassList& render_passes) { | 6710 void VerifyLayerInMiddleOfViewport(const RenderPassList& render_passes) { |
6710 ASSERT_EQ(1u, render_passes.size()); | 6711 ASSERT_EQ(1u, render_passes.size()); |
6711 | 6712 |
6712 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list)); | 6713 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list)); |
6713 EXPECT_EQ(5u, render_passes[0]->quad_list.size()); | 6714 EXPECT_EQ(5u, render_passes[0]->quad_list.size()); |
6714 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6715 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
6715 | 6716 |
6716 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); | 6717 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); |
6717 } | 6718 } |
6718 | 6719 |
6719 void TestLayerInMiddleOfViewport() { | 6720 void TestLayerInMiddleOfViewport() { |
6720 SetUpLayerInMiddleOfViewport(); | 6721 SetUpLayerInMiddleOfViewport(); |
6721 LayerTreeHostImpl::FrameData frame; | 6722 LayerTreeHostImpl::FrameData frame; |
6722 SetNeedsRebuildPropertyTrees(); | 6723 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6723 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
6724 VerifyLayerInMiddleOfViewport(frame.render_passes); | 6724 VerifyLayerInMiddleOfViewport(frame.render_passes); |
6725 host_impl_->DidDrawAllLayers(frame); | 6725 host_impl_->DidDrawAllLayers(frame); |
6726 } | 6726 } |
6727 | 6727 |
6728 void TestLayerInMiddleOfViewportWithOnDraw() { | 6728 void TestLayerInMiddleOfViewportWithOnDraw() { |
6729 SetUpLayerInMiddleOfViewport(); | 6729 SetUpLayerInMiddleOfViewport(); |
6730 gfx::Transform identity; | 6730 gfx::Transform identity; |
6731 gfx::Rect viewport(viewport_size_); | 6731 gfx::Rect viewport(viewport_size_); |
6732 bool resourceless_software_draw = true; | 6732 bool resourceless_software_draw = true; |
6733 SetNeedsRebuildPropertyTrees(); | |
6734 host_impl_->OnDraw(identity, viewport, viewport, | 6733 host_impl_->OnDraw(identity, viewport, viewport, |
6735 resourceless_software_draw); | 6734 resourceless_software_draw); |
6736 VerifyLayerInMiddleOfViewport(last_on_draw_render_passes_); | 6735 VerifyLayerInMiddleOfViewport(last_on_draw_render_passes_); |
6737 } | 6736 } |
6738 | 6737 |
6739 // Expect no gutter rects. | 6738 // Expect no gutter rects. |
6740 void SetUpLayerIsLargerThanViewport() { | 6739 void SetUpLayerIsLargerThanViewport() { |
6741 gfx::Rect layer_rect(viewport_size_.width() + 10, | 6740 gfx::Rect layer_rect(viewport_size_.width() + 10, |
6742 viewport_size_.height() + 10); | 6741 viewport_size_.height() + 10); |
6743 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6742 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
6744 child_->SetBounds(layer_rect.size()); | 6743 child_->SetBounds(layer_rect.size()); |
6745 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6744 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
6746 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 6745 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 6746 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
6747 } | 6747 } |
6748 | 6748 |
6749 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) { | 6749 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) { |
6750 ASSERT_EQ(1u, render_passes.size()); | 6750 ASSERT_EQ(1u, render_passes.size()); |
6751 | 6751 |
6752 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list)); | 6752 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list)); |
6753 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); | 6753 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); |
6754 ValidateTextureDrawQuads(render_passes[0]->quad_list); | 6754 ValidateTextureDrawQuads(render_passes[0]->quad_list); |
6755 } | 6755 } |
6756 | 6756 |
6757 void TestLayerIsLargerThanViewport() { | 6757 void TestLayerIsLargerThanViewport() { |
6758 SetUpLayerIsLargerThanViewport(); | 6758 SetUpLayerIsLargerThanViewport(); |
6759 LayerTreeHostImpl::FrameData frame; | 6759 LayerTreeHostImpl::FrameData frame; |
6760 SetNeedsRebuildPropertyTrees(); | 6760 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6761 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
6762 VerifyLayerIsLargerThanViewport(frame.render_passes); | 6761 VerifyLayerIsLargerThanViewport(frame.render_passes); |
6763 host_impl_->DidDrawAllLayers(frame); | 6762 host_impl_->DidDrawAllLayers(frame); |
6764 } | 6763 } |
6765 | 6764 |
6766 void TestLayerIsLargerThanViewportWithOnDraw() { | 6765 void TestLayerIsLargerThanViewportWithOnDraw() { |
6767 SetUpLayerIsLargerThanViewport(); | 6766 SetUpLayerIsLargerThanViewport(); |
6768 gfx::Transform identity; | 6767 gfx::Transform identity; |
6769 gfx::Rect viewport(viewport_size_); | 6768 gfx::Rect viewport(viewport_size_); |
6770 bool resourceless_software_draw = true; | 6769 bool resourceless_software_draw = true; |
6771 SetNeedsRebuildPropertyTrees(); | |
6772 host_impl_->OnDraw(identity, viewport, viewport, | 6770 host_impl_->OnDraw(identity, viewport, viewport, |
6773 resourceless_software_draw); | 6771 resourceless_software_draw); |
6774 VerifyLayerIsLargerThanViewport(last_on_draw_render_passes_); | 6772 VerifyLayerIsLargerThanViewport(last_on_draw_render_passes_); |
6775 } | 6773 } |
6776 | 6774 |
6777 void DidActivateSyncTree() override { did_activate_pending_tree_ = true; } | 6775 void DidActivateSyncTree() override { did_activate_pending_tree_ = true; } |
6778 | 6776 |
6779 void set_gutter_quad_material(DrawQuad::Material material) { | 6777 void set_gutter_quad_material(DrawQuad::Material material) { |
6780 gutter_quad_material_ = material; | 6778 gutter_quad_material_ = material; |
6781 } | 6779 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6924 std::unique_ptr<OutputSurface> output_surface( | 6922 std::unique_ptr<OutputSurface> output_surface( |
6925 FakeOutputSurface::Create3d(provider)); | 6923 FakeOutputSurface::Create3d(provider)); |
6926 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6924 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6927 | 6925 |
6928 std::unique_ptr<LayerImpl> root = | 6926 std::unique_ptr<LayerImpl> root = |
6929 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6927 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6930 root->SetBounds(gfx::Size(10, 10)); | 6928 root->SetBounds(gfx::Size(10, 10)); |
6931 root->SetDrawsContent(true); | 6929 root->SetDrawsContent(true); |
6932 root->test_properties()->force_render_surface = true; | 6930 root->test_properties()->force_render_surface = true; |
6933 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 6931 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 6932 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6933 |
6934 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 6934 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
6935 provider->TestContext3d()->clear_reshape_called(); | 6935 provider->TestContext3d()->clear_reshape_called(); |
6936 | 6936 |
6937 LayerTreeHostImpl::FrameData frame; | 6937 LayerTreeHostImpl::FrameData frame; |
6938 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6938 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
6939 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 6939 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
6940 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6940 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6941 host_impl_->DrawLayers(&frame); | 6941 host_impl_->DrawLayers(&frame); |
6942 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6942 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
6943 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 6943 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
6944 EXPECT_EQ(provider->TestContext3d()->height(), 10); | 6944 EXPECT_EQ(provider->TestContext3d()->height(), 10); |
6945 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 6945 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
6946 host_impl_->DidDrawAllLayers(frame); | 6946 host_impl_->DidDrawAllLayers(frame); |
6947 provider->TestContext3d()->clear_reshape_called(); | 6947 provider->TestContext3d()->clear_reshape_called(); |
6948 | 6948 |
6949 host_impl_->SetViewportSize(gfx::Size(20, 30)); | 6949 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
6950 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6950 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6951 host_impl_->DrawLayers(&frame); | 6951 host_impl_->DrawLayers(&frame); |
6952 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6952 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
6953 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 6953 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
6954 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 6954 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
6955 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 6955 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
6956 host_impl_->DidDrawAllLayers(frame); | 6956 host_impl_->DidDrawAllLayers(frame); |
6957 provider->TestContext3d()->clear_reshape_called(); | 6957 provider->TestContext3d()->clear_reshape_called(); |
6958 | 6958 |
6959 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); | 6959 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); |
6960 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6960 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6961 host_impl_->DrawLayers(&frame); | 6961 host_impl_->DrawLayers(&frame); |
6962 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6962 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
6963 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 6963 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
6964 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 6964 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
6965 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | 6965 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); |
6966 host_impl_->DidDrawAllLayers(frame); | 6966 host_impl_->DidDrawAllLayers(frame); |
6967 provider->TestContext3d()->clear_reshape_called(); | 6967 provider->TestContext3d()->clear_reshape_called(); |
6968 } | 6968 } |
6969 | 6969 |
6970 // Make sure damage tracking propagates all the way to the graphics context, | 6970 // Make sure damage tracking propagates all the way to the graphics context, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7027 layer_tree_host_impl->active_tree() | 7027 layer_tree_host_impl->active_tree() |
7028 ->root_layer_for_testing() | 7028 ->root_layer_for_testing() |
7029 ->test_properties() | 7029 ->test_properties() |
7030 ->children[0] | 7030 ->children[0] |
7031 ->SetPosition(gfx::PointF()); | 7031 ->SetPosition(gfx::PointF()); |
7032 layer_tree_host_impl->active_tree() | 7032 layer_tree_host_impl->active_tree() |
7033 ->root_layer_for_testing() | 7033 ->root_layer_for_testing() |
7034 ->test_properties() | 7034 ->test_properties() |
7035 ->children[0] | 7035 ->children[0] |
7036 ->NoteLayerPropertyChanged(); | 7036 ->NoteLayerPropertyChanged(); |
7037 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; | |
7038 layer_tree_host_impl->active_tree() | 7037 layer_tree_host_impl->active_tree() |
7039 ->BuildLayerListAndPropertyTreesForTesting(); | 7038 ->BuildLayerListAndPropertyTreesForTesting(); |
7040 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7039 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7041 layer_tree_host_impl->DrawLayers(&frame); | 7040 layer_tree_host_impl->DrawLayers(&frame); |
7042 host_impl_->DidDrawAllLayers(frame); | 7041 host_impl_->DidDrawAllLayers(frame); |
7043 layer_tree_host_impl->SwapBuffers(frame); | 7042 layer_tree_host_impl->SwapBuffers(frame); |
7044 | 7043 |
7045 // Make sure that partial swap is constrained to the viewport dimensions | 7044 // Make sure that partial swap is constrained to the viewport dimensions |
7046 // expected damage rect: gfx::Rect(500, 500); | 7045 // expected damage rect: gfx::Rect(500, 500); |
7047 // expected swap rect: flipped damage rect, but also clamped to viewport | 7046 // expected swap rect: flipped damage rect, but also clamped to viewport |
(...skipping 22 matching lines...) Expand all Loading... |
7070 std::unique_ptr<LayerImpl> child = | 7069 std::unique_ptr<LayerImpl> child = |
7071 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 7070 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
7072 child->SetBounds(gfx::Size(10, 10)); | 7071 child->SetBounds(gfx::Size(10, 10)); |
7073 child->SetDrawsContent(true); | 7072 child->SetDrawsContent(true); |
7074 root->SetBounds(gfx::Size(10, 10)); | 7073 root->SetBounds(gfx::Size(10, 10)); |
7075 root->SetDrawsContent(true); | 7074 root->SetDrawsContent(true); |
7076 root->test_properties()->force_render_surface = true; | 7075 root->test_properties()->force_render_surface = true; |
7077 root->test_properties()->AddChild(std::move(child)); | 7076 root->test_properties()->AddChild(std::move(child)); |
7078 | 7077 |
7079 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 7078 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7079 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7080 | 7080 |
7081 LayerTreeHostImpl::FrameData frame; | 7081 LayerTreeHostImpl::FrameData frame; |
7082 | 7082 |
7083 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7083 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7084 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 7084 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
7085 EXPECT_EQ(1u, frame.render_passes.size()); | 7085 EXPECT_EQ(1u, frame.render_passes.size()); |
7086 host_impl_->DidDrawAllLayers(frame); | 7086 host_impl_->DidDrawAllLayers(frame); |
7087 } | 7087 } |
7088 | 7088 |
7089 class FakeLayerWithQuads : public LayerImpl { | 7089 class FakeLayerWithQuads : public LayerImpl { |
7090 public: | 7090 public: |
7091 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 7091 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
7092 return base::WrapUnique(new FakeLayerWithQuads(tree_impl, id)); | 7092 return base::WrapUnique(new FakeLayerWithQuads(tree_impl, id)); |
7093 } | 7093 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7203 std::unique_ptr<MockContext> mock_context_owned(new MockContext); | 7203 std::unique_ptr<MockContext> mock_context_owned(new MockContext); |
7204 MockContext* mock_context = mock_context_owned.get(); | 7204 MockContext* mock_context = mock_context_owned.get(); |
7205 MockContextHarness harness(mock_context); | 7205 MockContextHarness harness(mock_context); |
7206 | 7206 |
7207 // Run test case | 7207 // Run test case |
7208 LayerTreeSettings settings = DefaultSettings(); | 7208 LayerTreeSettings settings = DefaultSettings(); |
7209 settings.renderer_settings.partial_swap_enabled = false; | 7209 settings.renderer_settings.partial_swap_enabled = false; |
7210 CreateHostImpl(settings, | 7210 CreateHostImpl(settings, |
7211 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7211 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
7212 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7212 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7213 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7213 | 7214 |
7214 // Without partial swap, and no clipping, no scissor is set. | 7215 // Without partial swap, and no clipping, no scissor is set. |
7215 harness.MustDrawSolidQuad(); | 7216 harness.MustDrawSolidQuad(); |
7216 harness.MustSetNoScissor(); | 7217 harness.MustSetNoScissor(); |
7217 { | 7218 { |
7218 LayerTreeHostImpl::FrameData frame; | 7219 LayerTreeHostImpl::FrameData frame; |
7219 SetNeedsRebuildPropertyTrees(); | 7220 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7220 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
7221 host_impl_->DrawLayers(&frame); | 7221 host_impl_->DrawLayers(&frame); |
7222 host_impl_->DidDrawAllLayers(frame); | 7222 host_impl_->DidDrawAllLayers(frame); |
7223 } | 7223 } |
7224 Mock::VerifyAndClearExpectations(&mock_context); | 7224 Mock::VerifyAndClearExpectations(&mock_context); |
7225 | 7225 |
7226 // Without partial swap, but a layer does clip its subtree, one scissor is | 7226 // Without partial swap, but a layer does clip its subtree, one scissor is |
7227 // set. | 7227 // set. |
7228 host_impl_->active_tree()->root_layer_for_testing()->SetMasksToBounds(true); | 7228 auto* root = host_impl_->active_tree()->root_layer_for_testing(); |
7229 host_impl_->active_tree() | 7229 root->SetMasksToBounds(true); |
7230 ->root_layer_for_testing() | 7230 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7231 ->NoteLayerPropertyChanged(); | 7231 root->NoteLayerPropertyChanged(); |
7232 harness.MustDrawSolidQuad(); | 7232 harness.MustDrawSolidQuad(); |
7233 harness.MustSetScissor(0, 0, 10, 10); | 7233 harness.MustSetScissor(0, 0, 10, 10); |
7234 { | 7234 { |
7235 LayerTreeHostImpl::FrameData frame; | 7235 LayerTreeHostImpl::FrameData frame; |
7236 SetNeedsRebuildPropertyTrees(); | 7236 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7237 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | |
7238 host_impl_->DrawLayers(&frame); | 7237 host_impl_->DrawLayers(&frame); |
7239 host_impl_->DidDrawAllLayers(frame); | 7238 host_impl_->DidDrawAllLayers(frame); |
7240 } | 7239 } |
7241 Mock::VerifyAndClearExpectations(&mock_context); | 7240 Mock::VerifyAndClearExpectations(&mock_context); |
7242 } | 7241 } |
7243 | 7242 |
7244 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 7243 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
7245 std::unique_ptr<MockContext> context_owned(new MockContext); | 7244 std::unique_ptr<MockContext> context_owned(new MockContext); |
7246 MockContext* mock_context = context_owned.get(); | 7245 MockContext* mock_context = context_owned.get(); |
7247 MockContextHarness harness(mock_context); | 7246 MockContextHarness harness(mock_context); |
7248 | 7247 |
7249 LayerTreeSettings settings = DefaultSettings(); | 7248 LayerTreeSettings settings = DefaultSettings(); |
7250 settings.renderer_settings.partial_swap_enabled = true; | 7249 settings.renderer_settings.partial_swap_enabled = true; |
7251 CreateHostImpl(settings, | 7250 CreateHostImpl(settings, |
7252 FakeOutputSurface::Create3d(std::move(context_owned))); | 7251 FakeOutputSurface::Create3d(std::move(context_owned))); |
7253 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7252 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7253 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7254 | 7254 |
7255 // The first frame is not a partially-swapped one. No scissor should be set. | 7255 // The first frame is not a partially-swapped one. No scissor should be set. |
7256 harness.MustSetNoScissor(); | 7256 harness.MustSetNoScissor(); |
7257 harness.MustDrawSolidQuad(); | 7257 harness.MustDrawSolidQuad(); |
7258 { | 7258 { |
7259 LayerTreeHostImpl::FrameData frame; | 7259 LayerTreeHostImpl::FrameData frame; |
7260 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7260 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7261 host_impl_->DrawLayers(&frame); | 7261 host_impl_->DrawLayers(&frame); |
7262 host_impl_->DidDrawAllLayers(frame); | 7262 host_impl_->DidDrawAllLayers(frame); |
7263 } | 7263 } |
7264 Mock::VerifyAndClearExpectations(&mock_context); | 7264 Mock::VerifyAndClearExpectations(&mock_context); |
7265 | 7265 |
7266 // Damage a portion of the frame. | 7266 // Damage a portion of the frame. |
7267 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( | 7267 auto* root = host_impl_->active_tree()->root_layer_for_testing(); |
7268 gfx::Rect(0, 0, 2, 3)); | 7268 root->SetUpdateRect(gfx::Rect(0, 0, 2, 3)); |
| 7269 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7269 | 7270 |
7270 // The second frame will be partially-swapped (the y coordinates are flipped). | 7271 // The second frame will be partially-swapped (the y coordinates are flipped). |
7271 harness.MustSetScissor(0, 7, 2, 3); | 7272 harness.MustSetScissor(0, 7, 2, 3); |
7272 harness.MustDrawSolidQuad(); | 7273 harness.MustDrawSolidQuad(); |
7273 { | 7274 { |
7274 LayerTreeHostImpl::FrameData frame; | 7275 LayerTreeHostImpl::FrameData frame; |
7275 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7276 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7276 host_impl_->DrawLayers(&frame); | 7277 host_impl_->DrawLayers(&frame); |
7277 host_impl_->DidDrawAllLayers(frame); | 7278 host_impl_->DidDrawAllLayers(frame); |
7278 } | 7279 } |
7279 Mock::VerifyAndClearExpectations(&mock_context); | 7280 Mock::VerifyAndClearExpectations(&mock_context); |
7280 } | 7281 } |
7281 | 7282 |
7282 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7283 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7283 LayerTreeSettings settings, | 7284 LayerTreeSettings settings, |
7284 bool partial_swap, | 7285 bool partial_swap, |
7285 LayerTreeHostImplClient* client, | 7286 LayerTreeHostImplClient* client, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7432 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7433 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
7433 FakeVideoFrameProvider provider; | 7434 FakeVideoFrameProvider provider; |
7434 provider.set_frame(softwareFrame); | 7435 provider.set_frame(softwareFrame); |
7435 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7436 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7436 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7437 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
7437 video_layer->SetBounds(gfx::Size(10, 10)); | 7438 video_layer->SetBounds(gfx::Size(10, 10)); |
7438 video_layer->SetDrawsContent(true); | 7439 video_layer->SetDrawsContent(true); |
7439 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7440 root_layer->test_properties()->AddChild(std::move(video_layer)); |
7440 | 7441 |
7441 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); | 7442 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
| 7443 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7442 | 7444 |
7443 EXPECT_EQ(0u, context3d->NumTextures()); | 7445 EXPECT_EQ(0u, context3d->NumTextures()); |
7444 | 7446 |
7445 LayerTreeHostImpl::FrameData frame; | 7447 LayerTreeHostImpl::FrameData frame; |
7446 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7448 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7447 host_impl_->DrawLayers(&frame); | 7449 host_impl_->DrawLayers(&frame); |
7448 host_impl_->DidDrawAllLayers(frame); | 7450 host_impl_->DidDrawAllLayers(frame); |
7449 host_impl_->SwapBuffers(frame); | 7451 host_impl_->SwapBuffers(frame); |
7450 | 7452 |
7451 EXPECT_GT(context3d->NumTextures(), 0u); | 7453 EXPECT_GT(context3d->NumTextures(), 0u); |
7452 | 7454 |
7453 // Kill the layer tree. | 7455 // Kill the layer tree. |
7454 host_impl_->active_tree()->DetachLayers(); | 7456 host_impl_->active_tree()->DetachLayers(); |
7455 // There should be no textures left in use after. | 7457 // There should be no textures left in use after. |
7456 EXPECT_EQ(0u, context3d->NumTextures()); | 7458 EXPECT_EQ(0u, context3d->NumTextures()); |
(...skipping 12 matching lines...) Expand all Loading... |
7469 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 7471 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
7470 new MockDrawQuadsToFillScreenContext); | 7472 new MockDrawQuadsToFillScreenContext); |
7471 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 7473 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
7472 | 7474 |
7473 // Run test case | 7475 // Run test case |
7474 LayerTreeSettings settings = DefaultSettings(); | 7476 LayerTreeSettings settings = DefaultSettings(); |
7475 settings.renderer_settings.partial_swap_enabled = false; | 7477 settings.renderer_settings.partial_swap_enabled = false; |
7476 CreateHostImpl(settings, | 7478 CreateHostImpl(settings, |
7477 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7479 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
7478 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7480 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 7481 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7482 |
7479 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7483 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
7480 | 7484 |
7481 // Verify one quad is drawn when transparent background set is not set. | 7485 // Verify one quad is drawn when transparent background set is not set. |
7482 host_impl_->active_tree()->set_has_transparent_background(false); | 7486 host_impl_->active_tree()->set_has_transparent_background(false); |
7483 EXPECT_CALL(*mock_context, useProgram(_)) | 7487 EXPECT_CALL(*mock_context, useProgram(_)) |
7484 .Times(1); | 7488 .Times(1); |
7485 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 7489 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
7486 .Times(1); | 7490 .Times(1); |
7487 LayerTreeHostImpl::FrameData frame; | 7491 LayerTreeHostImpl::FrameData frame; |
7488 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7492 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7489 host_impl_->DrawLayers(&frame); | 7493 host_impl_->DrawLayers(&frame); |
7490 host_impl_->DidDrawAllLayers(frame); | 7494 host_impl_->DidDrawAllLayers(frame); |
7491 Mock::VerifyAndClearExpectations(&mock_context); | 7495 Mock::VerifyAndClearExpectations(&mock_context); |
7492 | 7496 |
7493 // Verify no quads are drawn when transparent background is set. | 7497 // Verify no quads are drawn when transparent background is set. |
7494 host_impl_->active_tree()->set_has_transparent_background(true); | 7498 host_impl_->active_tree()->set_has_transparent_background(true); |
7495 host_impl_->SetFullRootLayerDamage(); | 7499 host_impl_->SetFullRootLayerDamage(); |
7496 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7500 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7497 host_impl_->DrawLayers(&frame); | 7501 host_impl_->DrawLayers(&frame); |
7498 host_impl_->DidDrawAllLayers(frame); | 7502 host_impl_->DidDrawAllLayers(frame); |
7499 Mock::VerifyAndClearExpectations(&mock_context); | 7503 Mock::VerifyAndClearExpectations(&mock_context); |
7500 } | 7504 } |
7501 | 7505 |
7502 class LayerTreeHostImplTestWithDelegatingRenderer | 7506 class LayerTreeHostImplTestWithDelegatingRenderer |
7503 : public LayerTreeHostImplTest { | 7507 : public LayerTreeHostImplTest { |
7504 protected: | 7508 protected: |
7505 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 7509 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
7506 return FakeOutputSurface::CreateDelegating3d(); | 7510 return FakeOutputSurface::CreateDelegating3d(); |
7507 } | 7511 } |
7508 | 7512 |
7509 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { | 7513 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { |
7510 bool expect_to_draw = !expected_damage.IsEmpty(); | 7514 bool expect_to_draw = !expected_damage.IsEmpty(); |
7511 | 7515 |
7512 LayerTreeHostImpl::FrameData frame; | 7516 LayerTreeHostImpl::FrameData frame; |
7513 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7517 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7514 | 7518 |
7515 if (!expect_to_draw) { | 7519 if (!expect_to_draw) { |
7516 // With no damage, we don't draw, and no quads are created. | 7520 // With no damage, we don't draw, and no quads are created. |
7517 ASSERT_EQ(0u, frame.render_passes.size()); | 7521 ASSERT_EQ(0u, frame.render_passes.size()); |
7518 } else { | 7522 } else { |
7519 ASSERT_EQ(1u, frame.render_passes.size()); | 7523 ASSERT_EQ(1u, frame.render_passes.size()); |
7520 | 7524 |
7521 // Verify the damage rect for the root render pass. | 7525 // Verify the damage rect for the root render pass. |
7522 const RenderPass* root_render_pass = frame.render_passes.back().get(); | 7526 const RenderPass* root_render_pass = frame.render_passes.back().get(); |
7523 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); | 7527 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7556 | 7560 |
7557 // Child layer is in the bottom right corner. | 7561 // Child layer is in the bottom right corner. |
7558 std::unique_ptr<SolidColorLayerImpl> child = | 7562 std::unique_ptr<SolidColorLayerImpl> child = |
7559 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7563 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
7560 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7564 child->SetPosition(gfx::PointF(9.f, 9.f)); |
7561 child->SetBounds(gfx::Size(1, 1)); | 7565 child->SetBounds(gfx::Size(1, 1)); |
7562 child->SetDrawsContent(true); | 7566 child->SetDrawsContent(true); |
7563 root->test_properties()->AddChild(std::move(child)); | 7567 root->test_properties()->AddChild(std::move(child)); |
7564 | 7568 |
7565 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 7569 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7570 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7566 | 7571 |
7567 // Draw a frame. In the first frame, the entire viewport should be damaged. | 7572 // Draw a frame. In the first frame, the entire viewport should be damaged. |
7568 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7573 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
7569 DrawFrameAndTestDamage(full_frame_damage); | 7574 DrawFrameAndTestDamage(full_frame_damage); |
7570 | 7575 |
7571 // The second frame has damage that doesn't touch the child layer. Its quads | 7576 // The second frame has damage that doesn't touch the child layer. Its quads |
7572 // should still be generated. | 7577 // should still be generated. |
7573 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); | 7578 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); |
7574 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( | 7579 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( |
7575 small_damage); | 7580 small_damage); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7635 | 7640 |
7636 gfx::ScrollOffset scroll_offset(100000, 0); | 7641 gfx::ScrollOffset scroll_offset(100000, 0); |
7637 scrolling_layer->SetScrollClipLayer(root->id()); | 7642 scrolling_layer->SetScrollClipLayer(root->id()); |
7638 scrolling_layer->layer_tree_impl() | 7643 scrolling_layer->layer_tree_impl() |
7639 ->property_trees() | 7644 ->property_trees() |
7640 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), | 7645 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), |
7641 scroll_offset); | 7646 scroll_offset); |
7642 | 7647 |
7643 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 7648 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7644 host_impl_->ActivateSyncTree(); | 7649 host_impl_->ActivateSyncTree(); |
7645 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | |
7646 | 7650 |
7647 bool update_lcd_text = false; | 7651 bool update_lcd_text = false; |
7648 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 7652 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
7649 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 7653 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
7650 | 7654 |
7651 LayerTreeHostImpl::FrameData frame; | 7655 LayerTreeHostImpl::FrameData frame; |
7652 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7656 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7653 | 7657 |
7654 ASSERT_EQ(1u, frame.render_passes.size()); | 7658 ASSERT_EQ(1u, frame.render_passes.size()); |
7655 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 7659 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
7656 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); | 7660 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); |
7657 | 7661 |
7658 bool clipped = false, force_aa = false; | 7662 bool clipped = false, force_aa = false; |
7659 gfx::QuadF device_layer_quad = MathUtil::MapQuad( | 7663 gfx::QuadF device_layer_quad = MathUtil::MapQuad( |
7660 quad->shared_quad_state->quad_to_target_transform, | 7664 quad->shared_quad_state->quad_to_target_transform, |
7661 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)), | 7665 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)), |
7662 &clipped); | 7666 &clipped); |
7663 EXPECT_FALSE(clipped); | 7667 EXPECT_FALSE(clipped); |
7664 bool antialiased = | 7668 bool antialiased = |
7665 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( | 7669 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( |
7666 device_layer_quad, clipped, force_aa); | 7670 device_layer_quad, clipped, force_aa); |
7667 EXPECT_FALSE(antialiased); | 7671 EXPECT_FALSE(antialiased); |
7668 | 7672 |
7669 host_impl_->DrawLayers(&frame); | 7673 host_impl_->DrawLayers(&frame); |
7670 host_impl_->DidDrawAllLayers(frame); | 7674 host_impl_->DidDrawAllLayers(frame); |
7671 } | 7675 } |
7672 | 7676 |
7673 | |
7674 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 7677 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
7675 public: | 7678 public: |
7676 CompositorFrameMetadataTest() | 7679 CompositorFrameMetadataTest() |
7677 : swap_buffers_complete_(0) {} | 7680 : swap_buffers_complete_(0) {} |
7678 | 7681 |
7679 void DidSwapBuffersCompleteOnImplThread() override { | 7682 void DidSwapBuffersCompleteOnImplThread() override { |
7680 swap_buffers_complete_++; | 7683 swap_buffers_complete_++; |
7681 } | 7684 } |
7682 | 7685 |
7683 int swap_buffers_complete_; | 7686 int swap_buffers_complete_; |
7684 }; | 7687 }; |
7685 | 7688 |
7686 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 7689 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
7687 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 7690 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 7691 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7688 { | 7692 { |
7689 LayerTreeHostImpl::FrameData frame; | 7693 LayerTreeHostImpl::FrameData frame; |
7690 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7694 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7691 host_impl_->DrawLayers(&frame); | 7695 host_impl_->DrawLayers(&frame); |
7692 host_impl_->DidDrawAllLayers(frame); | 7696 host_impl_->DidDrawAllLayers(frame); |
7693 } | 7697 } |
7694 CompositorFrameAck ack; | 7698 CompositorFrameAck ack; |
7695 host_impl_->ReclaimResources(&ack); | 7699 host_impl_->ReclaimResources(&ack); |
7696 host_impl_->DidSwapBuffersComplete(); | 7700 host_impl_->DidSwapBuffersComplete(); |
7697 EXPECT_EQ(swap_buffers_complete_, 1); | 7701 EXPECT_EQ(swap_buffers_complete_, 1); |
7698 } | 7702 } |
7699 | 7703 |
7700 class CountingSoftwareDevice : public SoftwareOutputDevice { | 7704 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); | 7769 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7766 | 7770 |
7767 // VideoLayerImpl will not be drawn. | 7771 // VideoLayerImpl will not be drawn. |
7768 FakeVideoFrameProvider provider; | 7772 FakeVideoFrameProvider provider; |
7769 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7773 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7770 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 7774 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
7771 video_layer->SetBounds(gfx::Size(10, 10)); | 7775 video_layer->SetBounds(gfx::Size(10, 10)); |
7772 video_layer->SetDrawsContent(true); | 7776 video_layer->SetDrawsContent(true); |
7773 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7777 root_layer->test_properties()->AddChild(std::move(video_layer)); |
7774 SetupRootLayerImpl(std::move(root_layer)); | 7778 SetupRootLayerImpl(std::move(root_layer)); |
| 7779 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7775 | 7780 |
7776 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7781 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
7777 resourceless_software_draw); | 7782 resourceless_software_draw); |
7778 | 7783 |
7779 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7784 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
7780 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), | 7785 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), |
7781 last_on_draw_frame_->will_draw_layers[0]); | 7786 last_on_draw_frame_->will_draw_layers[0]); |
7782 } | 7787 } |
7783 | 7788 |
7784 // Checks that we have a non-0 default allocation if we pass a context that | 7789 // 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 | 7953 |
7949 CreateHostImpl(DefaultSettings(), | 7954 CreateHostImpl(DefaultSettings(), |
7950 FakeOutputSurface::Create3d(context_provider)); | 7955 FakeOutputSurface::Create3d(context_provider)); |
7951 | 7956 |
7952 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7957 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7953 | 7958 |
7954 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 7959 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
7955 root->test_properties()->copy_requests.push_back( | 7960 root->test_properties()->copy_requests.push_back( |
7956 CopyOutputRequest::CreateRequest( | 7961 CopyOutputRequest::CreateRequest( |
7957 base::Bind(&ShutdownReleasesContext_Callback))); | 7962 base::Bind(&ShutdownReleasesContext_Callback))); |
| 7963 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7958 | 7964 |
7959 LayerTreeHostImpl::FrameData frame; | 7965 LayerTreeHostImpl::FrameData frame; |
7960 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7966 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7961 host_impl_->DrawLayers(&frame); | 7967 host_impl_->DrawLayers(&frame); |
7962 host_impl_->DidDrawAllLayers(frame); | 7968 host_impl_->DidDrawAllLayers(frame); |
7963 | 7969 |
7964 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 7970 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
7965 // texture in a texture mailbox. | 7971 // texture in a texture mailbox. |
7966 EXPECT_FALSE(context_provider->HasOneRef()); | 7972 EXPECT_FALSE(context_provider->HasOneRef()); |
7967 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 7973 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
7968 | 7974 |
7969 host_impl_ = nullptr; | 7975 host_impl_ = nullptr; |
7970 | 7976 |
(...skipping 22 matching lines...) Expand all Loading... |
7993 | 7999 |
7994 root_scroll->test_properties()->AddChild(std::move(child)); | 8000 root_scroll->test_properties()->AddChild(std::move(child)); |
7995 int root_id = root_scroll->id(); | 8001 int root_id = root_scroll->id(); |
7996 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8002 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
7997 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 8003 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
7998 | 8004 |
7999 host_impl_->SetViewportSize(surface_size); | 8005 host_impl_->SetViewportSize(surface_size); |
8000 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 8006 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
8001 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 8007 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, |
8002 Layer::INVALID_ID); | 8008 Layer::INVALID_ID); |
| 8009 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8003 host_impl_->active_tree()->DidBecomeActive(); | 8010 host_impl_->active_tree()->DidBecomeActive(); |
8004 SetNeedsRebuildPropertyTrees(); | |
8005 DrawFrame(); | 8011 DrawFrame(); |
8006 { | 8012 { |
8007 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8013 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8008 host_impl_ | 8014 host_impl_ |
8009 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8015 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8010 InputHandler::TOUCHSCREEN) | 8016 InputHandler::TOUCHSCREEN) |
8011 .thread); | 8017 .thread); |
8012 | 8018 |
8013 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8019 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8014 host_impl_->FlingScrollBegin().thread); | 8020 host_impl_->FlingScrollBegin().thread); |
(...skipping 13 matching lines...) Expand all Loading... |
8028 } | 8034 } |
8029 } | 8035 } |
8030 | 8036 |
8031 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 8037 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
8032 // Scroll a child layer beyond its maximum scroll range and make sure the | 8038 // Scroll a child layer beyond its maximum scroll range and make sure the |
8033 // the scroll doesn't bubble up to the parent layer. | 8039 // the scroll doesn't bubble up to the parent layer. |
8034 gfx::Size surface_size(10, 10); | 8040 gfx::Size surface_size(10, 10); |
8035 std::unique_ptr<LayerImpl> root = | 8041 std::unique_ptr<LayerImpl> root = |
8036 LayerImpl::Create(host_impl_->active_tree(), 1); | 8042 LayerImpl::Create(host_impl_->active_tree(), 1); |
8037 root->test_properties()->force_render_surface = true; | 8043 root->test_properties()->force_render_surface = true; |
8038 std::unique_ptr<LayerImpl> root_scrolling = | 8044 |
| 8045 std::unique_ptr<LayerImpl> root_scrolling_owned = |
8039 CreateScrollableLayer(2, surface_size, root.get()); | 8046 CreateScrollableLayer(2, surface_size, root.get()); |
| 8047 auto* root_scrolling = root_scrolling_owned.get(); |
| 8048 root->test_properties()->AddChild(std::move(root_scrolling_owned)); |
8040 | 8049 |
8041 std::unique_ptr<LayerImpl> grand_child = | 8050 std::unique_ptr<LayerImpl> child_owned = |
| 8051 CreateScrollableLayer(3, surface_size, root.get()); |
| 8052 auto* child = child_owned.get(); |
| 8053 root_scrolling->test_properties()->AddChild(std::move(child_owned)); |
| 8054 |
| 8055 std::unique_ptr<LayerImpl> grand_child_owned = |
8042 CreateScrollableLayer(4, surface_size, root.get()); | 8056 CreateScrollableLayer(4, surface_size, root.get()); |
| 8057 auto* grand_child = grand_child_owned.get(); |
| 8058 child->test_properties()->AddChild(std::move(grand_child_owned)); |
| 8059 |
| 8060 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8061 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8062 host_impl_->active_tree()->DidBecomeActive(); |
| 8063 |
| 8064 child->layer_tree_impl() |
| 8065 ->property_trees() |
| 8066 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), |
| 8067 gfx::ScrollOffset(0, 4)); |
8043 grand_child->layer_tree_impl() | 8068 grand_child->layer_tree_impl() |
8044 ->property_trees() | 8069 ->property_trees() |
8045 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), | 8070 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), |
8046 gfx::ScrollOffset(0, 2)); | 8071 gfx::ScrollOffset(0, 2)); |
8047 | 8072 |
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); | 8073 host_impl_->SetViewportSize(surface_size); |
8061 SetNeedsRebuildPropertyTrees(); | |
8062 DrawFrame(); | 8074 DrawFrame(); |
8063 { | 8075 { |
8064 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 8076 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
8065 LayerImpl* child = host_impl_->active_tree() | 8077 LayerImpl* child = host_impl_->active_tree() |
8066 ->root_layer_for_testing() | 8078 ->root_layer_for_testing() |
8067 ->test_properties() | 8079 ->test_properties() |
8068 ->children[0] | 8080 ->children[0] |
8069 ->test_properties() | 8081 ->test_properties() |
8070 ->children[0]; | 8082 ->children[0]; |
8071 LayerImpl* grand_child = child->test_properties()->children[0]; | 8083 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; | 8142 root_clip->test_properties()->force_render_surface = true; |
8131 std::unique_ptr<LayerImpl> root_scroll = | 8143 std::unique_ptr<LayerImpl> root_scroll = |
8132 CreateScrollableLayer(1, content_size, root_clip.get()); | 8144 CreateScrollableLayer(1, content_size, root_clip.get()); |
8133 int root_scroll_id = root_scroll->id(); | 8145 int root_scroll_id = root_scroll->id(); |
8134 std::unique_ptr<LayerImpl> child = | 8146 std::unique_ptr<LayerImpl> child = |
8135 CreateScrollableLayer(2, content_size, root_clip.get()); | 8147 CreateScrollableLayer(2, content_size, root_clip.get()); |
8136 | 8148 |
8137 root_scroll->test_properties()->AddChild(std::move(child)); | 8149 root_scroll->test_properties()->AddChild(std::move(child)); |
8138 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8150 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
8139 | 8151 |
| 8152 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
| 8153 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8154 host_impl_->active_tree()->DidBecomeActive(); |
| 8155 |
8140 host_impl_->SetViewportSize(surface_size); | 8156 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(); | 8157 DrawFrame(); |
8145 { | 8158 { |
8146 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8159 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8147 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8160 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8148 InputHandler::WHEEL) | 8161 InputHandler::WHEEL) |
8149 .thread); | 8162 .thread); |
8150 | 8163 |
8151 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8164 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8152 host_impl_->FlingScrollBegin().thread); | 8165 host_impl_->FlingScrollBegin().thread); |
8153 | 8166 |
(...skipping 29 matching lines...) Expand all Loading... |
8183 | 8196 |
8184 int occluder_layer_id = 6; | 8197 int occluder_layer_id = 6; |
8185 std::unique_ptr<LayerImpl> occluder_layer = | 8198 std::unique_ptr<LayerImpl> occluder_layer = |
8186 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 8199 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
8187 occluder_layer->SetDrawsContent(true); | 8200 occluder_layer->SetDrawsContent(true); |
8188 occluder_layer->SetBounds(content_size); | 8201 occluder_layer->SetBounds(content_size); |
8189 occluder_layer->SetPosition(gfx::PointF()); | 8202 occluder_layer->SetPosition(gfx::PointF()); |
8190 | 8203 |
8191 // The parent of the occluder is *above* the scroller. | 8204 // The parent of the occluder is *above* the scroller. |
8192 page_scale_layer->test_properties()->AddChild(std::move(occluder_layer)); | 8205 page_scale_layer->test_properties()->AddChild(std::move(occluder_layer)); |
| 8206 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8193 | 8207 |
8194 SetNeedsRebuildPropertyTrees(); | |
8195 DrawFrame(); | 8208 DrawFrame(); |
8196 | 8209 |
8197 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 8210 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
8198 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 8211 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
8199 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 8212 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
8200 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 8213 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
8201 status.main_thread_scrolling_reasons); | 8214 status.main_thread_scrolling_reasons); |
8202 } | 8215 } |
8203 | 8216 |
8204 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { | 8217 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
(...skipping 21 matching lines...) Expand all Loading... |
8226 | 8239 |
8227 int child_scroll_layer_id = 8; | 8240 int child_scroll_layer_id = 8; |
8228 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 8241 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
8229 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 8242 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
8230 | 8243 |
8231 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 8244 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
8232 | 8245 |
8233 child_scroll->test_properties()->AddChild(std::move(occluder_layer)); | 8246 child_scroll->test_properties()->AddChild(std::move(occluder_layer)); |
8234 child_scroll_clip->test_properties()->AddChild(std::move(child_scroll)); | 8247 child_scroll_clip->test_properties()->AddChild(std::move(child_scroll)); |
8235 scroll_layer->test_properties()->AddChild(std::move(child_scroll_clip)); | 8248 scroll_layer->test_properties()->AddChild(std::move(child_scroll_clip)); |
| 8249 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8236 | 8250 |
8237 SetNeedsRebuildPropertyTrees(); | |
8238 DrawFrame(); | 8251 DrawFrame(); |
8239 | 8252 |
8240 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 8253 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
8241 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 8254 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
8242 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 8255 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
8243 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 8256 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
8244 status.main_thread_scrolling_reasons); | 8257 status.main_thread_scrolling_reasons); |
8245 } | 8258 } |
8246 | 8259 |
8247 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { | 8260 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { |
8248 gfx::Size content_size(100, 100); | 8261 gfx::Size content_size(100, 100); |
8249 SetupScrollAndContentsLayers(content_size); | 8262 SetupScrollAndContentsLayers(content_size); |
8250 | 8263 |
8251 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8264 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
8252 | 8265 |
8253 int scroll_layer_id = 2; | 8266 int scroll_layer_id = 2; |
8254 LayerImpl* scroll_layer = | 8267 LayerImpl* scroll_layer = |
8255 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8268 host_impl_->active_tree()->LayerById(scroll_layer_id); |
8256 | 8269 |
8257 int child_scroll_layer_id = 7; | 8270 int child_scroll_layer_id = 7; |
8258 std::unique_ptr<LayerImpl> child_scroll = | 8271 std::unique_ptr<LayerImpl> child_scroll = |
8259 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 8272 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
8260 child_scroll->SetDrawsContent(false); | 8273 child_scroll->SetDrawsContent(false); |
8261 | 8274 |
8262 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); | 8275 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); |
| 8276 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8263 | 8277 |
8264 SetNeedsRebuildPropertyTrees(); | |
8265 DrawFrame(); | 8278 DrawFrame(); |
8266 | 8279 |
8267 // We should not have scrolled |child_scroll| even though we technically "hit" | 8280 // 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 | 8281 // 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. | 8282 // any layer that is a drawn RSLL member, then we can ignore the hit. |
8270 // | 8283 // |
8271 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 8284 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
8272 // started scrolling the inner viewport. | 8285 // started scrolling the inner viewport. |
8273 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8286 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8274 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8287 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
(...skipping 22 matching lines...) Expand all Loading... |
8297 LayerImpl::Create(host_impl_->active_tree(), 9); | 8310 LayerImpl::Create(host_impl_->active_tree(), 9); |
8298 grand_child_layer->SetDrawsContent(true); | 8311 grand_child_layer->SetDrawsContent(true); |
8299 grand_child_layer->SetBounds(content_size); | 8312 grand_child_layer->SetBounds(content_size); |
8300 // Move the grand child so it's not hit by our test point. | 8313 // Move the grand child so it's not hit by our test point. |
8301 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 8314 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
8302 | 8315 |
8303 child_layer->test_properties()->AddChild(std::move(grand_child_layer)); | 8316 child_layer->test_properties()->AddChild(std::move(grand_child_layer)); |
8304 invisible_scroll_layer->test_properties()->AddChild(std::move(child_layer)); | 8317 invisible_scroll_layer->test_properties()->AddChild(std::move(child_layer)); |
8305 root_scroll_layer->test_properties()->AddChild( | 8318 root_scroll_layer->test_properties()->AddChild( |
8306 std::move(invisible_scroll_layer)); | 8319 std::move(invisible_scroll_layer)); |
| 8320 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8307 | 8321 |
8308 SetNeedsRebuildPropertyTrees(); | |
8309 DrawFrame(); | 8322 DrawFrame(); |
8310 | 8323 |
8311 // We should have scrolled |invisible_scroll_layer| as it was hit and it has | 8324 // We should have scrolled |invisible_scroll_layer| as it was hit and it has |
8312 // a descendant which is a drawn RSLL member. | 8325 // a descendant which is a drawn RSLL member. |
8313 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8326 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8314 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8327 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8315 InputHandler::WHEEL) | 8328 InputHandler::WHEEL) |
8316 .thread); | 8329 .thread); |
8317 | 8330 |
8318 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8331 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()); | 8367 scroll_children->insert(scroll_child.get()); |
8355 invisible_scroll->test_properties()->scroll_children.reset( | 8368 invisible_scroll->test_properties()->scroll_children.reset( |
8356 scroll_children.release()); | 8369 scroll_children.release()); |
8357 | 8370 |
8358 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); | 8371 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); |
8359 | 8372 |
8360 container->test_properties()->AddChild(std::move(invisible_scroll)); | 8373 container->test_properties()->AddChild(std::move(invisible_scroll)); |
8361 container->test_properties()->AddChild(std::move(scroll_child)); | 8374 container->test_properties()->AddChild(std::move(scroll_child)); |
8362 | 8375 |
8363 scroll_layer->test_properties()->AddChild(std::move(container)); | 8376 scroll_layer->test_properties()->AddChild(std::move(container)); |
| 8377 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
8364 | 8378 |
8365 SetNeedsRebuildPropertyTrees(); | |
8366 DrawFrame(); | 8379 DrawFrame(); |
8367 | 8380 |
8368 // We should have scrolled |child_scroll| even though it is invisible. | 8381 // 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 | 8382 // 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. | 8383 // that is a drawn RSLL member, then we should accept this hit. |
8371 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8384 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8372 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8385 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8373 InputHandler::WHEEL) | 8386 InputHandler::WHEEL) |
8374 .thread); | 8387 .thread); |
8375 | 8388 |
8376 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8389 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
8377 } | 8390 } |
8378 | 8391 |
8379 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8392 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
8380 // to CompositorFrameMetadata after SwapBuffers(); | 8393 // to CompositorFrameMetadata after SwapBuffers(); |
8381 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8394 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
8382 std::unique_ptr<SolidColorLayerImpl> root = | 8395 std::unique_ptr<SolidColorLayerImpl> root = |
8383 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8396 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
8384 root->SetPosition(gfx::PointF()); | 8397 root->SetPosition(gfx::PointF()); |
8385 root->SetBounds(gfx::Size(10, 10)); | 8398 root->SetBounds(gfx::Size(10, 10)); |
8386 root->SetDrawsContent(true); | 8399 root->SetDrawsContent(true); |
8387 root->test_properties()->force_render_surface = true; | 8400 root->test_properties()->force_render_surface = true; |
8388 | 8401 |
8389 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8402 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8403 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8390 | 8404 |
8391 FakeOutputSurface* fake_output_surface = | 8405 FakeOutputSurface* fake_output_surface = |
8392 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8406 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8393 | 8407 |
8394 ui::LatencyInfo latency_info; | 8408 ui::LatencyInfo latency_info; |
8395 latency_info.AddLatencyNumber( | 8409 latency_info.AddLatencyNumber( |
8396 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8410 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
8397 std::unique_ptr<SwapPromise> swap_promise( | 8411 std::unique_ptr<SwapPromise> swap_promise( |
8398 new LatencyInfoSwapPromise(latency_info)); | 8412 new LatencyInfoSwapPromise(latency_info)); |
8399 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8413 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
8400 host_impl_->SetNeedsRedraw(); | |
8401 | 8414 |
8402 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8415 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8403 LayerTreeHostImpl::FrameData frame; | 8416 LayerTreeHostImpl::FrameData frame; |
8404 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8417 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
8405 host_impl_->DrawLayers(&frame); | 8418 host_impl_->DrawLayers(&frame); |
8406 host_impl_->DidDrawAllLayers(frame); | 8419 host_impl_->DidDrawAllLayers(frame); |
8407 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8420 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
8408 | 8421 |
8409 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 8422 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
8410 fake_output_surface->last_sent_frame()->metadata.latency_info; | 8423 fake_output_surface->last_sent_frame()->metadata.latency_info; |
8411 EXPECT_EQ(1u, metadata_latency_after.size()); | 8424 EXPECT_EQ(1u, metadata_latency_after.size()); |
8412 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8425 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
8413 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8426 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
8414 } | 8427 } |
8415 | 8428 |
8416 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8429 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
8417 int root_layer_id = 1; | 8430 int root_layer_id = 1; |
8418 std::unique_ptr<SolidColorLayerImpl> root = | 8431 std::unique_ptr<SolidColorLayerImpl> root = |
8419 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8432 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
8420 root->SetPosition(gfx::PointF()); | 8433 root->SetPosition(gfx::PointF()); |
8421 root->SetBounds(gfx::Size(10, 10)); | 8434 root->SetBounds(gfx::Size(10, 10)); |
8422 root->SetDrawsContent(true); | 8435 root->SetDrawsContent(true); |
8423 root->test_properties()->force_render_surface = true; | 8436 root->test_properties()->force_render_surface = true; |
8424 | 8437 |
8425 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8438 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8439 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8426 | 8440 |
8427 // Ensure the default frame selection bounds are empty. | 8441 // Ensure the default frame selection bounds are empty. |
8428 FakeOutputSurface* fake_output_surface = | 8442 FakeOutputSurface* fake_output_surface = |
8429 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8443 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8430 | 8444 |
8431 // Plumb the layer-local selection bounds. | 8445 // Plumb the layer-local selection bounds. |
8432 gfx::Point selection_top(5, 0); | 8446 gfx::Point selection_top(5, 0); |
8433 gfx::Point selection_bottom(5, 5); | 8447 gfx::Point selection_bottom(5, 5); |
8434 LayerSelection selection; | 8448 LayerSelection selection; |
8435 selection.start.type = gfx::SelectionBound::CENTER; | 8449 selection.start.type = gfx::SelectionBound::CENTER; |
8436 selection.start.layer_id = root_layer_id; | 8450 selection.start.layer_id = root_layer_id; |
8437 selection.start.edge_bottom = selection_bottom; | 8451 selection.start.edge_bottom = selection_bottom; |
8438 selection.start.edge_top = selection_top; | 8452 selection.start.edge_top = selection_top; |
8439 selection.end = selection.start; | 8453 selection.end = selection.start; |
8440 host_impl_->active_tree()->RegisterSelection(selection); | 8454 host_impl_->active_tree()->RegisterSelection(selection); |
8441 | 8455 |
8442 // Trigger a draw-swap sequence. | 8456 // Trigger a draw-swap sequence. |
8443 host_impl_->SetNeedsRedraw(); | 8457 host_impl_->SetNeedsRedraw(); |
8444 | 8458 |
8445 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8459 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8446 LayerTreeHostImpl::FrameData frame; | 8460 LayerTreeHostImpl::FrameData frame; |
8447 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8461 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
8448 host_impl_->DrawLayers(&frame); | 8462 host_impl_->DrawLayers(&frame); |
8449 host_impl_->DidDrawAllLayers(frame); | 8463 host_impl_->DidDrawAllLayers(frame); |
8450 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 8464 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
8451 | 8465 |
8452 // Ensure the selection bounds have propagated to the frame metadata. | 8466 // Ensure the selection bounds have propagated to the frame metadata. |
8453 const Selection<gfx::SelectionBound>& selection_after = | 8467 const Selection<gfx::SelectionBound>& selection_after = |
8454 fake_output_surface->last_sent_frame()->metadata.selection; | 8468 fake_output_surface->last_sent_frame()->metadata.selection; |
8455 EXPECT_EQ(selection.start.type, selection_after.start.type()); | 8469 EXPECT_EQ(selection.start.type, selection_after.start.type()); |
8456 EXPECT_EQ(selection.end.type, selection_after.end.type()); | 8470 EXPECT_EQ(selection.end.type, selection_after.end.type()); |
8457 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); | 8471 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(), | 8656 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
8643 gfx::ScrollOffset(0, 10)); | 8657 gfx::ScrollOffset(0, 10)); |
8644 host_impl_->DidChangeTopControlsPosition(); | 8658 host_impl_->DidChangeTopControlsPosition(); |
8645 EXPECT_TRUE(did_request_next_frame_); | 8659 EXPECT_TRUE(did_request_next_frame_); |
8646 EXPECT_TRUE(did_request_redraw_); | 8660 EXPECT_TRUE(did_request_redraw_); |
8647 } | 8661 } |
8648 | 8662 |
8649 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 8663 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
8650 InputHandlerScrollResult result; | 8664 InputHandlerScrollResult result; |
8651 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8665 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8666 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8667 |
8652 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8668 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
8653 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8669 host_impl_->top_controls_manager()->UpdateTopControlsState( |
8654 BOTH, SHOWN, false); | 8670 BOTH, SHOWN, false); |
8655 DrawFrame(); | 8671 DrawFrame(); |
8656 | 8672 |
8657 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8673 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8658 host_impl_ | 8674 host_impl_ |
8659 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8675 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8660 InputHandler::TOUCHSCREEN) | 8676 InputHandler::TOUCHSCREEN) |
8661 .thread); | 8677 .thread); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8752 host_impl_->ScrollBy( | 8768 host_impl_->ScrollBy( |
8753 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 8769 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
8754 .did_scroll); | 8770 .did_scroll); |
8755 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8771 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
8756 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), | 8772 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), |
8757 viewport_layer->CurrentScrollOffset()); | 8773 viewport_layer->CurrentScrollOffset()); |
8758 } | 8774 } |
8759 | 8775 |
8760 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 8776 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
8761 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8777 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8778 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8779 |
8762 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 8780 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
8763 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8781 host_impl_->top_controls_manager()->UpdateTopControlsState( |
8764 BOTH, SHOWN, false); | 8782 BOTH, SHOWN, false); |
8765 DrawFrame(); | 8783 DrawFrame(); |
8766 | 8784 |
8767 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8785 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8768 host_impl_ | 8786 host_impl_ |
8769 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8787 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8770 InputHandler::TOUCHSCREEN) | 8788 InputHandler::TOUCHSCREEN) |
8771 .thread); | 8789 .thread); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8828 EXPECT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 8846 EXPECT_TRUE(host_impl_->top_controls_manager()->has_animation()); |
8829 EXPECT_TRUE(did_request_next_frame_); | 8847 EXPECT_TRUE(did_request_next_frame_); |
8830 } | 8848 } |
8831 host_impl_->DidFinishImplFrame(); | 8849 host_impl_->DidFinishImplFrame(); |
8832 } | 8850 } |
8833 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8851 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
8834 } | 8852 } |
8835 | 8853 |
8836 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 8854 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
8837 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8855 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8856 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8857 |
8838 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8858 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
8839 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8859 host_impl_->top_controls_manager()->UpdateTopControlsState( |
8840 BOTH, SHOWN, false); | 8860 BOTH, SHOWN, false); |
8841 float initial_scroll_offset = 50; | 8861 float initial_scroll_offset = 50; |
8842 scroll_layer->layer_tree_impl() | 8862 scroll_layer->layer_tree_impl() |
8843 ->property_trees() | 8863 ->property_trees() |
8844 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 8864 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
8845 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 8865 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
8846 DrawFrame(); | 8866 DrawFrame(); |
8847 | 8867 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8902 host_impl_->DidFinishImplFrame(); | 8922 host_impl_->DidFinishImplFrame(); |
8903 } | 8923 } |
8904 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8924 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
8905 EXPECT_EQ(-top_controls_height_, | 8925 EXPECT_EQ(-top_controls_height_, |
8906 host_impl_->top_controls_manager()->ControlsTopOffset()); | 8926 host_impl_->top_controls_manager()->ControlsTopOffset()); |
8907 } | 8927 } |
8908 | 8928 |
8909 TEST_F(LayerTreeHostImplWithTopControlsTest, | 8929 TEST_F(LayerTreeHostImplWithTopControlsTest, |
8910 TopControlsAnimationAfterMainThreadFlingStopped) { | 8930 TopControlsAnimationAfterMainThreadFlingStopped) { |
8911 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8931 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8932 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8933 |
8912 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8934 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
8913 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 8935 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
8914 false); | 8936 false); |
8915 float initial_scroll_offset = 50; | 8937 float initial_scroll_offset = 50; |
8916 scroll_layer->layer_tree_impl() | 8938 scroll_layer->layer_tree_impl() |
8917 ->property_trees() | 8939 ->property_trees() |
8918 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 8940 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
8919 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 8941 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
8920 DrawFrame(); | 8942 DrawFrame(); |
8921 | 8943 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8975 } | 8997 } |
8976 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 8998 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); |
8977 EXPECT_EQ(-top_controls_height_, | 8999 EXPECT_EQ(-top_controls_height_, |
8978 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9000 host_impl_->top_controls_manager()->ControlsTopOffset()); |
8979 } | 9001 } |
8980 | 9002 |
8981 TEST_F(LayerTreeHostImplWithTopControlsTest, | 9003 TEST_F(LayerTreeHostImplWithTopControlsTest, |
8982 TopControlsScrollDeltaInOverScroll) { | 9004 TopControlsScrollDeltaInOverScroll) { |
8983 // Verifies that the overscroll delta should not have accumulated in | 9005 // Verifies that the overscroll delta should not have accumulated in |
8984 // the top controls if we do a hide and show without releasing finger. | 9006 // the top controls if we do a hide and show without releasing finger. |
| 9007 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9008 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8985 | 9009 |
8986 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | |
8987 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 9010 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
8988 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 9011 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
8989 false); | 9012 false); |
8990 DrawFrame(); | 9013 DrawFrame(); |
8991 | 9014 |
8992 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9015 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8993 host_impl_ | 9016 host_impl_ |
8994 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9017 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8995 InputHandler::TOUCHSCREEN) | 9018 InputHandler::TOUCHSCREEN) |
8996 .thread); | 9019 .thread); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9113 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 9136 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
9114 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 9137 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
9115 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 9138 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
9116 | 9139 |
9117 inner_clip->test_properties()->force_render_surface = true; | 9140 inner_clip->test_properties()->force_render_surface = true; |
9118 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); | 9141 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); |
9119 layer_tree_impl->SetViewportLayersFromIds( | 9142 layer_tree_impl->SetViewportLayersFromIds( |
9120 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 9143 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
9121 kOuterViewportScrollLayerId); | 9144 kOuterViewportScrollLayerId); |
9122 | 9145 |
| 9146 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9123 host_impl_->active_tree()->DidBecomeActive(); | 9147 host_impl_->active_tree()->DidBecomeActive(); |
9124 } | 9148 } |
9125 }; | 9149 }; |
9126 | 9150 |
9127 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 9151 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
9128 gfx::Size content_size = gfx::Size(100, 160); | 9152 gfx::Size content_size = gfx::Size(100, 160); |
9129 gfx::Size outer_viewport = gfx::Size(50, 80); | 9153 gfx::Size outer_viewport = gfx::Size(50, 80); |
9130 gfx::Size inner_viewport = gfx::Size(25, 40); | 9154 gfx::Size inner_viewport = gfx::Size(25, 40); |
9131 | 9155 |
9132 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9156 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9133 | 9157 |
9134 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9158 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9135 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9159 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9136 SetNeedsRebuildPropertyTrees(); | 9160 |
9137 DrawFrame(); | 9161 DrawFrame(); |
9138 { | 9162 { |
9139 gfx::ScrollOffset inner_expected; | 9163 gfx::ScrollOffset inner_expected; |
9140 gfx::ScrollOffset outer_expected; | 9164 gfx::ScrollOffset outer_expected; |
9141 EXPECT_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9165 EXPECT_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
9142 EXPECT_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9166 EXPECT_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
9143 | 9167 |
9144 gfx::ScrollOffset current_offset(70.f, 100.f); | 9168 gfx::ScrollOffset current_offset(70.f, 100.f); |
9145 | 9169 |
9146 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); | 9170 host_impl_->SetSynchronousInputHandlerRootScrollOffset(current_offset); |
(...skipping 11 matching lines...) Expand all Loading... |
9158 | 9182 |
9159 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 9183 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
9160 gfx::Size content_size = gfx::Size(200, 320); | 9184 gfx::Size content_size = gfx::Size(200, 320); |
9161 gfx::Size outer_viewport = gfx::Size(100, 160); | 9185 gfx::Size outer_viewport = gfx::Size(100, 160); |
9162 gfx::Size inner_viewport = gfx::Size(50, 80); | 9186 gfx::Size inner_viewport = gfx::Size(50, 80); |
9163 | 9187 |
9164 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9188 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9165 | 9189 |
9166 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9190 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9167 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9191 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9168 SetNeedsRebuildPropertyTrees(); | 9192 |
9169 DrawFrame(); | 9193 DrawFrame(); |
9170 { | 9194 { |
9171 gfx::Vector2dF inner_expected; | 9195 gfx::Vector2dF inner_expected; |
9172 gfx::Vector2dF outer_expected; | 9196 gfx::Vector2dF outer_expected; |
9173 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9197 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
9174 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9198 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
9175 | 9199 |
9176 // Scrolling the viewport always sets the outer scroll layer as the | 9200 // Scrolling the viewport always sets the outer scroll layer as the |
9177 // currently scrolling layer. | 9201 // currently scrolling layer. |
9178 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9202 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9227 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9251 TEST_F(LayerTreeHostImplVirtualViewportTest, |
9228 DiagonalScrollBubblesPerfectlyToInner) { | 9252 DiagonalScrollBubblesPerfectlyToInner) { |
9229 gfx::Size content_size = gfx::Size(200, 320); | 9253 gfx::Size content_size = gfx::Size(200, 320); |
9230 gfx::Size outer_viewport = gfx::Size(100, 160); | 9254 gfx::Size outer_viewport = gfx::Size(100, 160); |
9231 gfx::Size inner_viewport = gfx::Size(50, 80); | 9255 gfx::Size inner_viewport = gfx::Size(50, 80); |
9232 | 9256 |
9233 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9257 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9234 | 9258 |
9235 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9259 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9236 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9260 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9237 SetNeedsRebuildPropertyTrees(); | 9261 |
9238 DrawFrame(); | 9262 DrawFrame(); |
9239 { | 9263 { |
9240 gfx::Vector2dF inner_expected; | 9264 gfx::Vector2dF inner_expected; |
9241 gfx::Vector2dF outer_expected; | 9265 gfx::Vector2dF outer_expected; |
9242 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9266 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
9243 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9267 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
9244 | 9268 |
9245 // Make sure the scroll goes to the inner viewport first. | 9269 // Make sure the scroll goes to the inner viewport first. |
9246 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9270 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9247 host_impl_ | 9271 host_impl_ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9291 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9315 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9292 | 9316 |
9293 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9317 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9294 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9318 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9295 | 9319 |
9296 std::unique_ptr<LayerImpl> child = | 9320 std::unique_ptr<LayerImpl> child = |
9297 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9321 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
9298 LayerImpl* child_scroll = child.get(); | 9322 LayerImpl* child_scroll = child.get(); |
9299 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( | 9323 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( |
9300 std::move(child)); | 9324 std::move(child)); |
| 9325 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9301 | 9326 |
9302 SetNeedsRebuildPropertyTrees(); | |
9303 DrawFrame(); | 9327 DrawFrame(); |
9304 { | 9328 { |
9305 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 9329 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
9306 | 9330 |
9307 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 9331 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
9308 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9332 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9309 host_impl_ | 9333 host_impl_ |
9310 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9334 ->ScrollBegin(BeginState(gfx::Point()).get(), |
9311 InputHandler::TOUCHSCREEN) | 9335 InputHandler::TOUCHSCREEN) |
9312 .thread); | 9336 .thread); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9360 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9384 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9361 | 9385 |
9362 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9386 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
9363 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9387 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9364 | 9388 |
9365 std::unique_ptr<LayerImpl> child = | 9389 std::unique_ptr<LayerImpl> child = |
9366 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9390 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
9367 LayerImpl* child_scroll = child.get(); | 9391 LayerImpl* child_scroll = child.get(); |
9368 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( | 9392 outer_scroll->test_properties()->children[0]->test_properties()->AddChild( |
9369 std::move(child)); | 9393 std::move(child)); |
| 9394 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9370 | 9395 |
9371 SetNeedsRebuildPropertyTrees(); | |
9372 DrawFrame(); | 9396 DrawFrame(); |
9373 | 9397 |
9374 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9398 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9375 host_impl_ | 9399 host_impl_ |
9376 ->RootScrollBegin(BeginState(gfx::Point()).get(), | 9400 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
9377 InputHandler::TOUCHSCREEN) | 9401 InputHandler::TOUCHSCREEN) |
9378 .thread); | 9402 .thread); |
9379 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 9403 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
9380 host_impl_->ScrollEnd(EndState().get()); | 9404 host_impl_->ScrollEnd(EndState().get()); |
9381 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9405 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9382 host_impl_ | 9406 host_impl_ |
9383 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9407 ->ScrollBegin(BeginState(gfx::Point()).get(), |
9384 InputHandler::TOUCHSCREEN) | 9408 InputHandler::TOUCHSCREEN) |
9385 .thread); | 9409 .thread); |
9386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9410 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
9387 host_impl_->ScrollEnd(EndState().get()); | 9411 host_impl_->ScrollEnd(EndState().get()); |
9388 } | 9412 } |
9389 | 9413 |
9390 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9414 TEST_F(LayerTreeHostImplVirtualViewportTest, |
9391 NoOverscrollWhenInnerViewportCantScroll) { | 9415 NoOverscrollWhenInnerViewportCantScroll) { |
9392 InputHandlerScrollResult scroll_result; | 9416 InputHandlerScrollResult scroll_result; |
9393 gfx::Size content_size = gfx::Size(100, 160); | 9417 gfx::Size content_size = gfx::Size(100, 160); |
9394 gfx::Size outer_viewport = gfx::Size(50, 80); | 9418 gfx::Size outer_viewport = gfx::Size(50, 80); |
9395 gfx::Size inner_viewport = gfx::Size(25, 40); | 9419 gfx::Size inner_viewport = gfx::Size(25, 40); |
9396 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9420 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
9397 // Make inner viewport unscrollable. | 9421 // Make inner viewport unscrollable. |
9398 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9422 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
9399 inner_scroll->set_user_scrollable_horizontal(false); | 9423 inner_scroll->set_user_scrollable_horizontal(false); |
9400 inner_scroll->set_user_scrollable_vertical(false); | 9424 inner_scroll->set_user_scrollable_vertical(false); |
9401 SetNeedsRebuildPropertyTrees(); | 9425 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 9426 |
9402 DrawFrame(); | 9427 DrawFrame(); |
9403 | 9428 |
9404 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). | 9429 // Ensure inner viewport doesn't react to scrolls (test it's unscrollable). |
9405 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); | 9430 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll->CurrentScrollOffset()); |
9406 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9431 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9407 host_impl_ | 9432 host_impl_ |
9408 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9433 ->ScrollBegin(BeginState(gfx::Point()).get(), |
9409 InputHandler::TOUCHSCREEN) | 9434 InputHandler::TOUCHSCREEN) |
9410 .thread); | 9435 .thread); |
9411 scroll_result = host_impl_->ScrollBy( | 9436 scroll_result = host_impl_->ScrollBy( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9459 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 9484 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
9460 external_transform); | 9485 external_transform); |
9461 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9486 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
9462 resourceless_software_draw); | 9487 resourceless_software_draw); |
9463 EXPECT_TRANSFORMATION_MATRIX_EQ( | 9488 EXPECT_TRANSFORMATION_MATRIX_EQ( |
9464 external_transform, layer->draw_properties().target_space_transform); | 9489 external_transform, layer->draw_properties().target_space_transform); |
9465 } | 9490 } |
9466 | 9491 |
9467 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { | 9492 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { |
9468 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9493 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9494 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
9469 | 9495 |
9470 const gfx::Size viewport_size(100, 100); | 9496 const gfx::Size viewport_size(100, 100); |
9471 host_impl_->SetViewportSize(viewport_size); | 9497 host_impl_->SetViewportSize(viewport_size); |
9472 | 9498 |
9473 const gfx::Transform transform_for_tile_priority; | 9499 const gfx::Transform transform_for_tile_priority; |
9474 const gfx::Transform draw_transform; | 9500 const gfx::Transform draw_transform; |
9475 const gfx::Rect viewport_for_tile_priority1(viewport_size); | 9501 const gfx::Rect viewport_for_tile_priority1(viewport_size); |
9476 const gfx::Rect viewport_for_tile_priority2(50, 50); | 9502 const gfx::Rect viewport_for_tile_priority2(50, 50); |
9477 const gfx::Rect draw_viewport(viewport_size); | 9503 const gfx::Rect draw_viewport(viewport_size); |
9478 const gfx::Rect clip(viewport_size); | 9504 const gfx::Rect clip(viewport_size); |
(...skipping 11 matching lines...) Expand all Loading... |
9490 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, | 9516 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, |
9491 transform_for_tile_priority); | 9517 transform_for_tile_priority); |
9492 EXPECT_TRUE(did_request_redraw_); | 9518 EXPECT_TRUE(did_request_redraw_); |
9493 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9519 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
9494 resourceless_software_draw); | 9520 resourceless_software_draw); |
9495 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9521 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
9496 } | 9522 } |
9497 | 9523 |
9498 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { | 9524 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { |
9499 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9525 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9526 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
9500 | 9527 |
9501 const gfx::Size viewport_size(100, 100); | 9528 const gfx::Size viewport_size(100, 100); |
9502 host_impl_->SetViewportSize(viewport_size); | 9529 host_impl_->SetViewportSize(viewport_size); |
9503 | 9530 |
9504 const gfx::Transform draw_transform; | 9531 const gfx::Transform draw_transform; |
9505 const gfx::Rect draw_viewport1(viewport_size); | 9532 const gfx::Rect draw_viewport1(viewport_size); |
9506 const gfx::Rect draw_viewport2(50, 50); | 9533 const gfx::Rect draw_viewport2(50, 50); |
9507 const gfx::Rect clip(viewport_size); | 9534 const gfx::Rect clip(viewport_size); |
9508 bool resourceless_software_draw = false; | 9535 bool resourceless_software_draw = false; |
9509 | 9536 |
(...skipping 21 matching lines...) Expand all Loading... |
9531 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 9558 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
9532 protected: | 9559 protected: |
9533 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 9560 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
9534 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); | 9561 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); |
9535 } | 9562 } |
9536 }; | 9563 }; |
9537 | 9564 |
9538 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9565 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
9539 ResourcelessSoftwareSetNeedsRedraw) { | 9566 ResourcelessSoftwareSetNeedsRedraw) { |
9540 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9567 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 9568 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
9541 | 9569 |
9542 const gfx::Size viewport_size(100, 100); | 9570 const gfx::Size viewport_size(100, 100); |
9543 host_impl_->SetViewportSize(viewport_size); | 9571 host_impl_->SetViewportSize(viewport_size); |
9544 | 9572 |
9545 const gfx::Transform draw_transform; | 9573 const gfx::Transform draw_transform; |
9546 const gfx::Rect draw_viewport(viewport_size); | 9574 const gfx::Rect draw_viewport(viewport_size); |
9547 const gfx::Rect clip(viewport_size); | 9575 const gfx::Rect clip(viewport_size); |
9548 bool resourceless_software_draw = false; | 9576 bool resourceless_software_draw = false; |
9549 | 9577 |
9550 // Clear any damage. | 9578 // Clear any damage. |
(...skipping 25 matching lines...) Expand all Loading... |
9576 FakeRasterSource::CreateFilled(viewport_size)); | 9604 FakeRasterSource::CreateFilled(viewport_size)); |
9577 std::unique_ptr<FakePictureLayerImpl> layer( | 9605 std::unique_ptr<FakePictureLayerImpl> layer( |
9578 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 9606 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
9579 11, raster_source)); | 9607 11, raster_source)); |
9580 layer->SetBounds(viewport_size); | 9608 layer->SetBounds(viewport_size); |
9581 layer->SetDrawsContent(true); | 9609 layer->SetDrawsContent(true); |
9582 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); | 9610 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); |
9583 | 9611 |
9584 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9612 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9585 host_impl_->ActivateSyncTree(); | 9613 host_impl_->ActivateSyncTree(); |
9586 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); | |
9587 | 9614 |
9588 const gfx::Transform draw_transform; | 9615 const gfx::Transform draw_transform; |
9589 const gfx::Rect draw_viewport(viewport_size); | 9616 const gfx::Rect draw_viewport(viewport_size); |
9590 const gfx::Rect clip(viewport_size); | 9617 const gfx::Rect clip(viewport_size); |
9591 bool resourceless_software_draw = false; | 9618 bool resourceless_software_draw = false; |
9592 | 9619 |
9593 // Regular draw causes UpdateTiles. | 9620 // Regular draw causes UpdateTiles. |
9594 did_request_prepare_tiles_ = false; | 9621 did_request_prepare_tiles_ = false; |
9595 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9622 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
9596 resourceless_software_draw); | 9623 resourceless_software_draw); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9641 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); | 9668 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); |
9642 } | 9669 } |
9643 | 9670 |
9644 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { | 9671 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { |
9645 const gfx::Size layer_size(100, 100); | 9672 const gfx::Size layer_size(100, 100); |
9646 SetupScrollAndContentsLayers(layer_size); | 9673 SetupScrollAndContentsLayers(layer_size); |
9647 LayerImpl* content_layer = host_impl_->active_tree() | 9674 LayerImpl* content_layer = host_impl_->active_tree() |
9648 ->OuterViewportScrollLayer() | 9675 ->OuterViewportScrollLayer() |
9649 ->test_properties() | 9676 ->test_properties() |
9650 ->children[0]; | 9677 ->children[0]; |
9651 SetNeedsRebuildPropertyTrees(); | |
9652 RebuildPropertyTrees(); | |
9653 | 9678 |
9654 bool update_lcd_text = false; | 9679 bool update_lcd_text = false; |
9655 | 9680 |
9656 host_impl_->SetViewportSize(gfx::Size(90, 90)); | 9681 host_impl_->SetViewportSize(gfx::Size(90, 90)); |
9657 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9682 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9658 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 9683 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
9659 | 9684 |
9660 gfx::Transform external_transform; | 9685 gfx::Transform external_transform; |
9661 gfx::Rect external_viewport(10, 20); | 9686 gfx::Rect external_viewport(10, 20); |
9662 gfx::Rect external_clip(layer_size); | 9687 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()); | 9702 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
9678 } | 9703 } |
9679 | 9704 |
9680 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { | 9705 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { |
9681 const gfx::Size layer_size(100, 100); | 9706 const gfx::Size layer_size(100, 100); |
9682 SetupScrollAndContentsLayers(layer_size); | 9707 SetupScrollAndContentsLayers(layer_size); |
9683 LayerImpl* content_layer = host_impl_->active_tree() | 9708 LayerImpl* content_layer = host_impl_->active_tree() |
9684 ->OuterViewportScrollLayer() | 9709 ->OuterViewportScrollLayer() |
9685 ->test_properties() | 9710 ->test_properties() |
9686 ->children[0]; | 9711 ->children[0]; |
9687 SetNeedsRebuildPropertyTrees(); | |
9688 RebuildPropertyTrees(); | |
9689 | 9712 |
9690 bool update_lcd_text = false; | 9713 bool update_lcd_text = false; |
9691 | 9714 |
9692 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9715 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
9693 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9716 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9694 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9717 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
9695 | 9718 |
9696 gfx::Transform external_transform; | 9719 gfx::Transform external_transform; |
9697 external_transform.Translate(10, 10); | 9720 external_transform.Translate(10, 10); |
9698 external_transform.Scale(2, 2); | 9721 external_transform.Scale(2, 2); |
(...skipping 28 matching lines...) Expand all Loading... |
9727 ->children[0]; | 9750 ->children[0]; |
9728 content_layer->test_properties()->AddChild( | 9751 content_layer->test_properties()->AddChild( |
9729 LayerImpl::Create(host_impl_->active_tree(), 100)); | 9752 LayerImpl::Create(host_impl_->active_tree(), 100)); |
9730 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9753 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
9731 test_layer->test_properties()->force_render_surface = true; | 9754 test_layer->test_properties()->force_render_surface = true; |
9732 test_layer->SetDrawsContent(true); | 9755 test_layer->SetDrawsContent(true); |
9733 test_layer->SetBounds(layer_size); | 9756 test_layer->SetBounds(layer_size); |
9734 gfx::Transform perspective_transform; | 9757 gfx::Transform perspective_transform; |
9735 perspective_transform.ApplyPerspectiveDepth(2); | 9758 perspective_transform.ApplyPerspectiveDepth(2); |
9736 test_layer->SetTransform(perspective_transform); | 9759 test_layer->SetTransform(perspective_transform); |
| 9760 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9737 | 9761 |
9738 SetNeedsRebuildPropertyTrees(); | |
9739 RebuildPropertyTrees(); | |
9740 bool update_lcd_text = false; | 9762 bool update_lcd_text = false; |
9741 | 9763 |
9742 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9764 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
9743 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9765 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9744 TransformNode* node = | 9766 TransformNode* node = |
9745 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9767 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
9746 test_layer->transform_tree_index()); | 9768 test_layer->transform_tree_index()); |
9747 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 9769 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
9748 | 9770 |
9749 gfx::Transform external_transform; | 9771 gfx::Transform external_transform; |
(...skipping 22 matching lines...) Expand all Loading... |
9772 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9794 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
9773 test_layer->transform_tree_index()); | 9795 test_layer->transform_tree_index()); |
9774 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 9796 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
9775 } | 9797 } |
9776 | 9798 |
9777 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { | 9799 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { |
9778 const gfx::Size content_size(1000, 1000); | 9800 const gfx::Size content_size(1000, 1000); |
9779 const gfx::Size viewport_size(50, 100); | 9801 const gfx::Size viewport_size(50, 100); |
9780 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9802 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
9781 | 9803 |
9782 SetNeedsRebuildPropertyTrees(); | |
9783 DrawFrame(); | 9804 DrawFrame(); |
9784 | 9805 |
9785 base::TimeTicks start_time = | 9806 base::TimeTicks start_time = |
9786 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 9807 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
9787 | 9808 |
9788 BeginFrameArgs begin_frame_args = | 9809 BeginFrameArgs begin_frame_args = |
9789 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 9810 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
9790 | 9811 |
9791 EXPECT_EQ( | 9812 EXPECT_EQ( |
9792 InputHandler::SCROLL_ON_IMPL_THREAD, | 9813 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()); | 9987 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
9967 host_impl_->DidFinishImplFrame(); | 9988 host_impl_->DidFinishImplFrame(); |
9968 } | 9989 } |
9969 | 9990 |
9970 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9991 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
9971 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9992 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
9972 const gfx::Size content_size(1000, 1000); | 9993 const gfx::Size content_size(1000, 1000); |
9973 const gfx::Size viewport_size(500, 500); | 9994 const gfx::Size viewport_size(500, 500); |
9974 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9995 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
9975 | 9996 |
9976 SetNeedsRebuildPropertyTrees(); | |
9977 DrawFrame(); | 9997 DrawFrame(); |
9978 | 9998 |
9979 base::TimeTicks start_time = | 9999 base::TimeTicks start_time = |
9980 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10000 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
9981 | 10001 |
9982 BeginFrameArgs begin_frame_args = | 10002 BeginFrameArgs begin_frame_args = |
9983 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10003 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
9984 | 10004 |
9985 EXPECT_EQ( | 10005 EXPECT_EQ( |
9986 InputHandler::SCROLL_ON_IMPL_THREAD, | 10006 InputHandler::SCROLL_ON_IMPL_THREAD, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10039 const gfx::Size content_size(200, 200); | 10059 const gfx::Size content_size(200, 200); |
10040 const gfx::Size viewport_size(100, 100); | 10060 const gfx::Size viewport_size(100, 100); |
10041 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10061 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10042 | 10062 |
10043 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 10063 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
10044 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 10064 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
10045 | 10065 |
10046 // Zoom into the page by a 2X factor | 10066 // Zoom into the page by a 2X factor |
10047 float min_page_scale = 1.f, max_page_scale = 4.f; | 10067 float min_page_scale = 1.f, max_page_scale = 4.f; |
10048 float page_scale_factor = 2.f; | 10068 float page_scale_factor = 2.f; |
10049 RebuildPropertyTrees(); | |
10050 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10069 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10051 page_scale_factor, min_page_scale, max_page_scale); | 10070 page_scale_factor, min_page_scale, max_page_scale); |
10052 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10071 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10053 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 10072 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
10054 | 10073 |
10055 // Scroll by a small amount, there should be no bubbling to the outer | 10074 // Scroll by a small amount, there should be no bubbling to the outer |
10056 // viewport. | 10075 // viewport. |
10057 base::TimeTicks start_time = | 10076 base::TimeTicks start_time = |
10058 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10077 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
10059 BeginFrameArgs begin_frame_args = | 10078 BeginFrameArgs begin_frame_args = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10130 const gfx::Size content_size(200, 200); | 10149 const gfx::Size content_size(200, 200); |
10131 const gfx::Size viewport_size(100, 100); | 10150 const gfx::Size viewport_size(100, 100); |
10132 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10151 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10133 | 10152 |
10134 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 10153 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
10135 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 10154 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
10136 | 10155 |
10137 // Zoom into the page by a 2X factor | 10156 // Zoom into the page by a 2X factor |
10138 float min_page_scale = 1.f, max_page_scale = 4.f; | 10157 float min_page_scale = 1.f, max_page_scale = 4.f; |
10139 float page_scale_factor = 2.f; | 10158 float page_scale_factor = 2.f; |
10140 RebuildPropertyTrees(); | |
10141 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10159 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10142 page_scale_factor, min_page_scale, max_page_scale); | 10160 page_scale_factor, min_page_scale, max_page_scale); |
10143 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10161 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10144 | 10162 |
10145 // Scroll the inner viewport. | 10163 // Scroll the inner viewport. |
10146 base::TimeTicks start_time = | 10164 base::TimeTicks start_time = |
10147 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10165 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
10148 BeginFrameArgs begin_frame_args = | 10166 BeginFrameArgs begin_frame_args = |
10149 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10167 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
10150 EXPECT_EQ( | 10168 EXPECT_EQ( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10183 | 10201 |
10184 // Test that smooth scroll offset animation doesn't happen for non user | 10202 // Test that smooth scroll offset animation doesn't happen for non user |
10185 // scrollable layers. | 10203 // scrollable layers. |
10186 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { | 10204 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { |
10187 const gfx::Size content_size(1000, 1000); | 10205 const gfx::Size content_size(1000, 1000); |
10188 const gfx::Size viewport_size(500, 500); | 10206 const gfx::Size viewport_size(500, 500); |
10189 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10207 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10190 | 10208 |
10191 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); | 10209 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); |
10192 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); | 10210 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); |
| 10211 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
10193 | 10212 |
10194 SetNeedsRebuildPropertyTrees(); | |
10195 DrawFrame(); | 10213 DrawFrame(); |
10196 | 10214 |
10197 base::TimeTicks start_time = | 10215 base::TimeTicks start_time = |
10198 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10216 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10199 | 10217 |
10200 BeginFrameArgs begin_frame_args = | 10218 BeginFrameArgs begin_frame_args = |
10201 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10219 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
10202 | 10220 |
10203 EXPECT_EQ( | 10221 EXPECT_EQ( |
10204 InputHandler::SCROLL_ON_IMPL_THREAD, | 10222 InputHandler::SCROLL_ON_IMPL_THREAD, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10254 } | 10272 } |
10255 | 10273 |
10256 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10274 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
10257 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10275 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
10258 const gfx::Size old_content_size(1000, 1000); | 10276 const gfx::Size old_content_size(1000, 1000); |
10259 const gfx::Size new_content_size(750, 750); | 10277 const gfx::Size new_content_size(750, 750); |
10260 const gfx::Size viewport_size(500, 500); | 10278 const gfx::Size viewport_size(500, 500); |
10261 | 10279 |
10262 LayerImpl* content_layer = | 10280 LayerImpl* content_layer = |
10263 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10281 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
10264 SetNeedsRebuildPropertyTrees(); | 10282 |
10265 DrawFrame(); | 10283 DrawFrame(); |
10266 | 10284 |
10267 base::TimeTicks start_time = | 10285 base::TimeTicks start_time = |
10268 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10286 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10269 BeginFrameArgs begin_frame_args = | 10287 BeginFrameArgs begin_frame_args = |
10270 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10288 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
10271 | 10289 |
10272 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10290 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
10273 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10291 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10274 | 10292 |
10275 begin_frame_args.frame_time = start_time; | 10293 begin_frame_args.frame_time = start_time; |
10276 host_impl_->WillBeginImplFrame(begin_frame_args); | 10294 host_impl_->WillBeginImplFrame(begin_frame_args); |
10277 host_impl_->Animate(); | 10295 host_impl_->Animate(); |
10278 host_impl_->UpdateAnimationState(true); | 10296 host_impl_->UpdateAnimationState(true); |
10279 host_impl_->DidFinishImplFrame(); | 10297 host_impl_->DidFinishImplFrame(); |
10280 | 10298 |
10281 content_layer->SetBounds(new_content_size); | 10299 content_layer->SetBounds(new_content_size); |
10282 scrolling_layer->SetBounds(new_content_size); | 10300 scrolling_layer->SetBounds(new_content_size); |
10283 SetNeedsRebuildPropertyTrees(); | 10301 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 10302 |
10284 DrawFrame(); | 10303 DrawFrame(); |
10285 | 10304 |
10286 begin_frame_args.frame_time = | 10305 begin_frame_args.frame_time = |
10287 start_time + base::TimeDelta::FromMilliseconds(200); | 10306 start_time + base::TimeDelta::FromMilliseconds(200); |
10288 host_impl_->WillBeginImplFrame(begin_frame_args); | 10307 host_impl_->WillBeginImplFrame(begin_frame_args); |
10289 host_impl_->Animate(); | 10308 host_impl_->Animate(); |
10290 host_impl_->UpdateAnimationState(true); | 10309 host_impl_->UpdateAnimationState(true); |
10291 host_impl_->DidFinishImplFrame(); | 10310 host_impl_->DidFinishImplFrame(); |
10292 | 10311 |
10293 EXPECT_EQ(gfx::ScrollOffset(250, 250), | 10312 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10367 FakePictureLayerImpl::Create(pending_tree, 12); | 10386 FakePictureLayerImpl::Create(pending_tree, 12); |
10368 std::unique_ptr<FakePictureLayerImpl> replica_mask_layer = | 10387 std::unique_ptr<FakePictureLayerImpl> replica_mask_layer = |
10369 FakePictureLayerImpl::Create(pending_tree, 13); | 10388 FakePictureLayerImpl::Create(pending_tree, 13); |
10370 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); | 10389 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); |
10371 replica_layer->test_properties()->SetMaskLayer(std::move(replica_mask_layer)); | 10390 replica_layer->test_properties()->SetMaskLayer(std::move(replica_mask_layer)); |
10372 raw_pending_layer->test_properties()->SetReplicaLayer( | 10391 raw_pending_layer->test_properties()->SetReplicaLayer( |
10373 std::move(replica_layer)); | 10392 std::move(replica_layer)); |
10374 ASSERT_EQ(raw_replica_mask_layer, raw_pending_layer->test_properties() | 10393 ASSERT_EQ(raw_replica_mask_layer, raw_pending_layer->test_properties() |
10375 ->replica_layer->test_properties() | 10394 ->replica_layer->test_properties() |
10376 ->mask_layer); | 10395 ->mask_layer); |
10377 pending_tree->property_trees()->needs_rebuild = true; | |
10378 pending_tree->BuildLayerListAndPropertyTreesForTesting(); | 10396 pending_tree->BuildLayerListAndPropertyTreesForTesting(); |
10379 | 10397 |
10380 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 10398 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
10381 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 10399 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
10382 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); | 10400 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); |
10383 pending_tree->DidBecomeActive(); | 10401 pending_tree->DidBecomeActive(); |
10384 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); | 10402 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); |
10385 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); | 10403 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); |
10386 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); | 10404 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); |
10387 } | 10405 } |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10822 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10840 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
10823 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); | 10841 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); |
10824 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10842 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
10825 page_scale_layer->test_properties()->AddChild( | 10843 page_scale_layer->test_properties()->AddChild( |
10826 LayerImpl::Create(host_impl_->active_tree(), 100)); | 10844 LayerImpl::Create(host_impl_->active_tree(), 100)); |
10827 | 10845 |
10828 LayerImpl* in_subtree_of_page_scale_layer = | 10846 LayerImpl* in_subtree_of_page_scale_layer = |
10829 host_impl_->active_tree()->LayerById(100); | 10847 host_impl_->active_tree()->LayerById(100); |
10830 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = | 10848 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = |
10831 true; | 10849 true; |
10832 SetNeedsRebuildPropertyTrees(); | 10850 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
10833 RebuildPropertyTrees(); | 10851 |
10834 DrawFrame(); | 10852 DrawFrame(); |
| 10853 |
10835 TransformNode* node = | 10854 TransformNode* node = |
10836 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10855 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
10837 in_subtree_of_page_scale_layer->transform_tree_index()); | 10856 in_subtree_of_page_scale_layer->transform_tree_index()); |
10838 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 10857 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
10839 | 10858 |
10840 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 10859 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 10860 |
10841 DrawFrame(); | 10861 DrawFrame(); |
| 10862 |
10842 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); | 10863 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); |
10843 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10864 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
10844 in_subtree_of_page_scale_layer->transform_tree_index()); | 10865 in_subtree_of_page_scale_layer->transform_tree_index()); |
10845 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); | 10866 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
10846 } | 10867 } |
10847 | 10868 |
10848 TEST_F(LayerTreeHostImplTest, JitterTest) { | 10869 TEST_F(LayerTreeHostImplTest, JitterTest) { |
10849 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 10870 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
10850 | 10871 |
10851 host_impl_->CreatePendingTree(); | 10872 host_impl_->CreatePendingTree(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10889 // layer->CurrentScrollOffset()). | 10910 // layer->CurrentScrollOffset()). |
10890 // However, layer_impl does not store scroll_offset, so it is using scroll | 10911 // 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 | 10912 // tree's scroll offset to initialize itself. Usually this approach works |
10892 // because this is a simple assignment. However if scroll_offset's pending | 10913 // because this is a simple assignment. However if scroll_offset's pending |
10893 // delta is not zero, the delta would be counted twice. | 10914 // delta is not zero, the delta would be counted twice. |
10894 // This hacking here is to restore the damaged scroll offset. | 10915 // This hacking here is to restore the damaged scroll offset. |
10895 gfx::ScrollOffset pending_base = | 10916 gfx::ScrollOffset pending_base = |
10896 pending_tree->property_trees() | 10917 pending_tree->property_trees() |
10897 ->scroll_tree.GetScrollOffsetBaseForTesting( | 10918 ->scroll_tree.GetScrollOffsetBaseForTesting( |
10898 last_scrolled_layer->id()); | 10919 last_scrolled_layer->id()); |
10899 pending_tree->property_trees()->needs_rebuild = true; | |
10900 pending_tree->BuildLayerListAndPropertyTreesForTesting(); | 10920 pending_tree->BuildLayerListAndPropertyTreesForTesting(); |
10901 pending_tree->property_trees() | 10921 pending_tree->property_trees() |
10902 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 10922 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
10903 last_scrolled_layer->id(), pending_base); | 10923 last_scrolled_layer->id(), pending_base); |
10904 pending_tree->LayerById(content_layer->id())->SetNeedsPushProperties(); | 10924 pending_tree->LayerById(content_layer->id())->SetNeedsPushProperties(); |
10905 | 10925 |
10906 pending_tree->set_needs_update_draw_properties(); | 10926 pending_tree->set_needs_update_draw_properties(); |
10907 pending_tree->UpdateDrawProperties(false); | 10927 pending_tree->UpdateDrawProperties(false); |
10908 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); | 10928 float jitter = LayerTreeHostCommon::CalculateLayerJitter(content_layer); |
10909 // There should not be any jitter measured till we hit the fixed point hits | 10929 // There should not be any jitter measured till we hit the fixed point hits |
(...skipping 25 matching lines...) Expand all Loading... |
10935 | 10955 |
10936 // Re-initialize with a software output surface. | 10956 // Re-initialize with a software output surface. |
10937 output_surface_ = FakeOutputSurface::CreateSoftware( | 10957 output_surface_ = FakeOutputSurface::CreateSoftware( |
10938 base::WrapUnique(new SoftwareOutputDevice)); | 10958 base::WrapUnique(new SoftwareOutputDevice)); |
10939 host_impl_->InitializeRenderer(output_surface_.get()); | 10959 host_impl_->InitializeRenderer(output_surface_.get()); |
10940 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10960 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10941 } | 10961 } |
10942 | 10962 |
10943 } // namespace | 10963 } // namespace |
10944 } // namespace cc | 10964 } // namespace cc |
OLD | NEW |