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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 | 1067 |
1068 // Non-anchor zoom-in | 1068 // Non-anchor zoom-in |
1069 { | 1069 { |
1070 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 1070 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
1071 min_page_scale, | 1071 min_page_scale, |
1072 max_page_scale); | 1072 max_page_scale); |
1073 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); | 1073 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); |
1074 | 1074 |
1075 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); | 1075 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); |
1076 did_request_redraw_ = false; | 1076 did_request_redraw_ = false; |
1077 host_impl_->Animate(start_time, base::Time()); | 1077 host_impl_->Animate(start_time); |
1078 EXPECT_TRUE(did_request_redraw_); | 1078 EXPECT_TRUE(did_request_redraw_); |
1079 | 1079 |
1080 did_request_redraw_ = false; | 1080 did_request_redraw_ = false; |
1081 host_impl_->Animate(halfway_through_animation, base::Time()); | 1081 host_impl_->Animate(halfway_through_animation); |
1082 EXPECT_TRUE(did_request_redraw_); | 1082 EXPECT_TRUE(did_request_redraw_); |
1083 | 1083 |
1084 did_request_redraw_ = false; | 1084 did_request_redraw_ = false; |
1085 did_request_commit_ = false; | 1085 did_request_commit_ = false; |
1086 host_impl_->Animate(end_time, base::Time()); | 1086 host_impl_->Animate(end_time); |
1087 EXPECT_TRUE(did_request_commit_); | 1087 EXPECT_TRUE(did_request_commit_); |
1088 | 1088 |
1089 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1089 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1090 host_impl_->ProcessScrollDeltas(); | 1090 host_impl_->ProcessScrollDeltas(); |
1091 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 1091 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
1092 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1092 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1093 } | 1093 } |
1094 | 1094 |
1095 // Anchor zoom-out | 1095 // Anchor zoom-out |
1096 { | 1096 { |
1097 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 1097 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
1098 min_page_scale, | 1098 min_page_scale, |
1099 max_page_scale); | 1099 max_page_scale); |
1100 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); | 1100 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); |
1101 | 1101 |
1102 host_impl_->StartPageScaleAnimation( | 1102 host_impl_->StartPageScaleAnimation( |
1103 gfx::Vector2d(25, 25), true, min_page_scale, duration); | 1103 gfx::Vector2d(25, 25), true, min_page_scale, duration); |
1104 did_request_redraw_ = false; | 1104 did_request_redraw_ = false; |
1105 host_impl_->Animate(start_time, base::Time()); | 1105 host_impl_->Animate(start_time); |
1106 EXPECT_TRUE(did_request_redraw_); | 1106 EXPECT_TRUE(did_request_redraw_); |
1107 | 1107 |
1108 did_request_redraw_ = false; | 1108 did_request_redraw_ = false; |
1109 did_request_commit_ = false; | 1109 did_request_commit_ = false; |
1110 host_impl_->Animate(end_time, base::Time()); | 1110 host_impl_->Animate(end_time); |
1111 EXPECT_TRUE(did_request_redraw_); | 1111 EXPECT_TRUE(did_request_redraw_); |
1112 EXPECT_TRUE(did_request_commit_); | 1112 EXPECT_TRUE(did_request_commit_); |
1113 | 1113 |
1114 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1114 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1115 host_impl_->ProcessScrollDeltas(); | 1115 host_impl_->ProcessScrollDeltas(); |
1116 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 1116 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
1117 // Pushed to (0,0) via clamping against contents layer size. | 1117 // Pushed to (0,0) via clamping against contents layer size. |
1118 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1118 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1119 } | 1119 } |
1120 } | 1120 } |
(...skipping 15 matching lines...) Expand all Loading... |
1136 base::TimeTicks end_time = start_time + duration; | 1136 base::TimeTicks end_time = start_time + duration; |
1137 | 1137 |
1138 // Anchor zoom with unchanged page scale should not change scroll or scale. | 1138 // Anchor zoom with unchanged page scale should not change scroll or scale. |
1139 { | 1139 { |
1140 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 1140 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
1141 min_page_scale, | 1141 min_page_scale, |
1142 max_page_scale); | 1142 max_page_scale); |
1143 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); | 1143 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); |
1144 | 1144 |
1145 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), true, 1.f, duration); | 1145 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), true, 1.f, duration); |
1146 host_impl_->Animate(start_time, base::Time()); | 1146 host_impl_->Animate(start_time); |
1147 host_impl_->Animate(halfway_through_animation, base::Time()); | 1147 host_impl_->Animate(halfway_through_animation); |
1148 EXPECT_TRUE(did_request_redraw_); | 1148 EXPECT_TRUE(did_request_redraw_); |
1149 host_impl_->Animate(end_time, base::Time()); | 1149 host_impl_->Animate(end_time); |
1150 EXPECT_TRUE(did_request_commit_); | 1150 EXPECT_TRUE(did_request_commit_); |
1151 | 1151 |
1152 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1152 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1153 host_impl_->ProcessScrollDeltas(); | 1153 host_impl_->ProcessScrollDeltas(); |
1154 EXPECT_EQ(scroll_info->page_scale_delta, 1); | 1154 EXPECT_EQ(scroll_info->page_scale_delta, 1); |
1155 ExpectNone(*scroll_info, scroll_layer->id()); | 1155 ExpectNone(*scroll_info, scroll_layer->id()); |
1156 } | 1156 } |
1157 } | 1157 } |
1158 | 1158 |
1159 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { | 1159 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
(...skipping 4821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5981 | 5981 |
5982 protected: | 5982 protected: |
5983 static const int top_controls_height_; | 5983 static const int top_controls_height_; |
5984 }; | 5984 }; |
5985 | 5985 |
5986 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 5986 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
5987 | 5987 |
5988 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 5988 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { |
5989 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 5989 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
5990 ->SetScrollOffset(gfx::Vector2d(0, 10)); | 5990 ->SetScrollOffset(gfx::Vector2d(0, 10)); |
5991 host_impl_->Animate(base::TimeTicks(), base::Time()); | 5991 host_impl_->Animate(base::TimeTicks()); |
5992 EXPECT_FALSE(did_request_redraw_); | 5992 EXPECT_FALSE(did_request_redraw_); |
5993 } | 5993 } |
5994 | 5994 |
5995 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 5995 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
5996 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 5996 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
5997 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 5997 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
5998 DrawFrame(); | 5998 DrawFrame(); |
5999 | 5999 |
6000 EXPECT_EQ(InputHandler::ScrollStarted, | 6000 EXPECT_EQ(InputHandler::ScrollStarted, |
6001 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 6001 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6178 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6178 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6179 300u * 1024u * 1024u); | 6179 300u * 1024u * 1024u); |
6180 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6180 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6181 150u * 1024u * 1024u); | 6181 150u * 1024u * 1024u); |
6182 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6182 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
6183 75u * 1024u * 1024u); | 6183 75u * 1024u * 1024u); |
6184 } | 6184 } |
6185 | 6185 |
6186 } // namespace | 6186 } // namespace |
6187 } // namespace cc | 6187 } // namespace cc |
OLD | NEW |