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 <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 5933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5944 | 5944 |
5945 scoped_ptr<ScrollAndScaleSet> scroll_info = | 5945 scoped_ptr<ScrollAndScaleSet> scroll_info = |
5946 host_impl_->ProcessScrollDeltas(); | 5946 host_impl_->ProcessScrollDeltas(); |
5947 | 5947 |
5948 // The root should have scrolled. | 5948 // The root should have scrolled. |
5949 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 5949 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
5950 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); | 5950 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); |
5951 } | 5951 } |
5952 } | 5952 } |
5953 | 5953 |
| 5954 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { |
| 5955 // If we ray cast a scroller that is not on the first layer's ancestor chain, |
| 5956 // we should return ScrollUnknown. |
| 5957 gfx::Size content_size(100, 100); |
| 5958 SetupScrollAndContentsLayers(content_size); |
| 5959 |
| 5960 int scroll_layer_id = 2; |
| 5961 LayerImpl* scroll_layer = |
| 5962 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 5963 scroll_layer->SetDrawsContent(true); |
| 5964 |
| 5965 int page_scale_layer_id = 5; |
| 5966 LayerImpl* page_scale_layer = |
| 5967 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
| 5968 |
| 5969 int occluder_layer_id = 6; |
| 5970 scoped_ptr<LayerImpl> occluder_layer = |
| 5971 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
| 5972 occluder_layer->SetDrawsContent(true); |
| 5973 occluder_layer->SetBounds(content_size); |
| 5974 occluder_layer->SetContentBounds(content_size); |
| 5975 occluder_layer->SetPosition(gfx::PointF()); |
| 5976 occluder_layer->SetAnchorPoint(gfx::PointF()); |
| 5977 |
| 5978 // The parent of the occluder is *above* the scroller. |
| 5979 page_scale_layer->AddChild(occluder_layer.Pass()); |
| 5980 |
| 5981 DrawFrame(); |
| 5982 |
| 5983 EXPECT_EQ(InputHandler::ScrollUnknown, |
| 5984 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 5985 } |
| 5986 |
| 5987 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
| 5988 // If we ray cast a scroller this is on the first layer's ancestor chain, but |
| 5989 // is not the first scroller we encounter when walking up from the layer, we |
| 5990 // should also return ScrollUnknown. |
| 5991 gfx::Size content_size(100, 100); |
| 5992 SetupScrollAndContentsLayers(content_size); |
| 5993 |
| 5994 int scroll_layer_id = 2; |
| 5995 LayerImpl* scroll_layer = |
| 5996 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 5997 scroll_layer->SetDrawsContent(true); |
| 5998 |
| 5999 int occluder_layer_id = 6; |
| 6000 scoped_ptr<LayerImpl> occluder_layer = |
| 6001 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
| 6002 occluder_layer->SetDrawsContent(true); |
| 6003 occluder_layer->SetBounds(content_size); |
| 6004 occluder_layer->SetContentBounds(content_size); |
| 6005 occluder_layer->SetPosition(gfx::PointF()); |
| 6006 occluder_layer->SetAnchorPoint(gfx::PointF()); |
| 6007 |
| 6008 int child_scroll_clip_layer_id = 7; |
| 6009 scoped_ptr<LayerImpl> child_scroll_clip = |
| 6010 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); |
| 6011 |
| 6012 int child_scroll_layer_id = 8; |
| 6013 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
| 6014 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
| 6015 |
| 6016 child_scroll->SetDrawsContent(false); |
| 6017 |
| 6018 child_scroll->AddChild(occluder_layer.Pass()); |
| 6019 scroll_layer->AddChild(child_scroll.Pass()); |
| 6020 |
| 6021 DrawFrame(); |
| 6022 |
| 6023 EXPECT_EQ(InputHandler::ScrollUnknown, |
| 6024 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 6025 } |
| 6026 |
5954 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6027 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
5955 // to CompositorFrameMetadata after SwapBuffers(); | 6028 // to CompositorFrameMetadata after SwapBuffers(); |
5956 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6029 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
5957 scoped_ptr<SolidColorLayerImpl> root = | 6030 scoped_ptr<SolidColorLayerImpl> root = |
5958 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6031 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5959 root->SetAnchorPoint(gfx::PointF()); | 6032 root->SetAnchorPoint(gfx::PointF()); |
5960 root->SetPosition(gfx::PointF()); | 6033 root->SetPosition(gfx::PointF()); |
5961 root->SetBounds(gfx::Size(10, 10)); | 6034 root->SetBounds(gfx::Size(10, 10)); |
5962 root->SetContentBounds(gfx::Size(10, 10)); | 6035 root->SetContentBounds(gfx::Size(10, 10)); |
5963 root->SetDrawsContent(true); | 6036 root->SetDrawsContent(true); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6345 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6273 300u * 1024u * 1024u); | 6346 300u * 1024u * 1024u); |
6274 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6347 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6275 150u * 1024u * 1024u); | 6348 150u * 1024u * 1024u); |
6276 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6349 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
6277 75u * 1024u * 1024u); | 6350 75u * 1024u * 1024u); |
6278 } | 6351 } |
6279 | 6352 |
6280 } // namespace | 6353 } // namespace |
6281 } // namespace cc | 6354 } // namespace cc |
OLD | NEW |