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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 983 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
984 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 984 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
985 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); | 985 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); |
986 host_impl_->ScrollEnd(); | 986 host_impl_->ScrollEnd(); |
987 | 987 |
988 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 988 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
989 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 989 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
990 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); | 990 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); |
991 } | 991 } |
992 | 992 |
993 TEST_F(LayerTreeHostImplTest, MasksToBoundsDoesntClobberInnerContainerSize) { | |
994 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
995 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
996 DrawFrame(); | |
997 | |
998 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | |
999 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | |
1000 DCHECK(scroll_layer); | |
1001 | |
1002 float min_page_scale = 1.f; | |
1003 float max_page_scale = 4.f; | |
1004 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | |
1005 min_page_scale, | |
1006 max_page_scale); | |
1007 | |
1008 // If the container's masks_to_bounds is false, the viewport size should | |
1009 // overwrite the inner viewport container layer's size. | |
1010 { | |
1011 EXPECT_EQ(gfx::Size(50, 50), | |
1012 container_layer->bounds()); | |
1013 container_layer->SetMasksToBounds(false); | |
1014 | |
1015 container_layer->SetBounds(gfx::Size(30, 25)); | |
1016 EXPECT_EQ(gfx::Size(30, 25), | |
1017 container_layer->bounds()); | |
1018 | |
1019 // This should cause a reset of the inner viewport container layer's bounds. | |
1020 host_impl_->DidChangeTopControlsPosition(); | |
1021 | |
1022 EXPECT_EQ(gfx::Size(50, 50), | |
1023 container_layer->bounds()); | |
1024 } | |
1025 | |
1026 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
1027 container_layer->SetBounds(gfx::Size(50, 50)); | |
1028 | |
1029 // If the container's masks_to_bounds is true, the viewport size should | |
1030 // *NOT* overwrite the inner viewport container layer's size. | |
1031 { | |
1032 EXPECT_EQ(gfx::Size(50, 50), | |
1033 container_layer->bounds()); | |
1034 container_layer->SetMasksToBounds(true); | |
1035 | |
1036 container_layer->SetBounds(gfx::Size(30, 25)); | |
1037 EXPECT_EQ(gfx::Size(30, 25), | |
1038 container_layer->bounds()); | |
1039 | |
1040 // This should cause a reset of the inner viewport container layer's bounds. | |
1041 host_impl_->DidChangeTopControlsPosition(); | |
1042 | |
1043 EXPECT_EQ(gfx::Size(30, 25), | |
1044 container_layer->bounds()); | |
1045 } | |
1046 } | |
1047 | |
1048 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 993 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
1049 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 994 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1050 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 995 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1051 DrawFrame(); | 996 DrawFrame(); |
1052 | 997 |
1053 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 998 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
1054 DCHECK(scroll_layer); | 999 DCHECK(scroll_layer); |
1055 | 1000 |
1056 float min_page_scale = 1.f; | 1001 float min_page_scale = 1.f; |
1057 float max_page_scale = 4.f; | 1002 float max_page_scale = 4.f; |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 root->SetIsContainerForFixedPositionLayers(true); | 2117 root->SetIsContainerForFixedPositionLayers(true); |
2173 int inner_viewport_scroll_layer_id = root->id(); | 2118 int inner_viewport_scroll_layer_id = root->id(); |
2174 int page_scale_layer_id = root_clip->id(); | 2119 int page_scale_layer_id = root_clip->id(); |
2175 root_clip->AddChild(root.Pass()); | 2120 root_clip->AddChild(root.Pass()); |
2176 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2121 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
2177 host_impl_->active_tree()->SetViewportLayersFromIds( | 2122 host_impl_->active_tree()->SetViewportLayersFromIds( |
2178 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); | 2123 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |
2179 // Set a viewport size that is large enough to contain both the top controls | 2124 // Set a viewport size that is large enough to contain both the top controls |
2180 // and some content. | 2125 // and some content. |
2181 host_impl_->SetViewportSize(viewport_size_); | 2126 host_impl_->SetViewportSize(viewport_size_); |
| 2127 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); |
2182 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2128 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
2183 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 2129 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
2184 } | 2130 } |
2185 | 2131 |
2186 protected: | 2132 protected: |
2187 gfx::Size layer_size_; | 2133 gfx::Size layer_size_; |
2188 gfx::Size clip_size_; | 2134 gfx::Size clip_size_; |
2189 gfx::Size viewport_size_; | 2135 gfx::Size viewport_size_; |
2190 | 2136 |
2191 LayerTreeSettings settings_; | 2137 LayerTreeSettings settings_; |
(...skipping 4662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6854 external_clip, | 6800 external_clip, |
6855 external_viewport, | 6801 external_viewport, |
6856 external_transform, | 6802 external_transform, |
6857 resourceless_software_draw); | 6803 resourceless_software_draw); |
6858 DrawFrame(); | 6804 DrawFrame(); |
6859 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6805 EXPECT_TRANSFORMATION_MATRIX_EQ( |
6860 external_transform, layer->draw_properties().target_space_transform); | 6806 external_transform, layer->draw_properties().target_space_transform); |
6861 } | 6807 } |
6862 | 6808 |
6863 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { | 6809 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { |
6864 SetupScrollAndContentsLayers(gfx::Size(100, 150)); | 6810 SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
6865 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
6866 DrawFrame(); | 6811 DrawFrame(); |
6867 | 6812 |
6868 base::TimeTicks start_time = | 6813 base::TimeTicks start_time = |
6869 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 6814 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
6870 | 6815 |
6871 EXPECT_EQ(InputHandler::ScrollStarted, | 6816 EXPECT_EQ(InputHandler::ScrollStarted, |
6872 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 6817 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
6873 | 6818 |
6874 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 6819 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
6875 | 6820 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7024 host_impl_->DidLoseOutputSurface(); | 6969 host_impl_->DidLoseOutputSurface(); |
7025 EXPECT_TRUE(host_impl_->IsContextLost()); | 6970 EXPECT_TRUE(host_impl_->IsContextLost()); |
7026 EXPECT_EQ(1, num_lost_surfaces_); | 6971 EXPECT_EQ(1, num_lost_surfaces_); |
7027 host_impl_->DidLoseOutputSurface(); | 6972 host_impl_->DidLoseOutputSurface(); |
7028 EXPECT_TRUE(host_impl_->IsContextLost()); | 6973 EXPECT_TRUE(host_impl_->IsContextLost()); |
7029 EXPECT_EQ(1, num_lost_surfaces_); | 6974 EXPECT_EQ(1, num_lost_surfaces_); |
7030 } | 6975 } |
7031 | 6976 |
7032 } // namespace | 6977 } // namespace |
7033 } // namespace cc | 6978 } // namespace cc |
OLD | NEW |