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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 settings, this, task_runner_provider, &stats_instrumentation_, | 200 settings, this, task_runner_provider, &stats_instrumentation_, |
201 &task_graph_runner_, | 201 &task_graph_runner_, |
202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
203 compositor_frame_sink_ = std::move(compositor_frame_sink); | 203 compositor_frame_sink_ = std::move(compositor_frame_sink); |
204 host_impl_->SetVisible(true); | 204 host_impl_->SetVisible(true); |
205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
206 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 206 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
208 // Set the BeginFrameArgs so that methods which use it are able to. | 208 // Set the BeginFrameArgs so that methods which use it are able to. |
209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
210 BEGINFRAME_FROM_HERE, | 210 BEGINFRAME_FROM_HERE, 0, 1, |
211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
212 host_impl_->DidFinishImplFrame(); | 212 host_impl_->DidFinishImplFrame(); |
213 | 213 |
214 timeline_ = | 214 timeline_ = |
215 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 215 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
216 GetImplAnimationHost()->AddAnimationTimeline(timeline_); | 216 GetImplAnimationHost()->AddAnimationTimeline(timeline_); |
217 | 217 |
218 return init; | 218 return init; |
219 } | 219 } |
220 | 220 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 layer_tree_impl->BuildPropertyTreesForTesting(); | 355 layer_tree_impl->BuildPropertyTreesForTesting(); |
356 layer_tree_impl->SetViewportLayersFromIds( | 356 layer_tree_impl->SetViewportLayersFromIds( |
357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
358 kOuterViewportScrollLayerId); | 358 kOuterViewportScrollLayerId); |
359 | 359 |
360 layer_tree_impl->DidBecomeActive(); | 360 layer_tree_impl->DidBecomeActive(); |
361 return layer_tree_impl->InnerViewportScrollLayer(); | 361 return layer_tree_impl->InnerViewportScrollLayer(); |
362 } | 362 } |
363 | 363 |
364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
365 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 365 LayerImpl* scroll_layer = |
366 host_impl_->active_tree(), content_size); | 366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
367 host_impl_->active_tree()->DidBecomeActive(); | 367 host_impl_->active_tree()->DidBecomeActive(); |
368 return scroll_layer; | 368 return scroll_layer; |
369 } | 369 } |
370 | 370 |
371 // Sets up a typical virtual viewport setup with one child content layer. | 371 // Sets up a typical virtual viewport setup with one child content layer. |
372 // Returns a pointer to the content layer. | 372 // Returns a pointer to the content layer. |
373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, | 373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, |
374 const gfx::Size& content_size) { | 374 const gfx::Size& content_size) { |
375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and | 375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and |
376 // the inner a different size from the outer. We'll reuse its layer | 376 // the inner a different size from the outer. We'll reuse its layer |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 if (layer_impl->layer_tree_impl() | 482 if (layer_impl->layer_tree_impl() |
483 ->property_trees() | 483 ->property_trees() |
484 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), | 484 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), |
485 delta)) | 485 delta)) |
486 layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id()); | 486 layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id()); |
487 } | 487 } |
488 | 488 |
489 void BeginImplFrameAndAnimate(BeginFrameArgs begin_frame_args, | 489 void BeginImplFrameAndAnimate(BeginFrameArgs begin_frame_args, |
490 base::TimeTicks frame_time) { | 490 base::TimeTicks frame_time) { |
491 begin_frame_args.frame_time = frame_time; | 491 begin_frame_args.frame_time = frame_time; |
492 begin_frame_args.sequence_number++; | |
brianderson
2016/12/15 22:10:33
Why isn't this incremented afterwards?
Eric Seckler
2016/12/16 17:25:58
Yeah, this is actually buggy since it copies |begi
| |
492 host_impl_->WillBeginImplFrame(begin_frame_args); | 493 host_impl_->WillBeginImplFrame(begin_frame_args); |
493 host_impl_->Animate(); | 494 host_impl_->Animate(); |
494 host_impl_->UpdateAnimationState(true); | 495 host_impl_->UpdateAnimationState(true); |
495 host_impl_->DidFinishImplFrame(); | 496 host_impl_->DidFinishImplFrame(); |
496 } | 497 } |
497 | 498 |
498 FakeImplTaskRunnerProvider task_runner_provider_; | 499 FakeImplTaskRunnerProvider task_runner_provider_; |
499 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 500 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
500 | 501 |
501 TestTaskGraphRunner task_graph_runner_; | 502 TestTaskGraphRunner task_graph_runner_; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 742 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
742 status.main_thread_scrolling_reasons); | 743 status.main_thread_scrolling_reasons); |
743 } | 744 } |
744 | 745 |
745 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 746 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
746 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 747 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
747 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 748 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
748 DrawFrame(); | 749 DrawFrame(); |
749 | 750 |
750 // We should not crash if the tree is replaced while we are scrolling. | 751 // We should not crash if the tree is replaced while we are scrolling. |
751 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 752 EXPECT_EQ( |
752 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 753 InputHandler::SCROLL_ON_IMPL_THREAD, |
753 InputHandler::WHEEL) | 754 host_impl_ |
754 .thread); | 755 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
756 .thread); | |
755 host_impl_->active_tree()->DetachLayers(); | 757 host_impl_->active_tree()->DetachLayers(); |
756 | 758 |
757 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 759 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
758 | 760 |
759 // We should still be scrolling, because the scrolled layer also exists in the | 761 // We should still be scrolling, because the scrolled layer also exists in the |
760 // new tree. | 762 // new tree. |
761 gfx::Vector2d scroll_delta(0, 10); | 763 gfx::Vector2d scroll_delta(0, 10); |
762 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 764 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
763 host_impl_->ScrollEnd(EndState().get()); | 765 host_impl_->ScrollEnd(EndState().get()); |
764 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 766 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
765 host_impl_->ProcessScrollDeltas(); | 767 host_impl_->ProcessScrollDeltas(); |
766 EXPECT_TRUE( | 768 EXPECT_TRUE( |
767 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); | 769 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); |
768 } | 770 } |
769 | 771 |
770 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 772 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
771 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 773 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
772 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 774 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
773 DrawFrame(); | 775 DrawFrame(); |
774 | 776 |
775 // Wheel handlers determine whether mouse events block scroll. | 777 // Wheel handlers determine whether mouse events block scroll. |
776 host_impl_->active_tree()->set_event_listener_properties( | 778 host_impl_->active_tree()->set_event_listener_properties( |
777 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); | 779 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); |
778 EXPECT_EQ( | 780 EXPECT_EQ( |
779 EventListenerProperties::kBlocking, | 781 EventListenerProperties::kBlocking, |
780 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); | 782 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); |
781 | 783 |
782 // But they don't influence the actual handling of the scroll gestures. | 784 // But they don't influence the actual handling of the scroll gestures. |
783 InputHandler::ScrollStatus status = | 785 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
784 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 786 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
785 InputHandler::WHEEL); | |
786 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 787 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
787 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 788 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
788 status.main_thread_scrolling_reasons); | 789 status.main_thread_scrolling_reasons); |
789 host_impl_->ScrollEnd(EndState().get()); | 790 host_impl_->ScrollEnd(EndState().get()); |
790 } | 791 } |
791 | 792 |
792 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 793 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
793 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 794 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
794 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 795 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
795 DrawFrame(); | 796 DrawFrame(); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1123 DrawFrame(); | 1124 DrawFrame(); |
1124 | 1125 |
1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1126 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
1126 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 1127 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1128 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1129 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
1129 status.main_thread_scrolling_reasons); | 1130 status.main_thread_scrolling_reasons); |
1130 | 1131 |
1131 // Trying to scroll to the left/top will not succeed. | 1132 // Trying to scroll to the left/top will not succeed. |
1132 EXPECT_FALSE( | 1133 EXPECT_FALSE( |
1133 host_impl_->ScrollBy( | 1134 host_impl_ |
1134 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1135 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
1135 .did_scroll); | 1136 .did_scroll); |
1136 EXPECT_FALSE( | 1137 EXPECT_FALSE( |
1137 host_impl_->ScrollBy( | 1138 host_impl_ |
1138 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) | 1139 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) |
1139 .did_scroll); | 1140 .did_scroll); |
1140 EXPECT_FALSE( | 1141 EXPECT_FALSE( |
1141 host_impl_->ScrollBy( | 1142 host_impl_ |
1142 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) | 1143 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) |
1143 .did_scroll); | 1144 .did_scroll); |
1144 | 1145 |
1145 // Scrolling to the right/bottom will succeed. | 1146 // Scrolling to the right/bottom will succeed. |
1146 EXPECT_TRUE( | 1147 EXPECT_TRUE( |
1147 host_impl_->ScrollBy( | 1148 host_impl_ |
1148 UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get()) | 1149 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get()) |
1149 .did_scroll); | 1150 .did_scroll); |
1150 EXPECT_TRUE( | 1151 EXPECT_TRUE( |
1151 host_impl_->ScrollBy( | 1152 host_impl_ |
1152 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 1153 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
1153 .did_scroll); | 1154 .did_scroll); |
1154 EXPECT_TRUE( | 1155 EXPECT_TRUE( |
1155 host_impl_->ScrollBy( | 1156 host_impl_ |
1156 UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get()) | 1157 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get()) |
1157 .did_scroll); | 1158 .did_scroll); |
1158 | 1159 |
1159 // Scrolling to left/top will now succeed. | 1160 // Scrolling to left/top will now succeed. |
1160 EXPECT_TRUE( | 1161 EXPECT_TRUE( |
1161 host_impl_->ScrollBy( | 1162 host_impl_ |
1162 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1163 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
1163 .did_scroll); | 1164 .did_scroll); |
1164 EXPECT_TRUE( | 1165 EXPECT_TRUE( |
1165 host_impl_->ScrollBy( | 1166 host_impl_ |
1166 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) | 1167 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) |
1167 .did_scroll); | 1168 .did_scroll); |
1168 EXPECT_TRUE( | 1169 EXPECT_TRUE( |
1169 host_impl_->ScrollBy( | 1170 host_impl_ |
1170 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) | 1171 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) |
1171 .did_scroll); | 1172 .did_scroll); |
1172 | 1173 |
1173 // Scrolling diagonally against an edge will succeed. | 1174 // Scrolling diagonally against an edge will succeed. |
1174 EXPECT_TRUE( | 1175 EXPECT_TRUE( |
1175 host_impl_->ScrollBy( | 1176 host_impl_ |
1176 UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get()) | 1177 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get()) |
1177 .did_scroll); | 1178 .did_scroll); |
1178 EXPECT_TRUE( | 1179 EXPECT_TRUE( |
1179 host_impl_->ScrollBy( | 1180 host_impl_ |
1180 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1181 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
1181 .did_scroll); | 1182 .did_scroll); |
1182 EXPECT_TRUE( | 1183 EXPECT_TRUE( |
1183 host_impl_->ScrollBy( | 1184 host_impl_ |
1184 UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) | 1185 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) |
1185 .did_scroll); | 1186 .did_scroll); |
1186 | 1187 |
1187 // Trying to scroll more than the available space will also succeed. | 1188 // Trying to scroll more than the available space will also succeed. |
1188 EXPECT_TRUE( | 1189 EXPECT_TRUE( |
1189 host_impl_->ScrollBy( | 1190 host_impl_ |
1190 UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) | 1191 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) |
1191 .did_scroll); | 1192 .did_scroll); |
1192 } | 1193 } |
1193 | 1194 |
1194 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1195 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
1195 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1196 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1196 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1197 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1197 | 1198 |
1198 gfx::Size overflow_size(400, 400); | 1199 gfx::Size overflow_size(400, 400); |
1199 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1200 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
1200 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1201 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
1201 overflow->SetBounds(overflow_size); | 1202 overflow->SetBounds(overflow_size); |
1202 overflow->SetScrollClipLayer( | 1203 overflow->SetScrollClipLayer( |
1203 scroll_layer->test_properties()->parent->test_properties()->parent->id()); | 1204 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
1204 overflow->layer_tree_impl() | 1205 overflow->layer_tree_impl() |
1205 ->property_trees() | 1206 ->property_trees() |
1206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1207 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
1207 gfx::ScrollOffset()); | 1208 gfx::ScrollOffset()); |
1208 overflow->SetPosition(gfx::PointF()); | 1209 overflow->SetPosition(gfx::PointF()); |
1209 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1210 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1210 | 1211 |
1211 DrawFrame(); | 1212 DrawFrame(); |
1212 gfx::Point scroll_position(10, 10); | 1213 gfx::Point scroll_position(10, 10); |
1213 | 1214 |
1214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1215 EXPECT_EQ( |
1215 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1216 InputHandler::SCROLL_ON_IMPL_THREAD, |
1216 InputHandler::WHEEL) | 1217 host_impl_ |
1217 .thread); | 1218 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
1219 .thread); | |
1218 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1220 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1219 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1221 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
1220 | 1222 |
1221 gfx::Vector2dF scroll_delta(10, 10); | 1223 gfx::Vector2dF scroll_delta(10, 10); |
1222 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1224 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
1223 host_impl_->ScrollEnd(EndState().get()); | 1225 host_impl_->ScrollEnd(EndState().get()); |
1224 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1226 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1225 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1227 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
1226 | 1228 |
1227 overflow->set_user_scrollable_horizontal(false); | 1229 overflow->set_user_scrollable_horizontal(false); |
1228 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1230 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1229 | 1231 |
1230 DrawFrame(); | 1232 DrawFrame(); |
1231 | 1233 |
1232 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1234 EXPECT_EQ( |
1233 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1235 InputHandler::SCROLL_ON_IMPL_THREAD, |
1234 InputHandler::WHEEL) | 1236 host_impl_ |
1235 .thread); | 1237 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
1238 .thread); | |
1236 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1239 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
1237 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1240 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
1238 | 1241 |
1239 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1242 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
1240 host_impl_->ScrollEnd(EndState().get()); | 1243 host_impl_->ScrollEnd(EndState().get()); |
1241 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1244 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
1242 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1245 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1243 | 1246 |
1244 overflow->set_user_scrollable_vertical(false); | 1247 overflow->set_user_scrollable_vertical(false); |
1245 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1248 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1246 DrawFrame(); | 1249 DrawFrame(); |
1247 | 1250 |
1248 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1251 EXPECT_EQ( |
1249 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1252 InputHandler::SCROLL_ON_IMPL_THREAD, |
1250 InputHandler::WHEEL) | 1253 host_impl_ |
1251 .thread); | 1254 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
1255 .thread); | |
1252 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1256 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
1253 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1257 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1254 | 1258 |
1255 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1259 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
1256 host_impl_->ScrollEnd(EndState().get()); | 1260 host_impl_->ScrollEnd(EndState().get()); |
1257 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); | 1261 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); |
1258 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1262 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1259 } | 1263 } |
1260 | 1264 |
1261 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1265 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1338 TransformOperations start; | 1342 TransformOperations start; |
1339 start.AppendTranslate(6.f, 7.f, 0.f); | 1343 start.AppendTranslate(6.f, 7.f, 0.f); |
1340 TransformOperations end; | 1344 TransformOperations end; |
1341 end.AppendTranslate(8.f, 9.f, 0.f); | 1345 end.AppendTranslate(8.f, 9.f, 0.f); |
1342 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1346 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
1343 start, end); | 1347 start, end); |
1344 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1348 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1345 | 1349 |
1346 base::TimeTicks now = base::TimeTicks::Now(); | 1350 base::TimeTicks now = base::TimeTicks::Now(); |
1347 host_impl_->WillBeginImplFrame( | 1351 host_impl_->WillBeginImplFrame( |
1348 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1352 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1349 | 1353 |
1350 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1354 // TODO(crbug.com/551134): We always request a new frame and a draw for |
1351 // animations that are on the pending tree, but we don't need to do that | 1355 // animations that are on the pending tree, but we don't need to do that |
1352 // unless they are waiting for some future time to start. | 1356 // unless they are waiting for some future time to start. |
1353 EXPECT_TRUE(did_request_next_frame_); | 1357 EXPECT_TRUE(did_request_next_frame_); |
1354 EXPECT_TRUE(did_request_redraw_); | 1358 EXPECT_TRUE(did_request_redraw_); |
1355 EXPECT_FALSE(did_request_commit_); | 1359 EXPECT_FALSE(did_request_commit_); |
1356 did_request_next_frame_ = false; | 1360 did_request_next_frame_ = false; |
1357 did_request_redraw_ = false; | 1361 did_request_redraw_ = false; |
1358 did_request_commit_ = false; | 1362 did_request_commit_ = false; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1450 TransformOperations start; | 1454 TransformOperations start; |
1451 start.AppendTranslate(6.f, 7.f, 0.f); | 1455 start.AppendTranslate(6.f, 7.f, 0.f); |
1452 TransformOperations end; | 1456 TransformOperations end; |
1453 end.AppendTranslate(8.f, 9.f, 0.f); | 1457 end.AppendTranslate(8.f, 9.f, 0.f); |
1454 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1458 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
1455 start, end); | 1459 start, end); |
1456 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1460 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1457 | 1461 |
1458 base::TimeTicks now = base::TimeTicks::Now(); | 1462 base::TimeTicks now = base::TimeTicks::Now(); |
1459 host_impl_->WillBeginImplFrame( | 1463 host_impl_->WillBeginImplFrame( |
1460 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1464 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1461 EXPECT_TRUE(did_request_next_frame_); | 1465 EXPECT_TRUE(did_request_next_frame_); |
1462 did_request_next_frame_ = false; | 1466 did_request_next_frame_ = false; |
1463 | 1467 |
1464 host_impl_->ActivateAnimations(); | 1468 host_impl_->ActivateAnimations(); |
1465 // On activating an animation, we should request another frame so that we'll | 1469 // On activating an animation, we should request another frame so that we'll |
1466 // continue ticking the animation. | 1470 // continue ticking the animation. |
1467 EXPECT_TRUE(did_request_next_frame_); | 1471 EXPECT_TRUE(did_request_next_frame_); |
1468 did_request_next_frame_ = false; | 1472 did_request_next_frame_ = false; |
1469 | 1473 |
1470 // The next frame after activating, we'll tick the animation again. | 1474 // The next frame after activating, we'll tick the animation again. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1530 TransformOperations start; | 1534 TransformOperations start; |
1531 start.AppendTranslate(6.f, 7.f, 0.f); | 1535 start.AppendTranslate(6.f, 7.f, 0.f); |
1532 TransformOperations end; | 1536 TransformOperations end; |
1533 end.AppendTranslate(8.f, 9.f, 0.f); | 1537 end.AppendTranslate(8.f, 9.f, 0.f); |
1534 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1538 int animation_id = AddAnimatedTransformToElementWithPlayer( |
1535 child->element_id(), timeline(), 4.0, start, end); | 1539 child->element_id(), timeline(), 4.0, start, end); |
1536 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1540 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1537 | 1541 |
1538 base::TimeTicks now = base::TimeTicks::Now(); | 1542 base::TimeTicks now = base::TimeTicks::Now(); |
1539 host_impl_->WillBeginImplFrame( | 1543 host_impl_->WillBeginImplFrame( |
1540 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1544 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1541 | 1545 |
1542 host_impl_->ActivateAnimations(); | 1546 host_impl_->ActivateAnimations(); |
1543 host_impl_->Animate(); | 1547 host_impl_->Animate(); |
1544 | 1548 |
1545 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1549 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1546 | 1550 |
1547 host_impl_->ResetRequiresHighResToDraw(); | 1551 host_impl_->ResetRequiresHighResToDraw(); |
1548 | 1552 |
1549 // Child layer has an animating transform but missing tiles. | 1553 // Child layer has an animating transform but missing tiles. |
1550 FakeLayerTreeHostImpl::FrameData frame; | 1554 FakeLayerTreeHostImpl::FrameData frame; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1644 float page_scale_delta = 2.f; | 1648 float page_scale_delta = 2.f; |
1645 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1649 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
1646 InputHandler::TOUCHSCREEN); | 1650 InputHandler::TOUCHSCREEN); |
1647 host_impl_->PinchGestureBegin(); | 1651 host_impl_->PinchGestureBegin(); |
1648 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1652 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
1649 host_impl_->PinchGestureEnd(); | 1653 host_impl_->PinchGestureEnd(); |
1650 host_impl_->ScrollEnd(EndState().get()); | 1654 host_impl_->ScrollEnd(EndState().get()); |
1651 | 1655 |
1652 gfx::Vector2d scroll_delta(0, 10); | 1656 gfx::Vector2d scroll_delta(0, 10); |
1653 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1657 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
1654 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 1658 host_impl_ |
1655 InputHandler::WHEEL) | 1659 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
1660 InputHandler::WHEEL) | |
1656 .thread); | 1661 .thread); |
1657 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 1662 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
1658 host_impl_->ScrollEnd(EndState().get()); | 1663 host_impl_->ScrollEnd(EndState().get()); |
1659 | 1664 |
1660 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 1665 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
1661 host_impl_->ProcessScrollDeltas(); | 1666 host_impl_->ProcessScrollDeltas(); |
1662 EXPECT_TRUE(ScrollInfoContains( | 1667 EXPECT_TRUE(ScrollInfoContains( |
1663 *scroll_info.get(), scroll_layer->id(), | 1668 *scroll_info.get(), scroll_layer->id(), |
1664 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); | 1669 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); |
1665 } | 1670 } |
1666 } | 1671 } |
1667 | 1672 |
1668 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { | 1673 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { |
1669 LayerTreeSettings settings = DefaultSettings(); | 1674 LayerTreeSettings settings = DefaultSettings(); |
1670 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1675 CreateHostImpl(settings, CreateCompositorFrameSink()); |
1671 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); | 1676 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); |
1672 | 1677 |
1673 const gfx::Size content_size(1000, 1000); | 1678 const gfx::Size content_size(1000, 1000); |
1674 const gfx::Size viewport_size(500, 500); | 1679 const gfx::Size viewport_size(500, 500); |
1675 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1680 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
1676 | 1681 |
1677 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1682 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
1678 outer_scroll_layer->SetDrawsContent(true); | 1683 outer_scroll_layer->SetDrawsContent(true); |
1679 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1684 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
1680 inner_scroll_layer->SetDrawsContent(true); | 1685 inner_scroll_layer->SetDrawsContent(true); |
1681 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1686 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1682 | 1687 |
1683 EXPECT_VECTOR_EQ( | 1688 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
1684 gfx::Vector2dF(500, 500), | 1689 outer_scroll_layer->MaxScrollOffset()); |
1685 outer_scroll_layer->MaxScrollOffset()); | |
1686 | 1690 |
1687 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1691 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
1688 InputHandler::TOUCHSCREEN); | 1692 InputHandler::TOUCHSCREEN); |
1689 host_impl_->PinchGestureBegin(); | 1693 host_impl_->PinchGestureBegin(); |
1690 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1694 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
1691 host_impl_->PinchGestureEnd(); | 1695 host_impl_->PinchGestureEnd(); |
1692 host_impl_->ScrollEnd(EndState().get()); | 1696 host_impl_->ScrollEnd(EndState().get()); |
1693 | 1697 |
1694 // Sanity check - we're zoomed in, starting from the origin. | 1698 // Sanity check - we're zoomed in, starting from the origin. |
1695 EXPECT_VECTOR_EQ( | 1699 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
1696 gfx::Vector2dF(0, 0), | 1700 outer_scroll_layer->CurrentScrollOffset()); |
1697 outer_scroll_layer->CurrentScrollOffset()); | 1701 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
1698 EXPECT_VECTOR_EQ( | 1702 inner_scroll_layer->CurrentScrollOffset()); |
1699 gfx::Vector2dF(0, 0), | |
1700 inner_scroll_layer->CurrentScrollOffset()); | |
1701 | 1703 |
1702 // Scroll down - only the inner viewport should scroll. | 1704 // Scroll down - only the inner viewport should scroll. |
1703 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1705 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
1704 InputHandler::TOUCHSCREEN); | 1706 InputHandler::TOUCHSCREEN); |
1705 host_impl_->ScrollBy( | 1707 host_impl_->ScrollBy( |
1706 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 1708 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
1707 host_impl_->ScrollEnd(EndState().get()); | 1709 host_impl_->ScrollEnd(EndState().get()); |
1708 | 1710 |
1709 EXPECT_VECTOR_EQ( | 1711 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
1710 gfx::Vector2dF(50, 50), | 1712 inner_scroll_layer->CurrentScrollOffset()); |
1711 inner_scroll_layer->CurrentScrollOffset()); | 1713 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
1712 EXPECT_VECTOR_EQ( | 1714 outer_scroll_layer->CurrentScrollOffset()); |
1713 gfx::Vector2dF(0, 0), | |
1714 outer_scroll_layer->CurrentScrollOffset()); | |
1715 | 1715 |
1716 // Scroll down - outer viewport should start scrolling after the inner is at | 1716 // Scroll down - outer viewport should start scrolling after the inner is at |
1717 // its maximum. | 1717 // its maximum. |
1718 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1718 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
1719 InputHandler::TOUCHSCREEN); | 1719 InputHandler::TOUCHSCREEN); |
1720 host_impl_->ScrollBy( | 1720 host_impl_->ScrollBy( |
1721 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); | 1721 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); |
1722 host_impl_->ScrollEnd(EndState().get()); | 1722 host_impl_->ScrollEnd(EndState().get()); |
1723 | 1723 |
1724 EXPECT_VECTOR_EQ( | 1724 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250), |
1725 gfx::Vector2dF(250, 250), | 1725 inner_scroll_layer->CurrentScrollOffset()); |
1726 inner_scroll_layer->CurrentScrollOffset()); | 1726 EXPECT_VECTOR_EQ(gfx::Vector2dF(300, 300), |
1727 EXPECT_VECTOR_EQ( | 1727 outer_scroll_layer->CurrentScrollOffset()); |
1728 gfx::Vector2dF(300, 300), | |
1729 outer_scroll_layer->CurrentScrollOffset()); | |
1730 } | 1728 } |
1731 | 1729 |
1732 // Make sure scrolls smaller than a unit applied to the viewport don't get | 1730 // Make sure scrolls smaller than a unit applied to the viewport don't get |
1733 // dropped. crbug.com/539334. | 1731 // dropped. crbug.com/539334. |
1734 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { | 1732 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { |
1735 LayerTreeSettings settings = DefaultSettings(); | 1733 LayerTreeSettings settings = DefaultSettings(); |
1736 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1734 CreateHostImpl(settings, CreateCompositorFrameSink()); |
1737 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1735 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
1738 | 1736 |
1739 const gfx::Size content_size(1000, 1000); | 1737 const gfx::Size content_size(1000, 1000); |
1740 const gfx::Size viewport_size(500, 500); | 1738 const gfx::Size viewport_size(500, 500); |
1741 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1739 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
1742 | 1740 |
1743 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1741 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
1744 outer_scroll_layer->SetDrawsContent(true); | 1742 outer_scroll_layer->SetDrawsContent(true); |
1745 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1743 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
1746 inner_scroll_layer->SetDrawsContent(true); | 1744 inner_scroll_layer->SetDrawsContent(true); |
1747 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1745 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1748 | 1746 |
1749 // Sanity checks. | 1747 // Sanity checks. |
1750 EXPECT_VECTOR_EQ( | 1748 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
1751 gfx::Vector2dF(500, 500), | 1749 outer_scroll_layer->MaxScrollOffset()); |
1752 outer_scroll_layer->MaxScrollOffset()); | |
1753 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 1750 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
1754 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); | 1751 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); |
1755 | 1752 |
1756 // Scroll only the layout viewport. | 1753 // Scroll only the layout viewport. |
1757 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1754 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
1758 InputHandler::TOUCHSCREEN); | 1755 InputHandler::TOUCHSCREEN); |
1759 host_impl_->ScrollBy( | 1756 host_impl_->ScrollBy( |
1760 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); | 1757 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); |
1761 EXPECT_VECTOR2DF_EQ( | 1758 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f), |
1762 gfx::Vector2dF(0.125f, 0.125f), | 1759 outer_scroll_layer->CurrentScrollOffset()); |
1763 outer_scroll_layer->CurrentScrollOffset()); | 1760 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0, 0), |
1764 EXPECT_VECTOR2DF_EQ( | 1761 inner_scroll_layer->CurrentScrollOffset()); |
1765 gfx::Vector2dF(0, 0), | |
1766 inner_scroll_layer->CurrentScrollOffset()); | |
1767 host_impl_->ScrollEnd(EndState().get()); | 1762 host_impl_->ScrollEnd(EndState().get()); |
1768 | 1763 |
1769 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 1764 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
1770 | 1765 |
1771 // Now that we zoomed in, the scroll should be applied to the inner viewport. | 1766 // Now that we zoomed in, the scroll should be applied to the inner viewport. |
1772 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1767 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
1773 InputHandler::TOUCHSCREEN); | 1768 InputHandler::TOUCHSCREEN); |
1774 host_impl_->ScrollBy( | 1769 host_impl_->ScrollBy( |
1775 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); | 1770 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); |
1776 EXPECT_VECTOR2DF_EQ( | 1771 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f), |
1777 gfx::Vector2dF(0.125f, 0.125f), | 1772 outer_scroll_layer->CurrentScrollOffset()); |
1778 outer_scroll_layer->CurrentScrollOffset()); | 1773 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.25f, 0.25f), |
1779 EXPECT_VECTOR2DF_EQ( | 1774 inner_scroll_layer->CurrentScrollOffset()); |
1780 gfx::Vector2dF(0.25f, 0.25f), | |
1781 inner_scroll_layer->CurrentScrollOffset()); | |
1782 host_impl_->ScrollEnd(EndState().get()); | 1775 host_impl_->ScrollEnd(EndState().get()); |
1783 } | 1776 } |
1784 | 1777 |
1785 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work | 1778 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work |
1786 // as expected. That is, scrolling during a pinch should bubble from the inner | 1779 // as expected. That is, scrolling during a pinch should bubble from the inner |
1787 // to the outer viewport. | 1780 // to the outer viewport. |
1788 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { | 1781 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { |
1789 LayerTreeSettings settings = DefaultSettings(); | 1782 LayerTreeSettings settings = DefaultSettings(); |
1790 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1783 CreateHostImpl(settings, CreateCompositorFrameSink()); |
1791 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1784 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
1792 | 1785 |
1793 const gfx::Size content_size(1000, 1000); | 1786 const gfx::Size content_size(1000, 1000); |
1794 const gfx::Size viewport_size(500, 500); | 1787 const gfx::Size viewport_size(500, 500); |
1795 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1788 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
1796 | 1789 |
1797 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1790 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
1798 outer_scroll_layer->SetDrawsContent(true); | 1791 outer_scroll_layer->SetDrawsContent(true); |
1799 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1792 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
1800 inner_scroll_layer->SetDrawsContent(true); | 1793 inner_scroll_layer->SetDrawsContent(true); |
1801 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1794 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1802 | 1795 |
1803 EXPECT_VECTOR_EQ( | 1796 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
1804 gfx::Vector2dF(500, 500), | 1797 outer_scroll_layer->MaxScrollOffset()); |
1805 outer_scroll_layer->MaxScrollOffset()); | |
1806 | 1798 |
1807 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1799 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
1808 InputHandler::TOUCHSCREEN); | 1800 InputHandler::TOUCHSCREEN); |
1809 host_impl_->PinchGestureBegin(); | 1801 host_impl_->PinchGestureBegin(); |
1810 | 1802 |
1811 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); | 1803 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); |
1812 EXPECT_VECTOR_EQ( | 1804 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
1813 gfx::Vector2dF(0, 0), | 1805 outer_scroll_layer->CurrentScrollOffset()); |
1814 outer_scroll_layer->CurrentScrollOffset()); | 1806 EXPECT_VECTOR_EQ(gfx::Vector2dF(125, 125), |
1815 EXPECT_VECTOR_EQ( | 1807 inner_scroll_layer->CurrentScrollOffset()); |
1816 gfx::Vector2dF(125, 125), | |
1817 inner_scroll_layer->CurrentScrollOffset()); | |
1818 | 1808 |
1819 // Needed so that the pinch is accounted for in draw properties. | 1809 // Needed so that the pinch is accounted for in draw properties. |
1820 DrawFrame(); | 1810 DrawFrame(); |
1821 | 1811 |
1822 host_impl_->ScrollBy( | 1812 host_impl_->ScrollBy( |
1823 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get()); | 1813 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get()); |
1824 EXPECT_VECTOR_EQ( | 1814 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
1825 gfx::Vector2dF(0, 0), | 1815 outer_scroll_layer->CurrentScrollOffset()); |
1826 outer_scroll_layer->CurrentScrollOffset()); | 1816 EXPECT_VECTOR_EQ(gfx::Vector2dF(130, 130), |
1827 EXPECT_VECTOR_EQ( | 1817 inner_scroll_layer->CurrentScrollOffset()); |
1828 gfx::Vector2dF(130, 130), | |
1829 inner_scroll_layer->CurrentScrollOffset()); | |
1830 | 1818 |
1831 DrawFrame(); | 1819 DrawFrame(); |
1832 | 1820 |
1833 host_impl_->ScrollBy( | 1821 host_impl_->ScrollBy( |
1834 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get()); | 1822 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get()); |
1835 EXPECT_VECTOR_EQ( | 1823 EXPECT_VECTOR_EQ(gfx::Vector2dF(80, 80), |
1836 gfx::Vector2dF(80, 80), | 1824 outer_scroll_layer->CurrentScrollOffset()); |
1837 outer_scroll_layer->CurrentScrollOffset()); | 1825 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250), |
1838 EXPECT_VECTOR_EQ( | 1826 inner_scroll_layer->CurrentScrollOffset()); |
1839 gfx::Vector2dF(250, 250), | |
1840 inner_scroll_layer->CurrentScrollOffset()); | |
1841 | 1827 |
1842 host_impl_->PinchGestureEnd(); | 1828 host_impl_->PinchGestureEnd(); |
1843 host_impl_->ScrollEnd(EndState().get()); | 1829 host_impl_->ScrollEnd(EndState().get()); |
1844 } | 1830 } |
1845 | 1831 |
1846 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when | 1832 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when |
1847 // a pinch zoom is anchored within a certain margin of the screen edge, we | 1833 // a pinch zoom is anchored within a certain margin of the screen edge, we |
1848 // should assume the user means to scroll into the edge of the screen. | 1834 // should assume the user means to scroll into the edge of the screen. |
1849 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { | 1835 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { |
1850 LayerTreeSettings settings = DefaultSettings(); | 1836 LayerTreeSettings settings = DefaultSettings(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1943 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1929 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
1944 | 1930 |
1945 // Scroll by a small amount, there should be no bubbling to the outer | 1931 // Scroll by a small amount, there should be no bubbling to the outer |
1946 // viewport. | 1932 // viewport. |
1947 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1933 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
1948 InputHandler::WHEEL); | 1934 InputHandler::WHEEL); |
1949 host_impl_->ScrollBy( | 1935 host_impl_->ScrollBy( |
1950 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); | 1936 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); |
1951 host_impl_->ScrollEnd(EndState().get()); | 1937 host_impl_->ScrollEnd(EndState().get()); |
1952 | 1938 |
1953 EXPECT_VECTOR_EQ( | 1939 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
1954 gfx::Vector2dF(5, 10), | 1940 inner_scroll_layer->CurrentScrollOffset()); |
1955 inner_scroll_layer->CurrentScrollOffset()); | 1941 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
1956 EXPECT_VECTOR_EQ( | |
1957 gfx::Vector2dF(), | |
1958 outer_scroll_layer->CurrentScrollOffset()); | |
1959 | 1942 |
1960 // Scroll by the inner viewport's max scroll extent, the remainder | 1943 // Scroll by the inner viewport's max scroll extent, the remainder |
1961 // should bubble up to the outer viewport. | 1944 // should bubble up to the outer viewport. |
1962 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1945 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
1963 InputHandler::WHEEL); | 1946 InputHandler::WHEEL); |
1964 host_impl_->ScrollBy( | 1947 host_impl_->ScrollBy( |
1965 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 1948 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
1966 host_impl_->ScrollEnd(EndState().get()); | 1949 host_impl_->ScrollEnd(EndState().get()); |
1967 | 1950 |
1968 EXPECT_VECTOR_EQ( | 1951 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
1969 gfx::Vector2dF(50, 50), | 1952 inner_scroll_layer->CurrentScrollOffset()); |
1970 inner_scroll_layer->CurrentScrollOffset()); | 1953 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
1971 EXPECT_VECTOR_EQ( | 1954 outer_scroll_layer->CurrentScrollOffset()); |
1972 gfx::Vector2dF(5, 10), | |
1973 outer_scroll_layer->CurrentScrollOffset()); | |
1974 | 1955 |
1975 // Scroll by the outer viewport's max scroll extent, it should all go to the | 1956 // Scroll by the outer viewport's max scroll extent, it should all go to the |
1976 // outer viewport. | 1957 // outer viewport. |
1977 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1958 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
1978 InputHandler::WHEEL); | 1959 InputHandler::WHEEL); |
1979 host_impl_->ScrollBy( | 1960 host_impl_->ScrollBy( |
1980 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get()); | 1961 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get()); |
1981 host_impl_->ScrollEnd(EndState().get()); | 1962 host_impl_->ScrollEnd(EndState().get()); |
1982 | 1963 |
1983 EXPECT_VECTOR_EQ( | 1964 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), |
1984 gfx::Vector2dF(100, 100), | 1965 outer_scroll_layer->CurrentScrollOffset()); |
1985 outer_scroll_layer->CurrentScrollOffset()); | 1966 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
1986 EXPECT_VECTOR_EQ( | 1967 inner_scroll_layer->CurrentScrollOffset()); |
1987 gfx::Vector2dF(50, 50), | |
1988 inner_scroll_layer->CurrentScrollOffset()); | |
1989 } | 1968 } |
1990 | 1969 |
1991 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1970 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
1992 ui::LatencyInfo latency_info; | 1971 ui::LatencyInfo latency_info; |
1993 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, | 1972 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
1994 1234); | 1973 1234); |
1995 std::unique_ptr<SwapPromise> swap_promise( | 1974 std::unique_ptr<SwapPromise> swap_promise( |
1996 new LatencyInfoSwapPromise(latency_info)); | 1975 new LatencyInfoSwapPromise(latency_info)); |
1997 | 1976 |
1998 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1977 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 15 matching lines...) Expand all Loading... | |
2014 | 1993 |
2015 // Test that scrolls targeting a layer with a non-null scroll_parent() don't | 1994 // Test that scrolls targeting a layer with a non-null scroll_parent() don't |
2016 // bubble up. | 1995 // bubble up. |
2017 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { | 1996 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
2018 LayerImpl* viewport_scroll = | 1997 LayerImpl* viewport_scroll = |
2019 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1998 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2020 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1999 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2021 | 2000 |
2022 // Set up two scrolling children of the root, one of which is a scroll parent | 2001 // Set up two scrolling children of the root, one of which is a scroll parent |
2023 // to the other. Scrolls shouldn't bubbling from the child. | 2002 // to the other. Scrolls shouldn't bubbling from the child. |
2024 LayerImpl *parent; | 2003 LayerImpl* parent; |
2025 LayerImpl *child; | 2004 LayerImpl* child; |
2026 LayerImpl *child_clip; | 2005 LayerImpl* child_clip; |
2027 | 2006 |
2028 std::unique_ptr<LayerImpl> scroll_parent_clip = | 2007 std::unique_ptr<LayerImpl> scroll_parent_clip = |
2029 LayerImpl::Create(host_impl_->active_tree(), 6); | 2008 LayerImpl::Create(host_impl_->active_tree(), 6); |
2030 std::unique_ptr<LayerImpl> scroll_parent = | 2009 std::unique_ptr<LayerImpl> scroll_parent = |
2031 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); | 2010 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); |
2032 parent = scroll_parent.get(); | 2011 parent = scroll_parent.get(); |
2033 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent)); | 2012 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent)); |
2034 | 2013 |
2035 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip)); | 2014 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip)); |
2036 | 2015 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2097 // The viewport shouldn't receive any scroll delta. | 2076 // The viewport shouldn't receive any scroll delta. |
2098 EXPECT_VECTOR_EQ( | 2077 EXPECT_VECTOR_EQ( |
2099 gfx::Vector2dF(0, 0), | 2078 gfx::Vector2dF(0, 0), |
2100 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 2079 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
2101 EXPECT_VECTOR_EQ( | 2080 EXPECT_VECTOR_EQ( |
2102 gfx::Vector2dF(0, 0), | 2081 gfx::Vector2dF(0, 0), |
2103 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); | 2082 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); |
2104 } | 2083 } |
2105 } | 2084 } |
2106 | 2085 |
2107 | |
2108 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 2086 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
2109 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2087 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2110 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2088 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2111 DrawFrame(); | 2089 DrawFrame(); |
2112 | 2090 |
2113 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2091 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2114 DCHECK(scroll_layer); | 2092 DCHECK(scroll_layer); |
2115 | 2093 |
2116 float min_page_scale = 1.f; | 2094 float min_page_scale = 1.f; |
2117 float max_page_scale = 4.f; | 2095 float max_page_scale = 4.f; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2329 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { | 2307 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { |
2330 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2308 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2331 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2309 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2332 DrawFrame(); | 2310 DrawFrame(); |
2333 | 2311 |
2334 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2312 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2335 DCHECK(scroll_layer); | 2313 DCHECK(scroll_layer); |
2336 | 2314 |
2337 float min_page_scale = 0.5f; | 2315 float min_page_scale = 0.5f; |
2338 float max_page_scale = 4.f; | 2316 float max_page_scale = 4.f; |
2339 base::TimeTicks start_time = base::TimeTicks() + | 2317 base::TimeTicks start_time = |
2340 base::TimeDelta::FromSeconds(1); | 2318 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
2341 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2319 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2342 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2320 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2343 base::TimeTicks end_time = start_time + duration; | 2321 base::TimeTicks end_time = start_time + duration; |
2344 | 2322 |
2345 BeginFrameArgs begin_frame_args = | 2323 BeginFrameArgs begin_frame_args = |
2346 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2324 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2347 | 2325 |
2348 // Non-anchor zoom-in | 2326 // Non-anchor zoom-in |
2349 { | 2327 { |
2350 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2328 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2351 max_page_scale); | 2329 max_page_scale); |
2352 scroll_layer->layer_tree_impl() | 2330 scroll_layer->layer_tree_impl() |
2353 ->property_trees() | 2331 ->property_trees() |
2354 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2332 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2355 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2333 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2356 | 2334 |
2357 did_request_redraw_ = false; | 2335 did_request_redraw_ = false; |
2358 did_request_next_frame_ = false; | 2336 did_request_next_frame_ = false; |
2359 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2337 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2360 std::unique_ptr<PendingPageScaleAnimation>( | 2338 std::unique_ptr<PendingPageScaleAnimation>( |
2361 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, | 2339 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, |
2362 duration))); | 2340 duration))); |
2363 host_impl_->ActivateSyncTree(); | 2341 host_impl_->ActivateSyncTree(); |
2364 EXPECT_FALSE(did_request_redraw_); | 2342 EXPECT_FALSE(did_request_redraw_); |
2365 EXPECT_TRUE(did_request_next_frame_); | 2343 EXPECT_TRUE(did_request_next_frame_); |
2366 | 2344 |
2367 did_request_redraw_ = false; | 2345 did_request_redraw_ = false; |
2368 did_request_next_frame_ = false; | 2346 did_request_next_frame_ = false; |
2369 begin_frame_args.frame_time = start_time; | 2347 begin_frame_args.frame_time = start_time; |
2348 begin_frame_args.sequence_number++; | |
2370 host_impl_->WillBeginImplFrame(begin_frame_args); | 2349 host_impl_->WillBeginImplFrame(begin_frame_args); |
2371 host_impl_->Animate(); | 2350 host_impl_->Animate(); |
2372 EXPECT_TRUE(did_request_redraw_); | 2351 EXPECT_TRUE(did_request_redraw_); |
2373 EXPECT_TRUE(did_request_next_frame_); | 2352 EXPECT_TRUE(did_request_next_frame_); |
2374 host_impl_->DidFinishImplFrame(); | 2353 host_impl_->DidFinishImplFrame(); |
2375 | 2354 |
2376 did_request_redraw_ = false; | 2355 did_request_redraw_ = false; |
2377 did_request_next_frame_ = false; | 2356 did_request_next_frame_ = false; |
2378 begin_frame_args.frame_time = halfway_through_animation; | 2357 begin_frame_args.frame_time = halfway_through_animation; |
2358 begin_frame_args.sequence_number++; | |
2379 host_impl_->WillBeginImplFrame(begin_frame_args); | 2359 host_impl_->WillBeginImplFrame(begin_frame_args); |
2380 host_impl_->Animate(); | 2360 host_impl_->Animate(); |
2381 EXPECT_TRUE(did_request_redraw_); | 2361 EXPECT_TRUE(did_request_redraw_); |
2382 EXPECT_TRUE(did_request_next_frame_); | 2362 EXPECT_TRUE(did_request_next_frame_); |
2383 host_impl_->DidFinishImplFrame(); | 2363 host_impl_->DidFinishImplFrame(); |
2384 | 2364 |
2385 did_request_redraw_ = false; | 2365 did_request_redraw_ = false; |
2386 did_request_next_frame_ = false; | 2366 did_request_next_frame_ = false; |
2387 did_request_commit_ = false; | 2367 did_request_commit_ = false; |
2388 begin_frame_args.frame_time = end_time; | 2368 begin_frame_args.frame_time = end_time; |
2369 begin_frame_args.sequence_number++; | |
2389 host_impl_->WillBeginImplFrame(begin_frame_args); | 2370 host_impl_->WillBeginImplFrame(begin_frame_args); |
2390 host_impl_->Animate(); | 2371 host_impl_->Animate(); |
2391 EXPECT_TRUE(did_request_commit_); | 2372 EXPECT_TRUE(did_request_commit_); |
2392 EXPECT_FALSE(did_request_next_frame_); | 2373 EXPECT_FALSE(did_request_next_frame_); |
2393 host_impl_->DidFinishImplFrame(); | 2374 host_impl_->DidFinishImplFrame(); |
2394 | 2375 |
2395 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2376 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2396 host_impl_->ProcessScrollDeltas(); | 2377 host_impl_->ProcessScrollDeltas(); |
2397 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 2378 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
2398 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2379 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
(...skipping 19 matching lines...) Expand all Loading... | |
2418 std::unique_ptr<PendingPageScaleAnimation>( | 2399 std::unique_ptr<PendingPageScaleAnimation>( |
2419 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, | 2400 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, |
2420 min_page_scale, duration))); | 2401 min_page_scale, duration))); |
2421 host_impl_->ActivateSyncTree(); | 2402 host_impl_->ActivateSyncTree(); |
2422 EXPECT_FALSE(did_request_redraw_); | 2403 EXPECT_FALSE(did_request_redraw_); |
2423 EXPECT_TRUE(did_request_next_frame_); | 2404 EXPECT_TRUE(did_request_next_frame_); |
2424 | 2405 |
2425 did_request_redraw_ = false; | 2406 did_request_redraw_ = false; |
2426 did_request_next_frame_ = false; | 2407 did_request_next_frame_ = false; |
2427 begin_frame_args.frame_time = start_time; | 2408 begin_frame_args.frame_time = start_time; |
2409 begin_frame_args.sequence_number++; | |
2428 host_impl_->WillBeginImplFrame(begin_frame_args); | 2410 host_impl_->WillBeginImplFrame(begin_frame_args); |
2429 host_impl_->Animate(); | 2411 host_impl_->Animate(); |
2430 EXPECT_TRUE(did_request_redraw_); | 2412 EXPECT_TRUE(did_request_redraw_); |
2431 EXPECT_TRUE(did_request_next_frame_); | 2413 EXPECT_TRUE(did_request_next_frame_); |
2432 host_impl_->DidFinishImplFrame(); | 2414 host_impl_->DidFinishImplFrame(); |
2433 | 2415 |
2434 did_request_redraw_ = false; | 2416 did_request_redraw_ = false; |
2435 did_request_commit_ = false; | 2417 did_request_commit_ = false; |
2436 did_request_next_frame_ = false; | 2418 did_request_next_frame_ = false; |
2437 begin_frame_args.frame_time = end_time; | 2419 begin_frame_args.frame_time = end_time; |
2420 begin_frame_args.sequence_number++; | |
2438 host_impl_->WillBeginImplFrame(begin_frame_args); | 2421 host_impl_->WillBeginImplFrame(begin_frame_args); |
2439 host_impl_->Animate(); | 2422 host_impl_->Animate(); |
2440 EXPECT_TRUE(did_request_redraw_); | 2423 EXPECT_TRUE(did_request_redraw_); |
2441 EXPECT_FALSE(did_request_next_frame_); | 2424 EXPECT_FALSE(did_request_next_frame_); |
2442 EXPECT_TRUE(did_request_commit_); | 2425 EXPECT_TRUE(did_request_commit_); |
2443 host_impl_->DidFinishImplFrame(); | 2426 host_impl_->DidFinishImplFrame(); |
2444 | 2427 |
2445 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2428 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2446 host_impl_->ProcessScrollDeltas(); | 2429 host_impl_->ProcessScrollDeltas(); |
2447 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2430 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
2448 // Pushed to (0,0) via clamping against contents layer size. | 2431 // Pushed to (0,0) via clamping against contents layer size. |
2449 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2432 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2450 gfx::Vector2d(-50, -50))); | 2433 gfx::Vector2d(-50, -50))); |
2451 } | 2434 } |
2452 } | 2435 } |
2453 | 2436 |
2454 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { | 2437 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { |
2455 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2438 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2456 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2439 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2457 DrawFrame(); | 2440 DrawFrame(); |
2458 | 2441 |
2459 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2442 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2460 DCHECK(scroll_layer); | 2443 DCHECK(scroll_layer); |
2461 | 2444 |
2462 float min_page_scale = 0.5f; | 2445 float min_page_scale = 0.5f; |
2463 float max_page_scale = 4.f; | 2446 float max_page_scale = 4.f; |
2464 base::TimeTicks start_time = base::TimeTicks() + | 2447 base::TimeTicks start_time = |
2465 base::TimeDelta::FromSeconds(1); | 2448 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
2466 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2449 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2467 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2450 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2468 base::TimeTicks end_time = start_time + duration; | 2451 base::TimeTicks end_time = start_time + duration; |
2469 | 2452 |
2470 BeginFrameArgs begin_frame_args = | 2453 BeginFrameArgs begin_frame_args = |
2471 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2454 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2472 | 2455 |
2473 // Anchor zoom with unchanged page scale should not change scroll or scale. | 2456 // Anchor zoom with unchanged page scale should not change scroll or scale. |
2474 { | 2457 { |
2475 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2458 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2476 max_page_scale); | 2459 max_page_scale); |
2477 scroll_layer->layer_tree_impl() | 2460 scroll_layer->layer_tree_impl() |
2478 ->property_trees() | 2461 ->property_trees() |
2479 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2462 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2480 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2463 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2481 | 2464 |
2482 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2465 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2483 std::unique_ptr<PendingPageScaleAnimation>( | 2466 std::unique_ptr<PendingPageScaleAnimation>( |
2484 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, | 2467 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, |
2485 duration))); | 2468 duration))); |
2486 host_impl_->ActivateSyncTree(); | 2469 host_impl_->ActivateSyncTree(); |
2487 begin_frame_args.frame_time = start_time; | 2470 begin_frame_args.frame_time = start_time; |
2471 begin_frame_args.sequence_number++; | |
2488 host_impl_->WillBeginImplFrame(begin_frame_args); | 2472 host_impl_->WillBeginImplFrame(begin_frame_args); |
2489 host_impl_->Animate(); | 2473 host_impl_->Animate(); |
2490 host_impl_->DidFinishImplFrame(); | 2474 host_impl_->DidFinishImplFrame(); |
2491 | 2475 |
2492 begin_frame_args.frame_time = halfway_through_animation; | 2476 begin_frame_args.frame_time = halfway_through_animation; |
2477 begin_frame_args.sequence_number++; | |
2493 host_impl_->WillBeginImplFrame(begin_frame_args); | 2478 host_impl_->WillBeginImplFrame(begin_frame_args); |
2494 host_impl_->Animate(); | 2479 host_impl_->Animate(); |
2495 EXPECT_TRUE(did_request_redraw_); | 2480 EXPECT_TRUE(did_request_redraw_); |
2496 host_impl_->DidFinishImplFrame(); | 2481 host_impl_->DidFinishImplFrame(); |
2497 | 2482 |
2498 begin_frame_args.frame_time = end_time; | 2483 begin_frame_args.frame_time = end_time; |
2484 begin_frame_args.sequence_number++; | |
2499 host_impl_->WillBeginImplFrame(begin_frame_args); | 2485 host_impl_->WillBeginImplFrame(begin_frame_args); |
2500 host_impl_->Animate(); | 2486 host_impl_->Animate(); |
2501 EXPECT_TRUE(did_request_commit_); | 2487 EXPECT_TRUE(did_request_commit_); |
2502 host_impl_->DidFinishImplFrame(); | 2488 host_impl_->DidFinishImplFrame(); |
2503 | 2489 |
2504 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2490 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2505 host_impl_->ProcessScrollDeltas(); | 2491 host_impl_->ProcessScrollDeltas(); |
2506 EXPECT_EQ(scroll_info->page_scale_delta, 1); | 2492 EXPECT_EQ(scroll_info->page_scale_delta, 1); |
2507 ExpectNone(*scroll_info, scroll_layer->id()); | 2493 ExpectNone(*scroll_info, scroll_layer->id()); |
2508 } | 2494 } |
2509 } | 2495 } |
2510 | 2496 |
2511 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { | 2497 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
2512 host_impl_->CreatePendingTree(); | 2498 host_impl_->CreatePendingTree(); |
2513 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2499 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2514 CreateScrollAndContentsLayers( | 2500 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
2515 host_impl_->pending_tree(), | 2501 gfx::Size(100, 100)); |
2516 gfx::Size(100, 100)); | |
2517 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 2502 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
2518 host_impl_->ActivateSyncTree(); | 2503 host_impl_->ActivateSyncTree(); |
2519 DrawFrame(); | 2504 DrawFrame(); |
2520 | 2505 |
2521 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2506 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2522 DCHECK(scroll_layer); | 2507 DCHECK(scroll_layer); |
2523 | 2508 |
2524 float min_page_scale = 0.5f; | 2509 float min_page_scale = 0.5f; |
2525 float max_page_scale = 4.f; | 2510 float max_page_scale = 4.f; |
2526 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2511 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2527 max_page_scale); | 2512 max_page_scale); |
2528 host_impl_->ActivateSyncTree(); | 2513 host_impl_->ActivateSyncTree(); |
2529 | 2514 |
2530 base::TimeTicks start_time = base::TimeTicks() + | 2515 base::TimeTicks start_time = |
2531 base::TimeDelta::FromSeconds(1); | 2516 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
2532 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2517 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2533 base::TimeTicks third_through_animation = start_time + duration / 3; | 2518 base::TimeTicks third_through_animation = start_time + duration / 3; |
2534 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2519 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2535 base::TimeTicks end_time = start_time + duration; | 2520 base::TimeTicks end_time = start_time + duration; |
2536 float target_scale = 2.f; | 2521 float target_scale = 2.f; |
2537 | 2522 |
2538 BeginFrameArgs begin_frame_args = | 2523 BeginFrameArgs begin_frame_args = |
2539 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2524 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2540 | 2525 |
2541 scroll_layer->layer_tree_impl() | 2526 scroll_layer->layer_tree_impl() |
2542 ->property_trees() | 2527 ->property_trees() |
2543 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2528 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2544 gfx::ScrollOffset(50, 50)); | 2529 gfx::ScrollOffset(50, 50)); |
2545 | 2530 |
2546 // Make sure TakePageScaleAnimation works properly. | 2531 // Make sure TakePageScaleAnimation works properly. |
2547 | 2532 |
2548 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2533 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2549 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2534 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2550 gfx::Vector2d(), false, target_scale, duration))); | 2535 gfx::Vector2d(), false, target_scale, duration))); |
2551 std::unique_ptr<PendingPageScaleAnimation> psa = | 2536 std::unique_ptr<PendingPageScaleAnimation> psa = |
2552 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); | 2537 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); |
2553 EXPECT_EQ(target_scale, psa->scale); | 2538 EXPECT_EQ(target_scale, psa->scale); |
2554 EXPECT_EQ(duration, psa->duration); | 2539 EXPECT_EQ(duration, psa->duration); |
2555 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); | 2540 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); |
2556 | 2541 |
2557 // Recreate the PSA. Nothing should happen here since the tree containing the | 2542 // Recreate the PSA. Nothing should happen here since the tree containing the |
2558 // PSA hasn't been activated yet. | 2543 // PSA hasn't been activated yet. |
2559 did_request_redraw_ = false; | 2544 did_request_redraw_ = false; |
2560 did_request_next_frame_ = false; | 2545 did_request_next_frame_ = false; |
2561 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2546 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2562 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2547 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2563 gfx::Vector2d(), false, target_scale, duration))); | 2548 gfx::Vector2d(), false, target_scale, duration))); |
2564 begin_frame_args.frame_time = halfway_through_animation; | 2549 begin_frame_args.frame_time = halfway_through_animation; |
2550 begin_frame_args.sequence_number++; | |
2565 host_impl_->WillBeginImplFrame(begin_frame_args); | 2551 host_impl_->WillBeginImplFrame(begin_frame_args); |
2566 host_impl_->Animate(); | 2552 host_impl_->Animate(); |
2567 EXPECT_FALSE(did_request_next_frame_); | 2553 EXPECT_FALSE(did_request_next_frame_); |
2568 EXPECT_FALSE(did_request_redraw_); | 2554 EXPECT_FALSE(did_request_redraw_); |
2569 host_impl_->DidFinishImplFrame(); | 2555 host_impl_->DidFinishImplFrame(); |
2570 | 2556 |
2571 // Activate the sync tree. This should cause the animation to become enabled. | 2557 // Activate the sync tree. This should cause the animation to become enabled. |
2572 // It should also clear the pointer on the sync tree. | 2558 // It should also clear the pointer on the sync tree. |
2573 host_impl_->ActivateSyncTree(); | 2559 host_impl_->ActivateSyncTree(); |
2574 EXPECT_EQ(nullptr, | 2560 EXPECT_EQ(nullptr, |
2575 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); | 2561 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); |
2576 EXPECT_FALSE(did_request_redraw_); | 2562 EXPECT_FALSE(did_request_redraw_); |
2577 EXPECT_TRUE(did_request_next_frame_); | 2563 EXPECT_TRUE(did_request_next_frame_); |
2578 | 2564 |
2579 start_time += base::TimeDelta::FromSeconds(10); | 2565 start_time += base::TimeDelta::FromSeconds(10); |
2580 third_through_animation += base::TimeDelta::FromSeconds(10); | 2566 third_through_animation += base::TimeDelta::FromSeconds(10); |
2581 halfway_through_animation += base::TimeDelta::FromSeconds(10); | 2567 halfway_through_animation += base::TimeDelta::FromSeconds(10); |
2582 end_time += base::TimeDelta::FromSeconds(10); | 2568 end_time += base::TimeDelta::FromSeconds(10); |
2583 | 2569 |
2584 // From here on, make sure the animation runs as normal. | 2570 // From here on, make sure the animation runs as normal. |
2585 did_request_redraw_ = false; | 2571 did_request_redraw_ = false; |
2586 did_request_next_frame_ = false; | 2572 did_request_next_frame_ = false; |
2587 begin_frame_args.frame_time = start_time; | 2573 begin_frame_args.frame_time = start_time; |
2574 begin_frame_args.sequence_number++; | |
2588 host_impl_->WillBeginImplFrame(begin_frame_args); | 2575 host_impl_->WillBeginImplFrame(begin_frame_args); |
2589 host_impl_->Animate(); | 2576 host_impl_->Animate(); |
2590 EXPECT_TRUE(did_request_redraw_); | 2577 EXPECT_TRUE(did_request_redraw_); |
2591 EXPECT_TRUE(did_request_next_frame_); | 2578 EXPECT_TRUE(did_request_next_frame_); |
2592 host_impl_->DidFinishImplFrame(); | 2579 host_impl_->DidFinishImplFrame(); |
2593 | 2580 |
2594 did_request_redraw_ = false; | 2581 did_request_redraw_ = false; |
2595 did_request_next_frame_ = false; | 2582 did_request_next_frame_ = false; |
2596 begin_frame_args.frame_time = third_through_animation; | 2583 begin_frame_args.frame_time = third_through_animation; |
2584 begin_frame_args.sequence_number++; | |
2597 host_impl_->WillBeginImplFrame(begin_frame_args); | 2585 host_impl_->WillBeginImplFrame(begin_frame_args); |
2598 host_impl_->Animate(); | 2586 host_impl_->Animate(); |
2599 EXPECT_TRUE(did_request_redraw_); | 2587 EXPECT_TRUE(did_request_redraw_); |
2600 EXPECT_TRUE(did_request_next_frame_); | 2588 EXPECT_TRUE(did_request_next_frame_); |
2601 host_impl_->DidFinishImplFrame(); | 2589 host_impl_->DidFinishImplFrame(); |
2602 | 2590 |
2603 // Another activation shouldn't have any effect on the animation. | 2591 // Another activation shouldn't have any effect on the animation. |
2604 host_impl_->ActivateSyncTree(); | 2592 host_impl_->ActivateSyncTree(); |
2605 | 2593 |
2606 did_request_redraw_ = false; | 2594 did_request_redraw_ = false; |
2607 did_request_next_frame_ = false; | 2595 did_request_next_frame_ = false; |
2608 begin_frame_args.frame_time = halfway_through_animation; | 2596 begin_frame_args.frame_time = halfway_through_animation; |
2597 begin_frame_args.sequence_number++; | |
2609 host_impl_->WillBeginImplFrame(begin_frame_args); | 2598 host_impl_->WillBeginImplFrame(begin_frame_args); |
2610 host_impl_->Animate(); | 2599 host_impl_->Animate(); |
2611 EXPECT_TRUE(did_request_redraw_); | 2600 EXPECT_TRUE(did_request_redraw_); |
2612 EXPECT_TRUE(did_request_next_frame_); | 2601 EXPECT_TRUE(did_request_next_frame_); |
2613 host_impl_->DidFinishImplFrame(); | 2602 host_impl_->DidFinishImplFrame(); |
2614 | 2603 |
2615 did_request_redraw_ = false; | 2604 did_request_redraw_ = false; |
2616 did_request_next_frame_ = false; | 2605 did_request_next_frame_ = false; |
2617 did_request_commit_ = false; | 2606 did_request_commit_ = false; |
2618 begin_frame_args.frame_time = end_time; | 2607 begin_frame_args.frame_time = end_time; |
2608 begin_frame_args.sequence_number++; | |
2619 host_impl_->WillBeginImplFrame(begin_frame_args); | 2609 host_impl_->WillBeginImplFrame(begin_frame_args); |
2620 host_impl_->Animate(); | 2610 host_impl_->Animate(); |
2621 EXPECT_TRUE(did_request_commit_); | 2611 EXPECT_TRUE(did_request_commit_); |
2622 EXPECT_FALSE(did_request_next_frame_); | 2612 EXPECT_FALSE(did_request_next_frame_); |
2623 host_impl_->DidFinishImplFrame(); | 2613 host_impl_->DidFinishImplFrame(); |
2624 | 2614 |
2625 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2615 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2626 host_impl_->ProcessScrollDeltas(); | 2616 host_impl_->ProcessScrollDeltas(); |
2627 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); | 2617 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); |
2628 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2618 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2629 gfx::Vector2d(-50, -50))); | 2619 gfx::Vector2d(-50, -50))); |
2630 } | 2620 } |
2631 | 2621 |
2632 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { | 2622 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { |
2633 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2623 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2634 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2624 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2635 DrawFrame(); | 2625 DrawFrame(); |
2636 | 2626 |
2637 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2627 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2638 DCHECK(scroll_layer); | 2628 DCHECK(scroll_layer); |
2639 | 2629 |
2640 base::TimeTicks start_time = | 2630 base::TimeTicks start_time = |
2641 base::TimeTicks() + base::TimeDelta::FromSeconds(1); | 2631 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
2642 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2632 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2643 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2633 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2644 base::TimeTicks end_time = start_time + duration; | 2634 base::TimeTicks end_time = start_time + duration; |
2645 | 2635 |
2646 BeginFrameArgs begin_frame_args = | 2636 BeginFrameArgs begin_frame_args = |
2647 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2637 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2648 | 2638 |
2649 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2639 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
2650 scroll_layer->layer_tree_impl() | 2640 scroll_layer->layer_tree_impl() |
2651 ->property_trees() | 2641 ->property_trees() |
2652 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2642 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2653 gfx::ScrollOffset(50, 50)); | 2643 gfx::ScrollOffset(50, 50)); |
2654 | 2644 |
2655 did_complete_page_scale_animation_ = false; | 2645 did_complete_page_scale_animation_ = false; |
2656 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2646 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2657 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2647 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2658 gfx::Vector2d(), false, 2.f, duration))); | 2648 gfx::Vector2d(), false, 2.f, duration))); |
2659 host_impl_->ActivateSyncTree(); | 2649 host_impl_->ActivateSyncTree(); |
2660 begin_frame_args.frame_time = start_time; | 2650 begin_frame_args.frame_time = start_time; |
2651 begin_frame_args.sequence_number++; | |
2661 host_impl_->WillBeginImplFrame(begin_frame_args); | 2652 host_impl_->WillBeginImplFrame(begin_frame_args); |
2662 host_impl_->Animate(); | 2653 host_impl_->Animate(); |
2663 EXPECT_FALSE(did_complete_page_scale_animation_); | 2654 EXPECT_FALSE(did_complete_page_scale_animation_); |
2664 host_impl_->DidFinishImplFrame(); | 2655 host_impl_->DidFinishImplFrame(); |
2665 | 2656 |
2666 begin_frame_args.frame_time = halfway_through_animation; | 2657 begin_frame_args.frame_time = halfway_through_animation; |
2658 begin_frame_args.sequence_number++; | |
2667 host_impl_->WillBeginImplFrame(begin_frame_args); | 2659 host_impl_->WillBeginImplFrame(begin_frame_args); |
2668 host_impl_->Animate(); | 2660 host_impl_->Animate(); |
2669 EXPECT_FALSE(did_complete_page_scale_animation_); | 2661 EXPECT_FALSE(did_complete_page_scale_animation_); |
2670 host_impl_->DidFinishImplFrame(); | 2662 host_impl_->DidFinishImplFrame(); |
2671 | 2663 |
2672 begin_frame_args.frame_time = end_time; | 2664 begin_frame_args.frame_time = end_time; |
2665 begin_frame_args.sequence_number++; | |
2673 host_impl_->WillBeginImplFrame(begin_frame_args); | 2666 host_impl_->WillBeginImplFrame(begin_frame_args); |
2674 host_impl_->Animate(); | 2667 host_impl_->Animate(); |
2675 EXPECT_TRUE(did_complete_page_scale_animation_); | 2668 EXPECT_TRUE(did_complete_page_scale_animation_); |
2676 host_impl_->DidFinishImplFrame(); | 2669 host_impl_->DidFinishImplFrame(); |
2677 } | 2670 } |
2678 | 2671 |
2679 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { | 2672 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { |
2680 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2673 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2681 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2674 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2682 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2675 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
(...skipping 30 matching lines...) Expand all Loading... | |
2713 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 2706 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
2714 : LayerTreeHostImpl(settings, | 2707 : LayerTreeHostImpl(settings, |
2715 client, | 2708 client, |
2716 task_runner_provider, | 2709 task_runner_provider, |
2717 rendering_stats_instrumentation, | 2710 rendering_stats_instrumentation, |
2718 task_graph_runner, | 2711 task_graph_runner, |
2719 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 2712 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
2720 0) {} | 2713 0) {} |
2721 | 2714 |
2722 BeginFrameArgs CurrentBeginFrameArgs() const override { | 2715 BeginFrameArgs CurrentBeginFrameArgs() const override { |
2723 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 2716 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, |
2724 fake_current_physical_time_); | 2717 fake_current_physical_time_); |
2725 } | 2718 } |
2726 | 2719 |
2727 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 2720 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
2728 fake_current_physical_time_ = fake_now; | 2721 fake_current_physical_time_ = fake_now; |
2729 } | 2722 } |
2730 | 2723 |
2731 private: | 2724 private: |
2732 base::TimeTicks fake_current_physical_time_; | 2725 base::TimeTicks fake_current_physical_time_; |
2733 }; | 2726 }; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2800 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2793 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2801 InputHandler::WHEEL); | 2794 InputHandler::WHEEL); |
2802 host_impl_->ScrollEnd(EndState().get()); | 2795 host_impl_->ScrollEnd(EndState().get()); |
2803 EXPECT_FALSE(did_request_next_frame_); | 2796 EXPECT_FALSE(did_request_next_frame_); |
2804 EXPECT_FALSE(did_request_redraw_); | 2797 EXPECT_FALSE(did_request_redraw_); |
2805 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2798 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2806 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2799 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2807 | 2800 |
2808 // Before the scrollbar animation exists, we should not get redraws. | 2801 // Before the scrollbar animation exists, we should not get redraws. |
2809 BeginFrameArgs begin_frame_args = | 2802 BeginFrameArgs begin_frame_args = |
2810 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2803 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
2811 host_impl_->WillBeginImplFrame(begin_frame_args); | 2804 host_impl_->WillBeginImplFrame(begin_frame_args); |
2812 host_impl_->Animate(); | 2805 host_impl_->Animate(); |
2813 EXPECT_FALSE(did_request_next_frame_); | 2806 EXPECT_FALSE(did_request_next_frame_); |
2814 did_request_next_frame_ = false; | 2807 did_request_next_frame_ = false; |
2815 EXPECT_FALSE(did_request_redraw_); | 2808 EXPECT_FALSE(did_request_redraw_); |
2816 did_request_redraw_ = false; | 2809 did_request_redraw_ = false; |
2817 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2810 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2818 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2811 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2819 host_impl_->DidFinishImplFrame(); | 2812 host_impl_->DidFinishImplFrame(); |
2820 | 2813 |
(...skipping 16 matching lines...) Expand all Loading... | |
2837 requested_animation_delay_); | 2830 requested_animation_delay_); |
2838 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2831 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
2839 } else { | 2832 } else { |
2840 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2833 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2841 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2834 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2842 } | 2835 } |
2843 | 2836 |
2844 if (expecting_animations) { | 2837 if (expecting_animations) { |
2845 // Before the scrollbar animation begins, we should not get redraws. | 2838 // Before the scrollbar animation begins, we should not get redraws. |
2846 begin_frame_args = | 2839 begin_frame_args = |
2847 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2840 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3, fake_now); |
2848 host_impl_->WillBeginImplFrame(begin_frame_args); | 2841 host_impl_->WillBeginImplFrame(begin_frame_args); |
2849 host_impl_->Animate(); | 2842 host_impl_->Animate(); |
2850 EXPECT_FALSE(did_request_next_frame_); | 2843 EXPECT_FALSE(did_request_next_frame_); |
2851 did_request_next_frame_ = false; | 2844 did_request_next_frame_ = false; |
2852 EXPECT_FALSE(did_request_redraw_); | 2845 EXPECT_FALSE(did_request_redraw_); |
2853 did_request_redraw_ = false; | 2846 did_request_redraw_ = false; |
2854 host_impl_->DidFinishImplFrame(); | 2847 host_impl_->DidFinishImplFrame(); |
2855 | 2848 |
2856 // Start the scrollbar animation. | 2849 // Start the scrollbar animation. |
2857 fake_now += requested_animation_delay_; | 2850 fake_now += requested_animation_delay_; |
2858 requested_animation_delay_ = base::TimeDelta(); | 2851 requested_animation_delay_ = base::TimeDelta(); |
2859 animation_task_.Run(); | 2852 animation_task_.Run(); |
2860 animation_task_ = base::Closure(); | 2853 animation_task_ = base::Closure(); |
2861 EXPECT_TRUE(did_request_next_frame_); | 2854 EXPECT_TRUE(did_request_next_frame_); |
2862 did_request_next_frame_ = false; | 2855 did_request_next_frame_ = false; |
2863 EXPECT_FALSE(did_request_redraw_); | 2856 EXPECT_FALSE(did_request_redraw_); |
2864 | 2857 |
2865 // After the scrollbar animation begins, we should start getting redraws. | 2858 // After the scrollbar animation begins, we should start getting redraws. |
2866 begin_frame_args = | 2859 begin_frame_args = |
2867 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2860 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 4, fake_now); |
2868 host_impl_->WillBeginImplFrame(begin_frame_args); | 2861 host_impl_->WillBeginImplFrame(begin_frame_args); |
2869 host_impl_->Animate(); | 2862 host_impl_->Animate(); |
2870 EXPECT_TRUE(did_request_next_frame_); | 2863 EXPECT_TRUE(did_request_next_frame_); |
2871 did_request_next_frame_ = false; | 2864 did_request_next_frame_ = false; |
2872 EXPECT_TRUE(did_request_redraw_); | 2865 EXPECT_TRUE(did_request_redraw_); |
2873 did_request_redraw_ = false; | 2866 did_request_redraw_ = false; |
2874 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2867 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2875 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2868 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2876 host_impl_->DidFinishImplFrame(); | 2869 host_impl_->DidFinishImplFrame(); |
2877 } | 2870 } |
(...skipping 17 matching lines...) Expand all Loading... | |
2895 animation_task_ = base::Closure(); | 2888 animation_task_ = base::Closure(); |
2896 } else { | 2889 } else { |
2897 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2890 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2898 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2891 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2899 } | 2892 } |
2900 | 2893 |
2901 if (expecting_animations) { | 2894 if (expecting_animations) { |
2902 // Scrolling should have stopped the animation, so we should not be | 2895 // Scrolling should have stopped the animation, so we should not be |
2903 // getting redraws. | 2896 // getting redraws. |
2904 begin_frame_args = | 2897 begin_frame_args = |
2905 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2898 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); |
2906 host_impl_->WillBeginImplFrame(begin_frame_args); | 2899 host_impl_->WillBeginImplFrame(begin_frame_args); |
2907 host_impl_->Animate(); | 2900 host_impl_->Animate(); |
2908 EXPECT_FALSE(did_request_next_frame_); | 2901 EXPECT_FALSE(did_request_next_frame_); |
2909 did_request_next_frame_ = false; | 2902 did_request_next_frame_ = false; |
2910 EXPECT_FALSE(did_request_redraw_); | 2903 EXPECT_FALSE(did_request_redraw_); |
2911 did_request_redraw_ = false; | 2904 did_request_redraw_ = false; |
2912 host_impl_->DidFinishImplFrame(); | 2905 host_impl_->DidFinishImplFrame(); |
2913 } | 2906 } |
2914 | 2907 |
2915 // Scrollbar animation is not triggered unnecessarily. | 2908 // Scrollbar animation is not triggered unnecessarily. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3299 EXPECT_EQ(1.f, metadata.page_scale_factor); | 3292 EXPECT_EQ(1.f, metadata.page_scale_factor); |
3300 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); | 3293 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); |
3301 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 3294 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
3302 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 3295 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
3303 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 3296 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
3304 EXPECT_FALSE(metadata.root_overflow_x_hidden); | 3297 EXPECT_FALSE(metadata.root_overflow_x_hidden); |
3305 EXPECT_FALSE(metadata.root_overflow_y_hidden); | 3298 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
3306 } | 3299 } |
3307 | 3300 |
3308 // Scrolling should update metadata immediately. | 3301 // Scrolling should update metadata immediately. |
3309 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3302 EXPECT_EQ( |
3310 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3303 InputHandler::SCROLL_ON_IMPL_THREAD, |
3311 InputHandler::WHEEL) | 3304 host_impl_ |
3312 .thread); | 3305 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
3306 .thread); | |
3313 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 3307 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
3314 { | 3308 { |
3315 CompositorFrameMetadata metadata = | 3309 CompositorFrameMetadata metadata = |
3316 host_impl_->MakeCompositorFrameMetadata(); | 3310 host_impl_->MakeCompositorFrameMetadata(); |
3317 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 3311 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
3318 } | 3312 } |
3319 host_impl_->ScrollEnd(EndState().get()); | 3313 host_impl_->ScrollEnd(EndState().get()); |
3320 { | 3314 { |
3321 CompositorFrameMetadata metadata = | 3315 CompositorFrameMetadata metadata = |
3322 host_impl_->MakeCompositorFrameMetadata(); | 3316 host_impl_->MakeCompositorFrameMetadata(); |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4584 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 4578 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
4585 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4579 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4586 host_impl_ | 4580 host_impl_ |
4587 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4581 ->ScrollBegin(BeginState(gfx::Point()).get(), |
4588 InputHandler::TOUCHSCREEN) | 4582 InputHandler::TOUCHSCREEN) |
4589 .thread); | 4583 .thread); |
4590 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4584 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
4591 host_impl_->ScrollEnd(EndState().get()); | 4585 host_impl_->ScrollEnd(EndState().get()); |
4592 | 4586 |
4593 // The viewport offset shouldn't have changed. | 4587 // The viewport offset shouldn't have changed. |
4594 EXPECT_EQ(viewport_offset, | 4588 EXPECT_EQ(viewport_offset, host_impl_->active_tree()->TotalScrollOffset()); |
4595 host_impl_->active_tree()->TotalScrollOffset()); | |
4596 | 4589 |
4597 // Scroll the viewports to max scroll offset. | 4590 // Scroll the viewports to max scroll offset. |
4598 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); | 4591 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); |
4599 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); | 4592 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); |
4600 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4593 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
4601 host_impl_->active_tree()->TotalScrollOffset()); | 4594 host_impl_->active_tree()->TotalScrollOffset()); |
4602 } | 4595 } |
4603 | 4596 |
4604 // Test that the browser controls coming in and out maintains the same aspect | 4597 // Test that the browser controls coming in and out maintains the same aspect |
4605 // ratio between the inner and outer viewports. | 4598 // ratio between the inner and outer viewports. |
(...skipping 16 matching lines...) Expand all Loading... | |
4622 host_impl_->ScrollEnd(EndState().get()); | 4615 host_impl_->ScrollEnd(EndState().get()); |
4623 | 4616 |
4624 EXPECT_FLOAT_EQ( | 4617 EXPECT_FLOAT_EQ( |
4625 scroll_delta.y(), | 4618 scroll_delta.y(), |
4626 top_controls_height_ - | 4619 top_controls_height_ - |
4627 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4620 host_impl_->browser_controls_manager()->ContentTopOffset()); |
4628 | 4621 |
4629 // Browser controls were hidden by 25px so the inner viewport should have | 4622 // Browser controls were hidden by 25px so the inner viewport should have |
4630 // expanded by that much. | 4623 // expanded by that much. |
4631 LayerImpl* outer_container = | 4624 LayerImpl* outer_container = |
4632 host_impl_->active_tree()->OuterViewportContainerLayer(); | 4625 host_impl_->active_tree()->OuterViewportContainerLayer(); |
4633 LayerImpl* inner_container = | 4626 LayerImpl* inner_container = |
4634 host_impl_->active_tree()->InnerViewportContainerLayer(); | 4627 host_impl_->active_tree()->InnerViewportContainerLayer(); |
4635 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), | 4628 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), |
4636 inner_container->BoundsForScrolling()); | 4629 inner_container->BoundsForScrolling()); |
4637 | 4630 |
4638 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. | 4631 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. |
4639 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 4632 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
4640 inner_container->BoundsForScrolling().height(); | 4633 inner_container->BoundsForScrolling().height(); |
4641 gfx::SizeF expected = | 4634 gfx::SizeF expected = |
4642 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); | 4635 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); |
4643 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); | 4636 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); |
4644 EXPECT_EQ(expected, | 4637 EXPECT_EQ(expected, |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4819 ASSERT_FLOAT_EQ(0, | 4812 ASSERT_FLOAT_EQ(0, |
4820 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4813 host_impl_->browser_controls_manager()->ContentTopOffset()); |
4821 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); | 4814 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); |
4822 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); | 4815 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); |
4823 | 4816 |
4824 // Kick off an animation to show the browser controls. | 4817 // Kick off an animation to show the browser controls. |
4825 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( | 4818 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
4826 BOTH, SHOWN, true); | 4819 BOTH, SHOWN, true); |
4827 base::TimeTicks start_time = base::TimeTicks::Now(); | 4820 base::TimeTicks start_time = base::TimeTicks::Now(); |
4828 BeginFrameArgs begin_frame_args = | 4821 BeginFrameArgs begin_frame_args = |
4829 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 4822 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
4830 | 4823 |
4831 // Pump an animation frame to put some delta in the browser controls. | 4824 // Pump an animation frame to put some delta in the browser controls. |
4832 { | 4825 { |
4833 begin_frame_args.frame_time = | 4826 begin_frame_args.frame_time = |
4834 start_time + base::TimeDelta::FromMilliseconds(50); | 4827 start_time + base::TimeDelta::FromMilliseconds(50); |
4828 begin_frame_args.sequence_number++; | |
4835 host_impl_->WillBeginImplFrame(begin_frame_args); | 4829 host_impl_->WillBeginImplFrame(begin_frame_args); |
4836 host_impl_->Animate(); | 4830 host_impl_->Animate(); |
4837 host_impl_->UpdateAnimationState(true); | 4831 host_impl_->UpdateAnimationState(true); |
4838 host_impl_->DidFinishImplFrame(); | 4832 host_impl_->DidFinishImplFrame(); |
4839 } | 4833 } |
4840 | 4834 |
4841 // Pull the browser controls delta and get it back to the pending tree so that | 4835 // Pull the browser controls delta and get it back to the pending tree so that |
4842 // when we go to activate the pending tree we cause a change to browser | 4836 // when we go to activate the pending tree we cause a change to browser |
4843 // controls. | 4837 // controls. |
4844 { | 4838 { |
4845 float delta = | 4839 float delta = |
4846 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); | 4840 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); |
4847 ASSERT_GT(delta, 0); | 4841 ASSERT_GT(delta, 0); |
4848 ASSERT_LT(delta, 1); | 4842 ASSERT_LT(delta, 1); |
4849 host_impl_->active_tree() | 4843 host_impl_->active_tree() |
4850 ->top_controls_shown_ratio() | 4844 ->top_controls_shown_ratio() |
4851 ->PullDeltaForMainThread(); | 4845 ->PullDeltaForMainThread(); |
4852 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4846 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
4853 delta); | 4847 delta); |
4854 } | 4848 } |
4855 | 4849 |
4856 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so | 4850 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so |
4857 // the browser controls should be fully animated in this frame. | 4851 // the browser controls should be fully animated in this frame. |
4858 { | 4852 { |
4859 begin_frame_args.frame_time = | 4853 begin_frame_args.frame_time = |
4860 start_time + base::TimeDelta::FromMilliseconds(200); | 4854 start_time + base::TimeDelta::FromMilliseconds(200); |
4855 begin_frame_args.sequence_number++; | |
4861 host_impl_->WillBeginImplFrame(begin_frame_args); | 4856 host_impl_->WillBeginImplFrame(begin_frame_args); |
4862 host_impl_->Animate(); | 4857 host_impl_->Animate(); |
4863 host_impl_->UpdateAnimationState(true); | 4858 host_impl_->UpdateAnimationState(true); |
4864 host_impl_->DidFinishImplFrame(); | 4859 host_impl_->DidFinishImplFrame(); |
4865 | 4860 |
4866 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); | 4861 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); |
4867 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); | 4862 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); |
4868 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we | 4863 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we |
4869 // lose some precision in the intermediate animation steps. | 4864 // lose some precision in the intermediate animation steps. |
4870 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); | 4865 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4907 scroll_layer->SetPosition(gfx::PointF()); | 4902 scroll_layer->SetPosition(gfx::PointF()); |
4908 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4903 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
4909 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4904 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
4910 | 4905 |
4911 scroll_clip_layer->test_properties()->force_render_surface = true; | 4906 scroll_clip_layer->test_properties()->force_render_surface = true; |
4912 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4907 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
4913 | 4908 |
4914 host_impl_->SetViewportSize(surface_size); | 4909 host_impl_->SetViewportSize(surface_size); |
4915 DrawFrame(); | 4910 DrawFrame(); |
4916 | 4911 |
4917 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4912 EXPECT_EQ( |
4918 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4913 InputHandler::SCROLL_ON_IMPL_THREAD, |
4919 InputHandler::WHEEL) | 4914 host_impl_ |
4920 .thread); | 4915 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
4916 .thread); | |
4921 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4917 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4922 host_impl_->ScrollEnd(EndState().get()); | 4918 host_impl_->ScrollEnd(EndState().get()); |
4923 EXPECT_TRUE(did_request_redraw_); | 4919 EXPECT_TRUE(did_request_redraw_); |
4924 EXPECT_TRUE(did_request_commit_); | 4920 EXPECT_TRUE(did_request_commit_); |
4925 } | 4921 } |
4926 | 4922 |
4927 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4923 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4928 gfx::Size surface_size(10, 10); | 4924 gfx::Size surface_size(10, 10); |
4929 gfx::Size contents_size(20, 20); | 4925 gfx::Size contents_size(20, 20); |
4930 | 4926 |
4931 LayerImpl* root = | 4927 LayerImpl* root = |
4932 CreateBasicVirtualViewportLayers(surface_size, surface_size); | 4928 CreateBasicVirtualViewportLayers(surface_size, surface_size); |
4933 | 4929 |
4934 root->test_properties()->AddChild( | 4930 root->test_properties()->AddChild( |
4935 CreateScrollableLayer(12, contents_size, root)); | 4931 CreateScrollableLayer(12, contents_size, root)); |
4936 root->test_properties()->force_render_surface = true; | 4932 root->test_properties()->force_render_surface = true; |
4937 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4933 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
4938 | 4934 |
4939 host_impl_->SetViewportSize(surface_size); | 4935 host_impl_->SetViewportSize(surface_size); |
4940 DrawFrame(); | 4936 DrawFrame(); |
4941 | 4937 |
4942 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4938 EXPECT_EQ( |
4943 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4939 InputHandler::SCROLL_ON_IMPL_THREAD, |
4944 InputHandler::WHEEL) | 4940 host_impl_ |
4945 .thread); | 4941 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
4942 .thread); | |
4946 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4943 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4947 host_impl_->ScrollEnd(EndState().get()); | 4944 host_impl_->ScrollEnd(EndState().get()); |
4948 EXPECT_TRUE(did_request_redraw_); | 4945 EXPECT_TRUE(did_request_redraw_); |
4949 EXPECT_TRUE(did_request_commit_); | 4946 EXPECT_TRUE(did_request_commit_); |
4950 } | 4947 } |
4951 | 4948 |
4952 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4949 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4953 gfx::Size surface_size(10, 10); | 4950 gfx::Size surface_size(10, 10); |
4954 std::unique_ptr<LayerImpl> root = | 4951 std::unique_ptr<LayerImpl> root = |
4955 LayerImpl::Create(host_impl_->active_tree(), 1); | 4952 LayerImpl::Create(host_impl_->active_tree(), 1); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5057 | 5054 |
5058 LayerImpl* root_scroll = | 5055 LayerImpl* root_scroll = |
5059 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5056 host_impl_->active_tree()->OuterViewportScrollLayer(); |
5060 LayerImpl* inner_scroll = | 5057 LayerImpl* inner_scroll = |
5061 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5058 host_impl_->active_tree()->InnerViewportScrollLayer(); |
5062 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5059 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
5063 | 5060 |
5064 gfx::Vector2d scroll_delta(0, 10); | 5061 gfx::Vector2d scroll_delta(0, 10); |
5065 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5062 gfx::Vector2d expected_scroll_delta = scroll_delta; |
5066 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5063 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
5067 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5064 EXPECT_EQ( |
5068 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5065 InputHandler::SCROLL_ON_IMPL_THREAD, |
5069 InputHandler::WHEEL) | 5066 host_impl_ |
5070 .thread); | 5067 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
5068 .thread); | |
5071 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5069 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5072 host_impl_->ScrollEnd(EndState().get()); | 5070 host_impl_->ScrollEnd(EndState().get()); |
5073 | 5071 |
5074 // Set new page scale from main thread. | 5072 // Set new page scale from main thread. |
5075 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 5073 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
5076 | 5074 |
5077 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5075 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5078 host_impl_->ProcessScrollDeltas(); | 5076 host_impl_->ProcessScrollDeltas(); |
5079 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5077 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
5080 expected_scroll_delta)); | 5078 expected_scroll_delta)); |
(...skipping 26 matching lines...) Expand all Loading... | |
5107 | 5105 |
5108 LayerImpl* root_scroll = | 5106 LayerImpl* root_scroll = |
5109 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5107 host_impl_->active_tree()->OuterViewportScrollLayer(); |
5110 LayerImpl* inner_scroll = | 5108 LayerImpl* inner_scroll = |
5111 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5109 host_impl_->active_tree()->InnerViewportScrollLayer(); |
5112 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5110 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
5113 | 5111 |
5114 gfx::Vector2d scroll_delta(0, 10); | 5112 gfx::Vector2d scroll_delta(0, 10); |
5115 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5113 gfx::Vector2d expected_scroll_delta = scroll_delta; |
5116 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5114 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
5117 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5115 EXPECT_EQ( |
5118 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5116 InputHandler::SCROLL_ON_IMPL_THREAD, |
5119 InputHandler::WHEEL) | 5117 host_impl_ |
5120 .thread); | 5118 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
5119 .thread); | |
5121 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5120 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5122 host_impl_->ScrollEnd(EndState().get()); | 5121 host_impl_->ScrollEnd(EndState().get()); |
5123 | 5122 |
5124 // Set new page scale on impl thread by pinching. | 5123 // Set new page scale on impl thread by pinching. |
5125 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5124 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5126 InputHandler::TOUCHSCREEN); | 5125 InputHandler::TOUCHSCREEN); |
5127 host_impl_->PinchGestureBegin(); | 5126 host_impl_->PinchGestureBegin(); |
5128 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 5127 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
5129 host_impl_->PinchGestureEnd(); | 5128 host_impl_->PinchGestureEnd(); |
5130 host_impl_->ScrollEnd(EndState().get()); | 5129 host_impl_->ScrollEnd(EndState().get()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5209 | 5208 |
5210 // Make the outer scroll layer scrollable. | 5209 // Make the outer scroll layer scrollable. |
5211 outer_scroll->SetBounds(gfx::Size(50, 50)); | 5210 outer_scroll->SetBounds(gfx::Size(50, 50)); |
5212 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5211 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5213 | 5212 |
5214 DrawFrame(); | 5213 DrawFrame(); |
5215 | 5214 |
5216 gfx::Vector2d scroll_delta(0, 10); | 5215 gfx::Vector2d scroll_delta(0, 10); |
5217 gfx::Vector2d expected_scroll_delta(scroll_delta); | 5216 gfx::Vector2d expected_scroll_delta(scroll_delta); |
5218 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); | 5217 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); |
5219 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5218 EXPECT_EQ( |
5220 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5219 InputHandler::SCROLL_ON_IMPL_THREAD, |
5221 InputHandler::WHEEL) | 5220 host_impl_ |
5222 .thread); | 5221 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
5222 .thread); | |
5223 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5223 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5224 host_impl_->ScrollEnd(EndState().get()); | 5224 host_impl_->ScrollEnd(EndState().get()); |
5225 | 5225 |
5226 float page_scale = 2.f; | 5226 float page_scale = 2.f; |
5227 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 5227 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
5228 page_scale); | 5228 page_scale); |
5229 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5229 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5230 | 5230 |
5231 DrawOneFrame(); | 5231 DrawOneFrame(); |
5232 | 5232 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5272 gfx::ScrollOffset(0, 5)); | 5272 gfx::ScrollOffset(0, 5)); |
5273 child_layer->layer_tree_impl() | 5273 child_layer->layer_tree_impl() |
5274 ->property_trees() | 5274 ->property_trees() |
5275 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5275 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
5276 gfx::ScrollOffset(3, 0)); | 5276 gfx::ScrollOffset(3, 0)); |
5277 | 5277 |
5278 host_impl_->SetViewportSize(surface_size); | 5278 host_impl_->SetViewportSize(surface_size); |
5279 DrawFrame(); | 5279 DrawFrame(); |
5280 { | 5280 { |
5281 gfx::Vector2d scroll_delta(-8, -7); | 5281 gfx::Vector2d scroll_delta(-8, -7); |
5282 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5282 EXPECT_EQ( |
5283 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5283 InputHandler::SCROLL_ON_IMPL_THREAD, |
5284 InputHandler::WHEEL) | 5284 host_impl_ |
5285 .thread); | 5285 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
5286 .thread); | |
5286 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5287 host_impl_->ScrollEnd(EndState().get()); | 5288 host_impl_->ScrollEnd(EndState().get()); |
5288 | 5289 |
5289 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5290 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5290 host_impl_->ProcessScrollDeltas(); | 5291 host_impl_->ProcessScrollDeltas(); |
5291 | 5292 |
5292 // The grand child should have scrolled up to its limit. | 5293 // The grand child should have scrolled up to its limit. |
5293 LayerImpl* child = host_impl_->active_tree() | 5294 LayerImpl* child = host_impl_->active_tree() |
5294 ->root_layer_for_testing() | 5295 ->root_layer_for_testing() |
5295 ->test_properties() | 5296 ->test_properties() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5343 gfx::ScrollOffset(0, 2)); | 5344 gfx::ScrollOffset(0, 2)); |
5344 child_layer->layer_tree_impl() | 5345 child_layer->layer_tree_impl() |
5345 ->property_trees() | 5346 ->property_trees() |
5346 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5347 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
5347 gfx::ScrollOffset(0, 3)); | 5348 gfx::ScrollOffset(0, 3)); |
5348 | 5349 |
5349 DrawFrame(); | 5350 DrawFrame(); |
5350 { | 5351 { |
5351 gfx::Vector2d scroll_delta(0, -10); | 5352 gfx::Vector2d scroll_delta(0, -10); |
5352 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5353 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5353 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5354 host_impl_ |
5354 InputHandler::NON_BUBBLING_GESTURE) | 5355 ->ScrollBegin(BeginState(gfx::Point()).get(), |
5356 InputHandler::NON_BUBBLING_GESTURE) | |
5355 .thread); | 5357 .thread); |
5356 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5358 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5357 host_impl_->ScrollEnd(EndState().get()); | 5359 host_impl_->ScrollEnd(EndState().get()); |
5358 | 5360 |
5359 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5361 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5360 host_impl_->ProcessScrollDeltas(); | 5362 host_impl_->ProcessScrollDeltas(); |
5361 | 5363 |
5362 // The grand child should have scrolled up to its limit. | 5364 // The grand child should have scrolled up to its limit. |
5363 LayerImpl* child = host_impl_->active_tree() | 5365 LayerImpl* child = host_impl_->active_tree() |
5364 ->root_layer_for_testing() | 5366 ->root_layer_for_testing() |
5365 ->test_properties() | 5367 ->test_properties() |
5366 ->children[0] | 5368 ->children[0] |
5367 ->test_properties() | 5369 ->test_properties() |
5368 ->children[0] | 5370 ->children[0] |
5369 ->test_properties() | 5371 ->test_properties() |
5370 ->children[0]; | 5372 ->children[0]; |
5371 LayerImpl* grand_child = child->test_properties()->children[0]; | 5373 LayerImpl* grand_child = child->test_properties()->children[0]; |
5372 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5374 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5373 gfx::Vector2d(0, -2))); | 5375 gfx::Vector2d(0, -2))); |
5374 | 5376 |
5375 // The child should not have scrolled. | 5377 // The child should not have scrolled. |
5376 ExpectNone(*scroll_info.get(), child->id()); | 5378 ExpectNone(*scroll_info.get(), child->id()); |
5377 | 5379 |
5378 // The next time we scroll we should only scroll the parent. | 5380 // The next time we scroll we should only scroll the parent. |
5379 scroll_delta = gfx::Vector2d(0, -3); | 5381 scroll_delta = gfx::Vector2d(0, -3); |
5380 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5382 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5381 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5383 host_impl_ |
5382 InputHandler::NON_BUBBLING_GESTURE) | 5384 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5385 InputHandler::NON_BUBBLING_GESTURE) | |
5383 .thread); | 5386 .thread); |
5384 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5387 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
5385 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5388 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 5389 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
5387 host_impl_->ScrollEnd(EndState().get()); | 5390 host_impl_->ScrollEnd(EndState().get()); |
5388 | 5391 |
5389 scroll_info = host_impl_->ProcessScrollDeltas(); | 5392 scroll_info = host_impl_->ProcessScrollDeltas(); |
5390 | 5393 |
5391 // The child should have scrolled up to its limit. | 5394 // The child should have scrolled up to its limit. |
5392 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5395 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
5393 gfx::Vector2d(0, -3))); | 5396 gfx::Vector2d(0, -3))); |
5394 | 5397 |
5395 // The grand child should not have scrolled. | 5398 // The grand child should not have scrolled. |
5396 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5399 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5397 gfx::Vector2d(0, -2))); | 5400 gfx::Vector2d(0, -2))); |
5398 | 5401 |
5399 // After scrolling the parent, another scroll on the opposite direction | 5402 // After scrolling the parent, another scroll on the opposite direction |
5400 // should still scroll the child. | 5403 // should still scroll the child. |
5401 scroll_delta = gfx::Vector2d(0, 7); | 5404 scroll_delta = gfx::Vector2d(0, 7); |
5402 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5405 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5403 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5406 host_impl_ |
5404 InputHandler::NON_BUBBLING_GESTURE) | 5407 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5408 InputHandler::NON_BUBBLING_GESTURE) | |
5405 .thread); | 5409 .thread); |
5406 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5410 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
5407 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5411 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5408 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5412 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
5409 host_impl_->ScrollEnd(EndState().get()); | 5413 host_impl_->ScrollEnd(EndState().get()); |
5410 | 5414 |
5411 scroll_info = host_impl_->ProcessScrollDeltas(); | 5415 scroll_info = host_impl_->ProcessScrollDeltas(); |
5412 | 5416 |
5413 // The grand child should have scrolled. | 5417 // The grand child should have scrolled. |
5414 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5418 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5415 gfx::Vector2d(0, 5))); | 5419 gfx::Vector2d(0, 5))); |
5416 | 5420 |
5417 // The child should not have scrolled. | 5421 // The child should not have scrolled. |
5418 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5422 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
5419 gfx::Vector2d(0, -3))); | 5423 gfx::Vector2d(0, -3))); |
5420 | 5424 |
5421 // Scrolling should be adjusted from viewport space. | 5425 // Scrolling should be adjusted from viewport space. |
5422 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); | 5426 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); |
5423 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 5427 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
5424 | 5428 |
5425 scroll_delta = gfx::Vector2d(0, -2); | 5429 scroll_delta = gfx::Vector2d(0, -2); |
5426 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5430 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5427 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5431 host_impl_ |
5428 InputHandler::NON_BUBBLING_GESTURE) | 5432 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
5433 InputHandler::NON_BUBBLING_GESTURE) | |
5429 .thread); | 5434 .thread); |
5430 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 5435 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); |
5431 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5436 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5432 host_impl_->ScrollEnd(EndState().get()); | 5437 host_impl_->ScrollEnd(EndState().get()); |
5433 | 5438 |
5434 scroll_info = host_impl_->ProcessScrollDeltas(); | 5439 scroll_info = host_impl_->ProcessScrollDeltas(); |
5435 | 5440 |
5436 // Should have scrolled by half the amount in layer space (5 - 2/2) | 5441 // Should have scrolled by half the amount in layer space (5 - 2/2) |
5437 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5442 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5438 gfx::Vector2d(0, 4))); | 5443 gfx::Vector2d(0, 4))); |
(...skipping 27 matching lines...) Expand all Loading... | |
5466 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5471 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
5467 Layer::INVALID_ID); | 5472 Layer::INVALID_ID); |
5468 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5473 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5469 host_impl_->active_tree()->DidBecomeActive(); | 5474 host_impl_->active_tree()->DidBecomeActive(); |
5470 | 5475 |
5471 host_impl_->SetViewportSize(surface_size); | 5476 host_impl_->SetViewportSize(surface_size); |
5472 DrawFrame(); | 5477 DrawFrame(); |
5473 { | 5478 { |
5474 gfx::Vector2d scroll_delta(0, 4); | 5479 gfx::Vector2d scroll_delta(0, 4); |
5475 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5480 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5476 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5481 host_impl_ |
5477 InputHandler::WHEEL) | 5482 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5483 InputHandler::WHEEL) | |
5478 .thread); | 5484 .thread); |
5479 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5485 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5480 host_impl_->ScrollEnd(EndState().get()); | 5486 host_impl_->ScrollEnd(EndState().get()); |
5481 | 5487 |
5482 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5488 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5483 host_impl_->ProcessScrollDeltas(); | 5489 host_impl_->ProcessScrollDeltas(); |
5484 | 5490 |
5485 // Only the root scroll should have scrolled. | 5491 // Only the root scroll should have scrolled. |
5486 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 5492 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
5487 EXPECT_TRUE( | 5493 EXPECT_TRUE( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5542 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); | 5548 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); |
5543 inner_clip2->test_properties()->force_render_surface = true; | 5549 inner_clip2->test_properties()->force_render_surface = true; |
5544 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); | 5550 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); |
5545 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); | 5551 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
5546 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5552 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5547 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5553 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
5548 10); | 5554 10); |
5549 host_impl_->active_tree()->DidBecomeActive(); | 5555 host_impl_->active_tree()->DidBecomeActive(); |
5550 | 5556 |
5551 // Scrolling should still work even though we did not draw yet. | 5557 // Scrolling should still work even though we did not draw yet. |
5552 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5558 EXPECT_EQ( |
5553 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5559 InputHandler::SCROLL_ON_IMPL_THREAD, |
5554 InputHandler::WHEEL) | 5560 host_impl_ |
5555 .thread); | 5561 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
5562 .thread); | |
5556 } | 5563 } |
5557 | 5564 |
5558 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5565 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
5559 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5566 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5560 scroll_layer->SetDrawsContent(true); | 5567 scroll_layer->SetDrawsContent(true); |
5561 | 5568 |
5562 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5569 // Rotate the root layer 90 degrees counter-clockwise about its center. |
5563 gfx::Transform rotate_transform; | 5570 gfx::Transform rotate_transform; |
5564 rotate_transform.Rotate(-90.0); | 5571 rotate_transform.Rotate(-90.0); |
5565 host_impl_->active_tree() | 5572 host_impl_->active_tree() |
(...skipping 18 matching lines...) Expand all Loading... | |
5584 | 5591 |
5585 // The layer should have scrolled down in its local coordinates. | 5592 // The layer should have scrolled down in its local coordinates. |
5586 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5593 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5587 host_impl_->ProcessScrollDeltas(); | 5594 host_impl_->ProcessScrollDeltas(); |
5588 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5595 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5589 gfx::Vector2d(0, gesture_scroll_delta.x()))); | 5596 gfx::Vector2d(0, gesture_scroll_delta.x()))); |
5590 | 5597 |
5591 // Reset and scroll down with the wheel. | 5598 // Reset and scroll down with the wheel. |
5592 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5599 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
5593 gfx::Vector2d wheel_scroll_delta(0, 10); | 5600 gfx::Vector2d wheel_scroll_delta(0, 10); |
5594 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5601 EXPECT_EQ( |
5595 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5602 InputHandler::SCROLL_ON_IMPL_THREAD, |
5596 InputHandler::WHEEL) | 5603 host_impl_ |
5597 .thread); | 5604 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
5605 .thread); | |
5598 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); | 5606 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); |
5599 host_impl_->ScrollEnd(EndState().get()); | 5607 host_impl_->ScrollEnd(EndState().get()); |
5600 | 5608 |
5601 // The layer should have scrolled down in its local coordinates. | 5609 // The layer should have scrolled down in its local coordinates. |
5602 scroll_info = host_impl_->ProcessScrollDeltas(); | 5610 scroll_info = host_impl_->ProcessScrollDeltas(); |
5603 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5611 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5604 wheel_scroll_delta)); | 5612 wheel_scroll_delta)); |
5605 } | 5613 } |
5606 | 5614 |
5607 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 5615 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5762 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5770 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
5763 expected_scroll_deltas[i])); | 5771 expected_scroll_deltas[i])); |
5764 | 5772 |
5765 // The root scroll layer should not have scrolled, because the input delta | 5773 // The root scroll layer should not have scrolled, because the input delta |
5766 // was close to the layer's axis of movement. | 5774 // was close to the layer's axis of movement. |
5767 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 5775 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
5768 } | 5776 } |
5769 } | 5777 } |
5770 | 5778 |
5771 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5779 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
5772 LayerImpl* scroll_layer = | 5780 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5773 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
5774 | 5781 |
5775 // Scale the layer to twice its normal size. | 5782 // Scale the layer to twice its normal size. |
5776 int scale = 2; | 5783 int scale = 2; |
5777 gfx::Transform scale_transform; | 5784 gfx::Transform scale_transform; |
5778 scale_transform.Scale(scale, scale); | 5785 scale_transform.Scale(scale, scale); |
5779 scroll_layer->test_properties()->parent->test_properties()->transform = | 5786 scroll_layer->test_properties()->parent->test_properties()->transform = |
5780 scale_transform; | 5787 scale_transform; |
5781 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5788 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
5782 | 5789 |
5783 gfx::Size surface_size(50, 50); | 5790 gfx::Size surface_size(50, 50); |
(...skipping 13 matching lines...) Expand all Loading... | |
5797 // The layer should have scrolled down in its local coordinates, but half the | 5804 // The layer should have scrolled down in its local coordinates, but half the |
5798 // amount. | 5805 // amount. |
5799 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5806 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5800 host_impl_->ProcessScrollDeltas(); | 5807 host_impl_->ProcessScrollDeltas(); |
5801 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5808 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5802 gfx::Vector2d(0, scroll_delta.y() / scale))); | 5809 gfx::Vector2d(0, scroll_delta.y() / scale))); |
5803 | 5810 |
5804 // Reset and scroll down with the wheel. | 5811 // Reset and scroll down with the wheel. |
5805 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5812 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
5806 gfx::Vector2d wheel_scroll_delta(0, 10); | 5813 gfx::Vector2d wheel_scroll_delta(0, 10); |
5807 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5814 EXPECT_EQ( |
5808 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5815 InputHandler::SCROLL_ON_IMPL_THREAD, |
5809 InputHandler::WHEEL) | 5816 host_impl_ |
5810 .thread); | 5817 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
5818 .thread); | |
5811 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); | 5819 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); |
5812 host_impl_->ScrollEnd(EndState().get()); | 5820 host_impl_->ScrollEnd(EndState().get()); |
5813 | 5821 |
5814 // It should apply the scale factor to the scroll delta for the wheel event. | 5822 // It should apply the scale factor to the scroll delta for the wheel event. |
5815 scroll_info = host_impl_->ProcessScrollDeltas(); | 5823 scroll_info = host_impl_->ProcessScrollDeltas(); |
5816 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5824 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
5817 wheel_scroll_delta)); | 5825 wheel_scroll_delta)); |
5818 } | 5826 } |
5819 | 5827 |
5820 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 5828 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5859 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); | 5867 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); |
5860 last_set_scroll_offset_ = total_scroll_offset; | 5868 last_set_scroll_offset_ = total_scroll_offset; |
5861 max_scroll_offset_ = max_scroll_offset; | 5869 max_scroll_offset_ = max_scroll_offset; |
5862 scrollable_size_ = scrollable_size; | 5870 scrollable_size_ = scrollable_size; |
5863 page_scale_factor_ = page_scale_factor; | 5871 page_scale_factor_ = page_scale_factor; |
5864 min_page_scale_factor_ = min_page_scale_factor; | 5872 min_page_scale_factor_ = min_page_scale_factor; |
5865 max_page_scale_factor_ = max_page_scale_factor; | 5873 max_page_scale_factor_ = max_page_scale_factor; |
5866 } | 5874 } |
5867 void DeliverInputForBeginFrame() override {} | 5875 void DeliverInputForBeginFrame() override {} |
5868 | 5876 |
5869 gfx::ScrollOffset last_set_scroll_offset() { | 5877 gfx::ScrollOffset last_set_scroll_offset() { return last_set_scroll_offset_; } |
5870 return last_set_scroll_offset_; | |
5871 } | |
5872 | 5878 |
5873 gfx::ScrollOffset max_scroll_offset() const { | 5879 gfx::ScrollOffset max_scroll_offset() const { return max_scroll_offset_; } |
5874 return max_scroll_offset_; | |
5875 } | |
5876 | 5880 |
5877 gfx::SizeF scrollable_size() const { | 5881 gfx::SizeF scrollable_size() const { return scrollable_size_; } |
5878 return scrollable_size_; | |
5879 } | |
5880 | 5882 |
5881 float page_scale_factor() const { | 5883 float page_scale_factor() const { return page_scale_factor_; } |
5882 return page_scale_factor_; | |
5883 } | |
5884 | 5884 |
5885 float min_page_scale_factor() const { | 5885 float min_page_scale_factor() const { return min_page_scale_factor_; } |
5886 return min_page_scale_factor_; | |
5887 } | |
5888 | 5886 |
5889 float max_page_scale_factor() const { | 5887 float max_page_scale_factor() const { return max_page_scale_factor_; } |
5890 return max_page_scale_factor_; | |
5891 } | |
5892 | 5888 |
5893 private: | 5889 private: |
5894 gfx::ScrollOffset last_set_scroll_offset_; | 5890 gfx::ScrollOffset last_set_scroll_offset_; |
5895 gfx::ScrollOffset max_scroll_offset_; | 5891 gfx::ScrollOffset max_scroll_offset_; |
5896 gfx::SizeF scrollable_size_; | 5892 gfx::SizeF scrollable_size_; |
5897 float page_scale_factor_; | 5893 float page_scale_factor_; |
5898 float min_page_scale_factor_; | 5894 float min_page_scale_factor_; |
5899 float max_page_scale_factor_; | 5895 float max_page_scale_factor_; |
5900 }; | 5896 }; |
5901 | 5897 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6043 InputHandlerScrollResult scroll_result; | 6039 InputHandlerScrollResult scroll_result; |
6044 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 6040 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
6045 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6041 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6046 | 6042 |
6047 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6043 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
6048 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6044 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
6049 DrawFrame(); | 6045 DrawFrame(); |
6050 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6046 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6051 | 6047 |
6052 // In-bounds scrolling does not affect overscroll. | 6048 // In-bounds scrolling does not affect overscroll. |
6053 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6049 EXPECT_EQ( |
6054 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6050 InputHandler::SCROLL_ON_IMPL_THREAD, |
6055 InputHandler::WHEEL) | 6051 host_impl_ |
6056 .thread); | 6052 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
6053 .thread); | |
6057 scroll_result = host_impl_->ScrollBy( | 6054 scroll_result = host_impl_->ScrollBy( |
6058 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6055 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
6059 EXPECT_TRUE(scroll_result.did_scroll); | 6056 EXPECT_TRUE(scroll_result.did_scroll); |
6060 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6057 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6061 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); | 6058 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
6062 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6059 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6063 | 6060 |
6064 // Overscroll events are reflected immediately. | 6061 // Overscroll events are reflected immediately. |
6065 scroll_result = host_impl_->ScrollBy( | 6062 scroll_result = host_impl_->ScrollBy( |
6066 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get()); | 6063 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6205 grand_child_layer->layer_tree_impl() | 6202 grand_child_layer->layer_tree_impl() |
6206 ->property_trees() | 6203 ->property_trees() |
6207 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 6204 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
6208 gfx::ScrollOffset(0, 2)); | 6205 gfx::ScrollOffset(0, 2)); |
6209 | 6206 |
6210 host_impl_->SetViewportSize(surface_size); | 6207 host_impl_->SetViewportSize(surface_size); |
6211 DrawFrame(); | 6208 DrawFrame(); |
6212 { | 6209 { |
6213 gfx::Vector2d scroll_delta(0, -10); | 6210 gfx::Vector2d scroll_delta(0, -10); |
6214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6211 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6215 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6212 host_impl_ |
6216 InputHandler::NON_BUBBLING_GESTURE) | 6213 ->ScrollBegin(BeginState(gfx::Point()).get(), |
6214 InputHandler::NON_BUBBLING_GESTURE) | |
6217 .thread); | 6215 .thread); |
6218 scroll_result = | 6216 scroll_result = |
6219 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6217 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6220 EXPECT_TRUE(scroll_result.did_scroll); | 6218 EXPECT_TRUE(scroll_result.did_scroll); |
6221 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6219 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6222 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6220 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6223 host_impl_->ScrollEnd(EndState().get()); | 6221 host_impl_->ScrollEnd(EndState().get()); |
6224 | 6222 |
6225 // The next time we scroll we should only scroll the parent, but overscroll | 6223 // The next time we scroll we should only scroll the parent, but overscroll |
6226 // should still not reach the root layer. | 6224 // should still not reach the root layer. |
6227 scroll_delta = gfx::Vector2d(0, -30); | 6225 scroll_delta = gfx::Vector2d(0, -30); |
6228 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6226 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6229 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6227 host_impl_ |
6230 InputHandler::NON_BUBBLING_GESTURE) | 6228 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
6229 InputHandler::NON_BUBBLING_GESTURE) | |
6231 .thread); | 6230 .thread); |
6232 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6231 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
6233 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6232 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6234 host_impl_->ScrollEnd(EndState().get()); | 6233 host_impl_->ScrollEnd(EndState().get()); |
6235 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6234 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6236 host_impl_ | 6235 host_impl_ |
6237 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6236 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
6238 InputHandler::NON_BUBBLING_GESTURE) | 6237 InputHandler::NON_BUBBLING_GESTURE) |
6239 .thread); | 6238 .thread); |
6240 scroll_result = | 6239 scroll_result = |
6241 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6240 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6242 EXPECT_TRUE(scroll_result.did_scroll); | 6241 EXPECT_TRUE(scroll_result.did_scroll); |
6243 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6242 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6244 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); | 6243 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); |
6245 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6244 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6246 host_impl_->ScrollEnd(EndState().get()); | 6245 host_impl_->ScrollEnd(EndState().get()); |
6247 | 6246 |
6248 // After scrolling the parent, another scroll on the opposite direction | 6247 // After scrolling the parent, another scroll on the opposite direction |
6249 // should scroll the child. | 6248 // should scroll the child. |
6250 scroll_delta = gfx::Vector2d(0, 70); | 6249 scroll_delta = gfx::Vector2d(0, 70); |
6251 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6250 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6252 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6251 host_impl_ |
6253 InputHandler::NON_BUBBLING_GESTURE) | 6252 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
6253 InputHandler::NON_BUBBLING_GESTURE) | |
6254 .thread); | 6254 .thread); |
6255 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6255 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
6256 scroll_result = | 6256 scroll_result = |
6257 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6257 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6258 EXPECT_TRUE(scroll_result.did_scroll); | 6258 EXPECT_TRUE(scroll_result.did_scroll); |
6259 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6259 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6260 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6260 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
6261 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6261 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6262 host_impl_->ScrollEnd(EndState().get()); | 6262 host_impl_->ScrollEnd(EndState().get()); |
6263 } | 6263 } |
6264 } | 6264 } |
6265 | 6265 |
6266 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 6266 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
6267 // When we try to scroll a non-scrollable child layer, the scroll delta | 6267 // When we try to scroll a non-scrollable child layer, the scroll delta |
6268 // should be applied to one of its ancestors if possible. Overscroll should | 6268 // should be applied to one of its ancestors if possible. Overscroll should |
6269 // be reflected only when it has bubbled up to the root scrolling layer. | 6269 // be reflected only when it has bubbled up to the root scrolling layer. |
6270 InputHandlerScrollResult scroll_result; | 6270 InputHandlerScrollResult scroll_result; |
6271 SetupScrollAndContentsLayers(gfx::Size(20, 20)); | 6271 SetupScrollAndContentsLayers(gfx::Size(20, 20)); |
6272 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6272 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6273 | 6273 |
6274 DrawFrame(); | 6274 DrawFrame(); |
6275 { | 6275 { |
6276 gfx::Vector2d scroll_delta(0, 8); | 6276 gfx::Vector2d scroll_delta(0, 8); |
6277 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6277 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6278 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6278 host_impl_ |
6279 InputHandler::WHEEL) | 6279 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
6280 InputHandler::WHEEL) | |
6280 .thread); | 6281 .thread); |
6281 scroll_result = | 6282 scroll_result = |
6282 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6283 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6283 EXPECT_TRUE(scroll_result.did_scroll); | 6284 EXPECT_TRUE(scroll_result.did_scroll); |
6284 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6285 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6285 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6286 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6286 scroll_result = | 6287 scroll_result = |
6287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6288 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
6288 EXPECT_TRUE(scroll_result.did_scroll); | 6289 EXPECT_TRUE(scroll_result.did_scroll); |
6289 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6290 EXPECT_TRUE(scroll_result.did_overscroll_root); |
(...skipping 18 matching lines...) Expand all Loading... | |
6308 | 6309 |
6309 clip_layer->SetBounds(gfx::Size(50, 50)); | 6310 clip_layer->SetBounds(gfx::Size(50, 50)); |
6310 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6311 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6311 | 6312 |
6312 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6313 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
6313 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6314 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
6314 DrawFrame(); | 6315 DrawFrame(); |
6315 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6316 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
6316 | 6317 |
6317 // Even though the layer can't scroll the overscroll still happens. | 6318 // Even though the layer can't scroll the overscroll still happens. |
6318 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6319 EXPECT_EQ( |
6319 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6320 InputHandler::SCROLL_ON_IMPL_THREAD, |
6320 InputHandler::WHEEL) | 6321 host_impl_ |
6321 .thread); | 6322 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
6323 .thread); | |
6322 scroll_result = host_impl_->ScrollBy( | 6324 scroll_result = host_impl_->ScrollBy( |
6323 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6325 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
6324 EXPECT_FALSE(scroll_result.did_scroll); | 6326 EXPECT_FALSE(scroll_result.did_scroll); |
6325 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6327 EXPECT_TRUE(scroll_result.did_overscroll_root); |
6326 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 6328 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
6327 } | 6329 } |
6328 | 6330 |
6329 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 6331 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
6330 InputHandlerScrollResult scroll_result; | 6332 InputHandlerScrollResult scroll_result; |
6331 gfx::Size viewport_size(100, 100); | 6333 gfx::Size viewport_size(100, 100); |
6332 gfx::Size content_size(200, 200); | 6334 gfx::Size content_size(200, 200); |
6333 LayerImpl* root_scroll_layer = | 6335 LayerImpl* root_scroll_layer = |
6334 CreateBasicVirtualViewportLayers(viewport_size, viewport_size); | 6336 CreateBasicVirtualViewportLayers(viewport_size, viewport_size); |
6335 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 6337 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
6336 content_size); | 6338 content_size); |
6337 root_scroll_layer->SetBounds(content_size); | 6339 root_scroll_layer->SetBounds(content_size); |
6338 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6340 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6339 | 6341 |
6340 DrawFrame(); | 6342 DrawFrame(); |
6341 { | 6343 { |
6342 // Edge glow effect should be applicable only upon reaching Edges | 6344 // Edge glow effect should be applicable only upon reaching Edges |
6343 // of the content. unnecessary glow effect calls shouldn't be | 6345 // of the content. unnecessary glow effect calls shouldn't be |
6344 // called while scrolling up without reaching the edge of the content. | 6346 // called while scrolling up without reaching the edge of the content. |
6345 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6347 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6346 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6348 host_impl_ |
6347 InputHandler::WHEEL) | 6349 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
6350 InputHandler::WHEEL) | |
6348 .thread); | 6351 .thread); |
6349 scroll_result = host_impl_->ScrollBy( | 6352 scroll_result = host_impl_->ScrollBy( |
6350 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); | 6353 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); |
6351 EXPECT_TRUE(scroll_result.did_scroll); | 6354 EXPECT_TRUE(scroll_result.did_scroll); |
6352 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6355 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6353 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6356 EXPECT_EQ(gfx::Vector2dF().ToString(), |
6354 host_impl_->accumulated_root_overscroll().ToString()); | 6357 host_impl_->accumulated_root_overscroll().ToString()); |
6355 scroll_result = host_impl_->ScrollBy( | 6358 scroll_result = host_impl_->ScrollBy( |
6356 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get()); | 6359 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get()); |
6357 EXPECT_TRUE(scroll_result.did_scroll); | 6360 EXPECT_TRUE(scroll_result.did_scroll); |
6358 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6361 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6359 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6362 EXPECT_EQ(gfx::Vector2dF().ToString(), |
6360 host_impl_->accumulated_root_overscroll().ToString()); | 6363 host_impl_->accumulated_root_overscroll().ToString()); |
6361 host_impl_->ScrollEnd(EndState().get()); | 6364 host_impl_->ScrollEnd(EndState().get()); |
6362 // unusedrootDelta should be subtracted from applied delta so that | 6365 // unusedrootDelta should be subtracted from applied delta so that |
6363 // unwanted glow effect calls are not called. | 6366 // unwanted glow effect calls are not called. |
6364 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6367 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6365 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6368 host_impl_ |
6366 InputHandler::NON_BUBBLING_GESTURE) | 6369 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
6370 InputHandler::NON_BUBBLING_GESTURE) | |
6367 .thread); | 6371 .thread); |
6368 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6372 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6369 host_impl_->FlingScrollBegin().thread); | 6373 host_impl_->FlingScrollBegin().thread); |
6370 scroll_result = host_impl_->ScrollBy( | 6374 scroll_result = host_impl_->ScrollBy( |
6371 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get()); | 6375 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get()); |
6372 EXPECT_TRUE(scroll_result.did_scroll); | 6376 EXPECT_TRUE(scroll_result.did_scroll); |
6373 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6377 EXPECT_TRUE(scroll_result.did_overscroll_root); |
6374 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), | 6378 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), |
6375 host_impl_->accumulated_root_overscroll()); | 6379 host_impl_->accumulated_root_overscroll()); |
6376 | 6380 |
6377 scroll_result = host_impl_->ScrollBy( | 6381 scroll_result = host_impl_->ScrollBy( |
6378 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get()); | 6382 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get()); |
6379 EXPECT_FALSE(scroll_result.did_scroll); | 6383 EXPECT_FALSE(scroll_result.did_scroll); |
6380 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6384 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6381 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), | 6385 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), |
6382 host_impl_->accumulated_root_overscroll()); | 6386 host_impl_->accumulated_root_overscroll()); |
6383 host_impl_->ScrollEnd(EndState().get()); | 6387 host_impl_->ScrollEnd(EndState().get()); |
6384 // TestCase to check kEpsilon, which prevents minute values to trigger | 6388 // TestCase to check kEpsilon, which prevents minute values to trigger |
6385 // gloweffect without reaching edge. | 6389 // gloweffect without reaching edge. |
6386 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6390 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6387 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6391 host_impl_ |
6388 InputHandler::WHEEL) | 6392 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
6393 InputHandler::WHEEL) | |
6389 .thread); | 6394 .thread); |
6390 scroll_result = host_impl_->ScrollBy( | 6395 scroll_result = host_impl_->ScrollBy( |
6391 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); | 6396 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); |
6392 EXPECT_FALSE(scroll_result.did_scroll); | 6397 EXPECT_FALSE(scroll_result.did_scroll); |
6393 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6398 EXPECT_FALSE(scroll_result.did_overscroll_root); |
6394 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6399 EXPECT_EQ(gfx::Vector2dF().ToString(), |
6395 host_impl_->accumulated_root_overscroll().ToString()); | 6400 host_impl_->accumulated_root_overscroll().ToString()); |
6396 host_impl_->ScrollEnd(EndState().get()); | 6401 host_impl_->ScrollEnd(EndState().get()); |
6397 } | 6402 } |
6398 } | 6403 } |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6891 else | 6896 else |
6892 opaque_rect = opaque_content_rect_; | 6897 opaque_rect = opaque_content_rect_; |
6893 gfx::Rect visible_quad_rect = quad_rect_; | 6898 gfx::Rect visible_quad_rect = quad_rect_; |
6894 | 6899 |
6895 SharedQuadState* shared_quad_state = | 6900 SharedQuadState* shared_quad_state = |
6896 render_pass->CreateAndAppendSharedQuadState(); | 6901 render_pass->CreateAndAppendSharedQuadState(); |
6897 PopulateSharedQuadState(shared_quad_state); | 6902 PopulateSharedQuadState(shared_quad_state); |
6898 | 6903 |
6899 TileDrawQuad* test_blending_draw_quad = | 6904 TileDrawQuad* test_blending_draw_quad = |
6900 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 6905 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
6901 test_blending_draw_quad->SetNew(shared_quad_state, | 6906 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect, |
6902 quad_rect_, | 6907 visible_quad_rect, resource_id_, |
6903 opaque_rect, | |
6904 visible_quad_rect, | |
6905 resource_id_, | |
6906 gfx::RectF(0.f, 0.f, 1.f, 1.f), | 6908 gfx::RectF(0.f, 0.f, 1.f, 1.f), |
6907 gfx::Size(1, 1), | 6909 gfx::Size(1, 1), false, false); |
6908 false, | |
6909 false); | |
6910 test_blending_draw_quad->visible_rect = quad_visible_rect_; | 6910 test_blending_draw_quad->visible_rect = quad_visible_rect_; |
6911 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); | 6911 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); |
6912 EXPECT_EQ(has_render_surface_, !!render_surface()); | 6912 EXPECT_EQ(has_render_surface_, !!render_surface()); |
6913 } | 6913 } |
6914 | 6914 |
6915 void SetExpectation(bool blend, bool has_render_surface) { | 6915 void SetExpectation(bool blend, bool has_render_surface) { |
6916 blend_ = blend; | 6916 blend_ = blend; |
6917 has_render_surface_ = has_render_surface; | 6917 has_render_surface_ = has_render_surface; |
6918 quads_appended_ = false; | 6918 quads_appended_ = false; |
6919 } | 6919 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7247 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); | 7247 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); |
7248 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); | 7248 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
7249 | 7249 |
7250 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); | 7250 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); |
7251 video_layer->NoteLayerPropertyChanged(); | 7251 video_layer->NoteLayerPropertyChanged(); |
7252 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); | 7252 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
7253 } | 7253 } |
7254 | 7254 |
7255 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 7255 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
7256 protected: | 7256 protected: |
7257 LayerTreeHostImplViewportCoveredTest() : | 7257 LayerTreeHostImplViewportCoveredTest() |
7258 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 7258 : gutter_quad_material_(DrawQuad::SOLID_COLOR), |
7259 child_(NULL), | 7259 child_(NULL), |
7260 did_activate_pending_tree_(false) {} | 7260 did_activate_pending_tree_(false) {} |
7261 | 7261 |
7262 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( | 7262 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( |
7263 bool software) { | 7263 bool software) { |
7264 if (software) | 7264 if (software) |
7265 return FakeCompositorFrameSink::CreateSoftware(); | 7265 return FakeCompositorFrameSink::CreateSoftware(); |
7266 return FakeCompositorFrameSink::Create3d(); | 7266 return FakeCompositorFrameSink::Create3d(); |
7267 } | 7267 } |
7268 | 7268 |
7269 void SetupActiveTreeLayers() { | 7269 void SetupActiveTreeLayers() { |
7270 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 7270 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7541 host_impl_->CreatePendingTree(); | 7541 host_impl_->CreatePendingTree(); |
7542 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 7542 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
7543 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); | 7543 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); |
7544 | 7544 |
7545 SetupActiveTreeLayers(); | 7545 SetupActiveTreeLayers(); |
7546 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); | 7546 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); |
7547 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); | 7547 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); |
7548 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); | 7548 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); |
7549 } | 7549 } |
7550 | 7550 |
7551 class FakeDrawableLayerImpl: public LayerImpl { | 7551 class FakeDrawableLayerImpl : public LayerImpl { |
7552 public: | 7552 public: |
7553 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 7553 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
7554 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); | 7554 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); |
7555 } | 7555 } |
7556 | |
7556 protected: | 7557 protected: |
7557 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 7558 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
7558 : LayerImpl(tree_impl, id) {} | 7559 : LayerImpl(tree_impl, id) {} |
7559 }; | 7560 }; |
7560 | 7561 |
7561 // Make sure damage tracking propagates all the way to the graphics context, | 7562 // Make sure damage tracking propagates all the way to the graphics context, |
7562 // where it should request to swap only the sub-buffer that is damaged. | 7563 // where it should request to swap only the sub-buffer that is damaged. |
7563 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 7564 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
7564 scoped_refptr<TestContextProvider> context_provider( | 7565 scoped_refptr<TestContextProvider> context_provider( |
7565 TestContextProvider::Create()); | 7566 TestContextProvider::Create()); |
(...skipping 10 matching lines...) Expand all Loading... | |
7576 LayerTreeSettings settings = DefaultSettings(); | 7577 LayerTreeSettings settings = DefaultSettings(); |
7577 settings.renderer_settings.partial_swap_enabled = true; | 7578 settings.renderer_settings.partial_swap_enabled = true; |
7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7579 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7579 LayerTreeHostImpl::Create( | 7580 LayerTreeHostImpl::Create( |
7580 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7581 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7581 &task_graph_runner_, | 7582 &task_graph_runner_, |
7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7583 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7583 layer_tree_host_impl->SetVisible(true); | 7584 layer_tree_host_impl->SetVisible(true); |
7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7585 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
7585 layer_tree_host_impl->WillBeginImplFrame( | 7586 layer_tree_host_impl->WillBeginImplFrame( |
7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7587 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7588 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
7588 | 7589 |
7589 std::unique_ptr<LayerImpl> root = | 7590 std::unique_ptr<LayerImpl> root = |
7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7591 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
7591 root->test_properties()->force_render_surface = true; | 7592 root->test_properties()->force_render_surface = true; |
7592 std::unique_ptr<LayerImpl> child = | 7593 std::unique_ptr<LayerImpl> child = |
7593 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 7594 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
7594 child->SetPosition(gfx::PointF(12.f, 13.f)); | 7595 child->SetPosition(gfx::PointF(12.f, 13.f)); |
7595 child->SetBounds(gfx::Size(14, 15)); | 7596 child->SetBounds(gfx::Size(14, 15)); |
7596 child->SetDrawsContent(true); | 7597 child->SetDrawsContent(true); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7680 AppendQuadsData* append_quads_data) override { | 7681 AppendQuadsData* append_quads_data) override { |
7681 SharedQuadState* shared_quad_state = | 7682 SharedQuadState* shared_quad_state = |
7682 render_pass->CreateAndAppendSharedQuadState(); | 7683 render_pass->CreateAndAppendSharedQuadState(); |
7683 PopulateSharedQuadState(shared_quad_state); | 7684 PopulateSharedQuadState(shared_quad_state); |
7684 | 7685 |
7685 SkColor gray = SkColorSetRGB(100, 100, 100); | 7686 SkColor gray = SkColorSetRGB(100, 100, 100); |
7686 gfx::Rect quad_rect(bounds()); | 7687 gfx::Rect quad_rect(bounds()); |
7687 gfx::Rect visible_quad_rect(quad_rect); | 7688 gfx::Rect visible_quad_rect(quad_rect); |
7688 SolidColorDrawQuad* my_quad = | 7689 SolidColorDrawQuad* my_quad = |
7689 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 7690 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
7690 my_quad->SetNew( | 7691 my_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, gray, |
7691 shared_quad_state, quad_rect, visible_quad_rect, gray, false); | 7692 false); |
7692 } | 7693 } |
7693 | 7694 |
7694 private: | 7695 private: |
7695 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 7696 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
7696 : LayerImpl(tree_impl, id) {} | 7697 : LayerImpl(tree_impl, id) {} |
7697 }; | 7698 }; |
7698 | 7699 |
7699 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7700 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7700 LayerTreeSettings settings, | 7701 LayerTreeSettings settings, |
7701 bool partial_swap, | 7702 bool partial_swap, |
7702 LayerTreeHostImplClient* client, | 7703 LayerTreeHostImplClient* client, |
7703 TaskRunnerProvider* task_runner_provider, | 7704 TaskRunnerProvider* task_runner_provider, |
7704 TaskGraphRunner* task_graph_runner, | 7705 TaskGraphRunner* task_graph_runner, |
7705 RenderingStatsInstrumentation* stats_instrumentation, | 7706 RenderingStatsInstrumentation* stats_instrumentation, |
7706 CompositorFrameSink* compositor_frame_sink) { | 7707 CompositorFrameSink* compositor_frame_sink) { |
7707 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7708 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7709 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7709 settings, client, task_runner_provider, stats_instrumentation, | 7710 settings, client, task_runner_provider, stats_instrumentation, |
7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 7711 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
7711 0); | 7712 0); |
7712 my_host_impl->SetVisible(true); | 7713 my_host_impl->SetVisible(true); |
7713 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7714 my_host_impl->InitializeRenderer(compositor_frame_sink); |
7714 my_host_impl->WillBeginImplFrame( | 7715 my_host_impl->WillBeginImplFrame( |
7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7716 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7717 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7717 | 7718 |
7718 /* | 7719 /* |
7719 Layers are created as follows: | 7720 Layers are created as follows: |
7720 | 7721 |
7721 +--------------------+ | 7722 +--------------------+ |
7722 | 1 | | 7723 | 1 | |
7723 | +-----------+ | | 7724 | +-----------+ | |
7724 | | 2 | | | 7725 | | 2 | | |
7725 | | +-------------------+ | 7726 | | +-------------------+ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7834 TestWebGraphicsContext3D* context3d = context.get(); | 7835 TestWebGraphicsContext3D* context3d = context.get(); |
7835 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7836 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
7836 FakeCompositorFrameSink::Create3d(std::move(context))); | 7837 FakeCompositorFrameSink::Create3d(std::move(context))); |
7837 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 7838 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
7838 | 7839 |
7839 std::unique_ptr<LayerImpl> root_layer = | 7840 std::unique_ptr<LayerImpl> root_layer = |
7840 LayerImpl::Create(host_impl_->active_tree(), 1); | 7841 LayerImpl::Create(host_impl_->active_tree(), 1); |
7841 root_layer->SetBounds(gfx::Size(10, 10)); | 7842 root_layer->SetBounds(gfx::Size(10, 10)); |
7842 root_layer->test_properties()->force_render_surface = true; | 7843 root_layer->test_properties()->force_render_surface = true; |
7843 | 7844 |
7844 scoped_refptr<VideoFrame> softwareFrame = | 7845 scoped_refptr<VideoFrame> softwareFrame = media::VideoFrame::CreateColorFrame( |
7845 media::VideoFrame::CreateColorFrame( | 7846 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
7846 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | |
7847 FakeVideoFrameProvider provider; | 7847 FakeVideoFrameProvider provider; |
7848 provider.set_frame(softwareFrame); | 7848 provider.set_frame(softwareFrame); |
7849 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7849 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7850 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7850 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
7851 video_layer->SetBounds(gfx::Size(10, 10)); | 7851 video_layer->SetBounds(gfx::Size(10, 10)); |
7852 video_layer->SetDrawsContent(true); | 7852 video_layer->SetDrawsContent(true); |
7853 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7853 root_layer->test_properties()->AddChild(std::move(video_layer)); |
7854 | 7854 |
7855 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); | 7855 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
7856 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7856 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7857 | 7857 |
7858 EXPECT_EQ(0u, context3d->NumTextures()); | 7858 EXPECT_EQ(0u, context3d->NumTextures()); |
7859 | 7859 |
7860 LayerTreeHostImpl::FrameData frame; | 7860 LayerTreeHostImpl::FrameData frame; |
7861 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7861 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7862 host_impl_->DrawLayers(&frame); | 7862 host_impl_->DrawLayers(&frame); |
7863 host_impl_->DidDrawAllLayers(frame); | 7863 host_impl_->DidDrawAllLayers(frame); |
7864 | 7864 |
7865 EXPECT_GT(context3d->NumTextures(), 0u); | 7865 EXPECT_GT(context3d->NumTextures(), 0u); |
7866 | 7866 |
7867 // Kill the layer tree. | 7867 // Kill the layer tree. |
7868 host_impl_->active_tree()->DetachLayers(); | 7868 host_impl_->active_tree()->DetachLayers(); |
7869 // There should be no textures left in use after. | 7869 // There should be no textures left in use after. |
7870 EXPECT_EQ(0u, context3d->NumTextures()); | 7870 EXPECT_EQ(0u, context3d->NumTextures()); |
7871 } | 7871 } |
7872 | 7872 |
7873 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7873 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
7874 public: | 7874 public: |
7875 MOCK_METHOD1(useProgram, void(GLuint program)); | 7875 MOCK_METHOD1(useProgram, void(GLuint program)); |
7876 MOCK_METHOD4(drawElements, void(GLenum mode, | 7876 MOCK_METHOD4(drawElements, |
7877 GLsizei count, | 7877 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
7878 GLenum type, | |
7879 GLintptr offset)); | |
7880 }; | 7878 }; |
7881 | 7879 |
7882 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 7880 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
7883 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7881 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7884 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7882 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7885 | 7883 |
7886 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7884 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
7887 | 7885 |
7888 // Verify one quad is drawn when transparent background set is not set. | 7886 // Verify one quad is drawn when transparent background set is not set. |
7889 host_impl_->active_tree()->set_has_transparent_background(false); | 7887 host_impl_->active_tree()->set_has_transparent_background(false); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8605 | 8603 |
8606 root_scroll->test_properties()->AddChild(std::move(child)); | 8604 root_scroll->test_properties()->AddChild(std::move(child)); |
8607 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8605 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
8608 | 8606 |
8609 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8607 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8610 host_impl_->active_tree()->DidBecomeActive(); | 8608 host_impl_->active_tree()->DidBecomeActive(); |
8611 | 8609 |
8612 host_impl_->SetViewportSize(surface_size); | 8610 host_impl_->SetViewportSize(surface_size); |
8613 DrawFrame(); | 8611 DrawFrame(); |
8614 { | 8612 { |
8615 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8613 EXPECT_EQ( |
8616 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8614 InputHandler::SCROLL_ON_IMPL_THREAD, |
8617 InputHandler::WHEEL) | 8615 host_impl_ |
8618 .thread); | 8616 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
8617 .thread); | |
8619 | 8618 |
8620 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8619 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8621 host_impl_->FlingScrollBegin().thread); | 8620 host_impl_->FlingScrollBegin().thread); |
8622 | 8621 |
8623 gfx::Vector2d scroll_delta(0, 100); | 8622 gfx::Vector2d scroll_delta(0, 100); |
8624 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8623 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
8625 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8624 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
8626 | 8625 |
8627 host_impl_->ScrollEnd(EndState().get()); | 8626 host_impl_->ScrollEnd(EndState().get()); |
8628 | 8627 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8728 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 8727 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
8729 child_scroll->SetDrawsContent(false); | 8728 child_scroll->SetDrawsContent(false); |
8730 | 8729 |
8731 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); | 8730 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); |
8732 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8731 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8733 | 8732 |
8734 DrawFrame(); | 8733 DrawFrame(); |
8735 | 8734 |
8736 // We should have scrolled |child_scroll| even though it does not move | 8735 // We should have scrolled |child_scroll| even though it does not move |
8737 // any layer that is a drawn RSLL member. | 8736 // any layer that is a drawn RSLL member. |
8738 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8737 EXPECT_EQ( |
8739 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8738 InputHandler::SCROLL_ON_IMPL_THREAD, |
8740 InputHandler::WHEEL) | 8739 host_impl_ |
8741 .thread); | 8740 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
8741 .thread); | |
8742 | 8742 |
8743 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8743 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
8744 } | 8744 } |
8745 | 8745 |
8746 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8746 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
8747 // in CompositorFrameMetadata. | 8747 // in CompositorFrameMetadata. |
8748 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8748 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
8749 std::unique_ptr<SolidColorLayerImpl> root = | 8749 std::unique_ptr<SolidColorLayerImpl> root = |
8750 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8750 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
8751 root->SetPosition(gfx::PointF()); | 8751 root->SetPosition(gfx::PointF()); |
8752 root->SetBounds(gfx::Size(10, 10)); | 8752 root->SetBounds(gfx::Size(10, 10)); |
8753 root->SetDrawsContent(true); | 8753 root->SetDrawsContent(true); |
8754 root->test_properties()->force_render_surface = true; | 8754 root->test_properties()->force_render_surface = true; |
8755 | 8755 |
8756 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8756 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
8757 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8757 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8758 | 8758 |
8759 FakeCompositorFrameSink* fake_compositor_frame_sink = | 8759 FakeCompositorFrameSink* fake_compositor_frame_sink = |
8760 static_cast<FakeCompositorFrameSink*>( | 8760 static_cast<FakeCompositorFrameSink*>( |
8761 host_impl_->compositor_frame_sink()); | 8761 host_impl_->compositor_frame_sink()); |
8762 | 8762 |
8763 ui::LatencyInfo latency_info; | 8763 ui::LatencyInfo latency_info; |
8764 latency_info.AddLatencyNumber( | 8764 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
8765 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8765 0); |
8766 std::unique_ptr<SwapPromise> swap_promise( | 8766 std::unique_ptr<SwapPromise> swap_promise( |
8767 new LatencyInfoSwapPromise(latency_info)); | 8767 new LatencyInfoSwapPromise(latency_info)); |
8768 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8768 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
8769 | 8769 |
8770 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8770 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
8771 LayerTreeHostImpl::FrameData frame; | 8771 LayerTreeHostImpl::FrameData frame; |
8772 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 8772 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
8773 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); | 8773 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); |
8774 host_impl_->DidDrawAllLayers(frame); | 8774 host_impl_->DidDrawAllLayers(frame); |
8775 | 8775 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8918 &set_needs_redraw_count, &forward_to_main_count)); | 8918 &set_needs_redraw_count, &forward_to_main_count)); |
8919 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8919 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8920 | 8920 |
8921 // Scrolling normally should not trigger any forwarding. | 8921 // Scrolling normally should not trigger any forwarding. |
8922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8923 host_impl_ | 8923 host_impl_ |
8924 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8924 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8925 InputHandler::TOUCHSCREEN) | 8925 InputHandler::TOUCHSCREEN) |
8926 .thread); | 8926 .thread); |
8927 EXPECT_TRUE( | 8927 EXPECT_TRUE( |
8928 host_impl_->ScrollBy( | 8928 host_impl_ |
8929 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8929 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
8930 .did_scroll); | 8930 .did_scroll); |
8931 host_impl_->ScrollEnd(EndState().get()); | 8931 host_impl_->ScrollEnd(EndState().get()); |
8932 | 8932 |
8933 EXPECT_EQ(0, set_needs_commit_count); | 8933 EXPECT_EQ(0, set_needs_commit_count); |
8934 EXPECT_EQ(1, set_needs_redraw_count); | 8934 EXPECT_EQ(1, set_needs_redraw_count); |
8935 EXPECT_EQ(0, forward_to_main_count); | 8935 EXPECT_EQ(0, forward_to_main_count); |
8936 | 8936 |
8937 // Scrolling with a scroll handler should defer the swap to the main | 8937 // Scrolling with a scroll handler should defer the swap to the main |
8938 // thread. | 8938 // thread. |
8939 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 8939 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
8940 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8940 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8941 host_impl_ | 8941 host_impl_ |
8942 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8942 ->ScrollBegin(BeginState(gfx::Point()).get(), |
8943 InputHandler::TOUCHSCREEN) | 8943 InputHandler::TOUCHSCREEN) |
8944 .thread); | 8944 .thread); |
8945 EXPECT_TRUE( | 8945 EXPECT_TRUE( |
8946 host_impl_->ScrollBy( | 8946 host_impl_ |
8947 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8947 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
8948 .did_scroll); | 8948 .did_scroll); |
8949 host_impl_->ScrollEnd(EndState().get()); | 8949 host_impl_->ScrollEnd(EndState().get()); |
8950 | 8950 |
8951 EXPECT_EQ(0, set_needs_commit_count); | 8951 EXPECT_EQ(0, set_needs_commit_count); |
8952 EXPECT_EQ(2, set_needs_redraw_count); | 8952 EXPECT_EQ(2, set_needs_redraw_count); |
8953 EXPECT_EQ(1, forward_to_main_count); | 8953 EXPECT_EQ(1, forward_to_main_count); |
8954 } | 8954 } |
8955 } | 8955 } |
8956 | 8956 |
8957 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { | 8957 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { |
(...skipping 12 matching lines...) Expand all Loading... | |
8970 | 8970 |
8971 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; | 8971 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; |
8972 | 8972 |
8973 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { | 8973 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { |
8974 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8974 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8975 scroll_layer->layer_tree_impl() | 8975 scroll_layer->layer_tree_impl() |
8976 ->property_trees() | 8976 ->property_trees() |
8977 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8977 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
8978 gfx::ScrollOffset(0, 10)); | 8978 gfx::ScrollOffset(0, 10)); |
8979 BeginFrameArgs begin_frame_args = | 8979 BeginFrameArgs begin_frame_args = |
8980 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 8980 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
8981 host_impl_->WillBeginImplFrame(begin_frame_args); | 8981 host_impl_->WillBeginImplFrame(begin_frame_args); |
8982 host_impl_->Animate(); | 8982 host_impl_->Animate(); |
8983 EXPECT_FALSE(did_request_redraw_); | 8983 EXPECT_FALSE(did_request_redraw_); |
8984 host_impl_->DidFinishImplFrame(); | 8984 host_impl_->DidFinishImplFrame(); |
8985 } | 8985 } |
8986 | 8986 |
8987 TEST_F(LayerTreeHostImplWithBrowserControlsTest, | 8987 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
8988 BrowserControlsHeightIsCommitted) { | 8988 BrowserControlsHeightIsCommitted) { |
8989 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8989 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8990 EXPECT_FALSE(did_request_redraw_); | 8990 EXPECT_FALSE(did_request_redraw_); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9103 WheelUnhandledByBrowserControls) { | 9103 WheelUnhandledByBrowserControls) { |
9104 SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9104 SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
9105 host_impl_->SetViewportSize(gfx::Size(50, 100)); | 9105 host_impl_->SetViewportSize(gfx::Size(50, 100)); |
9106 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); | 9106 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); |
9107 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( | 9107 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
9108 BOTH, SHOWN, false); | 9108 BOTH, SHOWN, false); |
9109 DrawFrame(); | 9109 DrawFrame(); |
9110 | 9110 |
9111 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); | 9111 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); |
9112 | 9112 |
9113 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9113 EXPECT_EQ( |
9114 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 9114 InputHandler::SCROLL_ON_IMPL_THREAD, |
9115 InputHandler::WHEEL) | 9115 host_impl_ |
9116 .thread); | 9116 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
9117 .thread); | |
9117 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9118 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9118 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); | 9119 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); |
9119 | 9120 |
9120 // Wheel scrolls should not affect the browser controls, and should pass | 9121 // Wheel scrolls should not affect the browser controls, and should pass |
9121 // directly through to the viewport. | 9122 // directly through to the viewport. |
9122 const float delta = top_controls_height_; | 9123 const float delta = top_controls_height_; |
9123 EXPECT_TRUE( | 9124 EXPECT_TRUE( |
9124 host_impl_->ScrollBy( | 9125 host_impl_ |
9125 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9126 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
9126 .did_scroll); | 9127 .did_scroll); |
9127 EXPECT_FLOAT_EQ(0, | 9128 EXPECT_FLOAT_EQ(0, |
9128 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9129 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9129 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), | 9130 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), |
9130 viewport_layer->CurrentScrollOffset()); | 9131 viewport_layer->CurrentScrollOffset()); |
9131 | 9132 |
9132 EXPECT_TRUE( | 9133 EXPECT_TRUE( |
9133 host_impl_->ScrollBy( | 9134 host_impl_ |
9134 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9135 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
9135 .did_scroll); | 9136 .did_scroll); |
9136 EXPECT_FLOAT_EQ(0, | 9137 EXPECT_FLOAT_EQ(0, |
9137 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9138 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9138 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), | 9139 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), |
9139 viewport_layer->CurrentScrollOffset()); | 9140 viewport_layer->CurrentScrollOffset()); |
9140 } | 9141 } |
9141 | 9142 |
9142 TEST_F(LayerTreeHostImplWithBrowserControlsTest, | 9143 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
9143 BrowserControlsAnimationAtOrigin) { | 9144 BrowserControlsAnimationAtOrigin) { |
9144 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9145 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
(...skipping 10 matching lines...) Expand all Loading... | |
9155 InputHandler::TOUCHSCREEN) | 9156 InputHandler::TOUCHSCREEN) |
9156 .thread); | 9157 .thread); |
9157 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9158 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9158 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9159 EXPECT_EQ(gfx::Vector2dF().ToString(), |
9159 scroll_layer->CurrentScrollOffset().ToString()); | 9160 scroll_layer->CurrentScrollOffset().ToString()); |
9160 | 9161 |
9161 // Scroll the browser controls partially. | 9162 // Scroll the browser controls partially. |
9162 const float residue = 35; | 9163 const float residue = 35; |
9163 float offset = top_controls_height_ - residue; | 9164 float offset = top_controls_height_ - residue; |
9164 EXPECT_TRUE( | 9165 EXPECT_TRUE( |
9165 host_impl_->ScrollBy( | 9166 host_impl_ |
9166 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9167 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9167 .did_scroll); | 9168 .did_scroll); |
9168 EXPECT_FLOAT_EQ(-offset, | 9169 EXPECT_FLOAT_EQ(-offset, |
9169 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9170 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9170 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9171 EXPECT_EQ(gfx::Vector2dF().ToString(), |
9171 scroll_layer->CurrentScrollOffset().ToString()); | 9172 scroll_layer->CurrentScrollOffset().ToString()); |
9172 | 9173 |
9173 did_request_redraw_ = false; | 9174 did_request_redraw_ = false; |
9174 did_request_next_frame_ = false; | 9175 did_request_next_frame_ = false; |
9175 did_request_commit_ = false; | 9176 did_request_commit_ = false; |
9176 | 9177 |
9177 // End the scroll while the controls are still offset from their limit. | 9178 // End the scroll while the controls are still offset from their limit. |
9178 host_impl_->ScrollEnd(EndState().get()); | 9179 host_impl_->ScrollEnd(EndState().get()); |
9179 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9180 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9180 EXPECT_TRUE(did_request_next_frame_); | 9181 EXPECT_TRUE(did_request_next_frame_); |
9181 EXPECT_TRUE(did_request_redraw_); | 9182 EXPECT_TRUE(did_request_redraw_); |
9182 EXPECT_FALSE(did_request_commit_); | 9183 EXPECT_FALSE(did_request_commit_); |
9183 | 9184 |
9184 // The browser controls should properly animate until finished, despite the | 9185 // The browser controls should properly animate until finished, despite the |
9185 // scroll offset being at the origin. | 9186 // scroll offset being at the origin. |
9186 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9187 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9187 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9188 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9188 while (did_request_next_frame_) { | 9189 while (did_request_next_frame_) { |
9189 did_request_redraw_ = false; | 9190 did_request_redraw_ = false; |
9190 did_request_next_frame_ = false; | 9191 did_request_next_frame_ = false; |
9191 did_request_commit_ = false; | 9192 did_request_commit_ = false; |
9192 | 9193 |
9193 float old_offset = | 9194 float old_offset = |
9194 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9195 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9195 | 9196 |
9196 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9197 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
9198 begin_frame_args.sequence_number++; | |
9197 host_impl_->WillBeginImplFrame(begin_frame_args); | 9199 host_impl_->WillBeginImplFrame(begin_frame_args); |
9198 host_impl_->Animate(); | 9200 host_impl_->Animate(); |
9199 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9201 EXPECT_EQ(gfx::Vector2dF().ToString(), |
9200 scroll_layer->CurrentScrollOffset().ToString()); | 9202 scroll_layer->CurrentScrollOffset().ToString()); |
9201 | 9203 |
9202 float new_offset = | 9204 float new_offset = |
9203 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9205 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9204 | 9206 |
9205 // No commit is needed as the controls are animating the content offset, | 9207 // No commit is needed as the controls are animating the content offset, |
9206 // not the scroll offset. | 9208 // not the scroll offset. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9239 InputHandler::TOUCHSCREEN) | 9241 InputHandler::TOUCHSCREEN) |
9240 .thread); | 9242 .thread); |
9241 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9243 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9242 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9244 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
9243 scroll_layer->CurrentScrollOffset().ToString()); | 9245 scroll_layer->CurrentScrollOffset().ToString()); |
9244 | 9246 |
9245 // Scroll the browser controls partially. | 9247 // Scroll the browser controls partially. |
9246 const float residue = 15; | 9248 const float residue = 15; |
9247 float offset = top_controls_height_ - residue; | 9249 float offset = top_controls_height_ - residue; |
9248 EXPECT_TRUE( | 9250 EXPECT_TRUE( |
9249 host_impl_->ScrollBy( | 9251 host_impl_ |
9250 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9252 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9251 .did_scroll); | 9253 .did_scroll); |
9252 EXPECT_FLOAT_EQ(-offset, | 9254 EXPECT_FLOAT_EQ(-offset, |
9253 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9255 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9254 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9256 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
9255 scroll_layer->CurrentScrollOffset().ToString()); | 9257 scroll_layer->CurrentScrollOffset().ToString()); |
9256 | 9258 |
9257 did_request_redraw_ = false; | 9259 did_request_redraw_ = false; |
9258 did_request_next_frame_ = false; | 9260 did_request_next_frame_ = false; |
9259 did_request_commit_ = false; | 9261 did_request_commit_ = false; |
9260 | 9262 |
9261 // End the scroll while the controls are still offset from the limit. | 9263 // End the scroll while the controls are still offset from the limit. |
9262 host_impl_->ScrollEnd(EndState().get()); | 9264 host_impl_->ScrollEnd(EndState().get()); |
9263 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9265 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9264 EXPECT_TRUE(did_request_next_frame_); | 9266 EXPECT_TRUE(did_request_next_frame_); |
9265 EXPECT_TRUE(did_request_redraw_); | 9267 EXPECT_TRUE(did_request_redraw_); |
9266 EXPECT_FALSE(did_request_commit_); | 9268 EXPECT_FALSE(did_request_commit_); |
9267 | 9269 |
9268 // Animate the browser controls to the limit. | 9270 // Animate the browser controls to the limit. |
9269 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9271 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9270 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9272 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9271 while (did_request_next_frame_) { | 9273 while (did_request_next_frame_) { |
9272 did_request_redraw_ = false; | 9274 did_request_redraw_ = false; |
9273 did_request_next_frame_ = false; | 9275 did_request_next_frame_ = false; |
9274 did_request_commit_ = false; | 9276 did_request_commit_ = false; |
9275 | 9277 |
9276 float old_offset = | 9278 float old_offset = |
9277 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9279 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9278 | 9280 |
9279 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9281 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
9282 begin_frame_args.sequence_number++; | |
9280 host_impl_->WillBeginImplFrame(begin_frame_args); | 9283 host_impl_->WillBeginImplFrame(begin_frame_args); |
9281 host_impl_->Animate(); | 9284 host_impl_->Animate(); |
9282 | 9285 |
9283 float new_offset = | 9286 float new_offset = |
9284 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9287 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9285 | 9288 |
9286 if (new_offset != old_offset) { | 9289 if (new_offset != old_offset) { |
9287 EXPECT_TRUE(did_request_redraw_); | 9290 EXPECT_TRUE(did_request_redraw_); |
9288 EXPECT_TRUE(did_request_commit_); | 9291 EXPECT_TRUE(did_request_commit_); |
9289 } | 9292 } |
(...skipping 25 matching lines...) Expand all Loading... | |
9315 InputHandler::TOUCHSCREEN) | 9318 InputHandler::TOUCHSCREEN) |
9316 .thread); | 9319 .thread); |
9317 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9320 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9318 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9321 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
9319 scroll_layer->CurrentScrollOffset().ToString()); | 9322 scroll_layer->CurrentScrollOffset().ToString()); |
9320 | 9323 |
9321 // Scroll the browser controls partially. | 9324 // Scroll the browser controls partially. |
9322 const float residue = 15; | 9325 const float residue = 15; |
9323 float offset = top_controls_height_ - residue; | 9326 float offset = top_controls_height_ - residue; |
9324 EXPECT_TRUE( | 9327 EXPECT_TRUE( |
9325 host_impl_->ScrollBy( | 9328 host_impl_ |
9326 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9329 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9327 .did_scroll); | 9330 .did_scroll); |
9328 EXPECT_FLOAT_EQ(-offset, | 9331 EXPECT_FLOAT_EQ(-offset, |
9329 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9332 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9330 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9333 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
9331 scroll_layer->CurrentScrollOffset().ToString()); | 9334 scroll_layer->CurrentScrollOffset().ToString()); |
9332 | 9335 |
9333 did_request_redraw_ = false; | 9336 did_request_redraw_ = false; |
9334 did_request_next_frame_ = false; | 9337 did_request_next_frame_ = false; |
9335 did_request_commit_ = false; | 9338 did_request_commit_ = false; |
9336 | 9339 |
9337 // End the fling while the controls are still offset from the limit. | 9340 // End the fling while the controls are still offset from the limit. |
9338 host_impl_->MainThreadHasStoppedFlinging(); | 9341 host_impl_->MainThreadHasStoppedFlinging(); |
9339 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9342 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9340 EXPECT_TRUE(did_request_next_frame_); | 9343 EXPECT_TRUE(did_request_next_frame_); |
9341 EXPECT_TRUE(did_request_redraw_); | 9344 EXPECT_TRUE(did_request_redraw_); |
9342 EXPECT_FALSE(did_request_commit_); | 9345 EXPECT_FALSE(did_request_commit_); |
9343 | 9346 |
9344 // Animate the browser controls to the limit. | 9347 // Animate the browser controls to the limit. |
9345 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9348 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9346 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9349 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9347 while (did_request_next_frame_) { | 9350 while (did_request_next_frame_) { |
9348 did_request_redraw_ = false; | 9351 did_request_redraw_ = false; |
9349 did_request_next_frame_ = false; | 9352 did_request_next_frame_ = false; |
9350 did_request_commit_ = false; | 9353 did_request_commit_ = false; |
9351 | 9354 |
9352 float old_offset = | 9355 float old_offset = |
9353 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9356 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9354 | 9357 |
9355 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9358 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
9359 begin_frame_args.sequence_number++; | |
9356 host_impl_->WillBeginImplFrame(begin_frame_args); | 9360 host_impl_->WillBeginImplFrame(begin_frame_args); |
9357 host_impl_->Animate(); | 9361 host_impl_->Animate(); |
9358 | 9362 |
9359 float new_offset = | 9363 float new_offset = |
9360 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9364 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9361 | 9365 |
9362 if (new_offset != old_offset) { | 9366 if (new_offset != old_offset) { |
9363 EXPECT_TRUE(did_request_redraw_); | 9367 EXPECT_TRUE(did_request_redraw_); |
9364 EXPECT_TRUE(did_request_commit_); | 9368 EXPECT_TRUE(did_request_commit_); |
9365 } | 9369 } |
(...skipping 18 matching lines...) Expand all Loading... | |
9384 | 9388 |
9385 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9389 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9386 host_impl_ | 9390 host_impl_ |
9387 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9391 ->ScrollBegin(BeginState(gfx::Point()).get(), |
9388 InputHandler::TOUCHSCREEN) | 9392 InputHandler::TOUCHSCREEN) |
9389 .thread); | 9393 .thread); |
9390 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9394 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9391 | 9395 |
9392 float offset = 50; | 9396 float offset = 50; |
9393 EXPECT_TRUE( | 9397 EXPECT_TRUE( |
9394 host_impl_->ScrollBy( | 9398 host_impl_ |
9395 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9399 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9396 .did_scroll); | 9400 .did_scroll); |
9397 EXPECT_EQ(-offset, | 9401 EXPECT_EQ(-offset, |
9398 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9402 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9399 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9403 EXPECT_EQ(gfx::Vector2dF().ToString(), |
9400 scroll_layer->CurrentScrollOffset().ToString()); | 9404 scroll_layer->CurrentScrollOffset().ToString()); |
9401 | 9405 |
9402 EXPECT_TRUE( | 9406 EXPECT_TRUE( |
9403 host_impl_->ScrollBy( | 9407 host_impl_ |
9404 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9408 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9405 .did_scroll); | 9409 .did_scroll); |
9406 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 9410 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
9407 scroll_layer->CurrentScrollOffset().ToString()); | 9411 scroll_layer->CurrentScrollOffset().ToString()); |
9408 | 9412 |
9409 EXPECT_TRUE( | 9413 EXPECT_TRUE( |
9410 host_impl_->ScrollBy( | 9414 host_impl_ |
9411 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9415 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
9412 .did_scroll); | 9416 .did_scroll); |
9413 | 9417 |
9414 // Should have fully scrolled | 9418 // Should have fully scrolled |
9415 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | 9419 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
9416 scroll_layer->CurrentScrollOffset().ToString()); | 9420 scroll_layer->CurrentScrollOffset().ToString()); |
9417 | 9421 |
9418 float overscrollamount = 10; | 9422 float overscrollamount = 10; |
9419 | 9423 |
9420 // Overscroll the content | 9424 // Overscroll the content |
9421 EXPECT_FALSE( | 9425 EXPECT_FALSE(host_impl_ |
9422 host_impl_->ScrollBy(UpdateState(gfx::Point(), | 9426 ->ScrollBy(UpdateState(gfx::Point(), |
9423 gfx::Vector2d(0, overscrollamount)) | 9427 gfx::Vector2d(0, overscrollamount)) |
9424 .get()) | 9428 .get()) |
9425 .did_scroll); | 9429 .did_scroll); |
9426 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | 9430 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
9427 scroll_layer->CurrentScrollOffset().ToString()); | 9431 scroll_layer->CurrentScrollOffset().ToString()); |
9428 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 9432 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
9429 host_impl_->accumulated_root_overscroll().ToString()); | 9433 host_impl_->accumulated_root_overscroll().ToString()); |
9430 | 9434 |
9431 EXPECT_TRUE(host_impl_->ScrollBy(UpdateState(gfx::Point(), | 9435 EXPECT_TRUE( |
9432 gfx::Vector2d(0, -2 * offset)) | 9436 host_impl_ |
9433 .get()) | 9437 ->ScrollBy( |
9434 .did_scroll); | 9438 UpdateState(gfx::Point(), gfx::Vector2d(0, -2 * offset)).get()) |
9439 .did_scroll); | |
9435 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9440 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
9436 scroll_layer->CurrentScrollOffset().ToString()); | 9441 scroll_layer->CurrentScrollOffset().ToString()); |
9437 EXPECT_EQ(-offset, | 9442 EXPECT_EQ(-offset, |
9438 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9443 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9439 | 9444 |
9440 EXPECT_TRUE( | 9445 EXPECT_TRUE( |
9441 host_impl_->ScrollBy( | 9446 host_impl_ |
9442 UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) | 9447 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) |
9443 .did_scroll); | 9448 .did_scroll); |
9444 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9449 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
9445 scroll_layer->CurrentScrollOffset().ToString()); | 9450 scroll_layer->CurrentScrollOffset().ToString()); |
9446 | 9451 |
9447 // Browser controls should be fully visible | 9452 // Browser controls should be fully visible |
9448 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9453 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
9449 | 9454 |
9450 host_impl_->ScrollEnd(EndState().get()); | 9455 host_impl_->ScrollEnd(EndState().get()); |
9451 } | 9456 } |
9452 | 9457 |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10283 const gfx::Size content_size(1000, 1000); | 10288 const gfx::Size content_size(1000, 1000); |
10284 const gfx::Size viewport_size(50, 100); | 10289 const gfx::Size viewport_size(50, 100); |
10285 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10290 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10286 | 10291 |
10287 DrawFrame(); | 10292 DrawFrame(); |
10288 | 10293 |
10289 base::TimeTicks start_time = | 10294 base::TimeTicks start_time = |
10290 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10295 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10291 | 10296 |
10292 BeginFrameArgs begin_frame_args = | 10297 BeginFrameArgs begin_frame_args = |
10293 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10298 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10294 | 10299 |
10295 EXPECT_EQ( | 10300 EXPECT_EQ( |
10296 InputHandler::SCROLL_ON_IMPL_THREAD, | 10301 InputHandler::SCROLL_ON_IMPL_THREAD, |
10297 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10302 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10298 | 10303 |
10299 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10304 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10300 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10305 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10301 | 10306 |
10302 begin_frame_args.frame_time = start_time; | 10307 begin_frame_args.frame_time = start_time; |
10308 begin_frame_args.sequence_number++; | |
10303 host_impl_->WillBeginImplFrame(begin_frame_args); | 10309 host_impl_->WillBeginImplFrame(begin_frame_args); |
10304 host_impl_->Animate(); | 10310 host_impl_->Animate(); |
10305 host_impl_->UpdateAnimationState(true); | 10311 host_impl_->UpdateAnimationState(true); |
10306 | 10312 |
10307 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10313 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10308 host_impl_->DidFinishImplFrame(); | 10314 host_impl_->DidFinishImplFrame(); |
10309 | 10315 |
10310 begin_frame_args.frame_time = | 10316 begin_frame_args.frame_time = |
10311 start_time + base::TimeDelta::FromMilliseconds(50); | 10317 start_time + base::TimeDelta::FromMilliseconds(50); |
10318 begin_frame_args.sequence_number++; | |
10312 host_impl_->WillBeginImplFrame(begin_frame_args); | 10319 host_impl_->WillBeginImplFrame(begin_frame_args); |
10313 host_impl_->Animate(); | 10320 host_impl_->Animate(); |
10314 host_impl_->UpdateAnimationState(true); | 10321 host_impl_->UpdateAnimationState(true); |
10315 | 10322 |
10316 float y = scrolling_layer->CurrentScrollOffset().y(); | 10323 float y = scrolling_layer->CurrentScrollOffset().y(); |
10317 EXPECT_TRUE(y > 1 && y < 49); | 10324 EXPECT_TRUE(y > 1 && y < 49); |
10318 | 10325 |
10319 // Update target. | 10326 // Update target. |
10320 EXPECT_EQ( | 10327 EXPECT_EQ( |
10321 InputHandler::SCROLL_ON_IMPL_THREAD, | 10328 InputHandler::SCROLL_ON_IMPL_THREAD, |
10322 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10329 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10323 host_impl_->DidFinishImplFrame(); | 10330 host_impl_->DidFinishImplFrame(); |
10324 | 10331 |
10325 begin_frame_args.frame_time = | 10332 begin_frame_args.frame_time = |
10326 start_time + base::TimeDelta::FromMilliseconds(200); | 10333 start_time + base::TimeDelta::FromMilliseconds(200); |
10334 begin_frame_args.sequence_number++; | |
10327 host_impl_->WillBeginImplFrame(begin_frame_args); | 10335 host_impl_->WillBeginImplFrame(begin_frame_args); |
10328 host_impl_->Animate(); | 10336 host_impl_->Animate(); |
10329 host_impl_->UpdateAnimationState(true); | 10337 host_impl_->UpdateAnimationState(true); |
10330 | 10338 |
10331 y = scrolling_layer->CurrentScrollOffset().y(); | 10339 y = scrolling_layer->CurrentScrollOffset().y(); |
10332 EXPECT_TRUE(y > 50 && y < 100); | 10340 EXPECT_TRUE(y > 50 && y < 100); |
10333 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10341 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10334 host_impl_->DidFinishImplFrame(); | 10342 host_impl_->DidFinishImplFrame(); |
10335 | 10343 |
10336 begin_frame_args.frame_time = | 10344 begin_frame_args.frame_time = |
10337 start_time + base::TimeDelta::FromMilliseconds(250); | 10345 start_time + base::TimeDelta::FromMilliseconds(250); |
10346 begin_frame_args.sequence_number++; | |
10338 host_impl_->WillBeginImplFrame(begin_frame_args); | 10347 host_impl_->WillBeginImplFrame(begin_frame_args); |
10339 host_impl_->Animate(); | 10348 host_impl_->Animate(); |
10340 host_impl_->UpdateAnimationState(true); | 10349 host_impl_->UpdateAnimationState(true); |
10341 | 10350 |
10342 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10351 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10343 scrolling_layer->CurrentScrollOffset()); | 10352 scrolling_layer->CurrentScrollOffset()); |
10344 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10353 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10345 host_impl_->DidFinishImplFrame(); | 10354 host_impl_->DidFinishImplFrame(); |
10346 } | 10355 } |
10347 | 10356 |
(...skipping 16 matching lines...) Expand all Loading... | |
10364 const gfx::Size content_size(1000, 1000); | 10373 const gfx::Size content_size(1000, 1000); |
10365 const gfx::Size viewport_size(50, 100); | 10374 const gfx::Size viewport_size(50, 100); |
10366 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10375 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10367 | 10376 |
10368 DrawFrame(); | 10377 DrawFrame(); |
10369 | 10378 |
10370 base::TimeTicks start_time = | 10379 base::TimeTicks start_time = |
10371 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); | 10380 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); |
10372 | 10381 |
10373 BeginFrameArgs begin_frame_args = | 10382 BeginFrameArgs begin_frame_args = |
10374 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10383 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10375 begin_frame_args.frame_time = start_time; | 10384 begin_frame_args.frame_time = start_time; |
10385 begin_frame_args.sequence_number++; | |
10376 host_impl_->WillBeginImplFrame(begin_frame_args); | 10386 host_impl_->WillBeginImplFrame(begin_frame_args); |
10377 host_impl_->UpdateAnimationState(true); | 10387 host_impl_->UpdateAnimationState(true); |
10378 host_impl_->DidFinishImplFrame(); | 10388 host_impl_->DidFinishImplFrame(); |
10379 | 10389 |
10380 EXPECT_EQ( | 10390 EXPECT_EQ( |
10381 InputHandler::SCROLL_ON_IMPL_THREAD, | 10391 InputHandler::SCROLL_ON_IMPL_THREAD, |
10382 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10392 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10383 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation | 10393 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation |
10384 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and | 10394 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and |
10385 // doesn't have a start time. | 10395 // doesn't have a start time. |
10386 EXPECT_EQ( | 10396 EXPECT_EQ( |
10387 InputHandler::SCROLL_ON_IMPL_THREAD, | 10397 InputHandler::SCROLL_ON_IMPL_THREAD, |
10388 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10398 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
10389 | 10399 |
10390 begin_frame_args.frame_time = | 10400 begin_frame_args.frame_time = |
10391 start_time + base::TimeDelta::FromMilliseconds(250); | 10401 start_time + base::TimeDelta::FromMilliseconds(250); |
10402 begin_frame_args.sequence_number++; | |
10392 // This is when the animation above gets promoted to STARTING. | 10403 // This is when the animation above gets promoted to STARTING. |
10393 host_impl_->WillBeginImplFrame(begin_frame_args); | 10404 host_impl_->WillBeginImplFrame(begin_frame_args); |
10394 host_impl_->UpdateAnimationState(true); | 10405 host_impl_->UpdateAnimationState(true); |
10395 host_impl_->DidFinishImplFrame(); | 10406 host_impl_->DidFinishImplFrame(); |
10396 | 10407 |
10397 begin_frame_args.frame_time = | 10408 begin_frame_args.frame_time = |
10398 start_time + base::TimeDelta::FromMilliseconds(300); | 10409 start_time + base::TimeDelta::FromMilliseconds(300); |
10410 begin_frame_args.sequence_number++; | |
10399 // This is when the animation above gets ticked. | 10411 // This is when the animation above gets ticked. |
10400 host_impl_->WillBeginImplFrame(begin_frame_args); | 10412 host_impl_->WillBeginImplFrame(begin_frame_args); |
10401 host_impl_->UpdateAnimationState(true); | 10413 host_impl_->UpdateAnimationState(true); |
10402 host_impl_->DidFinishImplFrame(); | 10414 host_impl_->DidFinishImplFrame(); |
10403 | 10415 |
10404 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10416 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10405 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10417 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10406 | 10418 |
10407 // Verify no jump. | 10419 // Verify no jump. |
10408 float y = scrolling_layer->CurrentScrollOffset().y(); | 10420 float y = scrolling_layer->CurrentScrollOffset().y(); |
10409 EXPECT_TRUE(y > 1 && y < 49); | 10421 EXPECT_TRUE(y > 1 && y < 49); |
10410 } | 10422 } |
10411 | 10423 |
10412 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { | 10424 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { |
10413 const gfx::Size content_size(1000, 1000); | 10425 const gfx::Size content_size(1000, 1000); |
10414 const gfx::Size viewport_size(50, 100); | 10426 const gfx::Size viewport_size(50, 100); |
10415 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10427 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10416 | 10428 |
10417 DrawFrame(); | 10429 DrawFrame(); |
10418 | 10430 |
10419 base::TimeTicks start_time = | 10431 base::TimeTicks start_time = |
10420 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10432 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10421 BeginFrameArgs begin_frame_args = | 10433 BeginFrameArgs begin_frame_args = |
10422 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10434 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10423 | 10435 |
10424 // Create animation with a 100ms delay. | 10436 // Create animation with a 100ms delay. |
10425 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10437 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10426 host_impl_ | 10438 host_impl_ |
10427 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10439 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
10428 base::TimeDelta::FromMilliseconds(100)) | 10440 base::TimeDelta::FromMilliseconds(100)) |
10429 .thread); | 10441 .thread); |
10430 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10442 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10431 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10443 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10432 | 10444 |
10433 // First tick, animation is started. | 10445 // First tick, animation is started. |
10434 begin_frame_args.frame_time = start_time; | 10446 begin_frame_args.frame_time = start_time; |
10447 begin_frame_args.sequence_number++; | |
10435 host_impl_->WillBeginImplFrame(begin_frame_args); | 10448 host_impl_->WillBeginImplFrame(begin_frame_args); |
10436 host_impl_->UpdateAnimationState(true); | 10449 host_impl_->UpdateAnimationState(true); |
10437 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10450 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10438 host_impl_->DidFinishImplFrame(); | 10451 host_impl_->DidFinishImplFrame(); |
10439 | 10452 |
10440 // Second tick after 50ms, animation should be half way done since | 10453 // Second tick after 50ms, animation should be half way done since |
10441 // the duration due to delay is 100ms. | 10454 // the duration due to delay is 100ms. |
10442 begin_frame_args.frame_time = | 10455 begin_frame_args.frame_time = |
10443 start_time + base::TimeDelta::FromMilliseconds(50); | 10456 start_time + base::TimeDelta::FromMilliseconds(50); |
10457 begin_frame_args.sequence_number++; | |
10444 host_impl_->WillBeginImplFrame(begin_frame_args); | 10458 host_impl_->WillBeginImplFrame(begin_frame_args); |
10445 host_impl_->UpdateAnimationState(true); | 10459 host_impl_->UpdateAnimationState(true); |
10446 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); | 10460 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); |
10447 host_impl_->DidFinishImplFrame(); | 10461 host_impl_->DidFinishImplFrame(); |
10448 | 10462 |
10449 // Update target. | 10463 // Update target. |
10450 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10464 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10451 host_impl_ | 10465 host_impl_ |
10452 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10466 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
10453 base::TimeDelta::FromMilliseconds(150)) | 10467 base::TimeDelta::FromMilliseconds(150)) |
10454 .thread); | 10468 .thread); |
10455 | 10469 |
10456 // Third tick after 100ms, should be at the target position since update | 10470 // Third tick after 100ms, should be at the target position since update |
10457 // target was called with a large value of jank. | 10471 // target was called with a large value of jank. |
10458 begin_frame_args.frame_time = | 10472 begin_frame_args.frame_time = |
10459 start_time + base::TimeDelta::FromMilliseconds(100); | 10473 start_time + base::TimeDelta::FromMilliseconds(100); |
10474 begin_frame_args.sequence_number++; | |
10460 host_impl_->WillBeginImplFrame(begin_frame_args); | 10475 host_impl_->WillBeginImplFrame(begin_frame_args); |
10461 host_impl_->UpdateAnimationState(true); | 10476 host_impl_->UpdateAnimationState(true); |
10462 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); | 10477 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); |
10463 } | 10478 } |
10464 | 10479 |
10465 // Test that a smooth scroll offset animation is aborted when followed by a | 10480 // Test that a smooth scroll offset animation is aborted when followed by a |
10466 // non-smooth scroll offset animation. | 10481 // non-smooth scroll offset animation. |
10467 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { | 10482 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { |
10468 const gfx::Size content_size(1000, 1000); | 10483 const gfx::Size content_size(1000, 1000); |
10469 const gfx::Size viewport_size(500, 500); | 10484 const gfx::Size viewport_size(500, 500); |
10470 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10485 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10471 | 10486 |
10472 DrawFrame(); | 10487 DrawFrame(); |
10473 | 10488 |
10474 base::TimeTicks start_time = | 10489 base::TimeTicks start_time = |
10475 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10490 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10476 | 10491 |
10477 BeginFrameArgs begin_frame_args = | 10492 BeginFrameArgs begin_frame_args = |
10478 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10493 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10479 | 10494 |
10480 // Perform animated scroll. | 10495 // Perform animated scroll. |
10481 EXPECT_EQ( | 10496 EXPECT_EQ( |
10482 InputHandler::SCROLL_ON_IMPL_THREAD, | 10497 InputHandler::SCROLL_ON_IMPL_THREAD, |
10483 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10498 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10484 | 10499 |
10485 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10500 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10486 | 10501 |
10487 begin_frame_args.frame_time = start_time; | 10502 begin_frame_args.frame_time = start_time; |
10503 begin_frame_args.sequence_number++; | |
10488 host_impl_->WillBeginImplFrame(begin_frame_args); | 10504 host_impl_->WillBeginImplFrame(begin_frame_args); |
10489 host_impl_->Animate(); | 10505 host_impl_->Animate(); |
10490 host_impl_->UpdateAnimationState(true); | 10506 host_impl_->UpdateAnimationState(true); |
10491 | 10507 |
10492 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10508 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
10493 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10509 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
10494 | 10510 |
10495 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10511 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10496 host_impl_->DidFinishImplFrame(); | 10512 host_impl_->DidFinishImplFrame(); |
10497 | 10513 |
10498 begin_frame_args.frame_time = | 10514 begin_frame_args.frame_time = |
10499 start_time + base::TimeDelta::FromMilliseconds(50); | 10515 start_time + base::TimeDelta::FromMilliseconds(50); |
10516 begin_frame_args.sequence_number++; | |
10500 host_impl_->WillBeginImplFrame(begin_frame_args); | 10517 host_impl_->WillBeginImplFrame(begin_frame_args); |
10501 host_impl_->Animate(); | 10518 host_impl_->Animate(); |
10502 host_impl_->UpdateAnimationState(true); | 10519 host_impl_->UpdateAnimationState(true); |
10503 | 10520 |
10504 float y = scrolling_layer->CurrentScrollOffset().y(); | 10521 float y = scrolling_layer->CurrentScrollOffset().y(); |
10505 EXPECT_TRUE(y > 1 && y < 49); | 10522 EXPECT_TRUE(y > 1 && y < 49); |
10506 | 10523 |
10507 // Perform instant scroll. | 10524 // Perform instant scroll. |
10508 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10525 EXPECT_EQ( |
10509 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), | 10526 InputHandler::SCROLL_ON_IMPL_THREAD, |
brianderson
2016/12/15 22:10:33
There's a lot of unrelated whitespace / formatting
Eric Seckler
2016/12/16 17:25:58
Sorry about that, must have accidentally formatted
| |
10510 InputHandler::WHEEL) | 10527 host_impl_ |
10511 .thread); | 10528 ->ScrollBegin(BeginState(gfx::Point(0, y)).get(), InputHandler::WHEEL) |
10529 .thread); | |
10512 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 10530 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
10513 InputHandler::WHEEL)); | 10531 InputHandler::WHEEL)); |
10514 host_impl_->ScrollBy( | 10532 host_impl_->ScrollBy( |
10515 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 10533 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
10516 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 10534 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
10517 InputHandler::WHEEL)); | 10535 InputHandler::WHEEL)); |
10518 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 10536 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
10519 host_impl_->ScrollEnd(scroll_state_end.get()); | 10537 host_impl_->ScrollEnd(scroll_state_end.get()); |
10520 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10538 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
10521 InputHandler::WHEEL)); | 10539 InputHandler::WHEEL)); |
(...skipping 17 matching lines...) Expand all Loading... | |
10539 const gfx::Size content_size(1000, 1000); | 10557 const gfx::Size content_size(1000, 1000); |
10540 const gfx::Size viewport_size(500, 500); | 10558 const gfx::Size viewport_size(500, 500); |
10541 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10559 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10542 | 10560 |
10543 DrawFrame(); | 10561 DrawFrame(); |
10544 | 10562 |
10545 base::TimeTicks start_time = | 10563 base::TimeTicks start_time = |
10546 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10564 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10547 | 10565 |
10548 BeginFrameArgs begin_frame_args = | 10566 BeginFrameArgs begin_frame_args = |
10549 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10567 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10550 | 10568 |
10551 // Perform animated scroll. | 10569 // Perform animated scroll. |
10552 EXPECT_EQ( | 10570 EXPECT_EQ( |
10553 InputHandler::SCROLL_ON_IMPL_THREAD, | 10571 InputHandler::SCROLL_ON_IMPL_THREAD, |
10554 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10572 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
10555 | 10573 |
10556 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10574 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10557 | 10575 |
10558 begin_frame_args.frame_time = start_time; | 10576 begin_frame_args.frame_time = start_time; |
10577 begin_frame_args.sequence_number++; | |
10559 host_impl_->WillBeginImplFrame(begin_frame_args); | 10578 host_impl_->WillBeginImplFrame(begin_frame_args); |
10560 host_impl_->Animate(); | 10579 host_impl_->Animate(); |
10561 host_impl_->UpdateAnimationState(true); | 10580 host_impl_->UpdateAnimationState(true); |
10562 | 10581 |
10563 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10582 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
10564 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10583 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
10565 | 10584 |
10566 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10585 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10567 host_impl_->DidFinishImplFrame(); | 10586 host_impl_->DidFinishImplFrame(); |
10568 | 10587 |
10569 begin_frame_args.frame_time = | 10588 begin_frame_args.frame_time = |
10570 start_time + base::TimeDelta::FromMilliseconds(50); | 10589 start_time + base::TimeDelta::FromMilliseconds(50); |
10590 begin_frame_args.sequence_number++; | |
10571 host_impl_->WillBeginImplFrame(begin_frame_args); | 10591 host_impl_->WillBeginImplFrame(begin_frame_args); |
10572 host_impl_->Animate(); | 10592 host_impl_->Animate(); |
10573 host_impl_->UpdateAnimationState(true); | 10593 host_impl_->UpdateAnimationState(true); |
10574 | 10594 |
10575 float y = scrolling_layer->CurrentScrollOffset().y(); | 10595 float y = scrolling_layer->CurrentScrollOffset().y(); |
10576 EXPECT_TRUE(y > 1 && y < 49); | 10596 EXPECT_TRUE(y > 1 && y < 49); |
10577 | 10597 |
10578 // Abort animation. | 10598 // Abort animation. |
10579 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); | 10599 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); |
10580 host_impl_->UpdateAnimationState(true); | 10600 host_impl_->UpdateAnimationState(true); |
(...skipping 12 matching lines...) Expand all Loading... | |
10593 const gfx::Size content_size(1000, 1000); | 10613 const gfx::Size content_size(1000, 1000); |
10594 const gfx::Size viewport_size(500, 500); | 10614 const gfx::Size viewport_size(500, 500); |
10595 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10615 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10596 | 10616 |
10597 DrawFrame(); | 10617 DrawFrame(); |
10598 | 10618 |
10599 base::TimeTicks start_time = | 10619 base::TimeTicks start_time = |
10600 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10620 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10601 | 10621 |
10602 BeginFrameArgs begin_frame_args = | 10622 BeginFrameArgs begin_frame_args = |
10603 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10623 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10604 | 10624 |
10605 EXPECT_EQ( | 10625 EXPECT_EQ( |
10606 InputHandler::SCROLL_ON_IMPL_THREAD, | 10626 InputHandler::SCROLL_ON_IMPL_THREAD, |
10607 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10627 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10608 | 10628 |
10609 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10629 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10610 begin_frame_args.frame_time = start_time; | 10630 begin_frame_args.frame_time = start_time; |
10631 begin_frame_args.sequence_number++; | |
10611 host_impl_->WillBeginImplFrame(begin_frame_args); | 10632 host_impl_->WillBeginImplFrame(begin_frame_args); |
10612 host_impl_->Animate(); | 10633 host_impl_->Animate(); |
10613 host_impl_->UpdateAnimationState(true); | 10634 host_impl_->UpdateAnimationState(true); |
10614 | 10635 |
10615 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10636 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10616 host_impl_->DidFinishImplFrame(); | 10637 host_impl_->DidFinishImplFrame(); |
10617 | 10638 |
10618 begin_frame_args.frame_time = | 10639 begin_frame_args.frame_time = |
10619 start_time + base::TimeDelta::FromMilliseconds(50); | 10640 start_time + base::TimeDelta::FromMilliseconds(50); |
10641 begin_frame_args.sequence_number++; | |
10620 host_impl_->WillBeginImplFrame(begin_frame_args); | 10642 host_impl_->WillBeginImplFrame(begin_frame_args); |
10621 host_impl_->Animate(); | 10643 host_impl_->Animate(); |
10622 host_impl_->UpdateAnimationState(true); | 10644 host_impl_->UpdateAnimationState(true); |
10623 | 10645 |
10624 float y = scrolling_layer->CurrentScrollOffset().y(); | 10646 float y = scrolling_layer->CurrentScrollOffset().y(); |
10625 EXPECT_TRUE(y > 1 && y < 49); | 10647 EXPECT_TRUE(y > 1 && y < 49); |
10626 | 10648 |
10627 // Update target. | 10649 // Update target. |
10628 EXPECT_EQ( | 10650 EXPECT_EQ( |
10629 InputHandler::SCROLL_ON_IMPL_THREAD, | 10651 InputHandler::SCROLL_ON_IMPL_THREAD, |
10630 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10652 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10631 host_impl_->DidFinishImplFrame(); | 10653 host_impl_->DidFinishImplFrame(); |
10632 | 10654 |
10633 begin_frame_args.frame_time = | 10655 begin_frame_args.frame_time = |
10634 start_time + base::TimeDelta::FromMilliseconds(200); | 10656 start_time + base::TimeDelta::FromMilliseconds(200); |
10657 begin_frame_args.sequence_number++; | |
10635 host_impl_->WillBeginImplFrame(begin_frame_args); | 10658 host_impl_->WillBeginImplFrame(begin_frame_args); |
10636 host_impl_->Animate(); | 10659 host_impl_->Animate(); |
10637 host_impl_->UpdateAnimationState(true); | 10660 host_impl_->UpdateAnimationState(true); |
10638 | 10661 |
10639 y = scrolling_layer->CurrentScrollOffset().y(); | 10662 y = scrolling_layer->CurrentScrollOffset().y(); |
10640 EXPECT_TRUE(y > 50 && y < 100); | 10663 EXPECT_TRUE(y > 50 && y < 100); |
10641 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10664 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10642 host_impl_->DidFinishImplFrame(); | 10665 host_impl_->DidFinishImplFrame(); |
10643 | 10666 |
10644 begin_frame_args.frame_time = | 10667 begin_frame_args.frame_time = |
10645 start_time + base::TimeDelta::FromMilliseconds(250); | 10668 start_time + base::TimeDelta::FromMilliseconds(250); |
10669 begin_frame_args.sequence_number++; | |
10646 host_impl_->WillBeginImplFrame(begin_frame_args); | 10670 host_impl_->WillBeginImplFrame(begin_frame_args); |
10647 host_impl_->Animate(); | 10671 host_impl_->Animate(); |
10648 host_impl_->UpdateAnimationState(true); | 10672 host_impl_->UpdateAnimationState(true); |
10649 | 10673 |
10650 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10674 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10651 scrolling_layer->CurrentScrollOffset()); | 10675 scrolling_layer->CurrentScrollOffset()); |
10652 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10676 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10653 host_impl_->DidFinishImplFrame(); | 10677 host_impl_->DidFinishImplFrame(); |
10654 } | 10678 } |
10655 | 10679 |
(...skipping 13 matching lines...) Expand all Loading... | |
10669 float page_scale_factor = 2.f; | 10693 float page_scale_factor = 2.f; |
10670 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10694 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10671 page_scale_factor, min_page_scale, max_page_scale); | 10695 page_scale_factor, min_page_scale, max_page_scale); |
10672 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10696 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10673 | 10697 |
10674 // Scroll by a small amount, there should be no bubbling to the outer | 10698 // Scroll by a small amount, there should be no bubbling to the outer |
10675 // viewport. | 10699 // viewport. |
10676 base::TimeTicks start_time = | 10700 base::TimeTicks start_time = |
10677 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10701 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
10678 BeginFrameArgs begin_frame_args = | 10702 BeginFrameArgs begin_frame_args = |
10679 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10703 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10680 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10704 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10681 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 10705 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
10682 .thread); | 10706 .thread); |
10683 host_impl_->Animate(); | 10707 host_impl_->Animate(); |
10684 host_impl_->UpdateAnimationState(true); | 10708 host_impl_->UpdateAnimationState(true); |
10685 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10709 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
10686 | 10710 |
10687 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10711 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
10688 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10712 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
10689 inner_scroll_layer->CurrentScrollOffset()); | 10713 inner_scroll_layer->CurrentScrollOffset()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10757 float min_page_scale = 1.f, max_page_scale = 4.f; | 10781 float min_page_scale = 1.f, max_page_scale = 4.f; |
10758 float page_scale_factor = 2.f; | 10782 float page_scale_factor = 2.f; |
10759 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10783 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10760 page_scale_factor, min_page_scale, max_page_scale); | 10784 page_scale_factor, min_page_scale, max_page_scale); |
10761 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10785 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10762 | 10786 |
10763 // Scroll the inner viewport. | 10787 // Scroll the inner viewport. |
10764 base::TimeTicks start_time = | 10788 base::TimeTicks start_time = |
10765 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10789 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
10766 BeginFrameArgs begin_frame_args = | 10790 BeginFrameArgs begin_frame_args = |
10767 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10791 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10768 EXPECT_EQ( | 10792 EXPECT_EQ( |
10769 InputHandler::SCROLL_ON_IMPL_THREAD, | 10793 InputHandler::SCROLL_ON_IMPL_THREAD, |
10770 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); | 10794 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); |
10771 host_impl_->Animate(); | 10795 host_impl_->Animate(); |
10772 host_impl_->UpdateAnimationState(true); | 10796 host_impl_->UpdateAnimationState(true); |
10773 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10797 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
10774 | 10798 |
10775 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10799 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
10776 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); | 10800 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); |
10777 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); | 10801 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10809 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); | 10833 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); |
10810 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); | 10834 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); |
10811 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10835 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
10812 | 10836 |
10813 DrawFrame(); | 10837 DrawFrame(); |
10814 | 10838 |
10815 base::TimeTicks start_time = | 10839 base::TimeTicks start_time = |
10816 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10840 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10817 | 10841 |
10818 BeginFrameArgs begin_frame_args = | 10842 BeginFrameArgs begin_frame_args = |
10819 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10843 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10820 | 10844 |
10821 EXPECT_EQ( | 10845 EXPECT_EQ( |
10822 InputHandler::SCROLL_ON_IMPL_THREAD, | 10846 InputHandler::SCROLL_ON_IMPL_THREAD, |
10823 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10847 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
10824 | 10848 |
10825 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10849 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10826 begin_frame_args.frame_time = start_time; | 10850 begin_frame_args.frame_time = start_time; |
10851 begin_frame_args.sequence_number++; | |
10827 host_impl_->WillBeginImplFrame(begin_frame_args); | 10852 host_impl_->WillBeginImplFrame(begin_frame_args); |
10828 host_impl_->Animate(); | 10853 host_impl_->Animate(); |
10829 host_impl_->UpdateAnimationState(true); | 10854 host_impl_->UpdateAnimationState(true); |
10830 | 10855 |
10831 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10856 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10832 host_impl_->DidFinishImplFrame(); | 10857 host_impl_->DidFinishImplFrame(); |
10833 | 10858 |
10834 begin_frame_args.frame_time = | 10859 begin_frame_args.frame_time = |
10835 start_time + base::TimeDelta::FromMilliseconds(50); | 10860 start_time + base::TimeDelta::FromMilliseconds(50); |
10861 begin_frame_args.sequence_number++; | |
10836 host_impl_->WillBeginImplFrame(begin_frame_args); | 10862 host_impl_->WillBeginImplFrame(begin_frame_args); |
10837 host_impl_->Animate(); | 10863 host_impl_->Animate(); |
10838 host_impl_->UpdateAnimationState(true); | 10864 host_impl_->UpdateAnimationState(true); |
10839 | 10865 |
10840 // Should not have scrolled horizontally. | 10866 // Should not have scrolled horizontally. |
10841 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); | 10867 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); |
10842 float y = scrolling_layer->CurrentScrollOffset().y(); | 10868 float y = scrolling_layer->CurrentScrollOffset().y(); |
10843 EXPECT_TRUE(y > 1 && y < 49); | 10869 EXPECT_TRUE(y > 1 && y < 49); |
10844 | 10870 |
10845 // Update target. | 10871 // Update target. |
10846 EXPECT_EQ( | 10872 EXPECT_EQ( |
10847 InputHandler::SCROLL_ON_IMPL_THREAD, | 10873 InputHandler::SCROLL_ON_IMPL_THREAD, |
10848 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10874 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
10849 host_impl_->DidFinishImplFrame(); | 10875 host_impl_->DidFinishImplFrame(); |
10850 | 10876 |
10851 begin_frame_args.frame_time = | 10877 begin_frame_args.frame_time = |
10852 start_time + base::TimeDelta::FromMilliseconds(200); | 10878 start_time + base::TimeDelta::FromMilliseconds(200); |
10879 begin_frame_args.sequence_number++; | |
10853 host_impl_->WillBeginImplFrame(begin_frame_args); | 10880 host_impl_->WillBeginImplFrame(begin_frame_args); |
10854 host_impl_->Animate(); | 10881 host_impl_->Animate(); |
10855 host_impl_->UpdateAnimationState(true); | 10882 host_impl_->UpdateAnimationState(true); |
10856 | 10883 |
10857 y = scrolling_layer->CurrentScrollOffset().y(); | 10884 y = scrolling_layer->CurrentScrollOffset().y(); |
10858 EXPECT_TRUE(y > 50 && y < 100); | 10885 EXPECT_TRUE(y > 50 && y < 100); |
10859 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10886 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10860 host_impl_->DidFinishImplFrame(); | 10887 host_impl_->DidFinishImplFrame(); |
10861 | 10888 |
10862 begin_frame_args.frame_time = | 10889 begin_frame_args.frame_time = |
10863 start_time + base::TimeDelta::FromMilliseconds(250); | 10890 start_time + base::TimeDelta::FromMilliseconds(250); |
10891 begin_frame_args.sequence_number++; | |
10864 host_impl_->WillBeginImplFrame(begin_frame_args); | 10892 host_impl_->WillBeginImplFrame(begin_frame_args); |
10865 host_impl_->Animate(); | 10893 host_impl_->Animate(); |
10866 host_impl_->UpdateAnimationState(true); | 10894 host_impl_->UpdateAnimationState(true); |
10867 | 10895 |
10868 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10896 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10869 scrolling_layer->CurrentScrollOffset()); | 10897 scrolling_layer->CurrentScrollOffset()); |
10870 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10898 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10871 host_impl_->DidFinishImplFrame(); | 10899 host_impl_->DidFinishImplFrame(); |
10872 } | 10900 } |
10873 | 10901 |
10874 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10902 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
10875 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10903 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
10876 const gfx::Size old_content_size(1000, 1000); | 10904 const gfx::Size old_content_size(1000, 1000); |
10877 const gfx::Size new_content_size(750, 750); | 10905 const gfx::Size new_content_size(750, 750); |
10878 const gfx::Size viewport_size(500, 500); | 10906 const gfx::Size viewport_size(500, 500); |
10879 | 10907 |
10880 LayerImpl* content_layer = | 10908 LayerImpl* content_layer = |
10881 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10909 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
10882 | 10910 |
10883 DrawFrame(); | 10911 DrawFrame(); |
10884 | 10912 |
10885 base::TimeTicks start_time = | 10913 base::TimeTicks start_time = |
10886 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10914 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10887 BeginFrameArgs begin_frame_args = | 10915 BeginFrameArgs begin_frame_args = |
10888 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10916 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10889 | 10917 |
10890 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10918 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
10891 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10919 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10892 | 10920 |
10893 begin_frame_args.frame_time = start_time; | 10921 begin_frame_args.frame_time = start_time; |
10922 begin_frame_args.sequence_number++; | |
10894 host_impl_->WillBeginImplFrame(begin_frame_args); | 10923 host_impl_->WillBeginImplFrame(begin_frame_args); |
10895 host_impl_->Animate(); | 10924 host_impl_->Animate(); |
10896 host_impl_->UpdateAnimationState(true); | 10925 host_impl_->UpdateAnimationState(true); |
10897 host_impl_->DidFinishImplFrame(); | 10926 host_impl_->DidFinishImplFrame(); |
10898 | 10927 |
10899 content_layer->SetBounds(new_content_size); | 10928 content_layer->SetBounds(new_content_size); |
10900 scrolling_layer->SetBounds(new_content_size); | 10929 scrolling_layer->SetBounds(new_content_size); |
10901 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10930 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
10902 | 10931 |
10903 DrawFrame(); | 10932 DrawFrame(); |
10904 | 10933 |
10905 begin_frame_args.frame_time = | 10934 begin_frame_args.frame_time = |
10906 start_time + base::TimeDelta::FromMilliseconds(200); | 10935 start_time + base::TimeDelta::FromMilliseconds(200); |
10936 begin_frame_args.sequence_number++; | |
10907 host_impl_->WillBeginImplFrame(begin_frame_args); | 10937 host_impl_->WillBeginImplFrame(begin_frame_args); |
10908 host_impl_->Animate(); | 10938 host_impl_->Animate(); |
10909 host_impl_->UpdateAnimationState(true); | 10939 host_impl_->UpdateAnimationState(true); |
10910 host_impl_->DidFinishImplFrame(); | 10940 host_impl_->DidFinishImplFrame(); |
10911 | 10941 |
10912 EXPECT_EQ(gfx::ScrollOffset(250, 250), | 10942 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
10913 scrolling_layer->CurrentScrollOffset()); | 10943 scrolling_layer->CurrentScrollOffset()); |
10914 } | 10944 } |
10915 | 10945 |
10916 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 10946 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11009 | 11039 |
11010 float page_scale_delta = 2.f; | 11040 float page_scale_delta = 2.f; |
11011 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 11041 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
11012 InputHandler::TOUCHSCREEN); | 11042 InputHandler::TOUCHSCREEN); |
11013 host_impl_->PinchGestureBegin(); | 11043 host_impl_->PinchGestureBegin(); |
11014 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 11044 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
11015 host_impl_->PinchGestureEnd(); | 11045 host_impl_->PinchGestureEnd(); |
11016 host_impl_->ScrollEnd(EndState().get()); | 11046 host_impl_->ScrollEnd(EndState().get()); |
11017 | 11047 |
11018 gfx::Vector2dF scroll_delta(0, 5); | 11048 gfx::Vector2dF scroll_delta(0, 5); |
11019 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 11049 EXPECT_EQ( |
11020 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 11050 InputHandler::SCROLL_ON_IMPL_THREAD, |
11021 InputHandler::WHEEL) | 11051 host_impl_ |
11022 .thread); | 11052 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
11053 .thread); | |
11023 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 11054 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
11024 | 11055 |
11025 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 11056 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
11026 host_impl_->ScrollEnd(EndState().get()); | 11057 host_impl_->ScrollEnd(EndState().get()); |
11027 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 11058 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
11028 scroll_layer->CurrentScrollOffset()); | 11059 scroll_layer->CurrentScrollOffset()); |
11029 } | 11060 } |
11030 } | 11061 } |
11031 | 11062 |
11032 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 11063 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11186 | 11217 |
11187 bool did_draw_frame() const { return did_draw_frame_; } | 11218 bool did_draw_frame() const { return did_draw_frame_; } |
11188 | 11219 |
11189 private: | 11220 private: |
11190 BeginFrameArgs begin_frame_args_; | 11221 BeginFrameArgs begin_frame_args_; |
11191 bool did_draw_frame_ = false; | 11222 bool did_draw_frame_ = false; |
11192 }; | 11223 }; |
11193 | 11224 |
11194 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { | 11225 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { |
11195 BeginFrameArgs begin_frame_args = | 11226 BeginFrameArgs begin_frame_args = |
11196 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11227 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
11197 FakeVideoFrameController controller; | 11228 FakeVideoFrameController controller; |
11198 | 11229 |
11199 host_impl_->WillBeginImplFrame(begin_frame_args); | 11230 host_impl_->WillBeginImplFrame(begin_frame_args); |
11200 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11231 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11201 host_impl_->AddVideoFrameController(&controller); | 11232 host_impl_->AddVideoFrameController(&controller); |
11202 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11233 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
11203 host_impl_->DidFinishImplFrame(); | 11234 host_impl_->DidFinishImplFrame(); |
11204 | 11235 |
11205 EXPECT_FALSE(controller.did_draw_frame()); | 11236 EXPECT_FALSE(controller.did_draw_frame()); |
11206 LayerTreeHostImpl::FrameData frame; | 11237 LayerTreeHostImpl::FrameData frame; |
11207 host_impl_->DidDrawAllLayers(frame); | 11238 host_impl_->DidDrawAllLayers(frame); |
11208 EXPECT_TRUE(controller.did_draw_frame()); | 11239 EXPECT_TRUE(controller.did_draw_frame()); |
11209 | 11240 |
11210 controller.OnBeginFrame(begin_frame_args); | 11241 controller.OnBeginFrame(begin_frame_args); |
11211 EXPECT_FALSE(controller.did_draw_frame()); | 11242 EXPECT_FALSE(controller.did_draw_frame()); |
11212 host_impl_->RemoveVideoFrameController(&controller); | 11243 host_impl_->RemoveVideoFrameController(&controller); |
11213 host_impl_->DidDrawAllLayers(frame); | 11244 host_impl_->DidDrawAllLayers(frame); |
11214 EXPECT_FALSE(controller.did_draw_frame()); | 11245 EXPECT_FALSE(controller.did_draw_frame()); |
11215 } | 11246 } |
11216 | 11247 |
11217 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { | 11248 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { |
11218 BeginFrameArgs begin_frame_args = | 11249 BeginFrameArgs begin_frame_args = |
11219 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11250 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
11220 FakeVideoFrameController controller; | 11251 FakeVideoFrameController controller; |
11221 | 11252 |
11222 host_impl_->WillBeginImplFrame(begin_frame_args); | 11253 host_impl_->WillBeginImplFrame(begin_frame_args); |
11223 host_impl_->DidFinishImplFrame(); | 11254 host_impl_->DidFinishImplFrame(); |
11224 | 11255 |
11225 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11256 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11226 host_impl_->AddVideoFrameController(&controller); | 11257 host_impl_->AddVideoFrameController(&controller); |
11227 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11258 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11228 | 11259 |
11229 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11260 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3); |
11230 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11261 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11231 host_impl_->WillBeginImplFrame(begin_frame_args); | 11262 host_impl_->WillBeginImplFrame(begin_frame_args); |
11232 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11263 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
11233 | 11264 |
11234 EXPECT_FALSE(controller.did_draw_frame()); | 11265 EXPECT_FALSE(controller.did_draw_frame()); |
11235 LayerTreeHostImpl::FrameData frame; | 11266 LayerTreeHostImpl::FrameData frame; |
11236 host_impl_->DidDrawAllLayers(frame); | 11267 host_impl_->DidDrawAllLayers(frame); |
11237 EXPECT_TRUE(controller.did_draw_frame()); | 11268 EXPECT_TRUE(controller.did_draw_frame()); |
11238 | 11269 |
11239 controller.OnBeginFrame(begin_frame_args); | 11270 controller.OnBeginFrame(begin_frame_args); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11731 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11762 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11732 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11763 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11733 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11764 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11734 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11765 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11735 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11766 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11736 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11737 } | 11768 } |
11738 | 11769 |
11739 } // namespace | 11770 } // namespace |
11740 } // namespace cc | 11771 } // namespace cc |
OLD | NEW |