Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2889093003: Refactor SetViewportLayerIds to use a struct instead of 6 values (Closed)
Patch Set: Fix small mistake made in a test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 outer_scroll->test_properties()->AddChild(std::move(contents)); 375 outer_scroll->test_properties()->AddChild(std::move(contents));
376 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 376 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
377 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); 377 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
378 page_scale->test_properties()->AddChild(std::move(inner_scroll)); 378 page_scale->test_properties()->AddChild(std::move(inner_scroll));
379 inner_clip->test_properties()->AddChild(std::move(page_scale)); 379 inner_clip->test_properties()->AddChild(std::move(page_scale));
380 root->test_properties()->AddChild(std::move(inner_clip)); 380 root->test_properties()->AddChild(std::move(inner_clip));
381 381
382 layer_tree_impl->SetRootLayerForTesting(std::move(root)); 382 layer_tree_impl->SetRootLayerForTesting(std::move(root));
383 layer_tree_impl->BuildPropertyTreesForTesting(); 383 layer_tree_impl->BuildPropertyTreesForTesting();
384 layer_tree_impl->SetViewportLayersFromIds( 384 LayerTreeImpl::ViewportLayerIds viewport_ids;
385 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, 385 viewport_ids.page_scale = kPageScaleLayerId;
386 kOuterViewportClipLayerId, kInnerViewportScrollLayerId, 386 viewport_ids.inner_viewport_container = kInnerViewportClipLayerId;
387 kOuterViewportScrollLayerId); 387 viewport_ids.outer_viewport_container = kOuterViewportClipLayerId;
388 viewport_ids.inner_viewport_scroll = kInnerViewportScrollLayerId;
389 viewport_ids.outer_viewport_scroll = kOuterViewportScrollLayerId;
390 layer_tree_impl->SetViewportLayersFromIds(viewport_ids);
388 391
389 layer_tree_impl->DidBecomeActive(); 392 layer_tree_impl->DidBecomeActive();
390 return layer_tree_impl->InnerViewportScrollLayer(); 393 return layer_tree_impl->InnerViewportScrollLayer();
391 } 394 }
392 395
393 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { 396 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) {
394 LayerImpl* scroll_layer = 397 LayerImpl* scroll_layer =
395 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 398 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
396 host_impl_->active_tree()->DidBecomeActive(); 399 host_impl_->active_tree()->DidBecomeActive();
397 return scroll_layer; 400 return scroll_layer;
(...skipping 3906 matching lines...) Expand 10 before | Expand all | Expand 10 after
4304 int inner_viewport_scroll_layer_id = root->id(); 4307 int inner_viewport_scroll_layer_id = root->id();
4305 int outer_viewport_scroll_layer_id = outer_scroll->id(); 4308 int outer_viewport_scroll_layer_id = outer_scroll->id();
4306 int page_scale_layer_id = page_scale->id(); 4309 int page_scale_layer_id = page_scale->id();
4307 4310
4308 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 4311 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
4309 root->test_properties()->AddChild(std::move(outer_clip)); 4312 root->test_properties()->AddChild(std::move(outer_clip));
4310 page_scale->test_properties()->AddChild(std::move(root)); 4313 page_scale->test_properties()->AddChild(std::move(root));
4311 root_clip->test_properties()->AddChild(std::move(page_scale)); 4314 root_clip->test_properties()->AddChild(std::move(page_scale));
4312 4315
4313 tree_impl->SetRootLayerForTesting(std::move(root_clip)); 4316 tree_impl->SetRootLayerForTesting(std::move(root_clip));
4314 tree_impl->SetViewportLayersFromIds( 4317 LayerTreeImpl::ViewportLayerIds viewport_ids;
4315 Layer::INVALID_ID, page_scale_layer_id, 4318 viewport_ids.page_scale = page_scale_layer_id;
4316 inner_viewport_container_layer_id, outer_viewport_container_layer_id, 4319 viewport_ids.inner_viewport_container = inner_viewport_container_layer_id;
4317 inner_viewport_scroll_layer_id, outer_viewport_scroll_layer_id); 4320 viewport_ids.outer_viewport_container = outer_viewport_container_layer_id;
4321 viewport_ids.inner_viewport_scroll = inner_viewport_scroll_layer_id;
4322 viewport_ids.outer_viewport_scroll = outer_viewport_scroll_layer_id;
4323 tree_impl->SetViewportLayersFromIds(viewport_ids);
4318 tree_impl->BuildPropertyTreesForTesting(); 4324 tree_impl->BuildPropertyTreesForTesting();
4319 4325
4320 host_impl_->SetViewportSize(inner_viewport_size); 4326 host_impl_->SetViewportSize(inner_viewport_size);
4321 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); 4327 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing();
4322 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); 4328 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
4323 } 4329 }
4324 4330
4325 protected: 4331 protected:
4326 gfx::Size layer_size_; 4332 gfx::Size layer_size_;
4327 gfx::Size clip_size_; 4333 gfx::Size clip_size_;
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
5728 LayerImpl* grand_child_layer = grand_child.get(); 5734 LayerImpl* grand_child_layer = grand_child.get();
5729 child->test_properties()->AddChild(std::move(grand_child)); 5735 child->test_properties()->AddChild(std::move(grand_child));
5730 5736
5731 LayerImpl* child_layer = child.get(); 5737 LayerImpl* child_layer = child.get();
5732 root_scrolling->test_properties()->AddChild(std::move(child)); 5738 root_scrolling->test_properties()->AddChild(std::move(child));
5733 root_clip->test_properties()->AddChild(std::move(root_scrolling)); 5739 root_clip->test_properties()->AddChild(std::move(root_scrolling));
5734 EXPECT_EQ(viewport_size, root_clip->bounds()); 5740 EXPECT_EQ(viewport_size, root_clip->bounds());
5735 root_ptr->test_properties()->AddChild(std::move(root_clip)); 5741 root_ptr->test_properties()->AddChild(std::move(root_clip));
5736 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); 5742 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr));
5737 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5743 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5738 host_impl_->active_tree()->SetViewportLayersFromIds( 5744 LayerTreeImpl::ViewportLayerIds viewport_ids;
5739 Layer::INVALID_ID, kPageScaleLayerId, kViewportClipLayerId, 5745 viewport_ids.page_scale = kPageScaleLayerId;
5740 Layer::INVALID_ID, kViewportScrollLayerId, Layer::INVALID_ID); 5746 viewport_ids.inner_viewport_container = kViewportClipLayerId;
5747 viewport_ids.inner_viewport_scroll = kViewportScrollLayerId;
5748 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids);
5741 host_impl_->active_tree()->DidBecomeActive(); 5749 host_impl_->active_tree()->DidBecomeActive();
5742 host_impl_->SetViewportSize(viewport_size); 5750 host_impl_->SetViewportSize(viewport_size);
5743 5751
5744 grand_child_layer->layer_tree_impl() 5752 grand_child_layer->layer_tree_impl()
5745 ->property_trees() 5753 ->property_trees()
5746 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), 5754 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
5747 gfx::ScrollOffset(0, 2)); 5755 gfx::ScrollOffset(0, 2));
5748 child_layer->layer_tree_impl() 5756 child_layer->layer_tree_impl()
5749 ->property_trees() 5757 ->property_trees()
5750 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), 5758 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5872 kViewportScrollLayerId, content_size, root_scroll.get()); 5880 kViewportScrollLayerId, content_size, root_scroll.get());
5873 child->test_properties()->is_container_for_fixed_position_layers = true; 5881 child->test_properties()->is_container_for_fixed_position_layers = true;
5874 root_scroll->SetBounds(content_size); 5882 root_scroll->SetBounds(content_size);
5875 5883
5876 int root_scroll_id = root_scroll->id(); 5884 int root_scroll_id = root_scroll->id();
5877 root_scroll->test_properties()->AddChild(std::move(child)); 5885 root_scroll->test_properties()->AddChild(std::move(child));
5878 root_clip->test_properties()->AddChild(std::move(root_scroll)); 5886 root_clip->test_properties()->AddChild(std::move(root_scroll));
5879 root_ptr->test_properties()->AddChild(std::move(root_clip)); 5887 root_ptr->test_properties()->AddChild(std::move(root_clip));
5880 5888
5881 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); 5889 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr));
5882 host_impl_->active_tree()->SetViewportLayersFromIds( 5890 LayerTreeImpl::ViewportLayerIds viewport_ids;
5883 Layer::INVALID_ID, kPageScaleLayerId, kViewportClipLayerId, 5891 viewport_ids.page_scale = kPageScaleLayerId;
5884 Layer::INVALID_ID, kViewportScrollLayerId, Layer::INVALID_ID); 5892 viewport_ids.inner_viewport_container = kViewportClipLayerId;
5893 viewport_ids.inner_viewport_scroll = kViewportScrollLayerId;
5894 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids);
5885 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5895 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5886 host_impl_->active_tree()->DidBecomeActive(); 5896 host_impl_->active_tree()->DidBecomeActive();
5887 5897
5888 host_impl_->SetViewportSize(surface_size); 5898 host_impl_->SetViewportSize(surface_size);
5889 DrawFrame(); 5899 DrawFrame();
5890 { 5900 {
5891 gfx::Vector2d scroll_delta(0, 4); 5901 gfx::Vector2d scroll_delta(0, 4);
5892 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5902 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5893 host_impl_ 5903 host_impl_
5894 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5904 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 inner_clip->test_properties()->force_render_surface = true; 5937 inner_clip->test_properties()->force_render_surface = true;
5928 inner_scroll->test_properties()->is_container_for_fixed_position_layers = 5938 inner_scroll->test_properties()->is_container_for_fixed_position_layers =
5929 true; 5939 true;
5930 outer_scroll->test_properties()->is_container_for_fixed_position_layers = 5940 outer_scroll->test_properties()->is_container_for_fixed_position_layers =
5931 true; 5941 true;
5932 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 5942 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
5933 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); 5943 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
5934 inner_clip->test_properties()->AddChild(std::move(inner_scroll)); 5944 inner_clip->test_properties()->AddChild(std::move(inner_scroll));
5935 root_ptr->test_properties()->AddChild(std::move(inner_clip)); 5945 root_ptr->test_properties()->AddChild(std::move(inner_clip));
5936 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); 5946 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr));
5937 host_impl_->active_tree()->SetViewportLayersFromIds( 5947 LayerTreeImpl::ViewportLayerIds viewport_ids;
5938 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, 5948 viewport_ids.page_scale = kPageScaleLayerId;
5939 kOuterViewportClipLayerId, kInnerViewportScrollLayerId, 5949 viewport_ids.inner_viewport_container = kInnerViewportClipLayerId;
5940 kOuterViewportScrollLayerId); 5950 viewport_ids.outer_viewport_container = kOuterViewportClipLayerId;
5951 viewport_ids.inner_viewport_scroll = kInnerViewportScrollLayerId;
5952 viewport_ids.outer_viewport_scroll = kOuterViewportScrollLayerId;
5953 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids);
5941 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5954 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5942 host_impl_->active_tree()->DidBecomeActive(); 5955 host_impl_->active_tree()->DidBecomeActive();
5943 5956
5944 host_impl_->SetViewportSize(surface_size); 5957 host_impl_->SetViewportSize(surface_size);
5945 5958
5946 // Draw one frame and then immediately rebuild the layer tree to mimic a tree 5959 // Draw one frame and then immediately rebuild the layer tree to mimic a tree
5947 // synchronization. 5960 // synchronization.
5948 DrawFrame(); 5961 DrawFrame();
5949 5962
5950 const int kPageScaleLayerId2 = 4; 5963 const int kPageScaleLayerId2 = 4;
(...skipping 16 matching lines...) Expand all
5967 true; 5980 true;
5968 outer_scroll2->test_properties()->is_container_for_fixed_position_layers = 5981 outer_scroll2->test_properties()->is_container_for_fixed_position_layers =
5969 true; 5982 true;
5970 outer_clip2->test_properties()->AddChild(std::move(outer_scroll2)); 5983 outer_clip2->test_properties()->AddChild(std::move(outer_scroll2));
5971 inner_scroll2->test_properties()->AddChild(std::move(outer_clip2)); 5984 inner_scroll2->test_properties()->AddChild(std::move(outer_clip2));
5972 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); 5985 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2));
5973 inner_clip2->test_properties()->force_render_surface = true; 5986 inner_clip2->test_properties()->force_render_surface = true;
5974 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); 5987 root_ptr2->test_properties()->AddChild(std::move(inner_clip2));
5975 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); 5988 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2));
5976 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 5989 host_impl_->active_tree()->BuildPropertyTreesForTesting();
5977 host_impl_->active_tree()->SetViewportLayersFromIds( 5990 LayerTreeImpl::ViewportLayerIds viewport_ids2;
5978 Layer::INVALID_ID, kPageScaleLayerId2, kInnerViewportClipLayerId2, 5991 viewport_ids2.page_scale = kPageScaleLayerId2;
5979 kOuterViewportClipLayerId2, kInnerViewportScrollLayerId2, 5992 viewport_ids2.inner_viewport_container = kInnerViewportClipLayerId2;
5980 kOuterViewportScrollLayerId2); 5993 viewport_ids2.outer_viewport_container = kOuterViewportClipLayerId2;
5994 viewport_ids2.inner_viewport_scroll = kInnerViewportScrollLayerId2;
5995 viewport_ids2.outer_viewport_scroll = kOuterViewportScrollLayerId2;
5996 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids2);
5981 host_impl_->active_tree()->DidBecomeActive(); 5997 host_impl_->active_tree()->DidBecomeActive();
5982 5998
5983 // Scrolling should still work even though we did not draw yet. 5999 // Scrolling should still work even though we did not draw yet.
5984 EXPECT_EQ( 6000 EXPECT_EQ(
5985 InputHandler::SCROLL_ON_IMPL_THREAD, 6001 InputHandler::SCROLL_ON_IMPL_THREAD,
5986 host_impl_ 6002 host_impl_
5987 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) 6003 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL)
5988 .thread); 6004 .thread);
5989 } 6005 }
5990 6006
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
6554 kInnerViewportScrollLayerId, surface_size, root_clip.get()); 6570 kInnerViewportScrollLayerId, surface_size, root_clip.get());
6555 6571
6556 std::unique_ptr<LayerImpl> grand_child = 6572 std::unique_ptr<LayerImpl> grand_child =
6557 CreateScrollableLayer(3, surface_size, root_clip.get()); 6573 CreateScrollableLayer(3, surface_size, root_clip.get());
6558 6574
6559 std::unique_ptr<LayerImpl> child = 6575 std::unique_ptr<LayerImpl> child =
6560 CreateScrollableLayer(2, surface_size, root_clip.get()); 6576 CreateScrollableLayer(2, surface_size, root_clip.get());
6561 LayerImpl* grand_child_layer = grand_child.get(); 6577 LayerImpl* grand_child_layer = grand_child.get();
6562 child->test_properties()->AddChild(std::move(grand_child)); 6578 child->test_properties()->AddChild(std::move(grand_child));
6563 6579
6564 host_impl_->active_tree()->SetViewportLayersFromIds( 6580 LayerTreeImpl::ViewportLayerIds viewport_ids;
6565 Layer::INVALID_ID, Layer::INVALID_ID, kInnerViewportClipLayerId, 6581 viewport_ids.inner_viewport_container = kInnerViewportClipLayerId;
6566 Layer::INVALID_ID, kInnerViewportScrollLayerId, Layer::INVALID_ID); 6582 viewport_ids.inner_viewport_scroll = kInnerViewportScrollLayerId;
6583 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids);
6567 6584
6568 LayerImpl* child_layer = child.get(); 6585 LayerImpl* child_layer = child.get();
6569 root->test_properties()->AddChild(std::move(child)); 6586 root->test_properties()->AddChild(std::move(child));
6570 root_clip->test_properties()->AddChild(std::move(root)); 6587 root_clip->test_properties()->AddChild(std::move(root));
6571 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); 6588 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip));
6572 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6589 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6573 host_impl_->active_tree()->DidBecomeActive(); 6590 host_impl_->active_tree()->DidBecomeActive();
6574 6591
6575 child_layer->layer_tree_impl() 6592 child_layer->layer_tree_impl()
6576 ->property_trees() 6593 ->property_trees()
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
6959 scroll2->SetDrawsContent(true); 6976 scroll2->SetDrawsContent(true);
6960 6977
6961 scroll_layer = scroll.get(); 6978 scroll_layer = scroll.get();
6962 child_scroll_layer = scroll2.get(); 6979 child_scroll_layer = scroll2.get();
6963 6980
6964 clip2->test_properties()->AddChild(std::move(scroll2)); 6981 clip2->test_properties()->AddChild(std::move(scroll2));
6965 scroll->test_properties()->AddChild(std::move(clip2)); 6982 scroll->test_properties()->AddChild(std::move(clip2));
6966 6983
6967 clip->test_properties()->AddChild(std::move(scroll)); 6984 clip->test_properties()->AddChild(std::move(scroll));
6968 content_layer->test_properties()->AddChild(std::move(clip)); 6985 content_layer->test_properties()->AddChild(std::move(clip));
6969 layer_tree_impl->SetViewportLayersFromIds( 6986 LayerTreeImpl::ViewportLayerIds viewport_ids;
6970 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), 6987 viewport_ids.page_scale = layer_tree_impl->PageScaleLayer()->id();
6971 Layer::INVALID_ID, Layer::INVALID_ID, inner_scroll_layer->id(), 6988 viewport_ids.inner_viewport_scroll = inner_scroll_layer->id();
6972 scroll_layer->id()); 6989 viewport_ids.outer_viewport_scroll = scroll_layer->id();
6990 layer_tree_impl->SetViewportLayersFromIds(viewport_ids);
6973 layer_tree_impl->BuildPropertyTreesForTesting(); 6991 layer_tree_impl->BuildPropertyTreesForTesting();
6974 } 6992 }
6975 6993
6976 // Scroll should target the nested scrolling layer in the content and then 6994 // Scroll should target the nested scrolling layer in the content and then
6977 // chain to the parent scrolling layer which is now set as the outer 6995 // chain to the parent scrolling layer which is now set as the outer
6978 // viewport. The original outer viewport layer shouldn't get any scroll here. 6996 // viewport. The original outer viewport layer shouldn't get any scroll here.
6979 { 6997 {
6980 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 6998 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
6981 InputHandler::TOUCHSCREEN); 6999 InputHandler::TOUCHSCREEN);
6982 host_impl_->ScrollBy( 7000 host_impl_->ScrollBy(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
7097 scroll2->SetElementId(LayerIdToElementIdForTesting(scroll2->id())); 7115 scroll2->SetElementId(LayerIdToElementIdForTesting(scroll2->id()));
7098 scroll2->SetDrawsContent(true); 7116 scroll2->SetDrawsContent(true);
7099 7117
7100 sibling_scroll_layer = scroll2.get(); 7118 sibling_scroll_layer = scroll2.get();
7101 7119
7102 clip2->test_properties()->AddChild(std::move(scroll2)); 7120 clip2->test_properties()->AddChild(std::move(scroll2));
7103 content_layer->test_properties()->AddChild(std::move(clip2)); 7121 content_layer->test_properties()->AddChild(std::move(clip2));
7104 7122
7105 LayerImpl* inner_container = 7123 LayerImpl* inner_container =
7106 host_impl_->active_tree()->InnerViewportContainerLayer(); 7124 host_impl_->active_tree()->InnerViewportContainerLayer();
7107 layer_tree_impl->SetViewportLayersFromIds( 7125 LayerTreeImpl::ViewportLayerIds viewport_ids;
7108 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), 7126 viewport_ids.page_scale = layer_tree_impl->PageScaleLayer()->id();
7109 inner_container->id(), Layer::INVALID_ID, inner_scroll_layer->id(), 7127 viewport_ids.inner_viewport_container = inner_container->id();
7110 outer_scroll_layer->id()); 7128 viewport_ids.inner_viewport_scroll = inner_scroll_layer->id();
7129 viewport_ids.outer_viewport_scroll = outer_scroll_layer->id();
7130 layer_tree_impl->SetViewportLayersFromIds(viewport_ids);
7111 layer_tree_impl->BuildPropertyTreesForTesting(); 7131 layer_tree_impl->BuildPropertyTreesForTesting();
7112 7132
7113 ASSERT_EQ(outer_scroll_layer, layer_tree_impl->OuterViewportScrollLayer()); 7133 ASSERT_EQ(outer_scroll_layer, layer_tree_impl->OuterViewportScrollLayer());
7114 } 7134 }
7115 7135
7116 // Scrolls should target the non-descendant scroller. Chaining should not 7136 // Scrolls should target the non-descendant scroller. Chaining should not
7117 // propagate to the outer viewport scroll layer. 7137 // propagate to the outer viewport scroll layer.
7118 { 7138 {
7119 // This should fully scroll the layer. 7139 // This should fully scroll the layer.
7120 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 7140 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
8873 std::unique_ptr<LayerImpl> child = 8893 std::unique_ptr<LayerImpl> child =
8874 CreateScrollableLayer(2, content_size, root_clip.get()); 8894 CreateScrollableLayer(2, content_size, root_clip.get());
8875 8895
8876 root_scroll->test_properties()->AddChild(std::move(child)); 8896 root_scroll->test_properties()->AddChild(std::move(child));
8877 int root_id = root_scroll->id(); 8897 int root_id = root_scroll->id();
8878 root_clip->test_properties()->AddChild(std::move(root_scroll)); 8898 root_clip->test_properties()->AddChild(std::move(root_scroll));
8879 root_ptr->test_properties()->AddChild(std::move(root_clip)); 8899 root_ptr->test_properties()->AddChild(std::move(root_clip));
8880 8900
8881 host_impl_->SetViewportSize(surface_size); 8901 host_impl_->SetViewportSize(surface_size);
8882 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); 8902 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr));
8883 host_impl_->active_tree()->SetViewportLayersFromIds( 8903 LayerTreeImpl::ViewportLayerIds viewport_ids;
8884 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, 8904 viewport_ids.page_scale = kPageScaleLayerId;
8885 Layer::INVALID_ID, kInnerViewportScrollLayerId, Layer::INVALID_ID); 8905 viewport_ids.inner_viewport_container = kInnerViewportClipLayerId;
8906 viewport_ids.inner_viewport_scroll = kInnerViewportScrollLayerId;
8907 host_impl_->active_tree()->SetViewportLayersFromIds(viewport_ids);
8886 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8908 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8887 host_impl_->active_tree()->DidBecomeActive(); 8909 host_impl_->active_tree()->DidBecomeActive();
8888 DrawFrame(); 8910 DrawFrame();
8889 { 8911 {
8890 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8912 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8891 host_impl_ 8913 host_impl_
8892 ->ScrollBegin(BeginState(gfx::Point()).get(), 8914 ->ScrollBegin(BeginState(gfx::Point()).get(),
8893 InputHandler::TOUCHSCREEN) 8915 InputHandler::TOUCHSCREEN)
8894 .thread); 8916 .thread);
8895 8917
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
9903 scroll->SetBounds(scroll_content_size); 9925 scroll->SetBounds(scroll_content_size);
9904 scroll->SetScrollClipLayer(clip->id()); 9926 scroll->SetScrollClipLayer(clip->id());
9905 scroll->SetElementId(LayerIdToElementIdForTesting(scroll->id())); 9927 scroll->SetElementId(LayerIdToElementIdForTesting(scroll->id()));
9906 scroll->SetDrawsContent(true); 9928 scroll->SetDrawsContent(true);
9907 9929
9908 scroll_layer = scroll.get(); 9930 scroll_layer = scroll.get();
9909 clip_layer = clip.get(); 9931 clip_layer = clip.get();
9910 9932
9911 clip->test_properties()->AddChild(std::move(scroll)); 9933 clip->test_properties()->AddChild(std::move(scroll));
9912 outer_scroll->test_properties()->AddChild(std::move(clip)); 9934 outer_scroll->test_properties()->AddChild(std::move(clip));
9913 layer_tree_impl->SetViewportLayersFromIds( 9935 LayerTreeImpl::ViewportLayerIds viewport_ids;
9914 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), 9936 viewport_ids.page_scale = layer_tree_impl->PageScaleLayer()->id();
9915 layer_tree_impl->InnerViewportContainerLayer()->id(), clip_layer->id(), 9937 viewport_ids.inner_viewport_container =
9916 inner_scroll->id(), scroll_layer->id()); 9938 layer_tree_impl->InnerViewportContainerLayer()->id();
9939 viewport_ids.outer_viewport_container = clip_layer->id();
9940 viewport_ids.inner_viewport_scroll = inner_scroll->id();
9941 viewport_ids.outer_viewport_scroll = scroll_layer->id();
9942 layer_tree_impl->SetViewportLayersFromIds(viewport_ids);
9917 layer_tree_impl->BuildPropertyTreesForTesting(); 9943 layer_tree_impl->BuildPropertyTreesForTesting();
9918 DrawFrame(); 9944 DrawFrame();
9919 } 9945 }
9920 9946
9921 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); 9947 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio());
9922 9948
9923 // Scrolling should scroll the child content and the browser controls. The 9949 // Scrolling should scroll the child content and the browser controls. The
9924 // original outer viewport should get no scroll. 9950 // original outer viewport should get no scroll.
9925 { 9951 {
9926 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 9952 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
9995 contents->SetPosition(gfx::PointF()); 10021 contents->SetPosition(gfx::PointF());
9996 10022
9997 outer_scroll->test_properties()->AddChild(std::move(contents)); 10023 outer_scroll->test_properties()->AddChild(std::move(contents));
9998 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); 10024 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
9999 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); 10025 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
10000 page_scale->test_properties()->AddChild(std::move(inner_scroll)); 10026 page_scale->test_properties()->AddChild(std::move(inner_scroll));
10001 inner_clip->test_properties()->AddChild(std::move(page_scale)); 10027 inner_clip->test_properties()->AddChild(std::move(page_scale));
10002 10028
10003 inner_clip->test_properties()->force_render_surface = true; 10029 inner_clip->test_properties()->force_render_surface = true;
10004 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); 10030 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip));
10005 layer_tree_impl->SetViewportLayersFromIds( 10031 LayerTreeImpl::ViewportLayerIds viewport_ids;
10006 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportClipLayerId, 10032 viewport_ids.page_scale = kPageScaleLayerId;
10007 kOuterViewportClipLayerId, kInnerViewportScrollLayerId, 10033 viewport_ids.inner_viewport_container = kInnerViewportClipLayerId;
10008 kOuterViewportScrollLayerId); 10034 viewport_ids.outer_viewport_container = kOuterViewportClipLayerId;
10035 viewport_ids.inner_viewport_scroll = kInnerViewportScrollLayerId;
10036 viewport_ids.outer_viewport_scroll = kOuterViewportScrollLayerId;
10037 layer_tree_impl->SetViewportLayersFromIds(viewport_ids);
10009 10038
10010 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 10039 host_impl_->active_tree()->BuildPropertyTreesForTesting();
10011 host_impl_->active_tree()->DidBecomeActive(); 10040 host_impl_->active_tree()->DidBecomeActive();
10012 } 10041 }
10013 }; 10042 };
10014 10043
10015 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { 10044 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) {
10016 gfx::Size content_size = gfx::Size(100, 160); 10045 gfx::Size content_size = gfx::Size(100, 160);
10017 gfx::Size outer_viewport = gfx::Size(50, 80); 10046 gfx::Size outer_viewport = gfx::Size(50, 80);
10018 gfx::Size inner_viewport = gfx::Size(25, 40); 10047 gfx::Size inner_viewport = gfx::Size(25, 40);
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
12434 else 12463 else
12435 EXPECT_FALSE(tile->HasRasterTask()); 12464 EXPECT_FALSE(tile->HasRasterTask());
12436 } 12465 }
12437 Region expected_invalidation( 12466 Region expected_invalidation(
12438 raster_source->GetRectForImage(checkerable_image.stable_id())); 12467 raster_source->GetRectForImage(checkerable_image.stable_id()));
12439 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12468 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12440 } 12469 }
12441 12470
12442 } // namespace 12471 } // namespace
12443 } // namespace cc 12472 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698