| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // Create both an inner viewport scroll layer and an outer viewport scroll | 274 // Create both an inner viewport scroll layer and an outer viewport scroll |
| 275 // layer. The MaxScrollOffset of the outer viewport scroll layer will be | 275 // layer. The MaxScrollOffset of the outer viewport scroll layer will be |
| 276 // 0x0, so the scrolls will be applied directly to the inner viewport. | 276 // 0x0, so the scrolls will be applied directly to the inner viewport. |
| 277 const int kOuterViewportClipLayerId = 116; | 277 const int kOuterViewportClipLayerId = 116; |
| 278 const int kOuterViewportScrollLayerId = 117; | 278 const int kOuterViewportScrollLayerId = 117; |
| 279 const int kContentLayerId = 118; | 279 const int kContentLayerId = 118; |
| 280 const int kInnerViewportScrollLayerId = 2; | 280 const int kInnerViewportScrollLayerId = 2; |
| 281 const int kInnerViewportClipLayerId = 4; | 281 const int kInnerViewportClipLayerId = 4; |
| 282 const int kPageScaleLayerId = 5; | 282 const int kPageScaleLayerId = 5; |
| 283 | 283 |
| 284 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); | 284 std::unique_ptr<LayerImpl> root = CreateTestLayerImpl(layer_tree_impl, 1); |
| 285 root->SetBounds(content_size); | 285 root->SetBounds(content_size); |
| 286 root->SetPosition(gfx::PointF()); | 286 root->SetPosition(gfx::PointF()); |
| 287 root->test_properties()->force_render_surface = true; | 287 root->test_properties()->force_render_surface = true; |
| 288 | 288 |
| 289 std::unique_ptr<LayerImpl> inner_scroll = | 289 std::unique_ptr<LayerImpl> inner_scroll = |
| 290 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 290 CreateTestLayerImpl(layer_tree_impl, kInnerViewportScrollLayerId); |
| 291 inner_scroll->test_properties()->is_container_for_fixed_position_layers = | 291 inner_scroll->test_properties()->is_container_for_fixed_position_layers = |
| 292 true; | 292 true; |
| 293 inner_scroll->layer_tree_impl() | 293 inner_scroll->layer_tree_impl() |
| 294 ->property_trees() | 294 ->property_trees() |
| 295 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), | 295 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), |
| 296 gfx::ScrollOffset()); | 296 gfx::ScrollOffset()); |
| 297 | 297 |
| 298 std::unique_ptr<LayerImpl> inner_clip = | 298 std::unique_ptr<LayerImpl> inner_clip = |
| 299 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 299 CreateTestLayerImpl(layer_tree_impl, kInnerViewportClipLayerId); |
| 300 inner_clip->SetBounds( | 300 inner_clip->SetBounds( |
| 301 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 301 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
| 302 | 302 |
| 303 std::unique_ptr<LayerImpl> page_scale = | 303 std::unique_ptr<LayerImpl> page_scale = |
| 304 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 304 CreateTestLayerImpl(layer_tree_impl, kPageScaleLayerId); |
| 305 | 305 |
| 306 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 306 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
| 307 inner_scroll->SetBounds(content_size); | 307 inner_scroll->SetBounds(content_size); |
| 308 inner_scroll->SetPosition(gfx::PointF()); | 308 inner_scroll->SetPosition(gfx::PointF()); |
| 309 | 309 |
| 310 std::unique_ptr<LayerImpl> outer_clip = | 310 std::unique_ptr<LayerImpl> outer_clip = |
| 311 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 311 CreateTestLayerImpl(layer_tree_impl, kOuterViewportClipLayerId); |
| 312 outer_clip->SetBounds(content_size); | 312 outer_clip->SetBounds(content_size); |
| 313 outer_clip->test_properties()->is_container_for_fixed_position_layers = | 313 outer_clip->test_properties()->is_container_for_fixed_position_layers = |
| 314 true; | 314 true; |
| 315 | 315 |
| 316 std::unique_ptr<LayerImpl> outer_scroll = | 316 std::unique_ptr<LayerImpl> outer_scroll = |
| 317 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 317 CreateTestLayerImpl(layer_tree_impl, kOuterViewportScrollLayerId); |
| 318 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 318 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 319 outer_scroll->layer_tree_impl() | 319 outer_scroll->layer_tree_impl() |
| 320 ->property_trees() | 320 ->property_trees() |
| 321 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), | 321 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), |
| 322 gfx::ScrollOffset()); | 322 gfx::ScrollOffset()); |
| 323 outer_scroll->SetBounds(content_size); | 323 outer_scroll->SetBounds(content_size); |
| 324 outer_scroll->SetPosition(gfx::PointF()); | 324 outer_scroll->SetPosition(gfx::PointF()); |
| 325 | 325 |
| 326 std::unique_ptr<LayerImpl> contents = | 326 std::unique_ptr<LayerImpl> contents = |
| 327 LayerImpl::Create(layer_tree_impl, kContentLayerId); | 327 CreateTestLayerImpl(layer_tree_impl, kContentLayerId); |
| 328 contents->SetDrawsContent(true); | 328 contents->SetDrawsContent(true); |
| 329 contents->SetBounds(content_size); | 329 contents->SetBounds(content_size); |
| 330 contents->SetPosition(gfx::PointF()); | 330 contents->SetPosition(gfx::PointF()); |
| 331 | 331 |
| 332 outer_scroll->AddChild(std::move(contents)); | 332 outer_scroll->AddChild(std::move(contents)); |
| 333 outer_clip->AddChild(std::move(outer_scroll)); | 333 outer_clip->AddChild(std::move(outer_scroll)); |
| 334 inner_scroll->AddChild(std::move(outer_clip)); | 334 inner_scroll->AddChild(std::move(outer_clip)); |
| 335 page_scale->AddChild(std::move(inner_scroll)); | 335 page_scale->AddChild(std::move(inner_scroll)); |
| 336 inner_clip->AddChild(std::move(page_scale)); | 336 inner_clip->AddChild(std::move(page_scale)); |
| 337 root->AddChild(std::move(inner_clip)); | 337 root->AddChild(std::move(inner_clip)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 return content_layer; | 383 return content_layer; |
| 384 } | 384 } |
| 385 | 385 |
| 386 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, | 386 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, |
| 387 const gfx::Size& size, | 387 const gfx::Size& size, |
| 388 LayerImpl* clip_layer) { | 388 LayerImpl* clip_layer) { |
| 389 DCHECK(clip_layer); | 389 DCHECK(clip_layer); |
| 390 DCHECK(id != clip_layer->id()); | 390 DCHECK(id != clip_layer->id()); |
| 391 std::unique_ptr<LayerImpl> layer = | 391 std::unique_ptr<LayerImpl> layer = |
| 392 LayerImpl::Create(host_impl_->active_tree(), id); | 392 CreateTestLayerImpl(host_impl_->active_tree(), id); |
| 393 layer->SetScrollClipLayer(clip_layer->id()); | 393 layer->SetScrollClipLayer(clip_layer->id()); |
| 394 layer->SetDrawsContent(true); | 394 layer->SetDrawsContent(true); |
| 395 layer->SetBounds(size); | 395 layer->SetBounds(size); |
| 396 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 396 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
| 397 return layer; | 397 return layer; |
| 398 } | 398 } |
| 399 | 399 |
| 400 std::unique_ptr<ScrollState> BeginState(const gfx::Point& point) { | 400 std::unique_ptr<ScrollState> BeginState(const gfx::Point& point) { |
| 401 ScrollStateData scroll_state_data; | 401 ScrollStateData scroll_state_data; |
| 402 scroll_state_data.is_beginning = true; | 402 scroll_state_data.is_beginning = true; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 452 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
| 453 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 453 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 454 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 454 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 455 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 455 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 456 float device_scale_factor); | 456 float device_scale_factor); |
| 457 | 457 |
| 458 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 458 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
| 459 | 459 |
| 460 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 460 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
| 461 | 461 |
| 462 std::unique_ptr<LayerImpl> CreateTestLayerImpl(LayerTreeImpl* tree_impl, |
| 463 int id) { |
| 464 auto layer = LayerImpl::Create(tree_impl, id); |
| 465 layer->SetElementId(NextElementId()); |
| 466 return layer; |
| 467 } |
| 468 |
| 462 protected: | 469 protected: |
| 463 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { | 470 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { |
| 464 return FakeOutputSurface::Create3d(); | 471 return FakeOutputSurface::Create3d(); |
| 465 } | 472 } |
| 466 | 473 |
| 467 void DrawOneFrame() { | 474 void DrawOneFrame() { |
| 468 LayerTreeHostImpl::FrameData frame_data; | 475 LayerTreeHostImpl::FrameData frame_data; |
| 469 PrepareToDrawFrame(&frame_data); | 476 PrepareToDrawFrame(&frame_data); |
| 470 host_impl_->DidDrawAllLayers(frame_data); | 477 host_impl_->DidDrawAllLayers(frame_data); |
| 471 } | 478 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 590 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); |
| 584 | 591 |
| 585 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 592 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 586 host_impl_->ProcessScrollDeltas(); | 593 host_impl_->ProcessScrollDeltas(); |
| 587 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 594 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 588 } | 595 } |
| 589 | 596 |
| 590 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { | 597 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { |
| 591 { | 598 { |
| 592 std::unique_ptr<LayerImpl> root = | 599 std::unique_ptr<LayerImpl> root = |
| 593 LayerImpl::Create(host_impl_->active_tree(), 1); | 600 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 594 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 601 root->AddChild(CreateTestLayerImpl(host_impl_->active_tree(), 2)); |
| 595 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); | 602 root->AddChild(CreateTestLayerImpl(host_impl_->active_tree(), 3)); |
| 596 root->children()[1]->AddChild( | 603 root->children()[1]->AddChild( |
| 597 LayerImpl::Create(host_impl_->active_tree(), 4)); | 604 CreateTestLayerImpl(host_impl_->active_tree(), 4)); |
| 598 root->children()[1]->AddChild( | 605 root->children()[1]->AddChild( |
| 599 LayerImpl::Create(host_impl_->active_tree(), 5)); | 606 CreateTestLayerImpl(host_impl_->active_tree(), 5)); |
| 600 root->children()[1]->children()[0]->AddChild( | 607 root->children()[1]->children()[0]->AddChild( |
| 601 LayerImpl::Create(host_impl_->active_tree(), 6)); | 608 CreateTestLayerImpl(host_impl_->active_tree(), 6)); |
| 602 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 609 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 603 } | 610 } |
| 604 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 611 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 605 | 612 |
| 606 ExpectClearedScrollDeltasRecursive(root); | 613 ExpectClearedScrollDeltasRecursive(root); |
| 607 | 614 |
| 608 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 615 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 609 | 616 |
| 610 scroll_info = host_impl_->ProcessScrollDeltas(); | 617 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 611 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 618 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 612 ExpectClearedScrollDeltasRecursive(root); | 619 ExpectClearedScrollDeltasRecursive(root); |
| 613 | 620 |
| 614 scroll_info = host_impl_->ProcessScrollDeltas(); | 621 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 615 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 622 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 616 ExpectClearedScrollDeltasRecursive(root); | 623 ExpectClearedScrollDeltasRecursive(root); |
| 617 } | 624 } |
| 618 | 625 |
| 619 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 626 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
| 620 gfx::ScrollOffset scroll_offset(20, 30); | 627 gfx::ScrollOffset scroll_offset(20, 30); |
| 621 gfx::Vector2d scroll_delta(11, -15); | 628 gfx::Vector2d scroll_delta(11, -15); |
| 622 { | 629 { |
| 623 std::unique_ptr<LayerImpl> root_clip = | 630 std::unique_ptr<LayerImpl> root_clip = |
| 624 LayerImpl::Create(host_impl_->active_tree(), 2); | 631 CreateTestLayerImpl(host_impl_->active_tree(), 2); |
| 625 std::unique_ptr<LayerImpl> root = | 632 std::unique_ptr<LayerImpl> root = |
| 626 LayerImpl::Create(host_impl_->active_tree(), 1); | 633 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 627 root_clip->SetBounds(gfx::Size(10, 10)); | 634 root_clip->SetBounds(gfx::Size(10, 10)); |
| 628 LayerImpl* root_layer = root.get(); | 635 LayerImpl* root_layer = root.get(); |
| 629 root_clip->AddChild(std::move(root)); | 636 root_clip->AddChild(std::move(root)); |
| 630 root_layer->SetBounds(gfx::Size(110, 110)); | 637 root_layer->SetBounds(gfx::Size(110, 110)); |
| 631 root_layer->SetScrollClipLayer(root_clip->id()); | 638 root_layer->SetScrollClipLayer(root_clip->id()); |
| 632 root_layer->layer_tree_impl() | 639 root_layer->layer_tree_impl() |
| 633 ->property_trees() | 640 ->property_trees() |
| 634 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), | 641 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), |
| 635 scroll_offset); | 642 scroll_offset); |
| 636 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 643 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 809 |
| 803 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 810 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
| 804 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 811 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 805 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 812 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 806 DrawFrame(); | 813 DrawFrame(); |
| 807 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 814 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 808 | 815 |
| 809 LayerImpl* child = 0; | 816 LayerImpl* child = 0; |
| 810 { | 817 { |
| 811 std::unique_ptr<LayerImpl> child_layer = | 818 std::unique_ptr<LayerImpl> child_layer = |
| 812 LayerImpl::Create(host_impl_->active_tree(), 6); | 819 CreateTestLayerImpl(host_impl_->active_tree(), 6); |
| 813 child = child_layer.get(); | 820 child = child_layer.get(); |
| 814 child_layer->SetDrawsContent(true); | 821 child_layer->SetDrawsContent(true); |
| 815 child_layer->SetPosition(gfx::PointF(0, 20)); | 822 child_layer->SetPosition(gfx::PointF(0, 20)); |
| 816 child_layer->SetBounds(gfx::Size(50, 50)); | 823 child_layer->SetBounds(gfx::Size(50, 50)); |
| 817 scroll->AddChild(std::move(child_layer)); | 824 scroll->AddChild(std::move(child_layer)); |
| 818 SetNeedsRebuildPropertyTrees(); | 825 SetNeedsRebuildPropertyTrees(); |
| 819 RebuildPropertyTrees(); | 826 RebuildPropertyTrees(); |
| 820 } | 827 } |
| 821 | 828 |
| 822 // Touch handler regions determine whether touch events block scroll. | 829 // Touch handler regions determine whether touch events block scroll. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 status.main_thread_scrolling_reasons); | 943 status.main_thread_scrolling_reasons); |
| 937 } | 944 } |
| 938 | 945 |
| 939 TEST_F(LayerTreeHostImplTest, ScrollWithOverlappingNonScrollableLayer) { | 946 TEST_F(LayerTreeHostImplTest, ScrollWithOverlappingNonScrollableLayer) { |
| 940 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 947 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 941 gfx::Size content_size = gfx::Size(360, 600); | 948 gfx::Size content_size = gfx::Size(360, 600); |
| 942 gfx::Size scroll_content_size = gfx::Size(345, 3800); | 949 gfx::Size scroll_content_size = gfx::Size(345, 3800); |
| 943 gfx::Size scrollbar_size = gfx::Size(15, 600); | 950 gfx::Size scrollbar_size = gfx::Size(15, 600); |
| 944 | 951 |
| 945 host_impl_->SetViewportSize(content_size); | 952 host_impl_->SetViewportSize(content_size); |
| 946 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); | 953 std::unique_ptr<LayerImpl> root = CreateTestLayerImpl(layer_tree_impl, 1); |
| 947 root->SetBounds(content_size); | 954 root->SetBounds(content_size); |
| 948 root->SetPosition(gfx::PointF()); | 955 root->SetPosition(gfx::PointF()); |
| 949 | 956 |
| 950 std::unique_ptr<LayerImpl> clip = LayerImpl::Create(layer_tree_impl, 2); | 957 std::unique_ptr<LayerImpl> clip = CreateTestLayerImpl(layer_tree_impl, 2); |
| 951 clip->SetBounds(content_size); | 958 clip->SetBounds(content_size); |
| 952 clip->SetPosition(gfx::PointF()); | 959 clip->SetPosition(gfx::PointF()); |
| 953 | 960 |
| 954 std::unique_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, 3); | 961 std::unique_ptr<LayerImpl> scroll = CreateTestLayerImpl(layer_tree_impl, 3); |
| 955 scroll->SetBounds(scroll_content_size); | 962 scroll->SetBounds(scroll_content_size); |
| 956 scroll->SetScrollClipLayer(clip->id()); | 963 scroll->SetScrollClipLayer(clip->id()); |
| 957 scroll->SetDrawsContent(true); | 964 scroll->SetDrawsContent(true); |
| 958 | 965 |
| 959 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 966 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 960 SolidColorScrollbarLayerImpl::Create(layer_tree_impl, 4, VERTICAL, 10, 0, | 967 SolidColorScrollbarLayerImpl::Create(layer_tree_impl, 4, VERTICAL, 10, 0, |
| 961 false, true); | 968 false, true); |
| 962 scrollbar->SetBounds(scrollbar_size); | 969 scrollbar->SetBounds(scrollbar_size); |
| 963 scrollbar->SetPosition(gfx::PointF(345, 0)); | 970 scrollbar->SetPosition(gfx::PointF(345, 0)); |
| 964 scrollbar->SetScrollLayerId(scroll->id()); | 971 scrollbar->SetScrollLayerId(scroll->id()); |
| 965 scrollbar->SetDrawsContent(true); | 972 scrollbar->SetDrawsContent(true); |
| 966 scrollbar->SetOpacity(1.f); | 973 scrollbar->SetOpacity(1.f); |
| 967 | 974 |
| 968 std::unique_ptr<LayerImpl> squash1 = LayerImpl::Create(layer_tree_impl, 5); | 975 std::unique_ptr<LayerImpl> squash1 = CreateTestLayerImpl(layer_tree_impl, 5); |
| 969 squash1->SetBounds(gfx::Size(140, 300)); | 976 squash1->SetBounds(gfx::Size(140, 300)); |
| 970 squash1->SetPosition(gfx::PointF(220, 0)); | 977 squash1->SetPosition(gfx::PointF(220, 0)); |
| 971 squash1->SetDrawsContent(true); | 978 squash1->SetDrawsContent(true); |
| 972 | 979 |
| 973 std::unique_ptr<LayerImpl> squash2 = LayerImpl::Create(layer_tree_impl, 6); | 980 std::unique_ptr<LayerImpl> squash2 = CreateTestLayerImpl(layer_tree_impl, 6); |
| 974 squash2->SetBounds(gfx::Size(140, 300)); | 981 squash2->SetBounds(gfx::Size(140, 300)); |
| 975 squash2->SetPosition(gfx::PointF(220, 300)); | 982 squash2->SetPosition(gfx::PointF(220, 300)); |
| 976 squash2->SetDrawsContent(true); | 983 squash2->SetDrawsContent(true); |
| 977 | 984 |
| 978 scroll->AddChild(std::move(squash2)); | 985 scroll->AddChild(std::move(squash2)); |
| 979 clip->AddChild(std::move(scroll)); | 986 clip->AddChild(std::move(scroll)); |
| 980 clip->AddChild(std::move(scrollbar)); | 987 clip->AddChild(std::move(scrollbar)); |
| 981 clip->AddChild(std::move(squash1)); | 988 clip->AddChild(std::move(squash1)); |
| 982 root->AddChild(std::move(clip)); | 989 root->AddChild(std::move(clip)); |
| 983 | 990 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1303 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1297 } | 1304 } |
| 1298 | 1305 |
| 1299 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1306 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
| 1300 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1307 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 1301 | 1308 |
| 1302 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1309 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1303 | 1310 |
| 1304 host_impl_->CreatePendingTree(); | 1311 host_impl_->CreatePendingTree(); |
| 1305 host_impl_->pending_tree()->SetRootLayer( | 1312 host_impl_->pending_tree()->SetRootLayer( |
| 1306 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1313 CreateTestLayerImpl(host_impl_->pending_tree(), 1)); |
| 1307 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1314 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
| 1308 root->SetBounds(gfx::Size(50, 50)); | 1315 root->SetBounds(gfx::Size(50, 50)); |
| 1309 root->test_properties()->force_render_surface = true; | 1316 root->test_properties()->force_render_surface = true; |
| 1310 | 1317 |
| 1311 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1318 root->AddChild(CreateTestLayerImpl(host_impl_->pending_tree(), 2)); |
| 1312 LayerImpl* child = root->children()[0]; | 1319 LayerImpl* child = root->children()[0]; |
| 1313 child->SetBounds(gfx::Size(10, 10)); | 1320 child->SetBounds(gfx::Size(10, 10)); |
| 1314 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1321 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1315 child->SetDrawsContent(true); | 1322 child->SetDrawsContent(true); |
| 1316 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1323 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1324 3, 0); |
| 1317 | 1325 |
| 1318 EXPECT_FALSE(did_request_next_frame_); | 1326 EXPECT_FALSE(did_request_next_frame_); |
| 1319 EXPECT_FALSE(did_request_redraw_); | 1327 EXPECT_FALSE(did_request_redraw_); |
| 1320 EXPECT_FALSE(did_request_commit_); | 1328 EXPECT_FALSE(did_request_commit_); |
| 1321 | 1329 |
| 1322 host_impl_->AnimatePendingTreeAfterCommit(); | 1330 host_impl_->AnimatePendingTreeAfterCommit(); |
| 1323 | 1331 |
| 1324 // An animation exists on the pending layer. Doing | 1332 // An animation exists on the pending layer. Doing |
| 1325 // AnimatePendingTreeAfterCommit() requests another frame. | 1333 // AnimatePendingTreeAfterCommit() requests another frame. |
| 1326 // In reality, animations without has_set_start_time() == true do not need to | 1334 // In reality, animations without has_set_start_time() == true do not need to |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1346 EXPECT_FALSE(did_request_redraw_); | 1354 EXPECT_FALSE(did_request_redraw_); |
| 1347 EXPECT_FALSE(did_request_commit_); | 1355 EXPECT_FALSE(did_request_commit_); |
| 1348 } | 1356 } |
| 1349 | 1357 |
| 1350 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1358 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
| 1351 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1359 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 1352 | 1360 |
| 1353 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1361 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1354 | 1362 |
| 1355 host_impl_->active_tree()->SetRootLayer( | 1363 host_impl_->active_tree()->SetRootLayer( |
| 1356 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1364 CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 1357 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1365 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1358 root->SetBounds(gfx::Size(50, 50)); | 1366 root->SetBounds(gfx::Size(50, 50)); |
| 1359 root->test_properties()->force_render_surface = true; | 1367 root->test_properties()->force_render_surface = true; |
| 1360 | 1368 |
| 1361 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1369 root->AddChild(CreateTestLayerImpl(host_impl_->active_tree(), 2)); |
| 1362 LayerImpl* child = root->children()[0]; | 1370 LayerImpl* child = root->children()[0]; |
| 1363 child->SetBounds(gfx::Size(10, 10)); | 1371 child->SetBounds(gfx::Size(10, 10)); |
| 1364 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1372 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1365 child->SetDrawsContent(true); | 1373 child->SetDrawsContent(true); |
| 1366 | 1374 |
| 1367 // Add a translate from 6,7 to 8,9. | 1375 // Add a translate from 6,7 to 8,9. |
| 1368 TransformOperations start; | 1376 TransformOperations start; |
| 1369 start.AppendTranslate(6.f, 7.f, 0.f); | 1377 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1370 TransformOperations end; | 1378 TransformOperations end; |
| 1371 end.AppendTranslate(8.f, 9.f, 0.f); | 1379 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1372 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, | 1380 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
| 1373 end); | 1381 start, end); |
| 1374 | 1382 |
| 1375 base::TimeTicks now = base::TimeTicks::Now(); | 1383 base::TimeTicks now = base::TimeTicks::Now(); |
| 1376 host_impl_->WillBeginImplFrame( | 1384 host_impl_->WillBeginImplFrame( |
| 1377 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1385 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
| 1378 | 1386 |
| 1379 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1387 // TODO(crbug.com/551134): We always request a new frame and a draw for |
| 1380 // animations that are on the pending tree, but we don't need to do that | 1388 // animations that are on the pending tree, but we don't need to do that |
| 1381 // unless they are waiting for some future time to start. | 1389 // unless they are waiting for some future time to start. |
| 1382 EXPECT_TRUE(did_request_next_frame_); | 1390 EXPECT_TRUE(did_request_next_frame_); |
| 1383 EXPECT_TRUE(did_request_redraw_); | 1391 EXPECT_TRUE(did_request_redraw_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1410 | 1418 |
| 1411 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { | 1419 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
| 1412 FakeImplTaskRunnerProvider provider(nullptr); | 1420 FakeImplTaskRunnerProvider provider(nullptr); |
| 1413 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), | 1421 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), |
| 1414 &provider); | 1422 &provider); |
| 1415 EXPECT_TRUE(host_impl_->CommitToActiveTree()); | 1423 EXPECT_TRUE(host_impl_->CommitToActiveTree()); |
| 1416 | 1424 |
| 1417 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1425 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1418 | 1426 |
| 1419 host_impl_->active_tree()->SetRootLayer( | 1427 host_impl_->active_tree()->SetRootLayer( |
| 1420 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1428 CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 1421 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1429 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1422 root->SetBounds(gfx::Size(50, 50)); | 1430 root->SetBounds(gfx::Size(50, 50)); |
| 1423 root->SetHasRenderSurface(true); | 1431 root->SetHasRenderSurface(true); |
| 1424 | 1432 |
| 1425 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1433 root->AddChild(CreateTestLayerImpl(host_impl_->active_tree(), 2)); |
| 1426 LayerImpl* child = root->children()[0]; | 1434 LayerImpl* child = root->children()[0]; |
| 1427 child->SetBounds(gfx::Size(10, 10)); | 1435 child->SetBounds(gfx::Size(10, 10)); |
| 1428 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1436 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1429 child->SetDrawsContent(true); | 1437 child->SetDrawsContent(true); |
| 1430 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1438 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1439 3, 0); |
| 1431 | 1440 |
| 1432 // Set up the property trees so that UpdateDrawProperties will work in | 1441 // Set up the property trees so that UpdateDrawProperties will work in |
| 1433 // CommitComplete below. | 1442 // CommitComplete below. |
| 1434 LayerImplList list; | 1443 LayerImplList list; |
| 1435 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1444 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1436 root, gfx::Size(50, 50), &list); | 1445 root, gfx::Size(50, 50), &list); |
| 1437 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1446 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1438 | 1447 |
| 1439 EXPECT_FALSE(did_request_next_frame_); | 1448 EXPECT_FALSE(did_request_next_frame_); |
| 1440 EXPECT_FALSE(did_request_redraw_); | 1449 EXPECT_FALSE(did_request_redraw_); |
| 1441 EXPECT_FALSE(did_request_commit_); | 1450 EXPECT_FALSE(did_request_commit_); |
| 1442 | 1451 |
| 1443 host_impl_->CommitComplete(); | 1452 host_impl_->CommitComplete(); |
| 1444 | 1453 |
| 1445 // Animations on the active tree should be started and ticked, and a new frame | 1454 // Animations on the active tree should be started and ticked, and a new frame |
| 1446 // should be requested to continue ticking them. | 1455 // should be requested to continue ticking them. |
| 1447 EXPECT_TRUE(did_request_next_frame_); | 1456 EXPECT_TRUE(did_request_next_frame_); |
| 1448 EXPECT_TRUE(did_request_redraw_); | 1457 EXPECT_TRUE(did_request_redraw_); |
| 1449 EXPECT_FALSE(did_request_commit_); | 1458 EXPECT_FALSE(did_request_commit_); |
| 1450 | 1459 |
| 1451 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. | 1460 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
| 1452 host_impl_ = nullptr; | 1461 host_impl_ = nullptr; |
| 1453 } | 1462 } |
| 1454 | 1463 |
| 1455 class MissingTilesLayer : public LayerImpl { | 1464 class MissingTilesLayer : public LayerImpl { |
| 1456 public: | 1465 public: |
| 1457 MissingTilesLayer(LayerTreeImpl* layer_tree_impl, int id) | 1466 MissingTilesLayer(LayerTreeImpl* layer_tree_impl, int id) |
| 1458 : LayerImpl(layer_tree_impl, id), has_missing_tiles_(true) {} | 1467 : LayerImpl(layer_tree_impl, id), has_missing_tiles_(true) { |
| 1468 SetElementId(NextElementId()); |
| 1469 } |
| 1459 | 1470 |
| 1460 void set_has_missing_tiles(bool has_missing_tiles) { | 1471 void set_has_missing_tiles(bool has_missing_tiles) { |
| 1461 has_missing_tiles_ = has_missing_tiles; | 1472 has_missing_tiles_ = has_missing_tiles; |
| 1462 } | 1473 } |
| 1463 | 1474 |
| 1464 void AppendQuads(RenderPass* render_pass, | 1475 void AppendQuads(RenderPass* render_pass, |
| 1465 AppendQuadsData* append_quads_data) override { | 1476 AppendQuadsData* append_quads_data) override { |
| 1466 append_quads_data->num_missing_tiles += has_missing_tiles_; | 1477 append_quads_data->num_missing_tiles += has_missing_tiles_; |
| 1467 } | 1478 } |
| 1468 | 1479 |
| 1469 private: | 1480 private: |
| 1470 bool has_missing_tiles_; | 1481 bool has_missing_tiles_; |
| 1471 }; | 1482 }; |
| 1472 | 1483 |
| 1473 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { | 1484 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { |
| 1474 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1485 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1475 | 1486 |
| 1476 host_impl_->active_tree()->SetRootLayer( | 1487 host_impl_->active_tree()->SetRootLayer( |
| 1477 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1488 CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 1478 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1489 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1479 root->SetBounds(gfx::Size(50, 50)); | 1490 root->SetBounds(gfx::Size(50, 50)); |
| 1480 root->SetHasRenderSurface(true); | 1491 root->SetHasRenderSurface(true); |
| 1481 | 1492 |
| 1482 root->AddChild(std::unique_ptr<MissingTilesLayer>( | 1493 root->AddChild(std::unique_ptr<MissingTilesLayer>( |
| 1483 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1494 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
| 1484 MissingTilesLayer* child = | 1495 MissingTilesLayer* child = |
| 1485 static_cast<MissingTilesLayer*>(root->children()[0]); | 1496 static_cast<MissingTilesLayer*>(root->children()[0]); |
| 1486 child->SetBounds(gfx::Size(10, 10)); | 1497 child->SetBounds(gfx::Size(10, 10)); |
| 1487 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1498 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1488 child->SetDrawsContent(true); | 1499 child->SetDrawsContent(true); |
| 1489 | 1500 |
| 1490 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1501 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
| 1491 | 1502 |
| 1492 // Add a translate from 6,7 to 8,9. | 1503 // Add a translate from 6,7 to 8,9. |
| 1493 TransformOperations start; | 1504 TransformOperations start; |
| 1494 start.AppendTranslate(6.f, 7.f, 0.f); | 1505 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1495 TransformOperations end; | 1506 TransformOperations end; |
| 1496 end.AppendTranslate(8.f, 9.f, 0.f); | 1507 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1497 int animation_id = AddAnimatedTransformToLayerWithPlayer( | 1508 int animation_id = AddAnimatedTransformToElementWithPlayer( |
| 1498 child->id(), timeline(), 4.0, start, end); | 1509 child->element_id(), timeline(), 4.0, start, end); |
| 1499 | 1510 |
| 1500 base::TimeTicks now = base::TimeTicks::Now(); | 1511 base::TimeTicks now = base::TimeTicks::Now(); |
| 1501 host_impl_->WillBeginImplFrame( | 1512 host_impl_->WillBeginImplFrame( |
| 1502 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1513 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
| 1503 | 1514 |
| 1504 host_impl_->ActivateAnimations(); | 1515 host_impl_->ActivateAnimations(); |
| 1505 host_impl_->Animate(); | 1516 host_impl_->Animate(); |
| 1506 | 1517 |
| 1507 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1518 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
| 1508 | 1519 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1519 child->set_has_missing_tiles(false); | 1530 child->set_has_missing_tiles(false); |
| 1520 | 1531 |
| 1521 // Child layer has an animating and no missing tiles. | 1532 // Child layer has an animating and no missing tiles. |
| 1522 result = host_impl_->PrepareToDraw(&frame); | 1533 result = host_impl_->PrepareToDraw(&frame); |
| 1523 EXPECT_EQ(DRAW_SUCCESS, result); | 1534 EXPECT_EQ(DRAW_SUCCESS, result); |
| 1524 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1535 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
| 1525 host_impl_->DidDrawAllLayers(frame); | 1536 host_impl_->DidDrawAllLayers(frame); |
| 1526 | 1537 |
| 1527 // Remove the animation. | 1538 // Remove the animation. |
| 1528 child->set_has_missing_tiles(true); | 1539 child->set_has_missing_tiles(true); |
| 1529 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), | 1540 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
| 1530 animation_id); | 1541 animation_id); |
| 1531 child->draw_properties().screen_space_transform_is_animating = false; | 1542 child->draw_properties().screen_space_transform_is_animating = false; |
| 1532 | 1543 |
| 1533 // Child layer doesn't have an animation, but was never ready since the last | 1544 // Child layer doesn't have an animation, but was never ready since the last |
| 1534 // time it animated (and has missing tiles). | 1545 // time it animated (and has missing tiles). |
| 1535 result = host_impl_->PrepareToDraw(&frame); | 1546 result = host_impl_->PrepareToDraw(&frame); |
| 1536 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1547 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
| 1537 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1548 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
| 1538 host_impl_->DidDrawAllLayers(frame); | 1549 host_impl_->DidDrawAllLayers(frame); |
| 1539 | 1550 |
| 1540 child->set_has_missing_tiles(false); | 1551 child->set_has_missing_tiles(false); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1998 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1988 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1999 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1989 | 2000 |
| 1990 // Set up two scrolling children of the root, one of which is a scroll parent | 2001 // Set up two scrolling children of the root, one of which is a scroll parent |
| 1991 // to the other. Scrolls shouldn't bubbling from the child. | 2002 // to the other. Scrolls shouldn't bubbling from the child. |
| 1992 LayerImpl *parent; | 2003 LayerImpl *parent; |
| 1993 LayerImpl *child; | 2004 LayerImpl *child; |
| 1994 LayerImpl *child_clip; | 2005 LayerImpl *child_clip; |
| 1995 | 2006 |
| 1996 std::unique_ptr<LayerImpl> scroll_parent_clip = | 2007 std::unique_ptr<LayerImpl> scroll_parent_clip = |
| 1997 LayerImpl::Create(host_impl_->active_tree(), 6); | 2008 CreateTestLayerImpl(host_impl_->active_tree(), 6); |
| 1998 std::unique_ptr<LayerImpl> scroll_parent = | 2009 std::unique_ptr<LayerImpl> scroll_parent = |
| 1999 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); | 2010 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); |
| 2000 parent = scroll_parent.get(); | 2011 parent = scroll_parent.get(); |
| 2001 scroll_parent_clip->AddChild(std::move(scroll_parent)); | 2012 scroll_parent_clip->AddChild(std::move(scroll_parent)); |
| 2002 | 2013 |
| 2003 viewport_scroll->AddChild(std::move(scroll_parent_clip)); | 2014 viewport_scroll->AddChild(std::move(scroll_parent_clip)); |
| 2004 | 2015 |
| 2005 std::unique_ptr<LayerImpl> scroll_child_clip = | 2016 std::unique_ptr<LayerImpl> scroll_child_clip = |
| 2006 LayerImpl::Create(host_impl_->active_tree(), 8); | 2017 CreateTestLayerImpl(host_impl_->active_tree(), 8); |
| 2007 std::unique_ptr<LayerImpl> scroll_child = | 2018 std::unique_ptr<LayerImpl> scroll_child = |
| 2008 CreateScrollableLayer(9, gfx::Size(10, 10), scroll_child_clip.get()); | 2019 CreateScrollableLayer(9, gfx::Size(10, 10), scroll_child_clip.get()); |
| 2009 child = scroll_child.get(); | 2020 child = scroll_child.get(); |
| 2010 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); | 2021 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); |
| 2011 scroll_child_clip->AddChild(std::move(scroll_child)); | 2022 scroll_child_clip->AddChild(std::move(scroll_child)); |
| 2012 | 2023 |
| 2013 child_clip = scroll_child_clip.get(); | 2024 child_clip = scroll_child_clip.get(); |
| 2014 viewport_scroll->AddChild(std::move(scroll_child_clip)); | 2025 viewport_scroll->AddChild(std::move(scroll_child_clip)); |
| 2015 | 2026 |
| 2016 child_clip->test_properties()->scroll_parent = parent; | 2027 child_clip->test_properties()->scroll_parent = parent; |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 2933 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
| 2923 inner_viewport_size); | 2934 inner_viewport_size); |
| 2924 host_impl_->active_tree()->OuterViewportContainerLayer()->SetBounds( | 2935 host_impl_->active_tree()->OuterViewportContainerLayer()->SetBounds( |
| 2925 outer_viewport_size); | 2936 outer_viewport_size); |
| 2926 LayerImpl* root_scroll = | 2937 LayerImpl* root_scroll = |
| 2927 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2938 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2928 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_scrollbar = | 2939 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_scrollbar = |
| 2929 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), horiz_id, | 2940 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), horiz_id, |
| 2930 HORIZONTAL, 5, 5, true, true); | 2941 HORIZONTAL, 5, 5, true, true); |
| 2931 std::unique_ptr<LayerImpl> child = | 2942 std::unique_ptr<LayerImpl> child = |
| 2932 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 2943 CreateTestLayerImpl(host_impl_->active_tree(), child_scroll_id); |
| 2933 child->SetBounds(content_size); | 2944 child->SetBounds(content_size); |
| 2934 std::unique_ptr<LayerImpl> child_clip = | 2945 std::unique_ptr<LayerImpl> child_clip = |
| 2935 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 2946 CreateTestLayerImpl(host_impl_->active_tree(), child_clip_id); |
| 2936 child->SetBounds(inner_viewport_size); | 2947 child->SetBounds(inner_viewport_size); |
| 2937 | 2948 |
| 2938 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); | 2949 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); |
| 2939 | 2950 |
| 2940 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); | 2951 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); |
| 2941 } | 2952 } |
| 2942 | 2953 |
| 2943 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { | 2954 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { |
| 2944 LayerTreeSettings settings = DefaultSettings(); | 2955 LayerTreeSettings settings = DefaultSettings(); |
| 2945 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | 2956 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2968 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_1_scrollbar = | 2979 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_1_scrollbar = |
| 2969 SolidColorScrollbarLayerImpl::Create( | 2980 SolidColorScrollbarLayerImpl::Create( |
| 2970 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true); | 2981 host_impl_->active_tree(), horiz_1_id, HORIZONTAL, 5, 5, true, true); |
| 2971 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_2_scrollbar = | 2982 std::unique_ptr<SolidColorScrollbarLayerImpl> vert_2_scrollbar = |
| 2972 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_2_id, | 2983 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), vert_2_id, |
| 2973 VERTICAL, 5, 5, true, true); | 2984 VERTICAL, 5, 5, true, true); |
| 2974 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_2_scrollbar = | 2985 std::unique_ptr<SolidColorScrollbarLayerImpl> horiz_2_scrollbar = |
| 2975 SolidColorScrollbarLayerImpl::Create( | 2986 SolidColorScrollbarLayerImpl::Create( |
| 2976 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true); | 2987 host_impl_->active_tree(), horiz_2_id, HORIZONTAL, 5, 5, true, true); |
| 2977 std::unique_ptr<LayerImpl> child = | 2988 std::unique_ptr<LayerImpl> child = |
| 2978 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); | 2989 CreateTestLayerImpl(host_impl_->active_tree(), child_scroll_id); |
| 2979 child->SetBounds(content_size); | 2990 child->SetBounds(content_size); |
| 2980 std::unique_ptr<LayerImpl> child_clip = | 2991 std::unique_ptr<LayerImpl> child_clip = |
| 2981 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); | 2992 CreateTestLayerImpl(host_impl_->active_tree(), child_clip_id); |
| 2982 child->SetBounds(viewport_size); | 2993 child->SetBounds(viewport_size); |
| 2983 LayerImpl* child_ptr = child.get(); | 2994 LayerImpl* child_ptr = child.get(); |
| 2984 LayerImpl* child_clip_ptr = child_clip.get(); | 2995 LayerImpl* child_clip_ptr = child_clip.get(); |
| 2985 | 2996 |
| 2986 // Check scrollbar registration on the viewport layers. | 2997 // Check scrollbar registration on the viewport layers. |
| 2987 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); | 2998 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); |
| 2988 EXPECT_EQ(nullptr, | 2999 EXPECT_EQ(nullptr, |
| 2989 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 3000 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
| 2990 vert_1_scrollbar->SetScrollLayerId(root_scroll->id()); | 3001 vert_1_scrollbar->SetScrollLayerId(root_scroll->id()); |
| 2991 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); | 3002 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(root_scroll->id()).size()); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3303 PassCopyRequests(&requests); | 3314 PassCopyRequests(&requests); |
| 3304 } | 3315 } |
| 3305 | 3316 |
| 3306 protected: | 3317 protected: |
| 3307 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 3318 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
| 3308 : LayerImpl(tree_impl, id), | 3319 : LayerImpl(tree_impl, id), |
| 3309 will_draw_returns_false_(false), | 3320 will_draw_returns_false_(false), |
| 3310 will_draw_called_(false), | 3321 will_draw_called_(false), |
| 3311 append_quads_called_(false), | 3322 append_quads_called_(false), |
| 3312 did_draw_called_(false) { | 3323 did_draw_called_(false) { |
| 3324 SetElementId(NextElementId()); |
| 3313 SetBounds(gfx::Size(10, 10)); | 3325 SetBounds(gfx::Size(10, 10)); |
| 3314 SetDrawsContent(true); | 3326 SetDrawsContent(true); |
| 3315 draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 3327 draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
| 3316 } | 3328 } |
| 3317 | 3329 |
| 3318 private: | 3330 private: |
| 3319 bool will_draw_returns_false_; | 3331 bool will_draw_returns_false_; |
| 3320 bool will_draw_called_; | 3332 bool will_draw_called_; |
| 3321 bool append_quads_called_; | 3333 bool append_quads_called_; |
| 3322 bool did_draw_called_; | 3334 bool did_draw_called_; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3518 int id, | 3530 int id, |
| 3519 bool tile_missing, | 3531 bool tile_missing, |
| 3520 bool had_incomplete_tile, | 3532 bool had_incomplete_tile, |
| 3521 bool animating, | 3533 bool animating, |
| 3522 ResourceProvider* resource_provider, | 3534 ResourceProvider* resource_provider, |
| 3523 scoped_refptr<AnimationTimeline> timeline) | 3535 scoped_refptr<AnimationTimeline> timeline) |
| 3524 : DidDrawCheckLayer(tree_impl, id), | 3536 : DidDrawCheckLayer(tree_impl, id), |
| 3525 tile_missing_(tile_missing), | 3537 tile_missing_(tile_missing), |
| 3526 had_incomplete_tile_(had_incomplete_tile) { | 3538 had_incomplete_tile_(had_incomplete_tile) { |
| 3527 if (animating) | 3539 if (animating) |
| 3528 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); | 3540 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline, |
| 3541 10.0, 3, 0); |
| 3529 } | 3542 } |
| 3530 | 3543 |
| 3531 bool tile_missing_; | 3544 bool tile_missing_; |
| 3532 bool had_incomplete_tile_; | 3545 bool had_incomplete_tile_; |
| 3533 }; | 3546 }; |
| 3534 | 3547 |
| 3535 struct PrepareToDrawSuccessTestCase { | 3548 struct PrepareToDrawSuccessTestCase { |
| 3536 struct State { | 3549 struct State { |
| 3537 bool has_missing_tile = false; | 3550 bool has_missing_tile = false; |
| 3538 bool has_incomplete_tile = false; | 3551 bool has_incomplete_tile = false; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3775 host_impl_->SetRequiresHighResToDraw(); | 3788 host_impl_->SetRequiresHighResToDraw(); |
| 3776 | 3789 |
| 3777 SetNeedsRebuildPropertyTrees(); | 3790 SetNeedsRebuildPropertyTrees(); |
| 3778 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3791 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 3779 resourceless_software_draw); | 3792 resourceless_software_draw); |
| 3780 } | 3793 } |
| 3781 } | 3794 } |
| 3782 | 3795 |
| 3783 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3796 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 3784 std::unique_ptr<LayerImpl> root = | 3797 std::unique_ptr<LayerImpl> root = |
| 3785 LayerImpl::Create(host_impl_->active_tree(), 1); | 3798 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 3786 root->SetScrollClipLayer(Layer::INVALID_ID); | 3799 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 3787 root->test_properties()->force_render_surface = true; | 3800 root->test_properties()->force_render_surface = true; |
| 3788 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 3801 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 3789 SetNeedsRebuildPropertyTrees(); | 3802 SetNeedsRebuildPropertyTrees(); |
| 3790 DrawFrame(); | 3803 DrawFrame(); |
| 3791 | 3804 |
| 3792 // Scroll event is ignored because layer is not scrollable. | 3805 // Scroll event is ignored because layer is not scrollable. |
| 3793 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3806 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 3794 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3807 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 3795 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3808 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 LayerTreeImpl* tree_impl, | 3875 LayerTreeImpl* tree_impl, |
| 3863 const gfx::Size& inner_viewport_size, | 3876 const gfx::Size& inner_viewport_size, |
| 3864 const gfx::Size& outer_viewport_size, | 3877 const gfx::Size& outer_viewport_size, |
| 3865 const gfx::Size& scroll_layer_size) { | 3878 const gfx::Size& scroll_layer_size) { |
| 3866 tree_impl->set_top_controls_shrink_blink_size(true); | 3879 tree_impl->set_top_controls_shrink_blink_size(true); |
| 3867 tree_impl->set_top_controls_height(top_controls_height_); | 3880 tree_impl->set_top_controls_height(top_controls_height_); |
| 3868 tree_impl->SetCurrentTopControlsShownRatio(1.f); | 3881 tree_impl->SetCurrentTopControlsShownRatio(1.f); |
| 3869 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3882 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3870 host_impl_->DidChangeTopControlsPosition(); | 3883 host_impl_->DidChangeTopControlsPosition(); |
| 3871 | 3884 |
| 3872 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); | 3885 std::unique_ptr<LayerImpl> root = CreateTestLayerImpl(tree_impl, 1); |
| 3873 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); | 3886 std::unique_ptr<LayerImpl> root_clip = CreateTestLayerImpl(tree_impl, 2); |
| 3874 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); | 3887 std::unique_ptr<LayerImpl> page_scale = CreateTestLayerImpl(tree_impl, 3); |
| 3875 | 3888 |
| 3876 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); | 3889 std::unique_ptr<LayerImpl> outer_scroll = CreateTestLayerImpl(tree_impl, 4); |
| 3877 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); | 3890 std::unique_ptr<LayerImpl> outer_clip = CreateTestLayerImpl(tree_impl, 5); |
| 3878 | 3891 |
| 3879 root_clip->SetBounds(inner_viewport_size); | 3892 root_clip->SetBounds(inner_viewport_size); |
| 3880 root->SetScrollClipLayer(root_clip->id()); | 3893 root->SetScrollClipLayer(root_clip->id()); |
| 3881 root->SetBounds(outer_viewport_size); | 3894 root->SetBounds(outer_viewport_size); |
| 3882 root->SetPosition(gfx::PointF()); | 3895 root->SetPosition(gfx::PointF()); |
| 3883 root->SetDrawsContent(false); | 3896 root->SetDrawsContent(false); |
| 3884 root_clip->test_properties()->force_render_surface = true; | 3897 root_clip->test_properties()->force_render_surface = true; |
| 3885 root->test_properties()->is_container_for_fixed_position_layers = true; | 3898 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 3886 outer_clip->SetBounds(outer_viewport_size); | 3899 outer_clip->SetBounds(outer_viewport_size); |
| 3887 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 3900 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3928 TEST_F(LayerTreeHostImplTopControlsTest, | 3941 TEST_F(LayerTreeHostImplTopControlsTest, |
| 3929 HidingTopControlsExpandsScrollableSize) { | 3942 HidingTopControlsExpandsScrollableSize) { |
| 3930 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3943 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3931 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); | 3944 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); |
| 3932 | 3945 |
| 3933 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 3946 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 3934 | 3947 |
| 3935 // Create a content layer beneath the outer viewport scroll layer. | 3948 // Create a content layer beneath the outer viewport scroll layer. |
| 3936 int id = host_impl_->OuterViewportScrollLayer()->id(); | 3949 int id = host_impl_->OuterViewportScrollLayer()->id(); |
| 3937 host_impl_->OuterViewportScrollLayer()->AddChild( | 3950 host_impl_->OuterViewportScrollLayer()->AddChild( |
| 3938 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 3951 CreateTestLayerImpl(host_impl_->active_tree(), id + 2)); |
| 3939 LayerImpl* content = active_tree->OuterViewportScrollLayer()->children()[0]; | 3952 LayerImpl* content = active_tree->OuterViewportScrollLayer()->children()[0]; |
| 3940 content->SetBounds(gfx::Size(50, 50)); | 3953 content->SetBounds(gfx::Size(50, 50)); |
| 3941 | 3954 |
| 3942 SetNeedsRebuildPropertyTrees(); | 3955 SetNeedsRebuildPropertyTrees(); |
| 3943 DrawFrame(); | 3956 DrawFrame(); |
| 3944 | 3957 |
| 3945 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 3958 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 3946 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 3959 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 3947 | 3960 |
| 3948 // The top controls should start off showing so the viewport should be shrunk. | 3961 // The top controls should start off showing so the viewport should be shrunk. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4191 DrawFrame(); | 4204 DrawFrame(); |
| 4192 | 4205 |
| 4193 // Show top controls | 4206 // Show top controls |
| 4194 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4207 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4195 | 4208 |
| 4196 LayerImpl* outer_viewport_scroll_layer = | 4209 LayerImpl* outer_viewport_scroll_layer = |
| 4197 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4210 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4198 int id = outer_viewport_scroll_layer->id(); | 4211 int id = outer_viewport_scroll_layer->id(); |
| 4199 | 4212 |
| 4200 std::unique_ptr<LayerImpl> child = | 4213 std::unique_ptr<LayerImpl> child = |
| 4201 LayerImpl::Create(host_impl_->active_tree(), id + 2); | 4214 CreateTestLayerImpl(host_impl_->active_tree(), id + 2); |
| 4202 std::unique_ptr<LayerImpl> child_clip = | 4215 std::unique_ptr<LayerImpl> child_clip = |
| 4203 LayerImpl::Create(host_impl_->active_tree(), id + 3); | 4216 CreateTestLayerImpl(host_impl_->active_tree(), id + 3); |
| 4204 | 4217 |
| 4205 child_clip->SetBounds(sub_content_layer_size); | 4218 child_clip->SetBounds(sub_content_layer_size); |
| 4206 child->SetScrollClipLayer(child_clip->id()); | 4219 child->SetScrollClipLayer(child_clip->id()); |
| 4207 child->SetBounds(sub_content_size); | 4220 child->SetBounds(sub_content_size); |
| 4208 child->SetPosition(gfx::PointF()); | 4221 child->SetPosition(gfx::PointF()); |
| 4209 child->SetDrawsContent(true); | 4222 child->SetDrawsContent(true); |
| 4210 child->test_properties()->is_container_for_fixed_position_layers = true; | 4223 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 4211 | 4224 |
| 4212 // scroll child to limit | 4225 // scroll child to limit |
| 4213 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); | 4226 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4669 EXPECT_EQ(800, outer_scroll->CurrentScrollOffset().y()); | 4682 EXPECT_EQ(800, outer_scroll->CurrentScrollOffset().y()); |
| 4670 } | 4683 } |
| 4671 | 4684 |
| 4672 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 4685 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
| 4673 // Test the configuration where a non-composited root layer is embedded in a | 4686 // Test the configuration where a non-composited root layer is embedded in a |
| 4674 // scrollable outer layer. | 4687 // scrollable outer layer. |
| 4675 gfx::Size surface_size(10, 10); | 4688 gfx::Size surface_size(10, 10); |
| 4676 gfx::Size contents_size(20, 20); | 4689 gfx::Size contents_size(20, 20); |
| 4677 | 4690 |
| 4678 std::unique_ptr<LayerImpl> content_layer = | 4691 std::unique_ptr<LayerImpl> content_layer = |
| 4679 LayerImpl::Create(host_impl_->active_tree(), 1); | 4692 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 4680 content_layer->SetDrawsContent(true); | 4693 content_layer->SetDrawsContent(true); |
| 4681 content_layer->SetPosition(gfx::PointF()); | 4694 content_layer->SetPosition(gfx::PointF()); |
| 4682 content_layer->SetBounds(contents_size); | 4695 content_layer->SetBounds(contents_size); |
| 4683 | 4696 |
| 4684 std::unique_ptr<LayerImpl> scroll_clip_layer = | 4697 std::unique_ptr<LayerImpl> scroll_clip_layer = |
| 4685 LayerImpl::Create(host_impl_->active_tree(), 3); | 4698 CreateTestLayerImpl(host_impl_->active_tree(), 3); |
| 4686 scroll_clip_layer->SetBounds(surface_size); | 4699 scroll_clip_layer->SetBounds(surface_size); |
| 4687 | 4700 |
| 4688 std::unique_ptr<LayerImpl> scroll_layer = | 4701 std::unique_ptr<LayerImpl> scroll_layer = |
| 4689 LayerImpl::Create(host_impl_->active_tree(), 2); | 4702 CreateTestLayerImpl(host_impl_->active_tree(), 2); |
| 4690 scroll_layer->SetScrollClipLayer(3); | 4703 scroll_layer->SetScrollClipLayer(3); |
| 4691 scroll_layer->SetBounds(contents_size); | 4704 scroll_layer->SetBounds(contents_size); |
| 4692 scroll_layer->SetPosition(gfx::PointF()); | 4705 scroll_layer->SetPosition(gfx::PointF()); |
| 4693 scroll_layer->AddChild(std::move(content_layer)); | 4706 scroll_layer->AddChild(std::move(content_layer)); |
| 4694 scroll_clip_layer->AddChild(std::move(scroll_layer)); | 4707 scroll_clip_layer->AddChild(std::move(scroll_layer)); |
| 4695 | 4708 |
| 4696 scroll_clip_layer->test_properties()->force_render_surface = true; | 4709 scroll_clip_layer->test_properties()->force_render_surface = true; |
| 4697 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); | 4710 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); |
| 4698 host_impl_->SetViewportSize(surface_size); | 4711 host_impl_->SetViewportSize(surface_size); |
| 4699 SetNeedsRebuildPropertyTrees(); | 4712 SetNeedsRebuildPropertyTrees(); |
| 4700 DrawFrame(); | 4713 DrawFrame(); |
| 4701 | 4714 |
| 4702 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4715 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4703 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4716 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 4704 InputHandler::WHEEL) | 4717 InputHandler::WHEEL) |
| 4705 .thread); | 4718 .thread); |
| 4706 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4719 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4707 host_impl_->ScrollEnd(EndState().get()); | 4720 host_impl_->ScrollEnd(EndState().get()); |
| 4708 EXPECT_TRUE(did_request_redraw_); | 4721 EXPECT_TRUE(did_request_redraw_); |
| 4709 EXPECT_TRUE(did_request_commit_); | 4722 EXPECT_TRUE(did_request_commit_); |
| 4710 } | 4723 } |
| 4711 | 4724 |
| 4712 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4725 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 4713 gfx::Size surface_size(10, 10); | 4726 gfx::Size surface_size(10, 10); |
| 4714 gfx::Size contents_size(20, 20); | 4727 gfx::Size contents_size(20, 20); |
| 4715 std::unique_ptr<LayerImpl> root = | 4728 std::unique_ptr<LayerImpl> root = |
| 4716 LayerImpl::Create(host_impl_->active_tree(), 1); | 4729 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 4717 root->SetBounds(surface_size); | 4730 root->SetBounds(surface_size); |
| 4718 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 4731 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 4719 root->test_properties()->force_render_surface = true; | 4732 root->test_properties()->force_render_surface = true; |
| 4720 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4733 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 4721 host_impl_->SetViewportSize(surface_size); | 4734 host_impl_->SetViewportSize(surface_size); |
| 4722 SetNeedsRebuildPropertyTrees(); | 4735 SetNeedsRebuildPropertyTrees(); |
| 4723 DrawFrame(); | 4736 DrawFrame(); |
| 4724 | 4737 |
| 4725 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4738 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4726 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4739 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 4727 InputHandler::WHEEL) | 4740 InputHandler::WHEEL) |
| 4728 .thread); | 4741 .thread); |
| 4729 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4742 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4730 host_impl_->ScrollEnd(EndState().get()); | 4743 host_impl_->ScrollEnd(EndState().get()); |
| 4731 EXPECT_TRUE(did_request_redraw_); | 4744 EXPECT_TRUE(did_request_redraw_); |
| 4732 EXPECT_TRUE(did_request_commit_); | 4745 EXPECT_TRUE(did_request_commit_); |
| 4733 } | 4746 } |
| 4734 | 4747 |
| 4735 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4748 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 4736 gfx::Size surface_size(10, 10); | 4749 gfx::Size surface_size(10, 10); |
| 4737 std::unique_ptr<LayerImpl> root = | 4750 std::unique_ptr<LayerImpl> root = |
| 4738 LayerImpl::Create(host_impl_->active_tree(), 1); | 4751 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 4739 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 4752 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 4740 root->test_properties()->force_render_surface = true; | 4753 root->test_properties()->force_render_surface = true; |
| 4741 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4754 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 4742 host_impl_->SetViewportSize(surface_size); | 4755 host_impl_->SetViewportSize(surface_size); |
| 4743 SetNeedsRebuildPropertyTrees(); | 4756 SetNeedsRebuildPropertyTrees(); |
| 4744 DrawFrame(); | 4757 DrawFrame(); |
| 4745 | 4758 |
| 4746 // Scroll event is ignored because the input coordinate is outside the layer | 4759 // Scroll event is ignored because the input coordinate is outside the layer |
| 4747 // boundaries. | 4760 // boundaries. |
| 4748 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4761 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 4749 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4762 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
| 4750 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4763 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 4751 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4764 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 4752 status.main_thread_scrolling_reasons); | 4765 status.main_thread_scrolling_reasons); |
| 4753 | 4766 |
| 4754 EXPECT_FALSE(did_request_redraw_); | 4767 EXPECT_FALSE(did_request_redraw_); |
| 4755 EXPECT_FALSE(did_request_commit_); | 4768 EXPECT_FALSE(did_request_commit_); |
| 4756 } | 4769 } |
| 4757 | 4770 |
| 4758 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4771 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 4759 gfx::Size surface_size(10, 10); | 4772 gfx::Size surface_size(10, 10); |
| 4760 std::unique_ptr<LayerImpl> root = | 4773 std::unique_ptr<LayerImpl> root = |
| 4761 LayerImpl::Create(host_impl_->active_tree(), 1); | 4774 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 4762 root->test_properties()->force_render_surface = true; | 4775 root->test_properties()->force_render_surface = true; |
| 4763 std::unique_ptr<LayerImpl> child = | 4776 std::unique_ptr<LayerImpl> child = |
| 4764 CreateScrollableLayer(2, surface_size, root.get()); | 4777 CreateScrollableLayer(2, surface_size, root.get()); |
| 4765 host_impl_->SetViewportSize(surface_size); | 4778 host_impl_->SetViewportSize(surface_size); |
| 4766 | 4779 |
| 4767 gfx::Transform matrix; | 4780 gfx::Transform matrix; |
| 4768 matrix.RotateAboutXAxis(180.0); | 4781 matrix.RotateAboutXAxis(180.0); |
| 4769 child->SetTransform(matrix); | 4782 child->SetTransform(matrix); |
| 4770 child->test_properties()->double_sided = false; | 4783 child->test_properties()->double_sided = false; |
| 4771 | 4784 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4782 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4795 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
| 4783 status.main_thread_scrolling_reasons); | 4796 status.main_thread_scrolling_reasons); |
| 4784 | 4797 |
| 4785 EXPECT_FALSE(did_request_redraw_); | 4798 EXPECT_FALSE(did_request_redraw_); |
| 4786 EXPECT_FALSE(did_request_commit_); | 4799 EXPECT_FALSE(did_request_commit_); |
| 4787 } | 4800 } |
| 4788 | 4801 |
| 4789 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { | 4802 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { |
| 4790 gfx::Size surface_size(10, 10); | 4803 gfx::Size surface_size(10, 10); |
| 4791 std::unique_ptr<LayerImpl> clip_layer = | 4804 std::unique_ptr<LayerImpl> clip_layer = |
| 4792 LayerImpl::Create(host_impl_->active_tree(), 3); | 4805 CreateTestLayerImpl(host_impl_->active_tree(), 3); |
| 4793 std::unique_ptr<LayerImpl> content_layer = | 4806 std::unique_ptr<LayerImpl> content_layer = |
| 4794 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 4807 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 4795 content_layer->set_main_thread_scrolling_reasons( | 4808 content_layer->set_main_thread_scrolling_reasons( |
| 4796 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 4809 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 4797 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4810 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 4798 | 4811 |
| 4799 // Note: we can use the same clip layer for both since both calls to | 4812 // Note: we can use the same clip layer for both since both calls to |
| 4800 // CreateScrollableLayer() use the same surface size. | 4813 // CreateScrollableLayer() use the same surface size. |
| 4801 std::unique_ptr<LayerImpl> scroll_layer = | 4814 std::unique_ptr<LayerImpl> scroll_layer = |
| 4802 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4815 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4928 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 4941 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
| 4929 | 4942 |
| 4930 // Create a normal scrollable root layer and another scrollable child layer. | 4943 // Create a normal scrollable root layer and another scrollable child layer. |
| 4931 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 4944 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
| 4932 scroll->SetDrawsContent(true); | 4945 scroll->SetDrawsContent(true); |
| 4933 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4946 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4934 LayerImpl* child = scroll->children()[0]; | 4947 LayerImpl* child = scroll->children()[0]; |
| 4935 child->SetDrawsContent(true); | 4948 child->SetDrawsContent(true); |
| 4936 | 4949 |
| 4937 std::unique_ptr<LayerImpl> scrollable_child_clip = | 4950 std::unique_ptr<LayerImpl> scrollable_child_clip = |
| 4938 LayerImpl::Create(host_impl_->active_tree(), 6); | 4951 CreateTestLayerImpl(host_impl_->active_tree(), 6); |
| 4939 std::unique_ptr<LayerImpl> scrollable_child = | 4952 std::unique_ptr<LayerImpl> scrollable_child = |
| 4940 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4953 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 4941 scrollable_child_clip->AddChild(std::move(scrollable_child)); | 4954 scrollable_child_clip->AddChild(std::move(scrollable_child)); |
| 4942 child->AddChild(std::move(scrollable_child_clip)); | 4955 child->AddChild(std::move(scrollable_child_clip)); |
| 4943 LayerImpl* grand_child = child->children()[0]; | 4956 LayerImpl* grand_child = child->children()[0]; |
| 4944 grand_child->SetDrawsContent(true); | 4957 grand_child->SetDrawsContent(true); |
| 4945 | 4958 |
| 4946 // Set new page scale on impl thread by pinching. | 4959 // Set new page scale on impl thread by pinching. |
| 4947 SetNeedsRebuildPropertyTrees(); | 4960 SetNeedsRebuildPropertyTrees(); |
| 4948 RebuildPropertyTrees(); | 4961 RebuildPropertyTrees(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5012 // scale. | 5025 // scale. |
| 5013 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 5026 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
| 5014 } | 5027 } |
| 5015 | 5028 |
| 5016 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 5029 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 5017 // Scroll a child layer beyond its maximum scroll range and make sure the | 5030 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 5018 // parent layer isn't scrolled. | 5031 // parent layer isn't scrolled. |
| 5019 gfx::Size surface_size(10, 10); | 5032 gfx::Size surface_size(10, 10); |
| 5020 gfx::Size content_size(20, 20); | 5033 gfx::Size content_size(20, 20); |
| 5021 std::unique_ptr<LayerImpl> root = | 5034 std::unique_ptr<LayerImpl> root = |
| 5022 LayerImpl::Create(host_impl_->active_tree(), 1); | 5035 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 5023 root->SetBounds(surface_size); | 5036 root->SetBounds(surface_size); |
| 5024 root->test_properties()->force_render_surface = true; | 5037 root->test_properties()->force_render_surface = true; |
| 5025 std::unique_ptr<LayerImpl> grand_child = | 5038 std::unique_ptr<LayerImpl> grand_child = |
| 5026 CreateScrollableLayer(3, content_size, root.get()); | 5039 CreateScrollableLayer(3, content_size, root.get()); |
| 5027 | 5040 |
| 5028 std::unique_ptr<LayerImpl> child = | 5041 std::unique_ptr<LayerImpl> child = |
| 5029 CreateScrollableLayer(2, content_size, root.get()); | 5042 CreateScrollableLayer(2, content_size, root.get()); |
| 5030 LayerImpl* grand_child_layer = grand_child.get(); | 5043 LayerImpl* grand_child_layer = grand_child.get(); |
| 5031 child->AddChild(std::move(grand_child)); | 5044 child->AddChild(std::move(grand_child)); |
| 5032 | 5045 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5068 ExpectNone(*scroll_info.get(), child->id()); | 5081 ExpectNone(*scroll_info.get(), child->id()); |
| 5069 } | 5082 } |
| 5070 } | 5083 } |
| 5071 | 5084 |
| 5072 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 5085 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 5073 // Scroll a child layer beyond its maximum scroll range and make sure the | 5086 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 5074 // the scroll doesn't bubble up to the parent layer. | 5087 // the scroll doesn't bubble up to the parent layer. |
| 5075 gfx::Size surface_size(20, 20); | 5088 gfx::Size surface_size(20, 20); |
| 5076 gfx::Size viewport_size(10, 10); | 5089 gfx::Size viewport_size(10, 10); |
| 5077 std::unique_ptr<LayerImpl> root_ptr = | 5090 std::unique_ptr<LayerImpl> root_ptr = |
| 5078 LayerImpl::Create(host_impl_->active_tree(), 1); | 5091 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 5079 std::unique_ptr<LayerImpl> root_clip = | 5092 std::unique_ptr<LayerImpl> root_clip = |
| 5080 LayerImpl::Create(host_impl_->active_tree(), 2); | 5093 CreateTestLayerImpl(host_impl_->active_tree(), 2); |
| 5081 root_clip->test_properties()->force_render_surface = true; | 5094 root_clip->test_properties()->force_render_surface = true; |
| 5082 std::unique_ptr<LayerImpl> root_scrolling = | 5095 std::unique_ptr<LayerImpl> root_scrolling = |
| 5083 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5096 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 5084 root_scrolling->test_properties()->is_container_for_fixed_position_layers = | 5097 root_scrolling->test_properties()->is_container_for_fixed_position_layers = |
| 5085 true; | 5098 true; |
| 5086 | 5099 |
| 5087 std::unique_ptr<LayerImpl> grand_child = | 5100 std::unique_ptr<LayerImpl> grand_child = |
| 5088 CreateScrollableLayer(5, surface_size, root_clip.get()); | 5101 CreateScrollableLayer(5, surface_size, root_clip.get()); |
| 5089 | 5102 |
| 5090 std::unique_ptr<LayerImpl> child = | 5103 std::unique_ptr<LayerImpl> child = |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5201 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5214 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5202 gfx::Vector2d(0, 4))); | 5215 gfx::Vector2d(0, 4))); |
| 5203 } | 5216 } |
| 5204 } | 5217 } |
| 5205 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 5218 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
| 5206 // When we try to scroll a non-scrollable child layer, the scroll delta | 5219 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 5207 // should be applied to one of its ancestors if possible. | 5220 // should be applied to one of its ancestors if possible. |
| 5208 gfx::Size surface_size(10, 10); | 5221 gfx::Size surface_size(10, 10); |
| 5209 gfx::Size content_size(20, 20); | 5222 gfx::Size content_size(20, 20); |
| 5210 std::unique_ptr<LayerImpl> root_ptr = | 5223 std::unique_ptr<LayerImpl> root_ptr = |
| 5211 LayerImpl::Create(host_impl_->active_tree(), 4); | 5224 CreateTestLayerImpl(host_impl_->active_tree(), 4); |
| 5212 std::unique_ptr<LayerImpl> root_clip = | 5225 std::unique_ptr<LayerImpl> root_clip = |
| 5213 LayerImpl::Create(host_impl_->active_tree(), 3); | 5226 CreateTestLayerImpl(host_impl_->active_tree(), 3); |
| 5214 root_clip->test_properties()->force_render_surface = true; | 5227 root_clip->test_properties()->force_render_surface = true; |
| 5215 std::unique_ptr<LayerImpl> root_scroll = | 5228 std::unique_ptr<LayerImpl> root_scroll = |
| 5216 CreateScrollableLayer(1, content_size, root_clip.get()); | 5229 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 5217 // Make 'root' the clip layer for child: since they have the same sizes the | 5230 // Make 'root' the clip layer for child: since they have the same sizes the |
| 5218 // child will have zero max_scroll_offset and scrolls will bubble. | 5231 // child will have zero max_scroll_offset and scrolls will bubble. |
| 5219 std::unique_ptr<LayerImpl> child = | 5232 std::unique_ptr<LayerImpl> child = |
| 5220 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5233 CreateScrollableLayer(2, content_size, root_scroll.get()); |
| 5221 child->test_properties()->is_container_for_fixed_position_layers = true; | 5234 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 5222 root_scroll->SetBounds(content_size); | 5235 root_scroll->SetBounds(content_size); |
| 5223 | 5236 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5248 // Only the root scroll should have scrolled. | 5261 // Only the root scroll should have scrolled. |
| 5249 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 5262 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 5250 EXPECT_TRUE( | 5263 EXPECT_TRUE( |
| 5251 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); | 5264 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); |
| 5252 } | 5265 } |
| 5253 } | 5266 } |
| 5254 | 5267 |
| 5255 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 5268 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
| 5256 gfx::Size surface_size(10, 10); | 5269 gfx::Size surface_size(10, 10); |
| 5257 std::unique_ptr<LayerImpl> root_ptr = | 5270 std::unique_ptr<LayerImpl> root_ptr = |
| 5258 LayerImpl::Create(host_impl_->active_tree(), 1); | 5271 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 5259 std::unique_ptr<LayerImpl> root_clip = | 5272 std::unique_ptr<LayerImpl> root_clip = |
| 5260 LayerImpl::Create(host_impl_->active_tree(), 2); | 5273 CreateTestLayerImpl(host_impl_->active_tree(), 2); |
| 5261 std::unique_ptr<LayerImpl> root_scroll = | 5274 std::unique_ptr<LayerImpl> root_scroll = |
| 5262 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5275 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 5263 root_clip->test_properties()->force_render_surface = true; | 5276 root_clip->test_properties()->force_render_surface = true; |
| 5264 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 5277 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
| 5265 root_clip->AddChild(std::move(root_scroll)); | 5278 root_clip->AddChild(std::move(root_scroll)); |
| 5266 root_ptr->AddChild(std::move(root_clip)); | 5279 root_ptr->AddChild(std::move(root_clip)); |
| 5267 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5280 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
| 5268 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5281 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 5269 Layer::INVALID_ID); | 5282 Layer::INVALID_ID); |
| 5270 host_impl_->active_tree()->DidBecomeActive(); | 5283 host_impl_->active_tree()->DidBecomeActive(); |
| 5271 host_impl_->SetViewportSize(surface_size); | 5284 host_impl_->SetViewportSize(surface_size); |
| 5272 | 5285 |
| 5273 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5286 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 5274 // synchronization. | 5287 // synchronization. |
| 5275 SetNeedsRebuildPropertyTrees(); | 5288 SetNeedsRebuildPropertyTrees(); |
| 5276 DrawFrame(); | 5289 DrawFrame(); |
| 5277 host_impl_->active_tree()->ClearLayers(); | 5290 host_impl_->active_tree()->ClearLayers(); |
| 5278 std::unique_ptr<LayerImpl> root_ptr2 = | 5291 std::unique_ptr<LayerImpl> root_ptr2 = |
| 5279 LayerImpl::Create(host_impl_->active_tree(), 4); | 5292 CreateTestLayerImpl(host_impl_->active_tree(), 4); |
| 5280 std::unique_ptr<LayerImpl> root_clip2 = | 5293 std::unique_ptr<LayerImpl> root_clip2 = |
| 5281 LayerImpl::Create(host_impl_->active_tree(), 5); | 5294 CreateTestLayerImpl(host_impl_->active_tree(), 5); |
| 5282 std::unique_ptr<LayerImpl> root_scroll2 = | 5295 std::unique_ptr<LayerImpl> root_scroll2 = |
| 5283 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5296 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
| 5284 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5297 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
| 5285 true; | 5298 true; |
| 5286 root_clip2->AddChild(std::move(root_scroll2)); | 5299 root_clip2->AddChild(std::move(root_scroll2)); |
| 5287 root_clip2->test_properties()->force_render_surface = true; | 5300 root_clip2->test_properties()->force_render_surface = true; |
| 5288 root_ptr2->AddChild(std::move(root_clip2)); | 5301 root_ptr2->AddChild(std::move(root_clip2)); |
| 5289 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); | 5302 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); |
| 5290 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5303 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
| 5291 Layer::INVALID_ID); | 5304 Layer::INVALID_ID); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5347 } | 5360 } |
| 5348 | 5361 |
| 5349 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 5362 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
| 5350 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5363 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5351 int child_clip_layer_id = 6; | 5364 int child_clip_layer_id = 6; |
| 5352 int child_layer_id = 7; | 5365 int child_layer_id = 7; |
| 5353 float child_layer_angle = -20.f; | 5366 float child_layer_angle = -20.f; |
| 5354 | 5367 |
| 5355 // Create a child layer that is rotated to a non-axis-aligned angle. | 5368 // Create a child layer that is rotated to a non-axis-aligned angle. |
| 5356 std::unique_ptr<LayerImpl> clip_layer = | 5369 std::unique_ptr<LayerImpl> clip_layer = |
| 5357 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5370 CreateTestLayerImpl(host_impl_->active_tree(), child_clip_layer_id); |
| 5358 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( | 5371 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
| 5359 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5372 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
| 5360 gfx::Transform rotate_transform; | 5373 gfx::Transform rotate_transform; |
| 5361 rotate_transform.Translate(-50.0, -50.0); | 5374 rotate_transform.Translate(-50.0, -50.0); |
| 5362 rotate_transform.Rotate(child_layer_angle); | 5375 rotate_transform.Rotate(child_layer_angle); |
| 5363 rotate_transform.Translate(50.0, 50.0); | 5376 rotate_transform.Translate(50.0, 50.0); |
| 5364 clip_layer->SetTransform(rotate_transform); | 5377 clip_layer->SetTransform(rotate_transform); |
| 5365 | 5378 |
| 5366 // Only allow vertical scrolling. | 5379 // Only allow vertical scrolling. |
| 5367 clip_layer->SetBounds( | 5380 clip_layer->SetBounds( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5432 | 5445 |
| 5433 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { | 5446 TEST_F(LayerTreeHostImplTest, ScrollPerspectiveTransformedLayer) { |
| 5434 // When scrolling an element with perspective, the distance scrolled | 5447 // When scrolling an element with perspective, the distance scrolled |
| 5435 // depends on the point at which the scroll begins. | 5448 // depends on the point at which the scroll begins. |
| 5436 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5449 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5437 int child_clip_layer_id = 6; | 5450 int child_clip_layer_id = 6; |
| 5438 int child_layer_id = 7; | 5451 int child_layer_id = 7; |
| 5439 | 5452 |
| 5440 // Create a child layer that is rotated on its x axis, with perspective. | 5453 // Create a child layer that is rotated on its x axis, with perspective. |
| 5441 std::unique_ptr<LayerImpl> clip_layer = | 5454 std::unique_ptr<LayerImpl> clip_layer = |
| 5442 LayerImpl::Create(host_impl_->active_tree(), child_clip_layer_id); | 5455 CreateTestLayerImpl(host_impl_->active_tree(), child_clip_layer_id); |
| 5443 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( | 5456 std::unique_ptr<LayerImpl> child = CreateScrollableLayer( |
| 5444 child_layer_id, scroll_layer->bounds(), clip_layer.get()); | 5457 child_layer_id, scroll_layer->bounds(), clip_layer.get()); |
| 5445 LayerImpl* child_ptr = child.get(); | 5458 LayerImpl* child_ptr = child.get(); |
| 5446 gfx::Transform perspective_transform; | 5459 gfx::Transform perspective_transform; |
| 5447 perspective_transform.Translate(-50.0, -50.0); | 5460 perspective_transform.Translate(-50.0, -50.0); |
| 5448 perspective_transform.ApplyPerspectiveDepth(20); | 5461 perspective_transform.ApplyPerspectiveDepth(20); |
| 5449 perspective_transform.RotateAboutXAxis(45); | 5462 perspective_transform.RotateAboutXAxis(45); |
| 5450 perspective_transform.Translate(50.0, 50.0); | 5463 perspective_transform.Translate(50.0, 50.0); |
| 5451 clip_layer->SetTransform(perspective_transform); | 5464 clip_layer->SetTransform(perspective_transform); |
| 5452 | 5465 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5903 host_impl_->ScrollEnd(EndState().get()); | 5916 host_impl_->ScrollEnd(EndState().get()); |
| 5904 } | 5917 } |
| 5905 | 5918 |
| 5906 | 5919 |
| 5907 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 5920 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
| 5908 // Scroll child layers beyond their maximum scroll range and make sure root | 5921 // Scroll child layers beyond their maximum scroll range and make sure root |
| 5909 // overscroll does not accumulate. | 5922 // overscroll does not accumulate. |
| 5910 InputHandlerScrollResult scroll_result; | 5923 InputHandlerScrollResult scroll_result; |
| 5911 gfx::Size surface_size(10, 10); | 5924 gfx::Size surface_size(10, 10); |
| 5912 std::unique_ptr<LayerImpl> root_clip = | 5925 std::unique_ptr<LayerImpl> root_clip = |
| 5913 LayerImpl::Create(host_impl_->active_tree(), 4); | 5926 CreateTestLayerImpl(host_impl_->active_tree(), 4); |
| 5914 root_clip->test_properties()->force_render_surface = true; | 5927 root_clip->test_properties()->force_render_surface = true; |
| 5915 | 5928 |
| 5916 std::unique_ptr<LayerImpl> root = | 5929 std::unique_ptr<LayerImpl> root = |
| 5917 CreateScrollableLayer(1, surface_size, root_clip.get()); | 5930 CreateScrollableLayer(1, surface_size, root_clip.get()); |
| 5918 | 5931 |
| 5919 std::unique_ptr<LayerImpl> grand_child = | 5932 std::unique_ptr<LayerImpl> grand_child = |
| 5920 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5933 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 5921 | 5934 |
| 5922 std::unique_ptr<LayerImpl> child = | 5935 std::unique_ptr<LayerImpl> child = |
| 5923 CreateScrollableLayer(2, surface_size, root_clip.get()); | 5936 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6190 bool quads_appended_; | 6203 bool quads_appended_; |
| 6191 gfx::Rect quad_rect_; | 6204 gfx::Rect quad_rect_; |
| 6192 gfx::Rect opaque_content_rect_; | 6205 gfx::Rect opaque_content_rect_; |
| 6193 gfx::Rect quad_visible_rect_; | 6206 gfx::Rect quad_visible_rect_; |
| 6194 ResourceId resource_id_; | 6207 ResourceId resource_id_; |
| 6195 }; | 6208 }; |
| 6196 | 6209 |
| 6197 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 6210 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 6198 { | 6211 { |
| 6199 std::unique_ptr<LayerImpl> root = | 6212 std::unique_ptr<LayerImpl> root = |
| 6200 LayerImpl::Create(host_impl_->active_tree(), 1); | 6213 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 6201 root->SetBounds(gfx::Size(10, 10)); | 6214 root->SetBounds(gfx::Size(10, 10)); |
| 6202 root->SetDrawsContent(false); | 6215 root->SetDrawsContent(false); |
| 6203 root->test_properties()->force_render_surface = true; | 6216 root->test_properties()->force_render_surface = true; |
| 6204 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6217 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 6205 } | 6218 } |
| 6206 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6219 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 6207 | 6220 |
| 6208 root->AddChild( | 6221 root->AddChild( |
| 6209 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6222 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 6210 2, | 6223 2, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6458 if (software) { | 6471 if (software) { |
| 6459 return FakeOutputSurface::CreateSoftware( | 6472 return FakeOutputSurface::CreateSoftware( |
| 6460 base::WrapUnique(new SoftwareOutputDevice())); | 6473 base::WrapUnique(new SoftwareOutputDevice())); |
| 6461 } | 6474 } |
| 6462 return FakeOutputSurface::Create3d(); | 6475 return FakeOutputSurface::Create3d(); |
| 6463 } | 6476 } |
| 6464 | 6477 |
| 6465 void SetupActiveTreeLayers() { | 6478 void SetupActiveTreeLayers() { |
| 6466 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6479 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 6467 host_impl_->active_tree()->SetRootLayer( | 6480 host_impl_->active_tree()->SetRootLayer( |
| 6468 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6481 CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 6469 host_impl_->active_tree() | 6482 host_impl_->active_tree() |
| 6470 ->root_layer() | 6483 ->root_layer() |
| 6471 ->test_properties() | 6484 ->test_properties() |
| 6472 ->force_render_surface = true; | 6485 ->force_render_surface = true; |
| 6473 host_impl_->active_tree()->root_layer()->AddChild( | 6486 host_impl_->active_tree()->root_layer()->AddChild( |
| 6474 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6487 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 6475 2, | 6488 2, |
| 6476 host_impl_->resource_provider())); | 6489 host_impl_->resource_provider())); |
| 6477 child_ = static_cast<BlendStateCheckLayer*>( | 6490 child_ = static_cast<BlendStateCheckLayer*>( |
| 6478 host_impl_->active_tree()->root_layer()->children()[0]); | 6491 host_impl_->active_tree()->root_layer()->children()[0]); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6749 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); | 6762 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); |
| 6750 } | 6763 } |
| 6751 | 6764 |
| 6752 class FakeDrawableLayerImpl: public LayerImpl { | 6765 class FakeDrawableLayerImpl: public LayerImpl { |
| 6753 public: | 6766 public: |
| 6754 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 6767 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 6755 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); | 6768 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); |
| 6756 } | 6769 } |
| 6757 protected: | 6770 protected: |
| 6758 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 6771 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 6759 : LayerImpl(tree_impl, id) {} | 6772 : LayerImpl(tree_impl, id) { |
| 6773 SetElementId(NextElementId()); |
| 6774 } |
| 6760 }; | 6775 }; |
| 6761 | 6776 |
| 6762 // Only reshape when we know we are going to draw. Otherwise, the reshape | 6777 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 6763 // can leave the window at the wrong size if we never draw and the proper | 6778 // can leave the window at the wrong size if we never draw and the proper |
| 6764 // viewport size is never set. | 6779 // viewport size is never set. |
| 6765 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 6780 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
| 6766 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 6781 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 6767 std::unique_ptr<OutputSurface> output_surface( | 6782 std::unique_ptr<OutputSurface> output_surface( |
| 6768 FakeOutputSurface::Create3d(provider)); | 6783 FakeOutputSurface::Create3d(provider)); |
| 6769 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6784 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7144 | | | | | 7159 | | | | |
| 7145 | +-----------+ | | 7160 | +-----------+ | |
| 7146 | | | 7161 | | |
| 7147 | | | 7162 | | |
| 7148 +--------------------+ | 7163 +--------------------+ |
| 7149 | 7164 |
| 7150 Layers 1, 2 have render surfaces | 7165 Layers 1, 2 have render surfaces |
| 7151 */ | 7166 */ |
| 7152 std::unique_ptr<LayerImpl> root = | 7167 std::unique_ptr<LayerImpl> root = |
| 7153 LayerImpl::Create(my_host_impl->active_tree(), 1); | 7168 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 7169 root->SetElementId(NextElementId()); |
| 7170 |
| 7154 std::unique_ptr<LayerImpl> child = | 7171 std::unique_ptr<LayerImpl> child = |
| 7155 LayerImpl::Create(my_host_impl->active_tree(), 2); | 7172 LayerImpl::Create(my_host_impl->active_tree(), 2); |
| 7173 child->SetElementId(NextElementId()); |
| 7174 |
| 7156 std::unique_ptr<LayerImpl> grand_child = | 7175 std::unique_ptr<LayerImpl> grand_child = |
| 7157 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 7176 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
| 7158 | 7177 |
| 7159 gfx::Rect root_rect(0, 0, 100, 100); | 7178 gfx::Rect root_rect(0, 0, 100, 100); |
| 7160 gfx::Rect child_rect(10, 10, 50, 50); | 7179 gfx::Rect child_rect(10, 10, 50, 50); |
| 7161 gfx::Rect grand_child_rect(5, 5, 150, 150); | 7180 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 7162 | 7181 |
| 7163 root->test_properties()->force_render_surface = true; | 7182 root->test_properties()->force_render_surface = true; |
| 7164 root->SetPosition(gfx::PointF(root_rect.origin())); | 7183 root->SetPosition(gfx::PointF(root_rect.origin())); |
| 7165 root->SetBounds(root_rect.size()); | 7184 root->SetBounds(root_rect.size()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7248 | 7267 |
| 7249 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 7268 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
| 7250 std::unique_ptr<TestWebGraphicsContext3D> context = | 7269 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 7251 TestWebGraphicsContext3D::Create(); | 7270 TestWebGraphicsContext3D::Create(); |
| 7252 TestWebGraphicsContext3D* context3d = context.get(); | 7271 TestWebGraphicsContext3D* context3d = context.get(); |
| 7253 std::unique_ptr<OutputSurface> output_surface( | 7272 std::unique_ptr<OutputSurface> output_surface( |
| 7254 FakeOutputSurface::Create3d(std::move(context))); | 7273 FakeOutputSurface::Create3d(std::move(context))); |
| 7255 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7274 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
| 7256 | 7275 |
| 7257 std::unique_ptr<LayerImpl> root_layer = | 7276 std::unique_ptr<LayerImpl> root_layer = |
| 7258 LayerImpl::Create(host_impl_->active_tree(), 1); | 7277 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 7259 root_layer->SetBounds(gfx::Size(10, 10)); | 7278 root_layer->SetBounds(gfx::Size(10, 10)); |
| 7260 root_layer->test_properties()->force_render_surface = true; | 7279 root_layer->test_properties()->force_render_surface = true; |
| 7261 | 7280 |
| 7262 scoped_refptr<VideoFrame> softwareFrame = | 7281 scoped_refptr<VideoFrame> softwareFrame = |
| 7263 media::VideoFrame::CreateColorFrame( | 7282 media::VideoFrame::CreateColorFrame( |
| 7264 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7283 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 7265 FakeVideoFrameProvider provider; | 7284 FakeVideoFrameProvider provider; |
| 7266 provider.set_frame(softwareFrame); | 7285 provider.set_frame(softwareFrame); |
| 7267 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7286 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 7268 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7287 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 7288 video_layer->SetElementId(NextElementId()); |
| 7269 video_layer->SetBounds(gfx::Size(10, 10)); | 7289 video_layer->SetBounds(gfx::Size(10, 10)); |
| 7270 video_layer->SetDrawsContent(true); | 7290 video_layer->SetDrawsContent(true); |
| 7271 root_layer->AddChild(std::move(video_layer)); | 7291 root_layer->AddChild(std::move(video_layer)); |
| 7272 | 7292 |
| 7273 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); | 7293 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); |
| 7274 | 7294 |
| 7275 EXPECT_EQ(0u, context3d->NumTextures()); | 7295 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7276 | 7296 |
| 7277 LayerTreeHostImpl::FrameData frame; | 7297 LayerTreeHostImpl::FrameData frame; |
| 7278 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7298 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 7279 host_impl_->DrawLayers(&frame); | 7299 host_impl_->DrawLayers(&frame); |
| 7280 host_impl_->DidDrawAllLayers(frame); | 7300 host_impl_->DidDrawAllLayers(frame); |
| 7281 host_impl_->SwapBuffers(frame); | 7301 host_impl_->SwapBuffers(frame); |
| 7282 | 7302 |
| 7283 EXPECT_GT(context3d->NumTextures(), 0u); | 7303 EXPECT_GT(context3d->NumTextures(), 0u); |
| 7284 | 7304 |
| 7285 // Kill the layer tree. | 7305 // Kill the layer tree. |
| 7286 host_impl_->active_tree()->SetRootLayer( | 7306 host_impl_->active_tree()->SetRootLayer( |
| 7287 LayerImpl::Create(host_impl_->active_tree(), 100)); | 7307 CreateTestLayerImpl(host_impl_->active_tree(), 100)); |
| 7288 // There should be no textures left in use after. | 7308 // There should be no textures left in use after. |
| 7289 EXPECT_EQ(0u, context3d->NumTextures()); | 7309 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7290 } | 7310 } |
| 7291 | 7311 |
| 7292 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7312 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
| 7293 public: | 7313 public: |
| 7294 MOCK_METHOD1(useProgram, void(GLuint program)); | 7314 MOCK_METHOD1(useProgram, void(GLuint program)); |
| 7295 MOCK_METHOD4(drawElements, void(GLenum mode, | 7315 MOCK_METHOD4(drawElements, void(GLenum mode, |
| 7296 GLsizei count, | 7316 GLsizei count, |
| 7297 GLenum type, | 7317 GLenum type, |
| 7298 GLintptr offset)); | 7318 GLintptr offset)); |
| 7299 }; | 7319 }; |
| 7300 | 7320 |
| 7301 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 7321 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
| 7302 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 7322 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
| 7303 new MockDrawQuadsToFillScreenContext); | 7323 new MockDrawQuadsToFillScreenContext); |
| 7304 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 7324 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
| 7305 | 7325 |
| 7306 // Run test case | 7326 // Run test case |
| 7307 LayerTreeSettings settings = DefaultSettings(); | 7327 LayerTreeSettings settings = DefaultSettings(); |
| 7308 settings.renderer_settings.partial_swap_enabled = false; | 7328 settings.renderer_settings.partial_swap_enabled = false; |
| 7309 CreateHostImpl(settings, | 7329 CreateHostImpl(settings, |
| 7310 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 7330 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
| 7311 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7331 SetupRootLayerImpl(CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 7312 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7332 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 7313 | 7333 |
| 7314 // Verify one quad is drawn when transparent background set is not set. | 7334 // Verify one quad is drawn when transparent background set is not set. |
| 7315 host_impl_->active_tree()->set_has_transparent_background(false); | 7335 host_impl_->active_tree()->set_has_transparent_background(false); |
| 7316 EXPECT_CALL(*mock_context, useProgram(_)) | 7336 EXPECT_CALL(*mock_context, useProgram(_)) |
| 7317 .Times(1); | 7337 .Times(1); |
| 7318 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 7338 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
| 7319 .Times(1); | 7339 .Times(1); |
| 7320 LayerTreeHostImpl::FrameData frame; | 7340 LayerTreeHostImpl::FrameData frame; |
| 7321 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7341 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7372 | 7392 |
| 7373 host_impl_->DrawLayers(&frame); | 7393 host_impl_->DrawLayers(&frame); |
| 7374 host_impl_->DidDrawAllLayers(frame); | 7394 host_impl_->DidDrawAllLayers(frame); |
| 7375 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 7395 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
| 7376 } | 7396 } |
| 7377 }; | 7397 }; |
| 7378 | 7398 |
| 7379 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 7399 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 7380 std::unique_ptr<SolidColorLayerImpl> root = | 7400 std::unique_ptr<SolidColorLayerImpl> root = |
| 7381 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7401 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7402 root->SetElementId(NextElementId()); |
| 7382 root->SetPosition(gfx::PointF()); | 7403 root->SetPosition(gfx::PointF()); |
| 7383 root->SetBounds(gfx::Size(10, 10)); | 7404 root->SetBounds(gfx::Size(10, 10)); |
| 7384 root->SetDrawsContent(true); | 7405 root->SetDrawsContent(true); |
| 7385 root->test_properties()->force_render_surface = true; | 7406 root->test_properties()->force_render_surface = true; |
| 7386 | 7407 |
| 7387 // Child layer is in the bottom right corner. | 7408 // Child layer is in the bottom right corner. |
| 7388 std::unique_ptr<SolidColorLayerImpl> child = | 7409 std::unique_ptr<SolidColorLayerImpl> child = |
| 7389 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7410 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 7411 child->SetElementId(NextElementId()); |
| 7390 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7412 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 7391 child->SetBounds(gfx::Size(1, 1)); | 7413 child->SetBounds(gfx::Size(1, 1)); |
| 7392 child->SetDrawsContent(true); | 7414 child->SetDrawsContent(true); |
| 7393 root->AddChild(std::move(child)); | 7415 root->AddChild(std::move(child)); |
| 7394 | 7416 |
| 7395 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7417 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 7396 | 7418 |
| 7397 // Draw a frame. In the first frame, the entire viewport should be damaged. | 7419 // Draw a frame. In the first frame, the entire viewport should be damaged. |
| 7398 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7420 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 7399 DrawFrameAndTestDamage(full_frame_damage); | 7421 DrawFrameAndTestDamage(full_frame_damage); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 7430 gfx::Size device_viewport_size = | 7452 gfx::Size device_viewport_size = |
| 7431 gfx::ScaleToCeiledSize(root_size, device_scale_factor); | 7453 gfx::ScaleToCeiledSize(root_size, device_scale_factor); |
| 7432 host_impl_->SetViewportSize(device_viewport_size); | 7454 host_impl_->SetViewportSize(device_viewport_size); |
| 7433 | 7455 |
| 7434 host_impl_->CreatePendingTree(); | 7456 host_impl_->CreatePendingTree(); |
| 7435 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 7457 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 7436 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 7458 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
| 7437 16.f); | 7459 16.f); |
| 7438 | 7460 |
| 7439 std::unique_ptr<LayerImpl> scoped_root = | 7461 std::unique_ptr<LayerImpl> scoped_root = |
| 7440 LayerImpl::Create(host_impl_->pending_tree(), 1); | 7462 CreateTestLayerImpl(host_impl_->pending_tree(), 1); |
| 7441 LayerImpl* root = scoped_root.get(); | 7463 LayerImpl* root = scoped_root.get(); |
| 7442 root->test_properties()->force_render_surface = true; | 7464 root->test_properties()->force_render_surface = true; |
| 7443 | 7465 |
| 7444 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); | 7466 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); |
| 7445 | 7467 |
| 7446 std::unique_ptr<LayerImpl> scoped_scrolling_layer = | 7468 std::unique_ptr<LayerImpl> scoped_scrolling_layer = |
| 7447 LayerImpl::Create(host_impl_->pending_tree(), 2); | 7469 CreateTestLayerImpl(host_impl_->pending_tree(), 2); |
| 7448 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 7470 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 7449 root->AddChild(std::move(scoped_scrolling_layer)); | 7471 root->AddChild(std::move(scoped_scrolling_layer)); |
| 7450 | 7472 |
| 7451 gfx::Size content_layer_bounds(100000, 100); | 7473 gfx::Size content_layer_bounds(100000, 100); |
| 7452 scoped_refptr<FakeRasterSource> raster_source( | 7474 scoped_refptr<FakeRasterSource> raster_source( |
| 7453 FakeRasterSource::CreateFilled(content_layer_bounds)); | 7475 FakeRasterSource::CreateFilled(content_layer_bounds)); |
| 7454 | 7476 |
| 7455 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = | 7477 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = |
| 7456 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 7478 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
| 7457 3, raster_source); | 7479 3, raster_source); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7584 const gfx::Transform external_transform; | 7606 const gfx::Transform external_transform; |
| 7585 const gfx::Rect external_viewport; | 7607 const gfx::Rect external_viewport; |
| 7586 const gfx::Rect external_clip; | 7608 const gfx::Rect external_clip; |
| 7587 const bool resourceless_software_draw = true; | 7609 const bool resourceless_software_draw = true; |
| 7588 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7610 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 7589 external_transform); | 7611 external_transform); |
| 7590 | 7612 |
| 7591 // SolidColorLayerImpl will be drawn. | 7613 // SolidColorLayerImpl will be drawn. |
| 7592 std::unique_ptr<SolidColorLayerImpl> root_layer = | 7614 std::unique_ptr<SolidColorLayerImpl> root_layer = |
| 7593 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7615 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7616 root_layer->SetElementId(NextElementId()); |
| 7594 | 7617 |
| 7595 // VideoLayerImpl will not be drawn. | 7618 // VideoLayerImpl will not be drawn. |
| 7596 FakeVideoFrameProvider provider; | 7619 FakeVideoFrameProvider provider; |
| 7597 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7620 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 7598 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 7621 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
| 7622 video_layer->SetElementId(NextElementId()); |
| 7599 video_layer->SetBounds(gfx::Size(10, 10)); | 7623 video_layer->SetBounds(gfx::Size(10, 10)); |
| 7600 video_layer->SetDrawsContent(true); | 7624 video_layer->SetDrawsContent(true); |
| 7601 root_layer->AddChild(std::move(video_layer)); | 7625 root_layer->AddChild(std::move(video_layer)); |
| 7602 SetupRootLayerImpl(std::move(root_layer)); | 7626 SetupRootLayerImpl(std::move(root_layer)); |
| 7603 | 7627 |
| 7604 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7628 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 7605 resourceless_software_draw); | 7629 resourceless_software_draw); |
| 7606 | 7630 |
| 7607 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7631 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
| 7608 EXPECT_EQ(host_impl_->active_tree()->root_layer(), | 7632 EXPECT_EQ(host_impl_->active_tree()->root_layer(), |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7770 void ShutdownReleasesContext_Callback( | 7794 void ShutdownReleasesContext_Callback( |
| 7771 std::unique_ptr<CopyOutputResult> result) {} | 7795 std::unique_ptr<CopyOutputResult> result) {} |
| 7772 | 7796 |
| 7773 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 7797 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 7774 scoped_refptr<TestContextProvider> context_provider = | 7798 scoped_refptr<TestContextProvider> context_provider = |
| 7775 TestContextProvider::Create(); | 7799 TestContextProvider::Create(); |
| 7776 | 7800 |
| 7777 CreateHostImpl(DefaultSettings(), | 7801 CreateHostImpl(DefaultSettings(), |
| 7778 FakeOutputSurface::Create3d(context_provider)); | 7802 FakeOutputSurface::Create3d(context_provider)); |
| 7779 | 7803 |
| 7780 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7804 SetupRootLayerImpl(CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 7781 | 7805 |
| 7782 std::vector<std::unique_ptr<CopyOutputRequest>> requests; | 7806 std::vector<std::unique_ptr<CopyOutputRequest>> requests; |
| 7783 requests.push_back(CopyOutputRequest::CreateRequest( | 7807 requests.push_back(CopyOutputRequest::CreateRequest( |
| 7784 base::Bind(&ShutdownReleasesContext_Callback))); | 7808 base::Bind(&ShutdownReleasesContext_Callback))); |
| 7785 | 7809 |
| 7786 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 7810 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 7787 root->PassCopyRequests(&requests); | 7811 root->PassCopyRequests(&requests); |
| 7788 | 7812 |
| 7789 LayerTreeHostImpl::FrameData frame; | 7813 LayerTreeHostImpl::FrameData frame; |
| 7790 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7814 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7803 EXPECT_TRUE(context_provider->HasOneRef()); | 7827 EXPECT_TRUE(context_provider->HasOneRef()); |
| 7804 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 7828 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 7805 } | 7829 } |
| 7806 | 7830 |
| 7807 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 7831 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 7808 // When flinging via touch, only the child should scroll (we should not | 7832 // When flinging via touch, only the child should scroll (we should not |
| 7809 // bubble). | 7833 // bubble). |
| 7810 gfx::Size surface_size(10, 10); | 7834 gfx::Size surface_size(10, 10); |
| 7811 gfx::Size content_size(20, 20); | 7835 gfx::Size content_size(20, 20); |
| 7812 std::unique_ptr<LayerImpl> root_ptr = | 7836 std::unique_ptr<LayerImpl> root_ptr = |
| 7813 LayerImpl::Create(host_impl_->active_tree(), 4); | 7837 CreateTestLayerImpl(host_impl_->active_tree(), 4); |
| 7814 std::unique_ptr<LayerImpl> root_clip = | 7838 std::unique_ptr<LayerImpl> root_clip = |
| 7815 LayerImpl::Create(host_impl_->active_tree(), 3); | 7839 CreateTestLayerImpl(host_impl_->active_tree(), 3); |
| 7816 root_clip->test_properties()->force_render_surface = true; | 7840 root_clip->test_properties()->force_render_surface = true; |
| 7817 | 7841 |
| 7818 std::unique_ptr<LayerImpl> root_scroll = | 7842 std::unique_ptr<LayerImpl> root_scroll = |
| 7819 CreateScrollableLayer(1, content_size, root_clip.get()); | 7843 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 7820 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 7844 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
| 7821 std::unique_ptr<LayerImpl> child = | 7845 std::unique_ptr<LayerImpl> child = |
| 7822 CreateScrollableLayer(2, content_size, root_clip.get()); | 7846 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 7823 | 7847 |
| 7824 root_scroll->AddChild(std::move(child)); | 7848 root_scroll->AddChild(std::move(child)); |
| 7825 int root_id = root_scroll->id(); | 7849 int root_id = root_scroll->id(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 7856 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7880 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7857 ExpectNone(*scroll_info.get(), root_id); | 7881 ExpectNone(*scroll_info.get(), root_id); |
| 7858 } | 7882 } |
| 7859 } | 7883 } |
| 7860 | 7884 |
| 7861 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 7885 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
| 7862 // Scroll a child layer beyond its maximum scroll range and make sure the | 7886 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 7863 // the scroll doesn't bubble up to the parent layer. | 7887 // the scroll doesn't bubble up to the parent layer. |
| 7864 gfx::Size surface_size(10, 10); | 7888 gfx::Size surface_size(10, 10); |
| 7865 std::unique_ptr<LayerImpl> root = | 7889 std::unique_ptr<LayerImpl> root = |
| 7866 LayerImpl::Create(host_impl_->active_tree(), 1); | 7890 CreateTestLayerImpl(host_impl_->active_tree(), 1); |
| 7867 root->test_properties()->force_render_surface = true; | 7891 root->test_properties()->force_render_surface = true; |
| 7868 std::unique_ptr<LayerImpl> root_scrolling = | 7892 std::unique_ptr<LayerImpl> root_scrolling = |
| 7869 CreateScrollableLayer(2, surface_size, root.get()); | 7893 CreateScrollableLayer(2, surface_size, root.get()); |
| 7870 | 7894 |
| 7871 std::unique_ptr<LayerImpl> grand_child = | 7895 std::unique_ptr<LayerImpl> grand_child = |
| 7872 CreateScrollableLayer(4, surface_size, root.get()); | 7896 CreateScrollableLayer(4, surface_size, root.get()); |
| 7873 grand_child->layer_tree_impl() | 7897 grand_child->layer_tree_impl() |
| 7874 ->property_trees() | 7898 ->property_trees() |
| 7875 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), | 7899 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), |
| 7876 gfx::ScrollOffset(0, 2)); | 7900 gfx::ScrollOffset(0, 2)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7945 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 7969 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 7946 host_impl_->ScrollEnd(EndState().get()); | 7970 host_impl_->ScrollEnd(EndState().get()); |
| 7947 } | 7971 } |
| 7948 } | 7972 } |
| 7949 | 7973 |
| 7950 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { | 7974 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
| 7951 // When flinging via wheel, we shouldn't bubble. | 7975 // When flinging via wheel, we shouldn't bubble. |
| 7952 gfx::Size surface_size(10, 10); | 7976 gfx::Size surface_size(10, 10); |
| 7953 gfx::Size content_size(20, 20); | 7977 gfx::Size content_size(20, 20); |
| 7954 std::unique_ptr<LayerImpl> root_clip = | 7978 std::unique_ptr<LayerImpl> root_clip = |
| 7955 LayerImpl::Create(host_impl_->active_tree(), 3); | 7979 CreateTestLayerImpl(host_impl_->active_tree(), 3); |
| 7956 root_clip->test_properties()->force_render_surface = true; | 7980 root_clip->test_properties()->force_render_surface = true; |
| 7957 std::unique_ptr<LayerImpl> root_scroll = | 7981 std::unique_ptr<LayerImpl> root_scroll = |
| 7958 CreateScrollableLayer(1, content_size, root_clip.get()); | 7982 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 7959 int root_scroll_id = root_scroll->id(); | 7983 int root_scroll_id = root_scroll->id(); |
| 7960 std::unique_ptr<LayerImpl> child = | 7984 std::unique_ptr<LayerImpl> child = |
| 7961 CreateScrollableLayer(2, content_size, root_clip.get()); | 7985 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 7962 | 7986 |
| 7963 root_scroll->AddChild(std::move(child)); | 7987 root_scroll->AddChild(std::move(child)); |
| 7964 root_clip->AddChild(std::move(root_scroll)); | 7988 root_clip->AddChild(std::move(root_scroll)); |
| 7965 | 7989 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8002 LayerImpl* scroll_layer = | 8026 LayerImpl* scroll_layer = |
| 8003 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8027 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 8004 scroll_layer->SetDrawsContent(true); | 8028 scroll_layer->SetDrawsContent(true); |
| 8005 | 8029 |
| 8006 int page_scale_layer_id = 5; | 8030 int page_scale_layer_id = 5; |
| 8007 LayerImpl* page_scale_layer = | 8031 LayerImpl* page_scale_layer = |
| 8008 host_impl_->active_tree()->LayerById(page_scale_layer_id); | 8032 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
| 8009 | 8033 |
| 8010 int occluder_layer_id = 6; | 8034 int occluder_layer_id = 6; |
| 8011 std::unique_ptr<LayerImpl> occluder_layer = | 8035 std::unique_ptr<LayerImpl> occluder_layer = |
| 8012 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 8036 CreateTestLayerImpl(host_impl_->active_tree(), occluder_layer_id); |
| 8013 occluder_layer->SetDrawsContent(true); | 8037 occluder_layer->SetDrawsContent(true); |
| 8014 occluder_layer->SetBounds(content_size); | 8038 occluder_layer->SetBounds(content_size); |
| 8015 occluder_layer->SetPosition(gfx::PointF()); | 8039 occluder_layer->SetPosition(gfx::PointF()); |
| 8016 | 8040 |
| 8017 // The parent of the occluder is *above* the scroller. | 8041 // The parent of the occluder is *above* the scroller. |
| 8018 page_scale_layer->AddChild(std::move(occluder_layer)); | 8042 page_scale_layer->AddChild(std::move(occluder_layer)); |
| 8019 | 8043 |
| 8020 SetNeedsRebuildPropertyTrees(); | 8044 SetNeedsRebuildPropertyTrees(); |
| 8021 DrawFrame(); | 8045 DrawFrame(); |
| 8022 | 8046 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8034 gfx::Size content_size(100, 100); | 8058 gfx::Size content_size(100, 100); |
| 8035 SetupScrollAndContentsLayers(content_size); | 8059 SetupScrollAndContentsLayers(content_size); |
| 8036 | 8060 |
| 8037 int scroll_layer_id = 2; | 8061 int scroll_layer_id = 2; |
| 8038 LayerImpl* scroll_layer = | 8062 LayerImpl* scroll_layer = |
| 8039 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8063 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 8040 scroll_layer->SetDrawsContent(true); | 8064 scroll_layer->SetDrawsContent(true); |
| 8041 | 8065 |
| 8042 int occluder_layer_id = 6; | 8066 int occluder_layer_id = 6; |
| 8043 std::unique_ptr<LayerImpl> occluder_layer = | 8067 std::unique_ptr<LayerImpl> occluder_layer = |
| 8044 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 8068 CreateTestLayerImpl(host_impl_->active_tree(), occluder_layer_id); |
| 8045 occluder_layer->SetDrawsContent(true); | 8069 occluder_layer->SetDrawsContent(true); |
| 8046 occluder_layer->SetBounds(content_size); | 8070 occluder_layer->SetBounds(content_size); |
| 8047 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); | 8071 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 8048 | 8072 |
| 8049 int child_scroll_clip_layer_id = 7; | 8073 int child_scroll_clip_layer_id = 7; |
| 8050 std::unique_ptr<LayerImpl> child_scroll_clip = | 8074 std::unique_ptr<LayerImpl> child_scroll_clip = CreateTestLayerImpl( |
| 8051 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); | 8075 host_impl_->active_tree(), child_scroll_clip_layer_id); |
| 8052 | 8076 |
| 8053 int child_scroll_layer_id = 8; | 8077 int child_scroll_layer_id = 8; |
| 8054 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 8078 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
| 8055 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 8079 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
| 8056 | 8080 |
| 8057 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 8081 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
| 8058 | 8082 |
| 8059 child_scroll->AddChild(std::move(occluder_layer)); | 8083 child_scroll->AddChild(std::move(occluder_layer)); |
| 8060 child_scroll_clip->AddChild(std::move(child_scroll)); | 8084 child_scroll_clip->AddChild(std::move(child_scroll)); |
| 8061 scroll_layer->AddChild(std::move(child_scroll_clip)); | 8085 scroll_layer->AddChild(std::move(child_scroll_clip)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8109 SetupScrollAndContentsLayers(content_size); | 8133 SetupScrollAndContentsLayers(content_size); |
| 8110 | 8134 |
| 8111 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8135 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 8112 LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); | 8136 LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); |
| 8113 | 8137 |
| 8114 std::unique_ptr<LayerImpl> invisible_scroll_layer = | 8138 std::unique_ptr<LayerImpl> invisible_scroll_layer = |
| 8115 CreateScrollableLayer(7, content_size, root); | 8139 CreateScrollableLayer(7, content_size, root); |
| 8116 invisible_scroll_layer->SetDrawsContent(false); | 8140 invisible_scroll_layer->SetDrawsContent(false); |
| 8117 | 8141 |
| 8118 std::unique_ptr<LayerImpl> child_layer = | 8142 std::unique_ptr<LayerImpl> child_layer = |
| 8119 LayerImpl::Create(host_impl_->active_tree(), 8); | 8143 CreateTestLayerImpl(host_impl_->active_tree(), 8); |
| 8120 child_layer->SetDrawsContent(false); | 8144 child_layer->SetDrawsContent(false); |
| 8121 | 8145 |
| 8122 std::unique_ptr<LayerImpl> grand_child_layer = | 8146 std::unique_ptr<LayerImpl> grand_child_layer = |
| 8123 LayerImpl::Create(host_impl_->active_tree(), 9); | 8147 CreateTestLayerImpl(host_impl_->active_tree(), 9); |
| 8124 grand_child_layer->SetDrawsContent(true); | 8148 grand_child_layer->SetDrawsContent(true); |
| 8125 grand_child_layer->SetBounds(content_size); | 8149 grand_child_layer->SetBounds(content_size); |
| 8126 // Move the grand child so it's not hit by our test point. | 8150 // Move the grand child so it's not hit by our test point. |
| 8127 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 8151 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
| 8128 | 8152 |
| 8129 child_layer->AddChild(std::move(grand_child_layer)); | 8153 child_layer->AddChild(std::move(grand_child_layer)); |
| 8130 invisible_scroll_layer->AddChild(std::move(child_layer)); | 8154 invisible_scroll_layer->AddChild(std::move(child_layer)); |
| 8131 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); | 8155 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); |
| 8132 | 8156 |
| 8133 SetNeedsRebuildPropertyTrees(); | 8157 SetNeedsRebuildPropertyTrees(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 8152 SetupScrollAndContentsLayers(content_size); | 8176 SetupScrollAndContentsLayers(content_size); |
| 8153 | 8177 |
| 8154 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 8178 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 8155 | 8179 |
| 8156 int scroll_layer_id = 2; | 8180 int scroll_layer_id = 2; |
| 8157 LayerImpl* scroll_layer = | 8181 LayerImpl* scroll_layer = |
| 8158 host_impl_->active_tree()->LayerById(scroll_layer_id); | 8182 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 8159 | 8183 |
| 8160 int scroll_child_id = 6; | 8184 int scroll_child_id = 6; |
| 8161 std::unique_ptr<LayerImpl> scroll_child = | 8185 std::unique_ptr<LayerImpl> scroll_child = |
| 8162 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); | 8186 CreateTestLayerImpl(host_impl_->active_tree(), scroll_child_id); |
| 8163 scroll_child->SetDrawsContent(true); | 8187 scroll_child->SetDrawsContent(true); |
| 8164 scroll_child->SetBounds(content_size); | 8188 scroll_child->SetBounds(content_size); |
| 8165 // Move the scroll child so it's not hit by our test point. | 8189 // Move the scroll child so it's not hit by our test point. |
| 8166 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); | 8190 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 8167 | 8191 |
| 8168 int invisible_scroll_layer_id = 7; | 8192 int invisible_scroll_layer_id = 7; |
| 8169 std::unique_ptr<LayerImpl> invisible_scroll = | 8193 std::unique_ptr<LayerImpl> invisible_scroll = |
| 8170 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); | 8194 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); |
| 8171 invisible_scroll->SetDrawsContent(false); | 8195 invisible_scroll->SetDrawsContent(false); |
| 8172 | 8196 |
| 8173 int container_id = 8; | 8197 int container_id = 8; |
| 8174 std::unique_ptr<LayerImpl> container = | 8198 std::unique_ptr<LayerImpl> container = |
| 8175 LayerImpl::Create(host_impl_->active_tree(), container_id); | 8199 CreateTestLayerImpl(host_impl_->active_tree(), container_id); |
| 8176 | 8200 |
| 8177 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 8201 std::unique_ptr<std::set<LayerImpl*>> scroll_children( |
| 8178 new std::set<LayerImpl*>); | 8202 new std::set<LayerImpl*>); |
| 8179 scroll_children->insert(scroll_child.get()); | 8203 scroll_children->insert(scroll_child.get()); |
| 8180 invisible_scroll->test_properties()->scroll_children.reset( | 8204 invisible_scroll->test_properties()->scroll_children.reset( |
| 8181 scroll_children.release()); | 8205 scroll_children.release()); |
| 8182 | 8206 |
| 8183 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); | 8207 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); |
| 8184 | 8208 |
| 8185 container->AddChild(std::move(invisible_scroll)); | 8209 container->AddChild(std::move(invisible_scroll)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8199 .thread); | 8223 .thread); |
| 8200 | 8224 |
| 8201 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8225 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| 8202 } | 8226 } |
| 8203 | 8227 |
| 8204 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8228 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 8205 // to CompositorFrameMetadata after SwapBuffers(); | 8229 // to CompositorFrameMetadata after SwapBuffers(); |
| 8206 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8230 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 8207 std::unique_ptr<SolidColorLayerImpl> root = | 8231 std::unique_ptr<SolidColorLayerImpl> root = |
| 8208 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8232 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 8233 root->SetElementId(NextElementId()); |
| 8209 root->SetPosition(gfx::PointF()); | 8234 root->SetPosition(gfx::PointF()); |
| 8210 root->SetBounds(gfx::Size(10, 10)); | 8235 root->SetBounds(gfx::Size(10, 10)); |
| 8211 root->SetDrawsContent(true); | 8236 root->SetDrawsContent(true); |
| 8212 root->test_properties()->force_render_surface = true; | 8237 root->test_properties()->force_render_surface = true; |
| 8213 | 8238 |
| 8214 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8239 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 8215 | 8240 |
| 8216 FakeOutputSurface* fake_output_surface = | 8241 FakeOutputSurface* fake_output_surface = |
| 8217 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8242 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 8218 | 8243 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8239 fake_output_surface->last_sent_frame().metadata.latency_info; | 8264 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 8240 EXPECT_EQ(1u, metadata_latency_after.size()); | 8265 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 8241 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 8266 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 8242 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8267 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 8243 } | 8268 } |
| 8244 | 8269 |
| 8245 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8270 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 8246 int root_layer_id = 1; | 8271 int root_layer_id = 1; |
| 8247 std::unique_ptr<SolidColorLayerImpl> root = | 8272 std::unique_ptr<SolidColorLayerImpl> root = |
| 8248 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8273 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 8274 root->SetElementId(NextElementId()); |
| 8249 root->SetPosition(gfx::PointF()); | 8275 root->SetPosition(gfx::PointF()); |
| 8250 root->SetBounds(gfx::Size(10, 10)); | 8276 root->SetBounds(gfx::Size(10, 10)); |
| 8251 root->SetDrawsContent(true); | 8277 root->SetDrawsContent(true); |
| 8252 root->test_properties()->force_render_surface = true; | 8278 root->test_properties()->force_render_surface = true; |
| 8253 | 8279 |
| 8254 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8280 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 8255 | 8281 |
| 8256 // Ensure the default frame selection bounds are empty. | 8282 // Ensure the default frame selection bounds are empty. |
| 8257 FakeOutputSurface* fake_output_surface = | 8283 FakeOutputSurface* fake_output_surface = |
| 8258 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8284 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8894 const gfx::Size& outer_viewport, | 8920 const gfx::Size& outer_viewport, |
| 8895 const gfx::Size& inner_viewport) { | 8921 const gfx::Size& inner_viewport) { |
| 8896 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 8922 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 8897 const int kOuterViewportClipLayerId = 6; | 8923 const int kOuterViewportClipLayerId = 6; |
| 8898 const int kOuterViewportScrollLayerId = 7; | 8924 const int kOuterViewportScrollLayerId = 7; |
| 8899 const int kInnerViewportScrollLayerId = 2; | 8925 const int kInnerViewportScrollLayerId = 2; |
| 8900 const int kInnerViewportClipLayerId = 4; | 8926 const int kInnerViewportClipLayerId = 4; |
| 8901 const int kPageScaleLayerId = 5; | 8927 const int kPageScaleLayerId = 5; |
| 8902 | 8928 |
| 8903 std::unique_ptr<LayerImpl> inner_scroll = | 8929 std::unique_ptr<LayerImpl> inner_scroll = |
| 8904 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 8930 CreateTestLayerImpl(layer_tree_impl, kInnerViewportScrollLayerId); |
| 8905 inner_scroll->test_properties()->is_container_for_fixed_position_layers = | 8931 inner_scroll->test_properties()->is_container_for_fixed_position_layers = |
| 8906 true; | 8932 true; |
| 8907 inner_scroll->layer_tree_impl() | 8933 inner_scroll->layer_tree_impl() |
| 8908 ->property_trees() | 8934 ->property_trees() |
| 8909 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), | 8935 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), |
| 8910 gfx::ScrollOffset()); | 8936 gfx::ScrollOffset()); |
| 8911 | 8937 |
| 8912 std::unique_ptr<LayerImpl> inner_clip = | 8938 std::unique_ptr<LayerImpl> inner_clip = |
| 8913 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 8939 CreateTestLayerImpl(layer_tree_impl, kInnerViewportClipLayerId); |
| 8914 inner_clip->SetBounds(inner_viewport); | 8940 inner_clip->SetBounds(inner_viewport); |
| 8915 | 8941 |
| 8916 std::unique_ptr<LayerImpl> page_scale = | 8942 std::unique_ptr<LayerImpl> page_scale = |
| 8917 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 8943 CreateTestLayerImpl(layer_tree_impl, kPageScaleLayerId); |
| 8918 | 8944 |
| 8919 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 8945 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
| 8920 inner_scroll->SetBounds(outer_viewport); | 8946 inner_scroll->SetBounds(outer_viewport); |
| 8921 inner_scroll->SetPosition(gfx::PointF()); | 8947 inner_scroll->SetPosition(gfx::PointF()); |
| 8922 | 8948 |
| 8923 std::unique_ptr<LayerImpl> outer_clip = | 8949 std::unique_ptr<LayerImpl> outer_clip = |
| 8924 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 8950 CreateTestLayerImpl(layer_tree_impl, kOuterViewportClipLayerId); |
| 8925 outer_clip->SetBounds(outer_viewport); | 8951 outer_clip->SetBounds(outer_viewport); |
| 8926 outer_clip->test_properties()->is_container_for_fixed_position_layers = | 8952 outer_clip->test_properties()->is_container_for_fixed_position_layers = |
| 8927 true; | 8953 true; |
| 8928 | 8954 |
| 8929 std::unique_ptr<LayerImpl> outer_scroll = | 8955 std::unique_ptr<LayerImpl> outer_scroll = |
| 8930 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 8956 CreateTestLayerImpl(layer_tree_impl, kOuterViewportScrollLayerId); |
| 8931 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 8957 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 8932 outer_scroll->layer_tree_impl() | 8958 outer_scroll->layer_tree_impl() |
| 8933 ->property_trees() | 8959 ->property_trees() |
| 8934 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), | 8960 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), |
| 8935 gfx::ScrollOffset()); | 8961 gfx::ScrollOffset()); |
| 8936 outer_scroll->SetBounds(content_size); | 8962 outer_scroll->SetBounds(content_size); |
| 8937 outer_scroll->SetPosition(gfx::PointF()); | 8963 outer_scroll->SetPosition(gfx::PointF()); |
| 8938 | 8964 |
| 8939 std::unique_ptr<LayerImpl> contents = LayerImpl::Create(layer_tree_impl, 8); | 8965 std::unique_ptr<LayerImpl> contents = |
| 8966 CreateTestLayerImpl(layer_tree_impl, 8); |
| 8940 contents->SetDrawsContent(true); | 8967 contents->SetDrawsContent(true); |
| 8941 contents->SetBounds(content_size); | 8968 contents->SetBounds(content_size); |
| 8942 contents->SetPosition(gfx::PointF()); | 8969 contents->SetPosition(gfx::PointF()); |
| 8943 | 8970 |
| 8944 outer_scroll->AddChild(std::move(contents)); | 8971 outer_scroll->AddChild(std::move(contents)); |
| 8945 outer_clip->AddChild(std::move(outer_scroll)); | 8972 outer_clip->AddChild(std::move(outer_scroll)); |
| 8946 inner_scroll->AddChild(std::move(outer_clip)); | 8973 inner_scroll->AddChild(std::move(outer_clip)); |
| 8947 page_scale->AddChild(std::move(inner_scroll)); | 8974 page_scale->AddChild(std::move(inner_scroll)); |
| 8948 inner_clip->AddChild(std::move(page_scale)); | 8975 inner_clip->AddChild(std::move(page_scale)); |
| 8949 | 8976 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9289 external_transform.Translate(20, 20); | 9316 external_transform.Translate(20, 20); |
| 9290 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 9317 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 9291 external_transform); | 9318 external_transform); |
| 9292 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9319 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 9293 resourceless_software_draw); | 9320 resourceless_software_draw); |
| 9294 EXPECT_TRANSFORMATION_MATRIX_EQ( | 9321 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 9295 external_transform, layer->draw_properties().target_space_transform); | 9322 external_transform, layer->draw_properties().target_space_transform); |
| 9296 } | 9323 } |
| 9297 | 9324 |
| 9298 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { | 9325 TEST_F(LayerTreeHostImplTest, ExternalTransformSetNeedsRedraw) { |
| 9299 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9326 SetupRootLayerImpl(CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 9300 | 9327 |
| 9301 const gfx::Size viewport_size(100, 100); | 9328 const gfx::Size viewport_size(100, 100); |
| 9302 host_impl_->SetViewportSize(viewport_size); | 9329 host_impl_->SetViewportSize(viewport_size); |
| 9303 | 9330 |
| 9304 const gfx::Transform transform_for_tile_priority; | 9331 const gfx::Transform transform_for_tile_priority; |
| 9305 const gfx::Transform draw_transform; | 9332 const gfx::Transform draw_transform; |
| 9306 const gfx::Rect viewport_for_tile_priority1(viewport_size); | 9333 const gfx::Rect viewport_for_tile_priority1(viewport_size); |
| 9307 const gfx::Rect viewport_for_tile_priority2(50, 50); | 9334 const gfx::Rect viewport_for_tile_priority2(50, 50); |
| 9308 const gfx::Rect draw_viewport(viewport_size); | 9335 const gfx::Rect draw_viewport(viewport_size); |
| 9309 const gfx::Rect clip(viewport_size); | 9336 const gfx::Rect clip(viewport_size); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9320 did_request_redraw_ = false; | 9347 did_request_redraw_ = false; |
| 9321 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, | 9348 host_impl_->SetExternalTilePriorityConstraints(viewport_for_tile_priority2, |
| 9322 transform_for_tile_priority); | 9349 transform_for_tile_priority); |
| 9323 EXPECT_TRUE(did_request_redraw_); | 9350 EXPECT_TRUE(did_request_redraw_); |
| 9324 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9351 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
| 9325 resourceless_software_draw); | 9352 resourceless_software_draw); |
| 9326 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); | 9353 EXPECT_FALSE(last_on_draw_frame_->has_no_damage); |
| 9327 } | 9354 } |
| 9328 | 9355 |
| 9329 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { | 9356 TEST_F(LayerTreeHostImplTest, OnDrawConstraintSetNeedsRedraw) { |
| 9330 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9357 SetupRootLayerImpl(CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 9331 | 9358 |
| 9332 const gfx::Size viewport_size(100, 100); | 9359 const gfx::Size viewport_size(100, 100); |
| 9333 host_impl_->SetViewportSize(viewport_size); | 9360 host_impl_->SetViewportSize(viewport_size); |
| 9334 | 9361 |
| 9335 const gfx::Transform draw_transform; | 9362 const gfx::Transform draw_transform; |
| 9336 const gfx::Rect draw_viewport1(viewport_size); | 9363 const gfx::Rect draw_viewport1(viewport_size); |
| 9337 const gfx::Rect draw_viewport2(50, 50); | 9364 const gfx::Rect draw_viewport2(50, 50); |
| 9338 const gfx::Rect clip(viewport_size); | 9365 const gfx::Rect clip(viewport_size); |
| 9339 bool resourceless_software_draw = false; | 9366 bool resourceless_software_draw = false; |
| 9340 | 9367 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 9361 | 9388 |
| 9362 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 9389 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| 9363 protected: | 9390 protected: |
| 9364 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 9391 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 9365 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); | 9392 return FakeOutputSurface::Create3dWithResourcelessSoftwareSupport(); |
| 9366 } | 9393 } |
| 9367 }; | 9394 }; |
| 9368 | 9395 |
| 9369 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, | 9396 TEST_F(ResourcelessSoftwareLayerTreeHostImplTest, |
| 9370 ResourcelessSoftwareSetNeedsRedraw) { | 9397 ResourcelessSoftwareSetNeedsRedraw) { |
| 9371 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 9398 SetupRootLayerImpl(CreateTestLayerImpl(host_impl_->active_tree(), 1)); |
| 9372 | 9399 |
| 9373 const gfx::Size viewport_size(100, 100); | 9400 const gfx::Size viewport_size(100, 100); |
| 9374 host_impl_->SetViewportSize(viewport_size); | 9401 host_impl_->SetViewportSize(viewport_size); |
| 9375 | 9402 |
| 9376 const gfx::Transform draw_transform; | 9403 const gfx::Transform draw_transform; |
| 9377 const gfx::Rect draw_viewport(viewport_size); | 9404 const gfx::Rect draw_viewport(viewport_size); |
| 9378 const gfx::Rect clip(viewport_size); | 9405 const gfx::Rect clip(viewport_size); |
| 9379 bool resourceless_software_draw = false; | 9406 bool resourceless_software_draw = false; |
| 9380 | 9407 |
| 9381 // Clear any damage. | 9408 // Clear any damage. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9438 | 9465 |
| 9439 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { | 9466 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { |
| 9440 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 9467 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
| 9441 const gfx::Size layer_size(100, 100); | 9468 const gfx::Size layer_size(100, 100); |
| 9442 host_impl_->SetViewportSize(layer_size); | 9469 host_impl_->SetViewportSize(layer_size); |
| 9443 bool update_lcd_text = false; | 9470 bool update_lcd_text = false; |
| 9444 | 9471 |
| 9445 // Set up active and pending tree. | 9472 // Set up active and pending tree. |
| 9446 host_impl_->CreatePendingTree(); | 9473 host_impl_->CreatePendingTree(); |
| 9447 host_impl_->pending_tree()->SetRootLayer( | 9474 host_impl_->pending_tree()->SetRootLayer( |
| 9448 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 9475 CreateTestLayerImpl(host_impl_->pending_tree(), 1)); |
| 9449 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 9476 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 9450 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9477 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 9451 | 9478 |
| 9452 host_impl_->ActivateSyncTree(); | 9479 host_impl_->ActivateSyncTree(); |
| 9453 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9480 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9454 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9481 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9455 | 9482 |
| 9456 host_impl_->CreatePendingTree(); | 9483 host_impl_->CreatePendingTree(); |
| 9457 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9484 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 9458 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9485 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9541 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9568 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 9542 resourceless_software_draw); | 9569 resourceless_software_draw); |
| 9543 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9570 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 9544 } | 9571 } |
| 9545 | 9572 |
| 9546 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { | 9573 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { |
| 9547 const gfx::Size layer_size(100, 100); | 9574 const gfx::Size layer_size(100, 100); |
| 9548 SetupScrollAndContentsLayers(layer_size); | 9575 SetupScrollAndContentsLayers(layer_size); |
| 9549 LayerImpl* content_layer = | 9576 LayerImpl* content_layer = |
| 9550 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 9577 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; |
| 9551 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 9578 content_layer->AddChild(CreateTestLayerImpl(host_impl_->active_tree(), 100)); |
| 9552 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9579 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
| 9553 test_layer->test_properties()->force_render_surface = true; | 9580 test_layer->test_properties()->force_render_surface = true; |
| 9554 test_layer->SetDrawsContent(true); | 9581 test_layer->SetDrawsContent(true); |
| 9555 test_layer->SetBounds(layer_size); | 9582 test_layer->SetBounds(layer_size); |
| 9556 gfx::Transform perspective_transform; | 9583 gfx::Transform perspective_transform; |
| 9557 perspective_transform.ApplyPerspectiveDepth(2); | 9584 perspective_transform.ApplyPerspectiveDepth(2); |
| 9558 test_layer->SetTransform(perspective_transform); | 9585 test_layer->SetTransform(perspective_transform); |
| 9559 | 9586 |
| 9560 SetNeedsRebuildPropertyTrees(); | 9587 SetNeedsRebuildPropertyTrees(); |
| 9561 RebuildPropertyTrees(); | 9588 RebuildPropertyTrees(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9684 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 9711 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 9685 | 9712 |
| 9686 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9713 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 9687 | 9714 |
| 9688 begin_frame_args.frame_time = start_time; | 9715 begin_frame_args.frame_time = start_time; |
| 9689 host_impl_->WillBeginImplFrame(begin_frame_args); | 9716 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9690 host_impl_->Animate(); | 9717 host_impl_->Animate(); |
| 9691 host_impl_->UpdateAnimationState(true); | 9718 host_impl_->UpdateAnimationState(true); |
| 9692 | 9719 |
| 9693 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9720 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
| 9694 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9721 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 9695 | 9722 |
| 9696 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9723 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 9697 host_impl_->DidFinishImplFrame(); | 9724 host_impl_->DidFinishImplFrame(); |
| 9698 | 9725 |
| 9699 begin_frame_args.frame_time = | 9726 begin_frame_args.frame_time = |
| 9700 start_time + base::TimeDelta::FromMilliseconds(50); | 9727 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9701 host_impl_->WillBeginImplFrame(begin_frame_args); | 9728 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9702 host_impl_->Animate(); | 9729 host_impl_->Animate(); |
| 9703 host_impl_->UpdateAnimationState(true); | 9730 host_impl_->UpdateAnimationState(true); |
| 9704 | 9731 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9755 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 9782 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
| 9756 | 9783 |
| 9757 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9784 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 9758 | 9785 |
| 9759 begin_frame_args.frame_time = start_time; | 9786 begin_frame_args.frame_time = start_time; |
| 9760 host_impl_->WillBeginImplFrame(begin_frame_args); | 9787 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9761 host_impl_->Animate(); | 9788 host_impl_->Animate(); |
| 9762 host_impl_->UpdateAnimationState(true); | 9789 host_impl_->UpdateAnimationState(true); |
| 9763 | 9790 |
| 9764 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9791 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
| 9765 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9792 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 9766 | 9793 |
| 9767 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9794 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 9768 host_impl_->DidFinishImplFrame(); | 9795 host_impl_->DidFinishImplFrame(); |
| 9769 | 9796 |
| 9770 begin_frame_args.frame_time = | 9797 begin_frame_args.frame_time = |
| 9771 start_time + base::TimeDelta::FromMilliseconds(50); | 9798 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9772 host_impl_->WillBeginImplFrame(begin_frame_args); | 9799 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9773 host_impl_->Animate(); | 9800 host_impl_->Animate(); |
| 9774 host_impl_->UpdateAnimationState(true); | 9801 host_impl_->UpdateAnimationState(true); |
| 9775 | 9802 |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10589 page_scale_layer->transform_tree_index()); | 10616 page_scale_layer->transform_tree_index()); |
| 10590 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); | 10617 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); |
| 10591 } | 10618 } |
| 10592 | 10619 |
| 10593 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { | 10620 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { |
| 10594 // Checks that the sublayer scale of a transform node in the subtree of the | 10621 // Checks that the sublayer scale of a transform node in the subtree of the |
| 10595 // page scale layer is updated without a property tree rebuild. | 10622 // page scale layer is updated without a property tree rebuild. |
| 10596 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10623 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 10597 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); | 10624 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); |
| 10598 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10625 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
| 10599 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 10626 page_scale_layer->AddChild( |
| 10627 CreateTestLayerImpl(host_impl_->active_tree(), 100)); |
| 10600 | 10628 |
| 10601 LayerImpl* in_subtree_of_page_scale_layer = | 10629 LayerImpl* in_subtree_of_page_scale_layer = |
| 10602 host_impl_->active_tree()->LayerById(100); | 10630 host_impl_->active_tree()->LayerById(100); |
| 10603 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = | 10631 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = |
| 10604 true; | 10632 true; |
| 10605 SetNeedsRebuildPropertyTrees(); | 10633 SetNeedsRebuildPropertyTrees(); |
| 10606 RebuildPropertyTrees(); | 10634 RebuildPropertyTrees(); |
| 10607 DrawFrame(); | 10635 DrawFrame(); |
| 10608 TransformNode* node = | 10636 TransformNode* node = |
| 10609 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10637 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10679 // There should not be any jitter measured till we hit the fixed point hits | 10707 // There should not be any jitter measured till we hit the fixed point hits |
| 10680 // threshold. | 10708 // threshold. |
| 10681 float expected_jitter = | 10709 float expected_jitter = |
| 10682 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10710 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
| 10683 EXPECT_EQ(jitter, expected_jitter); | 10711 EXPECT_EQ(jitter, expected_jitter); |
| 10684 } | 10712 } |
| 10685 } | 10713 } |
| 10686 | 10714 |
| 10687 } // namespace | 10715 } // namespace |
| 10688 } // namespace cc | 10716 } // namespace cc |
| OLD | NEW |