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