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 261 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++; |
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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 TransformOperations start; | 1339 TransformOperations start; |
1339 start.AppendTranslate(6.f, 7.f, 0.f); | 1340 start.AppendTranslate(6.f, 7.f, 0.f); |
1340 TransformOperations end; | 1341 TransformOperations end; |
1341 end.AppendTranslate(8.f, 9.f, 0.f); | 1342 end.AppendTranslate(8.f, 9.f, 0.f); |
1342 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1343 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
1343 start, end); | 1344 start, end); |
1344 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1345 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1345 | 1346 |
1346 base::TimeTicks now = base::TimeTicks::Now(); | 1347 base::TimeTicks now = base::TimeTicks::Now(); |
1347 host_impl_->WillBeginImplFrame( | 1348 host_impl_->WillBeginImplFrame( |
1348 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1349 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1349 | 1350 |
1350 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1351 // 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 | 1352 // 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. | 1353 // unless they are waiting for some future time to start. |
1353 EXPECT_TRUE(did_request_next_frame_); | 1354 EXPECT_TRUE(did_request_next_frame_); |
1354 EXPECT_TRUE(did_request_redraw_); | 1355 EXPECT_TRUE(did_request_redraw_); |
1355 EXPECT_FALSE(did_request_commit_); | 1356 EXPECT_FALSE(did_request_commit_); |
1356 did_request_next_frame_ = false; | 1357 did_request_next_frame_ = false; |
1357 did_request_redraw_ = false; | 1358 did_request_redraw_ = false; |
1358 did_request_commit_ = false; | 1359 did_request_commit_ = false; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 TransformOperations start; | 1451 TransformOperations start; |
1451 start.AppendTranslate(6.f, 7.f, 0.f); | 1452 start.AppendTranslate(6.f, 7.f, 0.f); |
1452 TransformOperations end; | 1453 TransformOperations end; |
1453 end.AppendTranslate(8.f, 9.f, 0.f); | 1454 end.AppendTranslate(8.f, 9.f, 0.f); |
1454 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1455 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
1455 start, end); | 1456 start, end); |
1456 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1457 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1457 | 1458 |
1458 base::TimeTicks now = base::TimeTicks::Now(); | 1459 base::TimeTicks now = base::TimeTicks::Now(); |
1459 host_impl_->WillBeginImplFrame( | 1460 host_impl_->WillBeginImplFrame( |
1460 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1461 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1461 EXPECT_TRUE(did_request_next_frame_); | 1462 EXPECT_TRUE(did_request_next_frame_); |
1462 did_request_next_frame_ = false; | 1463 did_request_next_frame_ = false; |
1463 | 1464 |
1464 host_impl_->ActivateAnimations(); | 1465 host_impl_->ActivateAnimations(); |
1465 // On activating an animation, we should request another frame so that we'll | 1466 // On activating an animation, we should request another frame so that we'll |
1466 // continue ticking the animation. | 1467 // continue ticking the animation. |
1467 EXPECT_TRUE(did_request_next_frame_); | 1468 EXPECT_TRUE(did_request_next_frame_); |
1468 did_request_next_frame_ = false; | 1469 did_request_next_frame_ = false; |
1469 | 1470 |
1470 // The next frame after activating, we'll tick the animation again. | 1471 // 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; | 1531 TransformOperations start; |
1531 start.AppendTranslate(6.f, 7.f, 0.f); | 1532 start.AppendTranslate(6.f, 7.f, 0.f); |
1532 TransformOperations end; | 1533 TransformOperations end; |
1533 end.AppendTranslate(8.f, 9.f, 0.f); | 1534 end.AppendTranslate(8.f, 9.f, 0.f); |
1534 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1535 int animation_id = AddAnimatedTransformToElementWithPlayer( |
1535 child->element_id(), timeline(), 4.0, start, end); | 1536 child->element_id(), timeline(), 4.0, start, end); |
1536 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1537 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1537 | 1538 |
1538 base::TimeTicks now = base::TimeTicks::Now(); | 1539 base::TimeTicks now = base::TimeTicks::Now(); |
1539 host_impl_->WillBeginImplFrame( | 1540 host_impl_->WillBeginImplFrame( |
1540 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1541 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1541 | 1542 |
1542 host_impl_->ActivateAnimations(); | 1543 host_impl_->ActivateAnimations(); |
1543 host_impl_->Animate(); | 1544 host_impl_->Animate(); |
1544 | 1545 |
1545 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1546 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1546 | 1547 |
1547 host_impl_->ResetRequiresHighResToDraw(); | 1548 host_impl_->ResetRequiresHighResToDraw(); |
1548 | 1549 |
1549 // Child layer has an animating transform but missing tiles. | 1550 // Child layer has an animating transform but missing tiles. |
1550 FakeLayerTreeHostImpl::FrameData frame; | 1551 FakeLayerTreeHostImpl::FrameData frame; |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2336 | 2337 |
2337 float min_page_scale = 0.5f; | 2338 float min_page_scale = 0.5f; |
2338 float max_page_scale = 4.f; | 2339 float max_page_scale = 4.f; |
2339 base::TimeTicks start_time = base::TimeTicks() + | 2340 base::TimeTicks start_time = base::TimeTicks() + |
2340 base::TimeDelta::FromSeconds(1); | 2341 base::TimeDelta::FromSeconds(1); |
2341 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2342 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2342 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2343 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2343 base::TimeTicks end_time = start_time + duration; | 2344 base::TimeTicks end_time = start_time + duration; |
2344 | 2345 |
2345 BeginFrameArgs begin_frame_args = | 2346 BeginFrameArgs begin_frame_args = |
2346 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2347 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2347 | 2348 |
2348 // Non-anchor zoom-in | 2349 // Non-anchor zoom-in |
2349 { | 2350 { |
2350 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2351 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2351 max_page_scale); | 2352 max_page_scale); |
2352 scroll_layer->layer_tree_impl() | 2353 scroll_layer->layer_tree_impl() |
2353 ->property_trees() | 2354 ->property_trees() |
2354 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2355 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2355 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2356 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2356 | 2357 |
2357 did_request_redraw_ = false; | 2358 did_request_redraw_ = false; |
2358 did_request_next_frame_ = false; | 2359 did_request_next_frame_ = false; |
2359 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2360 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2360 std::unique_ptr<PendingPageScaleAnimation>( | 2361 std::unique_ptr<PendingPageScaleAnimation>( |
2361 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, | 2362 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, |
2362 duration))); | 2363 duration))); |
2363 host_impl_->ActivateSyncTree(); | 2364 host_impl_->ActivateSyncTree(); |
2364 EXPECT_FALSE(did_request_redraw_); | 2365 EXPECT_FALSE(did_request_redraw_); |
2365 EXPECT_TRUE(did_request_next_frame_); | 2366 EXPECT_TRUE(did_request_next_frame_); |
2366 | 2367 |
2367 did_request_redraw_ = false; | 2368 did_request_redraw_ = false; |
2368 did_request_next_frame_ = false; | 2369 did_request_next_frame_ = false; |
2369 begin_frame_args.frame_time = start_time; | 2370 begin_frame_args.frame_time = start_time; |
| 2371 begin_frame_args.sequence_number++; |
2370 host_impl_->WillBeginImplFrame(begin_frame_args); | 2372 host_impl_->WillBeginImplFrame(begin_frame_args); |
2371 host_impl_->Animate(); | 2373 host_impl_->Animate(); |
2372 EXPECT_TRUE(did_request_redraw_); | 2374 EXPECT_TRUE(did_request_redraw_); |
2373 EXPECT_TRUE(did_request_next_frame_); | 2375 EXPECT_TRUE(did_request_next_frame_); |
2374 host_impl_->DidFinishImplFrame(); | 2376 host_impl_->DidFinishImplFrame(); |
2375 | 2377 |
2376 did_request_redraw_ = false; | 2378 did_request_redraw_ = false; |
2377 did_request_next_frame_ = false; | 2379 did_request_next_frame_ = false; |
2378 begin_frame_args.frame_time = halfway_through_animation; | 2380 begin_frame_args.frame_time = halfway_through_animation; |
| 2381 begin_frame_args.sequence_number++; |
2379 host_impl_->WillBeginImplFrame(begin_frame_args); | 2382 host_impl_->WillBeginImplFrame(begin_frame_args); |
2380 host_impl_->Animate(); | 2383 host_impl_->Animate(); |
2381 EXPECT_TRUE(did_request_redraw_); | 2384 EXPECT_TRUE(did_request_redraw_); |
2382 EXPECT_TRUE(did_request_next_frame_); | 2385 EXPECT_TRUE(did_request_next_frame_); |
2383 host_impl_->DidFinishImplFrame(); | 2386 host_impl_->DidFinishImplFrame(); |
2384 | 2387 |
2385 did_request_redraw_ = false; | 2388 did_request_redraw_ = false; |
2386 did_request_next_frame_ = false; | 2389 did_request_next_frame_ = false; |
2387 did_request_commit_ = false; | 2390 did_request_commit_ = false; |
2388 begin_frame_args.frame_time = end_time; | 2391 begin_frame_args.frame_time = end_time; |
| 2392 begin_frame_args.sequence_number++; |
2389 host_impl_->WillBeginImplFrame(begin_frame_args); | 2393 host_impl_->WillBeginImplFrame(begin_frame_args); |
2390 host_impl_->Animate(); | 2394 host_impl_->Animate(); |
2391 EXPECT_TRUE(did_request_commit_); | 2395 EXPECT_TRUE(did_request_commit_); |
2392 EXPECT_FALSE(did_request_next_frame_); | 2396 EXPECT_FALSE(did_request_next_frame_); |
2393 host_impl_->DidFinishImplFrame(); | 2397 host_impl_->DidFinishImplFrame(); |
2394 | 2398 |
2395 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2399 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2396 host_impl_->ProcessScrollDeltas(); | 2400 host_impl_->ProcessScrollDeltas(); |
2397 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 2401 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
2398 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2402 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
(...skipping 19 matching lines...) Expand all Loading... |
2418 std::unique_ptr<PendingPageScaleAnimation>( | 2422 std::unique_ptr<PendingPageScaleAnimation>( |
2419 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, | 2423 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, |
2420 min_page_scale, duration))); | 2424 min_page_scale, duration))); |
2421 host_impl_->ActivateSyncTree(); | 2425 host_impl_->ActivateSyncTree(); |
2422 EXPECT_FALSE(did_request_redraw_); | 2426 EXPECT_FALSE(did_request_redraw_); |
2423 EXPECT_TRUE(did_request_next_frame_); | 2427 EXPECT_TRUE(did_request_next_frame_); |
2424 | 2428 |
2425 did_request_redraw_ = false; | 2429 did_request_redraw_ = false; |
2426 did_request_next_frame_ = false; | 2430 did_request_next_frame_ = false; |
2427 begin_frame_args.frame_time = start_time; | 2431 begin_frame_args.frame_time = start_time; |
| 2432 begin_frame_args.sequence_number++; |
2428 host_impl_->WillBeginImplFrame(begin_frame_args); | 2433 host_impl_->WillBeginImplFrame(begin_frame_args); |
2429 host_impl_->Animate(); | 2434 host_impl_->Animate(); |
2430 EXPECT_TRUE(did_request_redraw_); | 2435 EXPECT_TRUE(did_request_redraw_); |
2431 EXPECT_TRUE(did_request_next_frame_); | 2436 EXPECT_TRUE(did_request_next_frame_); |
2432 host_impl_->DidFinishImplFrame(); | 2437 host_impl_->DidFinishImplFrame(); |
2433 | 2438 |
2434 did_request_redraw_ = false; | 2439 did_request_redraw_ = false; |
2435 did_request_commit_ = false; | 2440 did_request_commit_ = false; |
2436 did_request_next_frame_ = false; | 2441 did_request_next_frame_ = false; |
2437 begin_frame_args.frame_time = end_time; | 2442 begin_frame_args.frame_time = end_time; |
| 2443 begin_frame_args.sequence_number++; |
2438 host_impl_->WillBeginImplFrame(begin_frame_args); | 2444 host_impl_->WillBeginImplFrame(begin_frame_args); |
2439 host_impl_->Animate(); | 2445 host_impl_->Animate(); |
2440 EXPECT_TRUE(did_request_redraw_); | 2446 EXPECT_TRUE(did_request_redraw_); |
2441 EXPECT_FALSE(did_request_next_frame_); | 2447 EXPECT_FALSE(did_request_next_frame_); |
2442 EXPECT_TRUE(did_request_commit_); | 2448 EXPECT_TRUE(did_request_commit_); |
2443 host_impl_->DidFinishImplFrame(); | 2449 host_impl_->DidFinishImplFrame(); |
2444 | 2450 |
2445 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2451 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2446 host_impl_->ProcessScrollDeltas(); | 2452 host_impl_->ProcessScrollDeltas(); |
2447 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2453 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
(...skipping 13 matching lines...) Expand all Loading... |
2461 | 2467 |
2462 float min_page_scale = 0.5f; | 2468 float min_page_scale = 0.5f; |
2463 float max_page_scale = 4.f; | 2469 float max_page_scale = 4.f; |
2464 base::TimeTicks start_time = base::TimeTicks() + | 2470 base::TimeTicks start_time = base::TimeTicks() + |
2465 base::TimeDelta::FromSeconds(1); | 2471 base::TimeDelta::FromSeconds(1); |
2466 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2472 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2467 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2473 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2468 base::TimeTicks end_time = start_time + duration; | 2474 base::TimeTicks end_time = start_time + duration; |
2469 | 2475 |
2470 BeginFrameArgs begin_frame_args = | 2476 BeginFrameArgs begin_frame_args = |
2471 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2477 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2472 | 2478 |
2473 // Anchor zoom with unchanged page scale should not change scroll or scale. | 2479 // Anchor zoom with unchanged page scale should not change scroll or scale. |
2474 { | 2480 { |
2475 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2481 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2476 max_page_scale); | 2482 max_page_scale); |
2477 scroll_layer->layer_tree_impl() | 2483 scroll_layer->layer_tree_impl() |
2478 ->property_trees() | 2484 ->property_trees() |
2479 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2485 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
2480 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2486 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
2481 | 2487 |
2482 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2488 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2483 std::unique_ptr<PendingPageScaleAnimation>( | 2489 std::unique_ptr<PendingPageScaleAnimation>( |
2484 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, | 2490 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, |
2485 duration))); | 2491 duration))); |
2486 host_impl_->ActivateSyncTree(); | 2492 host_impl_->ActivateSyncTree(); |
2487 begin_frame_args.frame_time = start_time; | 2493 begin_frame_args.frame_time = start_time; |
| 2494 begin_frame_args.sequence_number++; |
2488 host_impl_->WillBeginImplFrame(begin_frame_args); | 2495 host_impl_->WillBeginImplFrame(begin_frame_args); |
2489 host_impl_->Animate(); | 2496 host_impl_->Animate(); |
2490 host_impl_->DidFinishImplFrame(); | 2497 host_impl_->DidFinishImplFrame(); |
2491 | 2498 |
2492 begin_frame_args.frame_time = halfway_through_animation; | 2499 begin_frame_args.frame_time = halfway_through_animation; |
| 2500 begin_frame_args.sequence_number++; |
2493 host_impl_->WillBeginImplFrame(begin_frame_args); | 2501 host_impl_->WillBeginImplFrame(begin_frame_args); |
2494 host_impl_->Animate(); | 2502 host_impl_->Animate(); |
2495 EXPECT_TRUE(did_request_redraw_); | 2503 EXPECT_TRUE(did_request_redraw_); |
2496 host_impl_->DidFinishImplFrame(); | 2504 host_impl_->DidFinishImplFrame(); |
2497 | 2505 |
2498 begin_frame_args.frame_time = end_time; | 2506 begin_frame_args.frame_time = end_time; |
| 2507 begin_frame_args.sequence_number++; |
2499 host_impl_->WillBeginImplFrame(begin_frame_args); | 2508 host_impl_->WillBeginImplFrame(begin_frame_args); |
2500 host_impl_->Animate(); | 2509 host_impl_->Animate(); |
2501 EXPECT_TRUE(did_request_commit_); | 2510 EXPECT_TRUE(did_request_commit_); |
2502 host_impl_->DidFinishImplFrame(); | 2511 host_impl_->DidFinishImplFrame(); |
2503 | 2512 |
2504 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2513 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2505 host_impl_->ProcessScrollDeltas(); | 2514 host_impl_->ProcessScrollDeltas(); |
2506 EXPECT_EQ(scroll_info->page_scale_delta, 1); | 2515 EXPECT_EQ(scroll_info->page_scale_delta, 1); |
2507 ExpectNone(*scroll_info, scroll_layer->id()); | 2516 ExpectNone(*scroll_info, scroll_layer->id()); |
2508 } | 2517 } |
(...skipping 20 matching lines...) Expand all Loading... |
2529 | 2538 |
2530 base::TimeTicks start_time = base::TimeTicks() + | 2539 base::TimeTicks start_time = base::TimeTicks() + |
2531 base::TimeDelta::FromSeconds(1); | 2540 base::TimeDelta::FromSeconds(1); |
2532 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2541 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2533 base::TimeTicks third_through_animation = start_time + duration / 3; | 2542 base::TimeTicks third_through_animation = start_time + duration / 3; |
2534 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2543 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2535 base::TimeTicks end_time = start_time + duration; | 2544 base::TimeTicks end_time = start_time + duration; |
2536 float target_scale = 2.f; | 2545 float target_scale = 2.f; |
2537 | 2546 |
2538 BeginFrameArgs begin_frame_args = | 2547 BeginFrameArgs begin_frame_args = |
2539 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2548 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2540 | 2549 |
2541 scroll_layer->layer_tree_impl() | 2550 scroll_layer->layer_tree_impl() |
2542 ->property_trees() | 2551 ->property_trees() |
2543 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2552 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2544 gfx::ScrollOffset(50, 50)); | 2553 gfx::ScrollOffset(50, 50)); |
2545 | 2554 |
2546 // Make sure TakePageScaleAnimation works properly. | 2555 // Make sure TakePageScaleAnimation works properly. |
2547 | 2556 |
2548 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2557 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2549 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2558 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2550 gfx::Vector2d(), false, target_scale, duration))); | 2559 gfx::Vector2d(), false, target_scale, duration))); |
2551 std::unique_ptr<PendingPageScaleAnimation> psa = | 2560 std::unique_ptr<PendingPageScaleAnimation> psa = |
2552 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); | 2561 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); |
2553 EXPECT_EQ(target_scale, psa->scale); | 2562 EXPECT_EQ(target_scale, psa->scale); |
2554 EXPECT_EQ(duration, psa->duration); | 2563 EXPECT_EQ(duration, psa->duration); |
2555 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); | 2564 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); |
2556 | 2565 |
2557 // Recreate the PSA. Nothing should happen here since the tree containing the | 2566 // Recreate the PSA. Nothing should happen here since the tree containing the |
2558 // PSA hasn't been activated yet. | 2567 // PSA hasn't been activated yet. |
2559 did_request_redraw_ = false; | 2568 did_request_redraw_ = false; |
2560 did_request_next_frame_ = false; | 2569 did_request_next_frame_ = false; |
2561 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2570 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
2562 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2571 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2563 gfx::Vector2d(), false, target_scale, duration))); | 2572 gfx::Vector2d(), false, target_scale, duration))); |
2564 begin_frame_args.frame_time = halfway_through_animation; | 2573 begin_frame_args.frame_time = halfway_through_animation; |
| 2574 begin_frame_args.sequence_number++; |
2565 host_impl_->WillBeginImplFrame(begin_frame_args); | 2575 host_impl_->WillBeginImplFrame(begin_frame_args); |
2566 host_impl_->Animate(); | 2576 host_impl_->Animate(); |
2567 EXPECT_FALSE(did_request_next_frame_); | 2577 EXPECT_FALSE(did_request_next_frame_); |
2568 EXPECT_FALSE(did_request_redraw_); | 2578 EXPECT_FALSE(did_request_redraw_); |
2569 host_impl_->DidFinishImplFrame(); | 2579 host_impl_->DidFinishImplFrame(); |
2570 | 2580 |
2571 // Activate the sync tree. This should cause the animation to become enabled. | 2581 // Activate the sync tree. This should cause the animation to become enabled. |
2572 // It should also clear the pointer on the sync tree. | 2582 // It should also clear the pointer on the sync tree. |
2573 host_impl_->ActivateSyncTree(); | 2583 host_impl_->ActivateSyncTree(); |
2574 EXPECT_EQ(nullptr, | 2584 EXPECT_EQ(nullptr, |
2575 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); | 2585 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); |
2576 EXPECT_FALSE(did_request_redraw_); | 2586 EXPECT_FALSE(did_request_redraw_); |
2577 EXPECT_TRUE(did_request_next_frame_); | 2587 EXPECT_TRUE(did_request_next_frame_); |
2578 | 2588 |
2579 start_time += base::TimeDelta::FromSeconds(10); | 2589 start_time += base::TimeDelta::FromSeconds(10); |
2580 third_through_animation += base::TimeDelta::FromSeconds(10); | 2590 third_through_animation += base::TimeDelta::FromSeconds(10); |
2581 halfway_through_animation += base::TimeDelta::FromSeconds(10); | 2591 halfway_through_animation += base::TimeDelta::FromSeconds(10); |
2582 end_time += base::TimeDelta::FromSeconds(10); | 2592 end_time += base::TimeDelta::FromSeconds(10); |
2583 | 2593 |
2584 // From here on, make sure the animation runs as normal. | 2594 // From here on, make sure the animation runs as normal. |
2585 did_request_redraw_ = false; | 2595 did_request_redraw_ = false; |
2586 did_request_next_frame_ = false; | 2596 did_request_next_frame_ = false; |
2587 begin_frame_args.frame_time = start_time; | 2597 begin_frame_args.frame_time = start_time; |
| 2598 begin_frame_args.sequence_number++; |
2588 host_impl_->WillBeginImplFrame(begin_frame_args); | 2599 host_impl_->WillBeginImplFrame(begin_frame_args); |
2589 host_impl_->Animate(); | 2600 host_impl_->Animate(); |
2590 EXPECT_TRUE(did_request_redraw_); | 2601 EXPECT_TRUE(did_request_redraw_); |
2591 EXPECT_TRUE(did_request_next_frame_); | 2602 EXPECT_TRUE(did_request_next_frame_); |
2592 host_impl_->DidFinishImplFrame(); | 2603 host_impl_->DidFinishImplFrame(); |
2593 | 2604 |
2594 did_request_redraw_ = false; | 2605 did_request_redraw_ = false; |
2595 did_request_next_frame_ = false; | 2606 did_request_next_frame_ = false; |
2596 begin_frame_args.frame_time = third_through_animation; | 2607 begin_frame_args.frame_time = third_through_animation; |
| 2608 begin_frame_args.sequence_number++; |
2597 host_impl_->WillBeginImplFrame(begin_frame_args); | 2609 host_impl_->WillBeginImplFrame(begin_frame_args); |
2598 host_impl_->Animate(); | 2610 host_impl_->Animate(); |
2599 EXPECT_TRUE(did_request_redraw_); | 2611 EXPECT_TRUE(did_request_redraw_); |
2600 EXPECT_TRUE(did_request_next_frame_); | 2612 EXPECT_TRUE(did_request_next_frame_); |
2601 host_impl_->DidFinishImplFrame(); | 2613 host_impl_->DidFinishImplFrame(); |
2602 | 2614 |
2603 // Another activation shouldn't have any effect on the animation. | 2615 // Another activation shouldn't have any effect on the animation. |
2604 host_impl_->ActivateSyncTree(); | 2616 host_impl_->ActivateSyncTree(); |
2605 | 2617 |
2606 did_request_redraw_ = false; | 2618 did_request_redraw_ = false; |
2607 did_request_next_frame_ = false; | 2619 did_request_next_frame_ = false; |
2608 begin_frame_args.frame_time = halfway_through_animation; | 2620 begin_frame_args.frame_time = halfway_through_animation; |
| 2621 begin_frame_args.sequence_number++; |
2609 host_impl_->WillBeginImplFrame(begin_frame_args); | 2622 host_impl_->WillBeginImplFrame(begin_frame_args); |
2610 host_impl_->Animate(); | 2623 host_impl_->Animate(); |
2611 EXPECT_TRUE(did_request_redraw_); | 2624 EXPECT_TRUE(did_request_redraw_); |
2612 EXPECT_TRUE(did_request_next_frame_); | 2625 EXPECT_TRUE(did_request_next_frame_); |
2613 host_impl_->DidFinishImplFrame(); | 2626 host_impl_->DidFinishImplFrame(); |
2614 | 2627 |
2615 did_request_redraw_ = false; | 2628 did_request_redraw_ = false; |
2616 did_request_next_frame_ = false; | 2629 did_request_next_frame_ = false; |
2617 did_request_commit_ = false; | 2630 did_request_commit_ = false; |
2618 begin_frame_args.frame_time = end_time; | 2631 begin_frame_args.frame_time = end_time; |
| 2632 begin_frame_args.sequence_number++; |
2619 host_impl_->WillBeginImplFrame(begin_frame_args); | 2633 host_impl_->WillBeginImplFrame(begin_frame_args); |
2620 host_impl_->Animate(); | 2634 host_impl_->Animate(); |
2621 EXPECT_TRUE(did_request_commit_); | 2635 EXPECT_TRUE(did_request_commit_); |
2622 EXPECT_FALSE(did_request_next_frame_); | 2636 EXPECT_FALSE(did_request_next_frame_); |
2623 host_impl_->DidFinishImplFrame(); | 2637 host_impl_->DidFinishImplFrame(); |
2624 | 2638 |
2625 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2639 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
2626 host_impl_->ProcessScrollDeltas(); | 2640 host_impl_->ProcessScrollDeltas(); |
2627 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); | 2641 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); |
2628 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2642 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
2629 gfx::Vector2d(-50, -50))); | 2643 gfx::Vector2d(-50, -50))); |
2630 } | 2644 } |
2631 | 2645 |
2632 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { | 2646 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { |
2633 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2647 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2634 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2648 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2635 DrawFrame(); | 2649 DrawFrame(); |
2636 | 2650 |
2637 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2651 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2638 DCHECK(scroll_layer); | 2652 DCHECK(scroll_layer); |
2639 | 2653 |
2640 base::TimeTicks start_time = | 2654 base::TimeTicks start_time = |
2641 base::TimeTicks() + base::TimeDelta::FromSeconds(1); | 2655 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
2642 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2656 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
2643 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2657 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
2644 base::TimeTicks end_time = start_time + duration; | 2658 base::TimeTicks end_time = start_time + duration; |
2645 | 2659 |
2646 BeginFrameArgs begin_frame_args = | 2660 BeginFrameArgs begin_frame_args = |
2647 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2661 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
2648 | 2662 |
2649 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2663 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
2650 scroll_layer->layer_tree_impl() | 2664 scroll_layer->layer_tree_impl() |
2651 ->property_trees() | 2665 ->property_trees() |
2652 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2666 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
2653 gfx::ScrollOffset(50, 50)); | 2667 gfx::ScrollOffset(50, 50)); |
2654 | 2668 |
2655 did_complete_page_scale_animation_ = false; | 2669 did_complete_page_scale_animation_ = false; |
2656 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2670 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
2657 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2671 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
2658 gfx::Vector2d(), false, 2.f, duration))); | 2672 gfx::Vector2d(), false, 2.f, duration))); |
2659 host_impl_->ActivateSyncTree(); | 2673 host_impl_->ActivateSyncTree(); |
2660 begin_frame_args.frame_time = start_time; | 2674 begin_frame_args.frame_time = start_time; |
| 2675 begin_frame_args.sequence_number++; |
2661 host_impl_->WillBeginImplFrame(begin_frame_args); | 2676 host_impl_->WillBeginImplFrame(begin_frame_args); |
2662 host_impl_->Animate(); | 2677 host_impl_->Animate(); |
2663 EXPECT_FALSE(did_complete_page_scale_animation_); | 2678 EXPECT_FALSE(did_complete_page_scale_animation_); |
2664 host_impl_->DidFinishImplFrame(); | 2679 host_impl_->DidFinishImplFrame(); |
2665 | 2680 |
2666 begin_frame_args.frame_time = halfway_through_animation; | 2681 begin_frame_args.frame_time = halfway_through_animation; |
| 2682 begin_frame_args.sequence_number++; |
2667 host_impl_->WillBeginImplFrame(begin_frame_args); | 2683 host_impl_->WillBeginImplFrame(begin_frame_args); |
2668 host_impl_->Animate(); | 2684 host_impl_->Animate(); |
2669 EXPECT_FALSE(did_complete_page_scale_animation_); | 2685 EXPECT_FALSE(did_complete_page_scale_animation_); |
2670 host_impl_->DidFinishImplFrame(); | 2686 host_impl_->DidFinishImplFrame(); |
2671 | 2687 |
2672 begin_frame_args.frame_time = end_time; | 2688 begin_frame_args.frame_time = end_time; |
| 2689 begin_frame_args.sequence_number++; |
2673 host_impl_->WillBeginImplFrame(begin_frame_args); | 2690 host_impl_->WillBeginImplFrame(begin_frame_args); |
2674 host_impl_->Animate(); | 2691 host_impl_->Animate(); |
2675 EXPECT_TRUE(did_complete_page_scale_animation_); | 2692 EXPECT_TRUE(did_complete_page_scale_animation_); |
2676 host_impl_->DidFinishImplFrame(); | 2693 host_impl_->DidFinishImplFrame(); |
2677 } | 2694 } |
2678 | 2695 |
2679 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { | 2696 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { |
2680 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2697 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
2681 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2698 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
2682 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2699 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
(...skipping 30 matching lines...) Expand all Loading... |
2713 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 2730 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
2714 : LayerTreeHostImpl(settings, | 2731 : LayerTreeHostImpl(settings, |
2715 client, | 2732 client, |
2716 task_runner_provider, | 2733 task_runner_provider, |
2717 rendering_stats_instrumentation, | 2734 rendering_stats_instrumentation, |
2718 task_graph_runner, | 2735 task_graph_runner, |
2719 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 2736 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
2720 0) {} | 2737 0) {} |
2721 | 2738 |
2722 BeginFrameArgs CurrentBeginFrameArgs() const override { | 2739 BeginFrameArgs CurrentBeginFrameArgs() const override { |
2723 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 2740 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, |
2724 fake_current_physical_time_); | 2741 fake_current_physical_time_); |
2725 } | 2742 } |
2726 | 2743 |
2727 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 2744 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
2728 fake_current_physical_time_ = fake_now; | 2745 fake_current_physical_time_ = fake_now; |
2729 } | 2746 } |
2730 | 2747 |
2731 private: | 2748 private: |
2732 base::TimeTicks fake_current_physical_time_; | 2749 base::TimeTicks fake_current_physical_time_; |
2733 }; | 2750 }; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2817 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2801 InputHandler::WHEEL); | 2818 InputHandler::WHEEL); |
2802 host_impl_->ScrollEnd(EndState().get()); | 2819 host_impl_->ScrollEnd(EndState().get()); |
2803 EXPECT_FALSE(did_request_next_frame_); | 2820 EXPECT_FALSE(did_request_next_frame_); |
2804 EXPECT_FALSE(did_request_redraw_); | 2821 EXPECT_FALSE(did_request_redraw_); |
2805 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2822 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2806 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2823 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2807 | 2824 |
2808 // Before the scrollbar animation exists, we should not get redraws. | 2825 // Before the scrollbar animation exists, we should not get redraws. |
2809 BeginFrameArgs begin_frame_args = | 2826 BeginFrameArgs begin_frame_args = |
2810 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2827 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
2811 host_impl_->WillBeginImplFrame(begin_frame_args); | 2828 host_impl_->WillBeginImplFrame(begin_frame_args); |
2812 host_impl_->Animate(); | 2829 host_impl_->Animate(); |
2813 EXPECT_FALSE(did_request_next_frame_); | 2830 EXPECT_FALSE(did_request_next_frame_); |
2814 did_request_next_frame_ = false; | 2831 did_request_next_frame_ = false; |
2815 EXPECT_FALSE(did_request_redraw_); | 2832 EXPECT_FALSE(did_request_redraw_); |
2816 did_request_redraw_ = false; | 2833 did_request_redraw_ = false; |
2817 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2834 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2818 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2835 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2819 host_impl_->DidFinishImplFrame(); | 2836 host_impl_->DidFinishImplFrame(); |
2820 | 2837 |
(...skipping 16 matching lines...) Expand all Loading... |
2837 requested_animation_delay_); | 2854 requested_animation_delay_); |
2838 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2855 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
2839 } else { | 2856 } else { |
2840 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2857 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2841 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2858 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2842 } | 2859 } |
2843 | 2860 |
2844 if (expecting_animations) { | 2861 if (expecting_animations) { |
2845 // Before the scrollbar animation begins, we should not get redraws. | 2862 // Before the scrollbar animation begins, we should not get redraws. |
2846 begin_frame_args = | 2863 begin_frame_args = |
2847 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2864 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3, fake_now); |
2848 host_impl_->WillBeginImplFrame(begin_frame_args); | 2865 host_impl_->WillBeginImplFrame(begin_frame_args); |
2849 host_impl_->Animate(); | 2866 host_impl_->Animate(); |
2850 EXPECT_FALSE(did_request_next_frame_); | 2867 EXPECT_FALSE(did_request_next_frame_); |
2851 did_request_next_frame_ = false; | 2868 did_request_next_frame_ = false; |
2852 EXPECT_FALSE(did_request_redraw_); | 2869 EXPECT_FALSE(did_request_redraw_); |
2853 did_request_redraw_ = false; | 2870 did_request_redraw_ = false; |
2854 host_impl_->DidFinishImplFrame(); | 2871 host_impl_->DidFinishImplFrame(); |
2855 | 2872 |
2856 // Start the scrollbar animation. | 2873 // Start the scrollbar animation. |
2857 fake_now += requested_animation_delay_; | 2874 fake_now += requested_animation_delay_; |
2858 requested_animation_delay_ = base::TimeDelta(); | 2875 requested_animation_delay_ = base::TimeDelta(); |
2859 animation_task_.Run(); | 2876 animation_task_.Run(); |
2860 animation_task_ = base::Closure(); | 2877 animation_task_ = base::Closure(); |
2861 EXPECT_TRUE(did_request_next_frame_); | 2878 EXPECT_TRUE(did_request_next_frame_); |
2862 did_request_next_frame_ = false; | 2879 did_request_next_frame_ = false; |
2863 EXPECT_FALSE(did_request_redraw_); | 2880 EXPECT_FALSE(did_request_redraw_); |
2864 | 2881 |
2865 // After the scrollbar animation begins, we should start getting redraws. | 2882 // After the scrollbar animation begins, we should start getting redraws. |
2866 begin_frame_args = | 2883 begin_frame_args = |
2867 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2884 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 4, fake_now); |
2868 host_impl_->WillBeginImplFrame(begin_frame_args); | 2885 host_impl_->WillBeginImplFrame(begin_frame_args); |
2869 host_impl_->Animate(); | 2886 host_impl_->Animate(); |
2870 EXPECT_TRUE(did_request_next_frame_); | 2887 EXPECT_TRUE(did_request_next_frame_); |
2871 did_request_next_frame_ = false; | 2888 did_request_next_frame_ = false; |
2872 EXPECT_TRUE(did_request_redraw_); | 2889 EXPECT_TRUE(did_request_redraw_); |
2873 did_request_redraw_ = false; | 2890 did_request_redraw_ = false; |
2874 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2891 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2875 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2892 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2876 host_impl_->DidFinishImplFrame(); | 2893 host_impl_->DidFinishImplFrame(); |
2877 } | 2894 } |
(...skipping 17 matching lines...) Expand all Loading... |
2895 animation_task_ = base::Closure(); | 2912 animation_task_ = base::Closure(); |
2896 } else { | 2913 } else { |
2897 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2914 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
2898 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2915 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
2899 } | 2916 } |
2900 | 2917 |
2901 if (expecting_animations) { | 2918 if (expecting_animations) { |
2902 // Scrolling should have stopped the animation, so we should not be | 2919 // Scrolling should have stopped the animation, so we should not be |
2903 // getting redraws. | 2920 // getting redraws. |
2904 begin_frame_args = | 2921 begin_frame_args = |
2905 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2922 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); |
2906 host_impl_->WillBeginImplFrame(begin_frame_args); | 2923 host_impl_->WillBeginImplFrame(begin_frame_args); |
2907 host_impl_->Animate(); | 2924 host_impl_->Animate(); |
2908 EXPECT_FALSE(did_request_next_frame_); | 2925 EXPECT_FALSE(did_request_next_frame_); |
2909 did_request_next_frame_ = false; | 2926 did_request_next_frame_ = false; |
2910 EXPECT_FALSE(did_request_redraw_); | 2927 EXPECT_FALSE(did_request_redraw_); |
2911 did_request_redraw_ = false; | 2928 did_request_redraw_ = false; |
2912 host_impl_->DidFinishImplFrame(); | 2929 host_impl_->DidFinishImplFrame(); |
2913 } | 2930 } |
2914 | 2931 |
2915 // Scrollbar animation is not triggered unnecessarily. | 2932 // Scrollbar animation is not triggered unnecessarily. |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4819 ASSERT_FLOAT_EQ(0, | 4836 ASSERT_FLOAT_EQ(0, |
4820 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4837 host_impl_->browser_controls_manager()->ContentTopOffset()); |
4821 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); | 4838 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); |
4822 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); | 4839 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); |
4823 | 4840 |
4824 // Kick off an animation to show the browser controls. | 4841 // Kick off an animation to show the browser controls. |
4825 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( | 4842 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
4826 BOTH, SHOWN, true); | 4843 BOTH, SHOWN, true); |
4827 base::TimeTicks start_time = base::TimeTicks::Now(); | 4844 base::TimeTicks start_time = base::TimeTicks::Now(); |
4828 BeginFrameArgs begin_frame_args = | 4845 BeginFrameArgs begin_frame_args = |
4829 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 4846 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
4830 | 4847 |
4831 // Pump an animation frame to put some delta in the browser controls. | 4848 // Pump an animation frame to put some delta in the browser controls. |
4832 { | 4849 { |
4833 begin_frame_args.frame_time = | 4850 begin_frame_args.frame_time = |
4834 start_time + base::TimeDelta::FromMilliseconds(50); | 4851 start_time + base::TimeDelta::FromMilliseconds(50); |
| 4852 begin_frame_args.sequence_number++; |
4835 host_impl_->WillBeginImplFrame(begin_frame_args); | 4853 host_impl_->WillBeginImplFrame(begin_frame_args); |
4836 host_impl_->Animate(); | 4854 host_impl_->Animate(); |
4837 host_impl_->UpdateAnimationState(true); | 4855 host_impl_->UpdateAnimationState(true); |
4838 host_impl_->DidFinishImplFrame(); | 4856 host_impl_->DidFinishImplFrame(); |
4839 } | 4857 } |
4840 | 4858 |
4841 // Pull the browser controls delta and get it back to the pending tree so that | 4859 // 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 | 4860 // when we go to activate the pending tree we cause a change to browser |
4843 // controls. | 4861 // controls. |
4844 { | 4862 { |
4845 float delta = | 4863 float delta = |
4846 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); | 4864 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); |
4847 ASSERT_GT(delta, 0); | 4865 ASSERT_GT(delta, 0); |
4848 ASSERT_LT(delta, 1); | 4866 ASSERT_LT(delta, 1); |
4849 host_impl_->active_tree() | 4867 host_impl_->active_tree() |
4850 ->top_controls_shown_ratio() | 4868 ->top_controls_shown_ratio() |
4851 ->PullDeltaForMainThread(); | 4869 ->PullDeltaForMainThread(); |
4852 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4870 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
4853 delta); | 4871 delta); |
4854 } | 4872 } |
4855 | 4873 |
4856 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so | 4874 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so |
4857 // the browser controls should be fully animated in this frame. | 4875 // the browser controls should be fully animated in this frame. |
4858 { | 4876 { |
4859 begin_frame_args.frame_time = | 4877 begin_frame_args.frame_time = |
4860 start_time + base::TimeDelta::FromMilliseconds(200); | 4878 start_time + base::TimeDelta::FromMilliseconds(200); |
| 4879 begin_frame_args.sequence_number++; |
4861 host_impl_->WillBeginImplFrame(begin_frame_args); | 4880 host_impl_->WillBeginImplFrame(begin_frame_args); |
4862 host_impl_->Animate(); | 4881 host_impl_->Animate(); |
4863 host_impl_->UpdateAnimationState(true); | 4882 host_impl_->UpdateAnimationState(true); |
4864 host_impl_->DidFinishImplFrame(); | 4883 host_impl_->DidFinishImplFrame(); |
4865 | 4884 |
4866 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); | 4885 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); |
4867 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); | 4886 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); |
4868 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we | 4887 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we |
4869 // lose some precision in the intermediate animation steps. | 4888 // lose some precision in the intermediate animation steps. |
4870 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); | 4889 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7576 LayerTreeSettings settings = DefaultSettings(); | 7595 LayerTreeSettings settings = DefaultSettings(); |
7577 settings.renderer_settings.partial_swap_enabled = true; | 7596 settings.renderer_settings.partial_swap_enabled = true; |
7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7597 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7579 LayerTreeHostImpl::Create( | 7598 LayerTreeHostImpl::Create( |
7580 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7599 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7581 &task_graph_runner_, | 7600 &task_graph_runner_, |
7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7601 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7583 layer_tree_host_impl->SetVisible(true); | 7602 layer_tree_host_impl->SetVisible(true); |
7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7603 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
7585 layer_tree_host_impl->WillBeginImplFrame( | 7604 layer_tree_host_impl->WillBeginImplFrame( |
7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7605 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7606 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
7588 | 7607 |
7589 std::unique_ptr<LayerImpl> root = | 7608 std::unique_ptr<LayerImpl> root = |
7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7609 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
7591 root->test_properties()->force_render_surface = true; | 7610 root->test_properties()->force_render_surface = true; |
7592 std::unique_ptr<LayerImpl> child = | 7611 std::unique_ptr<LayerImpl> child = |
7593 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 7612 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
7594 child->SetPosition(gfx::PointF(12.f, 13.f)); | 7613 child->SetPosition(gfx::PointF(12.f, 13.f)); |
7595 child->SetBounds(gfx::Size(14, 15)); | 7614 child->SetBounds(gfx::Size(14, 15)); |
7596 child->SetDrawsContent(true); | 7615 child->SetDrawsContent(true); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7705 RenderingStatsInstrumentation* stats_instrumentation, | 7724 RenderingStatsInstrumentation* stats_instrumentation, |
7706 CompositorFrameSink* compositor_frame_sink) { | 7725 CompositorFrameSink* compositor_frame_sink) { |
7707 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7726 settings.renderer_settings.partial_swap_enabled = partial_swap; |
7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7727 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
7709 settings, client, task_runner_provider, stats_instrumentation, | 7728 settings, client, task_runner_provider, stats_instrumentation, |
7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 7729 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
7711 0); | 7730 0); |
7712 my_host_impl->SetVisible(true); | 7731 my_host_impl->SetVisible(true); |
7713 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7732 my_host_impl->InitializeRenderer(compositor_frame_sink); |
7714 my_host_impl->WillBeginImplFrame( | 7733 my_host_impl->WillBeginImplFrame( |
7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7734 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7735 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
7717 | 7736 |
7718 /* | 7737 /* |
7719 Layers are created as follows: | 7738 Layers are created as follows: |
7720 | 7739 |
7721 +--------------------+ | 7740 +--------------------+ |
7722 | 1 | | 7741 | 1 | |
7723 | +-----------+ | | 7742 | +-----------+ | |
7724 | | 2 | | | 7743 | | 2 | | |
7725 | | +-------------------+ | 7744 | | +-------------------+ |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8970 | 8989 |
8971 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; | 8990 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; |
8972 | 8991 |
8973 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { | 8992 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { |
8974 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8993 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8975 scroll_layer->layer_tree_impl() | 8994 scroll_layer->layer_tree_impl() |
8976 ->property_trees() | 8995 ->property_trees() |
8977 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8996 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
8978 gfx::ScrollOffset(0, 10)); | 8997 gfx::ScrollOffset(0, 10)); |
8979 BeginFrameArgs begin_frame_args = | 8998 BeginFrameArgs begin_frame_args = |
8980 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 8999 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
8981 host_impl_->WillBeginImplFrame(begin_frame_args); | 9000 host_impl_->WillBeginImplFrame(begin_frame_args); |
8982 host_impl_->Animate(); | 9001 host_impl_->Animate(); |
8983 EXPECT_FALSE(did_request_redraw_); | 9002 EXPECT_FALSE(did_request_redraw_); |
8984 host_impl_->DidFinishImplFrame(); | 9003 host_impl_->DidFinishImplFrame(); |
8985 } | 9004 } |
8986 | 9005 |
8987 TEST_F(LayerTreeHostImplWithBrowserControlsTest, | 9006 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
8988 BrowserControlsHeightIsCommitted) { | 9007 BrowserControlsHeightIsCommitted) { |
8989 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 9008 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
8990 EXPECT_FALSE(did_request_redraw_); | 9009 EXPECT_FALSE(did_request_redraw_); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9177 // End the scroll while the controls are still offset from their limit. | 9196 // End the scroll while the controls are still offset from their limit. |
9178 host_impl_->ScrollEnd(EndState().get()); | 9197 host_impl_->ScrollEnd(EndState().get()); |
9179 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9198 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9180 EXPECT_TRUE(did_request_next_frame_); | 9199 EXPECT_TRUE(did_request_next_frame_); |
9181 EXPECT_TRUE(did_request_redraw_); | 9200 EXPECT_TRUE(did_request_redraw_); |
9182 EXPECT_FALSE(did_request_commit_); | 9201 EXPECT_FALSE(did_request_commit_); |
9183 | 9202 |
9184 // The browser controls should properly animate until finished, despite the | 9203 // The browser controls should properly animate until finished, despite the |
9185 // scroll offset being at the origin. | 9204 // scroll offset being at the origin. |
9186 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9205 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9187 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9206 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9188 while (did_request_next_frame_) { | 9207 while (did_request_next_frame_) { |
9189 did_request_redraw_ = false; | 9208 did_request_redraw_ = false; |
9190 did_request_next_frame_ = false; | 9209 did_request_next_frame_ = false; |
9191 did_request_commit_ = false; | 9210 did_request_commit_ = false; |
9192 | 9211 |
9193 float old_offset = | 9212 float old_offset = |
9194 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9213 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9195 | 9214 |
9196 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9215 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9216 begin_frame_args.sequence_number++; |
9197 host_impl_->WillBeginImplFrame(begin_frame_args); | 9217 host_impl_->WillBeginImplFrame(begin_frame_args); |
9198 host_impl_->Animate(); | 9218 host_impl_->Animate(); |
9199 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9219 EXPECT_EQ(gfx::Vector2dF().ToString(), |
9200 scroll_layer->CurrentScrollOffset().ToString()); | 9220 scroll_layer->CurrentScrollOffset().ToString()); |
9201 | 9221 |
9202 float new_offset = | 9222 float new_offset = |
9203 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9223 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9204 | 9224 |
9205 // No commit is needed as the controls are animating the content offset, | 9225 // No commit is needed as the controls are animating the content offset, |
9206 // not the scroll offset. | 9226 // not the scroll offset. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9260 | 9280 |
9261 // End the scroll while the controls are still offset from the limit. | 9281 // End the scroll while the controls are still offset from the limit. |
9262 host_impl_->ScrollEnd(EndState().get()); | 9282 host_impl_->ScrollEnd(EndState().get()); |
9263 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9283 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9264 EXPECT_TRUE(did_request_next_frame_); | 9284 EXPECT_TRUE(did_request_next_frame_); |
9265 EXPECT_TRUE(did_request_redraw_); | 9285 EXPECT_TRUE(did_request_redraw_); |
9266 EXPECT_FALSE(did_request_commit_); | 9286 EXPECT_FALSE(did_request_commit_); |
9267 | 9287 |
9268 // Animate the browser controls to the limit. | 9288 // Animate the browser controls to the limit. |
9269 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9289 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9270 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9290 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9271 while (did_request_next_frame_) { | 9291 while (did_request_next_frame_) { |
9272 did_request_redraw_ = false; | 9292 did_request_redraw_ = false; |
9273 did_request_next_frame_ = false; | 9293 did_request_next_frame_ = false; |
9274 did_request_commit_ = false; | 9294 did_request_commit_ = false; |
9275 | 9295 |
9276 float old_offset = | 9296 float old_offset = |
9277 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9297 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9278 | 9298 |
9279 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9299 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9300 begin_frame_args.sequence_number++; |
9280 host_impl_->WillBeginImplFrame(begin_frame_args); | 9301 host_impl_->WillBeginImplFrame(begin_frame_args); |
9281 host_impl_->Animate(); | 9302 host_impl_->Animate(); |
9282 | 9303 |
9283 float new_offset = | 9304 float new_offset = |
9284 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9305 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9285 | 9306 |
9286 if (new_offset != old_offset) { | 9307 if (new_offset != old_offset) { |
9287 EXPECT_TRUE(did_request_redraw_); | 9308 EXPECT_TRUE(did_request_redraw_); |
9288 EXPECT_TRUE(did_request_commit_); | 9309 EXPECT_TRUE(did_request_commit_); |
9289 } | 9310 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9336 | 9357 |
9337 // End the fling while the controls are still offset from the limit. | 9358 // End the fling while the controls are still offset from the limit. |
9338 host_impl_->MainThreadHasStoppedFlinging(); | 9359 host_impl_->MainThreadHasStoppedFlinging(); |
9339 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9360 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
9340 EXPECT_TRUE(did_request_next_frame_); | 9361 EXPECT_TRUE(did_request_next_frame_); |
9341 EXPECT_TRUE(did_request_redraw_); | 9362 EXPECT_TRUE(did_request_redraw_); |
9342 EXPECT_FALSE(did_request_commit_); | 9363 EXPECT_FALSE(did_request_commit_); |
9343 | 9364 |
9344 // Animate the browser controls to the limit. | 9365 // Animate the browser controls to the limit. |
9345 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9366 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
9346 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9367 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
9347 while (did_request_next_frame_) { | 9368 while (did_request_next_frame_) { |
9348 did_request_redraw_ = false; | 9369 did_request_redraw_ = false; |
9349 did_request_next_frame_ = false; | 9370 did_request_next_frame_ = false; |
9350 did_request_commit_ = false; | 9371 did_request_commit_ = false; |
9351 | 9372 |
9352 float old_offset = | 9373 float old_offset = |
9353 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9374 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9354 | 9375 |
9355 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9376 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9377 begin_frame_args.sequence_number++; |
9356 host_impl_->WillBeginImplFrame(begin_frame_args); | 9378 host_impl_->WillBeginImplFrame(begin_frame_args); |
9357 host_impl_->Animate(); | 9379 host_impl_->Animate(); |
9358 | 9380 |
9359 float new_offset = | 9381 float new_offset = |
9360 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9382 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
9361 | 9383 |
9362 if (new_offset != old_offset) { | 9384 if (new_offset != old_offset) { |
9363 EXPECT_TRUE(did_request_redraw_); | 9385 EXPECT_TRUE(did_request_redraw_); |
9364 EXPECT_TRUE(did_request_commit_); | 9386 EXPECT_TRUE(did_request_commit_); |
9365 } | 9387 } |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10283 const gfx::Size content_size(1000, 1000); | 10305 const gfx::Size content_size(1000, 1000); |
10284 const gfx::Size viewport_size(50, 100); | 10306 const gfx::Size viewport_size(50, 100); |
10285 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10307 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10286 | 10308 |
10287 DrawFrame(); | 10309 DrawFrame(); |
10288 | 10310 |
10289 base::TimeTicks start_time = | 10311 base::TimeTicks start_time = |
10290 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10312 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10291 | 10313 |
10292 BeginFrameArgs begin_frame_args = | 10314 BeginFrameArgs begin_frame_args = |
10293 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10315 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10294 | 10316 |
10295 EXPECT_EQ( | 10317 EXPECT_EQ( |
10296 InputHandler::SCROLL_ON_IMPL_THREAD, | 10318 InputHandler::SCROLL_ON_IMPL_THREAD, |
10297 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10319 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10298 | 10320 |
10299 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10321 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10300 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10322 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10301 | 10323 |
10302 begin_frame_args.frame_time = start_time; | 10324 begin_frame_args.frame_time = start_time; |
| 10325 begin_frame_args.sequence_number++; |
10303 host_impl_->WillBeginImplFrame(begin_frame_args); | 10326 host_impl_->WillBeginImplFrame(begin_frame_args); |
10304 host_impl_->Animate(); | 10327 host_impl_->Animate(); |
10305 host_impl_->UpdateAnimationState(true); | 10328 host_impl_->UpdateAnimationState(true); |
10306 | 10329 |
10307 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10330 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10308 host_impl_->DidFinishImplFrame(); | 10331 host_impl_->DidFinishImplFrame(); |
10309 | 10332 |
10310 begin_frame_args.frame_time = | 10333 begin_frame_args.frame_time = |
10311 start_time + base::TimeDelta::FromMilliseconds(50); | 10334 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10335 begin_frame_args.sequence_number++; |
10312 host_impl_->WillBeginImplFrame(begin_frame_args); | 10336 host_impl_->WillBeginImplFrame(begin_frame_args); |
10313 host_impl_->Animate(); | 10337 host_impl_->Animate(); |
10314 host_impl_->UpdateAnimationState(true); | 10338 host_impl_->UpdateAnimationState(true); |
10315 | 10339 |
10316 float y = scrolling_layer->CurrentScrollOffset().y(); | 10340 float y = scrolling_layer->CurrentScrollOffset().y(); |
10317 EXPECT_TRUE(y > 1 && y < 49); | 10341 EXPECT_TRUE(y > 1 && y < 49); |
10318 | 10342 |
10319 // Update target. | 10343 // Update target. |
10320 EXPECT_EQ( | 10344 EXPECT_EQ( |
10321 InputHandler::SCROLL_ON_IMPL_THREAD, | 10345 InputHandler::SCROLL_ON_IMPL_THREAD, |
10322 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10346 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10323 host_impl_->DidFinishImplFrame(); | 10347 host_impl_->DidFinishImplFrame(); |
10324 | 10348 |
10325 begin_frame_args.frame_time = | 10349 begin_frame_args.frame_time = |
10326 start_time + base::TimeDelta::FromMilliseconds(200); | 10350 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10351 begin_frame_args.sequence_number++; |
10327 host_impl_->WillBeginImplFrame(begin_frame_args); | 10352 host_impl_->WillBeginImplFrame(begin_frame_args); |
10328 host_impl_->Animate(); | 10353 host_impl_->Animate(); |
10329 host_impl_->UpdateAnimationState(true); | 10354 host_impl_->UpdateAnimationState(true); |
10330 | 10355 |
10331 y = scrolling_layer->CurrentScrollOffset().y(); | 10356 y = scrolling_layer->CurrentScrollOffset().y(); |
10332 EXPECT_TRUE(y > 50 && y < 100); | 10357 EXPECT_TRUE(y > 50 && y < 100); |
10333 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10358 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10334 host_impl_->DidFinishImplFrame(); | 10359 host_impl_->DidFinishImplFrame(); |
10335 | 10360 |
10336 begin_frame_args.frame_time = | 10361 begin_frame_args.frame_time = |
10337 start_time + base::TimeDelta::FromMilliseconds(250); | 10362 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10363 begin_frame_args.sequence_number++; |
10338 host_impl_->WillBeginImplFrame(begin_frame_args); | 10364 host_impl_->WillBeginImplFrame(begin_frame_args); |
10339 host_impl_->Animate(); | 10365 host_impl_->Animate(); |
10340 host_impl_->UpdateAnimationState(true); | 10366 host_impl_->UpdateAnimationState(true); |
10341 | 10367 |
10342 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10368 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10343 scrolling_layer->CurrentScrollOffset()); | 10369 scrolling_layer->CurrentScrollOffset()); |
10344 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10370 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10345 host_impl_->DidFinishImplFrame(); | 10371 host_impl_->DidFinishImplFrame(); |
10346 } | 10372 } |
10347 | 10373 |
(...skipping 16 matching lines...) Expand all Loading... |
10364 const gfx::Size content_size(1000, 1000); | 10390 const gfx::Size content_size(1000, 1000); |
10365 const gfx::Size viewport_size(50, 100); | 10391 const gfx::Size viewport_size(50, 100); |
10366 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10392 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10367 | 10393 |
10368 DrawFrame(); | 10394 DrawFrame(); |
10369 | 10395 |
10370 base::TimeTicks start_time = | 10396 base::TimeTicks start_time = |
10371 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); | 10397 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); |
10372 | 10398 |
10373 BeginFrameArgs begin_frame_args = | 10399 BeginFrameArgs begin_frame_args = |
10374 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10400 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10375 begin_frame_args.frame_time = start_time; | 10401 begin_frame_args.frame_time = start_time; |
| 10402 begin_frame_args.sequence_number++; |
10376 host_impl_->WillBeginImplFrame(begin_frame_args); | 10403 host_impl_->WillBeginImplFrame(begin_frame_args); |
10377 host_impl_->UpdateAnimationState(true); | 10404 host_impl_->UpdateAnimationState(true); |
10378 host_impl_->DidFinishImplFrame(); | 10405 host_impl_->DidFinishImplFrame(); |
10379 | 10406 |
10380 EXPECT_EQ( | 10407 EXPECT_EQ( |
10381 InputHandler::SCROLL_ON_IMPL_THREAD, | 10408 InputHandler::SCROLL_ON_IMPL_THREAD, |
10382 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10409 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10383 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation | 10410 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation |
10384 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and | 10411 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and |
10385 // doesn't have a start time. | 10412 // doesn't have a start time. |
10386 EXPECT_EQ( | 10413 EXPECT_EQ( |
10387 InputHandler::SCROLL_ON_IMPL_THREAD, | 10414 InputHandler::SCROLL_ON_IMPL_THREAD, |
10388 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10415 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
10389 | 10416 |
10390 begin_frame_args.frame_time = | 10417 begin_frame_args.frame_time = |
10391 start_time + base::TimeDelta::FromMilliseconds(250); | 10418 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10419 begin_frame_args.sequence_number++; |
10392 // This is when the animation above gets promoted to STARTING. | 10420 // This is when the animation above gets promoted to STARTING. |
10393 host_impl_->WillBeginImplFrame(begin_frame_args); | 10421 host_impl_->WillBeginImplFrame(begin_frame_args); |
10394 host_impl_->UpdateAnimationState(true); | 10422 host_impl_->UpdateAnimationState(true); |
10395 host_impl_->DidFinishImplFrame(); | 10423 host_impl_->DidFinishImplFrame(); |
10396 | 10424 |
10397 begin_frame_args.frame_time = | 10425 begin_frame_args.frame_time = |
10398 start_time + base::TimeDelta::FromMilliseconds(300); | 10426 start_time + base::TimeDelta::FromMilliseconds(300); |
| 10427 begin_frame_args.sequence_number++; |
10399 // This is when the animation above gets ticked. | 10428 // This is when the animation above gets ticked. |
10400 host_impl_->WillBeginImplFrame(begin_frame_args); | 10429 host_impl_->WillBeginImplFrame(begin_frame_args); |
10401 host_impl_->UpdateAnimationState(true); | 10430 host_impl_->UpdateAnimationState(true); |
10402 host_impl_->DidFinishImplFrame(); | 10431 host_impl_->DidFinishImplFrame(); |
10403 | 10432 |
10404 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10433 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10405 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10434 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10406 | 10435 |
10407 // Verify no jump. | 10436 // Verify no jump. |
10408 float y = scrolling_layer->CurrentScrollOffset().y(); | 10437 float y = scrolling_layer->CurrentScrollOffset().y(); |
10409 EXPECT_TRUE(y > 1 && y < 49); | 10438 EXPECT_TRUE(y > 1 && y < 49); |
10410 } | 10439 } |
10411 | 10440 |
10412 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { | 10441 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { |
10413 const gfx::Size content_size(1000, 1000); | 10442 const gfx::Size content_size(1000, 1000); |
10414 const gfx::Size viewport_size(50, 100); | 10443 const gfx::Size viewport_size(50, 100); |
10415 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10444 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10416 | 10445 |
10417 DrawFrame(); | 10446 DrawFrame(); |
10418 | 10447 |
10419 base::TimeTicks start_time = | 10448 base::TimeTicks start_time = |
10420 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10449 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10421 BeginFrameArgs begin_frame_args = | 10450 BeginFrameArgs begin_frame_args = |
10422 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10451 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10423 | 10452 |
10424 // Create animation with a 100ms delay. | 10453 // Create animation with a 100ms delay. |
10425 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10454 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10426 host_impl_ | 10455 host_impl_ |
10427 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10456 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
10428 base::TimeDelta::FromMilliseconds(100)) | 10457 base::TimeDelta::FromMilliseconds(100)) |
10429 .thread); | 10458 .thread); |
10430 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10459 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10431 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10460 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
10432 | 10461 |
10433 // First tick, animation is started. | 10462 // First tick, animation is started. |
10434 begin_frame_args.frame_time = start_time; | 10463 begin_frame_args.frame_time = start_time; |
| 10464 begin_frame_args.sequence_number++; |
10435 host_impl_->WillBeginImplFrame(begin_frame_args); | 10465 host_impl_->WillBeginImplFrame(begin_frame_args); |
10436 host_impl_->UpdateAnimationState(true); | 10466 host_impl_->UpdateAnimationState(true); |
10437 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10467 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10438 host_impl_->DidFinishImplFrame(); | 10468 host_impl_->DidFinishImplFrame(); |
10439 | 10469 |
10440 // Second tick after 50ms, animation should be half way done since | 10470 // Second tick after 50ms, animation should be half way done since |
10441 // the duration due to delay is 100ms. | 10471 // the duration due to delay is 100ms. |
10442 begin_frame_args.frame_time = | 10472 begin_frame_args.frame_time = |
10443 start_time + base::TimeDelta::FromMilliseconds(50); | 10473 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10474 begin_frame_args.sequence_number++; |
10444 host_impl_->WillBeginImplFrame(begin_frame_args); | 10475 host_impl_->WillBeginImplFrame(begin_frame_args); |
10445 host_impl_->UpdateAnimationState(true); | 10476 host_impl_->UpdateAnimationState(true); |
10446 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); | 10477 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); |
10447 host_impl_->DidFinishImplFrame(); | 10478 host_impl_->DidFinishImplFrame(); |
10448 | 10479 |
10449 // Update target. | 10480 // Update target. |
10450 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10481 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10451 host_impl_ | 10482 host_impl_ |
10452 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10483 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
10453 base::TimeDelta::FromMilliseconds(150)) | 10484 base::TimeDelta::FromMilliseconds(150)) |
10454 .thread); | 10485 .thread); |
10455 | 10486 |
10456 // Third tick after 100ms, should be at the target position since update | 10487 // Third tick after 100ms, should be at the target position since update |
10457 // target was called with a large value of jank. | 10488 // target was called with a large value of jank. |
10458 begin_frame_args.frame_time = | 10489 begin_frame_args.frame_time = |
10459 start_time + base::TimeDelta::FromMilliseconds(100); | 10490 start_time + base::TimeDelta::FromMilliseconds(100); |
| 10491 begin_frame_args.sequence_number++; |
10460 host_impl_->WillBeginImplFrame(begin_frame_args); | 10492 host_impl_->WillBeginImplFrame(begin_frame_args); |
10461 host_impl_->UpdateAnimationState(true); | 10493 host_impl_->UpdateAnimationState(true); |
10462 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); | 10494 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); |
10463 } | 10495 } |
10464 | 10496 |
10465 // Test that a smooth scroll offset animation is aborted when followed by a | 10497 // Test that a smooth scroll offset animation is aborted when followed by a |
10466 // non-smooth scroll offset animation. | 10498 // non-smooth scroll offset animation. |
10467 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { | 10499 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { |
10468 const gfx::Size content_size(1000, 1000); | 10500 const gfx::Size content_size(1000, 1000); |
10469 const gfx::Size viewport_size(500, 500); | 10501 const gfx::Size viewport_size(500, 500); |
10470 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10502 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10471 | 10503 |
10472 DrawFrame(); | 10504 DrawFrame(); |
10473 | 10505 |
10474 base::TimeTicks start_time = | 10506 base::TimeTicks start_time = |
10475 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10507 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10476 | 10508 |
10477 BeginFrameArgs begin_frame_args = | 10509 BeginFrameArgs begin_frame_args = |
10478 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10510 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10479 | 10511 |
10480 // Perform animated scroll. | 10512 // Perform animated scroll. |
10481 EXPECT_EQ( | 10513 EXPECT_EQ( |
10482 InputHandler::SCROLL_ON_IMPL_THREAD, | 10514 InputHandler::SCROLL_ON_IMPL_THREAD, |
10483 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10515 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10484 | 10516 |
10485 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10517 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10486 | 10518 |
10487 begin_frame_args.frame_time = start_time; | 10519 begin_frame_args.frame_time = start_time; |
| 10520 begin_frame_args.sequence_number++; |
10488 host_impl_->WillBeginImplFrame(begin_frame_args); | 10521 host_impl_->WillBeginImplFrame(begin_frame_args); |
10489 host_impl_->Animate(); | 10522 host_impl_->Animate(); |
10490 host_impl_->UpdateAnimationState(true); | 10523 host_impl_->UpdateAnimationState(true); |
10491 | 10524 |
10492 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10525 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
10493 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10526 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
10494 | 10527 |
10495 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10528 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10496 host_impl_->DidFinishImplFrame(); | 10529 host_impl_->DidFinishImplFrame(); |
10497 | 10530 |
10498 begin_frame_args.frame_time = | 10531 begin_frame_args.frame_time = |
10499 start_time + base::TimeDelta::FromMilliseconds(50); | 10532 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10533 begin_frame_args.sequence_number++; |
10500 host_impl_->WillBeginImplFrame(begin_frame_args); | 10534 host_impl_->WillBeginImplFrame(begin_frame_args); |
10501 host_impl_->Animate(); | 10535 host_impl_->Animate(); |
10502 host_impl_->UpdateAnimationState(true); | 10536 host_impl_->UpdateAnimationState(true); |
10503 | 10537 |
10504 float y = scrolling_layer->CurrentScrollOffset().y(); | 10538 float y = scrolling_layer->CurrentScrollOffset().y(); |
10505 EXPECT_TRUE(y > 1 && y < 49); | 10539 EXPECT_TRUE(y > 1 && y < 49); |
10506 | 10540 |
10507 // Perform instant scroll. | 10541 // Perform instant scroll. |
10508 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10542 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10509 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), | 10543 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), |
(...skipping 29 matching lines...) Expand all Loading... |
10539 const gfx::Size content_size(1000, 1000); | 10573 const gfx::Size content_size(1000, 1000); |
10540 const gfx::Size viewport_size(500, 500); | 10574 const gfx::Size viewport_size(500, 500); |
10541 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10575 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10542 | 10576 |
10543 DrawFrame(); | 10577 DrawFrame(); |
10544 | 10578 |
10545 base::TimeTicks start_time = | 10579 base::TimeTicks start_time = |
10546 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10580 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10547 | 10581 |
10548 BeginFrameArgs begin_frame_args = | 10582 BeginFrameArgs begin_frame_args = |
10549 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10583 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10550 | 10584 |
10551 // Perform animated scroll. | 10585 // Perform animated scroll. |
10552 EXPECT_EQ( | 10586 EXPECT_EQ( |
10553 InputHandler::SCROLL_ON_IMPL_THREAD, | 10587 InputHandler::SCROLL_ON_IMPL_THREAD, |
10554 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10588 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
10555 | 10589 |
10556 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10590 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10557 | 10591 |
10558 begin_frame_args.frame_time = start_time; | 10592 begin_frame_args.frame_time = start_time; |
| 10593 begin_frame_args.sequence_number++; |
10559 host_impl_->WillBeginImplFrame(begin_frame_args); | 10594 host_impl_->WillBeginImplFrame(begin_frame_args); |
10560 host_impl_->Animate(); | 10595 host_impl_->Animate(); |
10561 host_impl_->UpdateAnimationState(true); | 10596 host_impl_->UpdateAnimationState(true); |
10562 | 10597 |
10563 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10598 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
10564 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10599 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
10565 | 10600 |
10566 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10601 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10567 host_impl_->DidFinishImplFrame(); | 10602 host_impl_->DidFinishImplFrame(); |
10568 | 10603 |
10569 begin_frame_args.frame_time = | 10604 begin_frame_args.frame_time = |
10570 start_time + base::TimeDelta::FromMilliseconds(50); | 10605 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10606 begin_frame_args.sequence_number++; |
10571 host_impl_->WillBeginImplFrame(begin_frame_args); | 10607 host_impl_->WillBeginImplFrame(begin_frame_args); |
10572 host_impl_->Animate(); | 10608 host_impl_->Animate(); |
10573 host_impl_->UpdateAnimationState(true); | 10609 host_impl_->UpdateAnimationState(true); |
10574 | 10610 |
10575 float y = scrolling_layer->CurrentScrollOffset().y(); | 10611 float y = scrolling_layer->CurrentScrollOffset().y(); |
10576 EXPECT_TRUE(y > 1 && y < 49); | 10612 EXPECT_TRUE(y > 1 && y < 49); |
10577 | 10613 |
10578 // Abort animation. | 10614 // Abort animation. |
10579 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); | 10615 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); |
10580 host_impl_->UpdateAnimationState(true); | 10616 host_impl_->UpdateAnimationState(true); |
(...skipping 12 matching lines...) Expand all Loading... |
10593 const gfx::Size content_size(1000, 1000); | 10629 const gfx::Size content_size(1000, 1000); |
10594 const gfx::Size viewport_size(500, 500); | 10630 const gfx::Size viewport_size(500, 500); |
10595 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10631 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
10596 | 10632 |
10597 DrawFrame(); | 10633 DrawFrame(); |
10598 | 10634 |
10599 base::TimeTicks start_time = | 10635 base::TimeTicks start_time = |
10600 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10636 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10601 | 10637 |
10602 BeginFrameArgs begin_frame_args = | 10638 BeginFrameArgs begin_frame_args = |
10603 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10639 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10604 | 10640 |
10605 EXPECT_EQ( | 10641 EXPECT_EQ( |
10606 InputHandler::SCROLL_ON_IMPL_THREAD, | 10642 InputHandler::SCROLL_ON_IMPL_THREAD, |
10607 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10643 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10608 | 10644 |
10609 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10645 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10610 begin_frame_args.frame_time = start_time; | 10646 begin_frame_args.frame_time = start_time; |
| 10647 begin_frame_args.sequence_number++; |
10611 host_impl_->WillBeginImplFrame(begin_frame_args); | 10648 host_impl_->WillBeginImplFrame(begin_frame_args); |
10612 host_impl_->Animate(); | 10649 host_impl_->Animate(); |
10613 host_impl_->UpdateAnimationState(true); | 10650 host_impl_->UpdateAnimationState(true); |
10614 | 10651 |
10615 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10652 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10616 host_impl_->DidFinishImplFrame(); | 10653 host_impl_->DidFinishImplFrame(); |
10617 | 10654 |
10618 begin_frame_args.frame_time = | 10655 begin_frame_args.frame_time = |
10619 start_time + base::TimeDelta::FromMilliseconds(50); | 10656 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10657 begin_frame_args.sequence_number++; |
10620 host_impl_->WillBeginImplFrame(begin_frame_args); | 10658 host_impl_->WillBeginImplFrame(begin_frame_args); |
10621 host_impl_->Animate(); | 10659 host_impl_->Animate(); |
10622 host_impl_->UpdateAnimationState(true); | 10660 host_impl_->UpdateAnimationState(true); |
10623 | 10661 |
10624 float y = scrolling_layer->CurrentScrollOffset().y(); | 10662 float y = scrolling_layer->CurrentScrollOffset().y(); |
10625 EXPECT_TRUE(y > 1 && y < 49); | 10663 EXPECT_TRUE(y > 1 && y < 49); |
10626 | 10664 |
10627 // Update target. | 10665 // Update target. |
10628 EXPECT_EQ( | 10666 EXPECT_EQ( |
10629 InputHandler::SCROLL_ON_IMPL_THREAD, | 10667 InputHandler::SCROLL_ON_IMPL_THREAD, |
10630 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10668 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
10631 host_impl_->DidFinishImplFrame(); | 10669 host_impl_->DidFinishImplFrame(); |
10632 | 10670 |
10633 begin_frame_args.frame_time = | 10671 begin_frame_args.frame_time = |
10634 start_time + base::TimeDelta::FromMilliseconds(200); | 10672 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10673 begin_frame_args.sequence_number++; |
10635 host_impl_->WillBeginImplFrame(begin_frame_args); | 10674 host_impl_->WillBeginImplFrame(begin_frame_args); |
10636 host_impl_->Animate(); | 10675 host_impl_->Animate(); |
10637 host_impl_->UpdateAnimationState(true); | 10676 host_impl_->UpdateAnimationState(true); |
10638 | 10677 |
10639 y = scrolling_layer->CurrentScrollOffset().y(); | 10678 y = scrolling_layer->CurrentScrollOffset().y(); |
10640 EXPECT_TRUE(y > 50 && y < 100); | 10679 EXPECT_TRUE(y > 50 && y < 100); |
10641 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10680 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10642 host_impl_->DidFinishImplFrame(); | 10681 host_impl_->DidFinishImplFrame(); |
10643 | 10682 |
10644 begin_frame_args.frame_time = | 10683 begin_frame_args.frame_time = |
10645 start_time + base::TimeDelta::FromMilliseconds(250); | 10684 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10685 begin_frame_args.sequence_number++; |
10646 host_impl_->WillBeginImplFrame(begin_frame_args); | 10686 host_impl_->WillBeginImplFrame(begin_frame_args); |
10647 host_impl_->Animate(); | 10687 host_impl_->Animate(); |
10648 host_impl_->UpdateAnimationState(true); | 10688 host_impl_->UpdateAnimationState(true); |
10649 | 10689 |
10650 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10690 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10651 scrolling_layer->CurrentScrollOffset()); | 10691 scrolling_layer->CurrentScrollOffset()); |
10652 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10692 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10653 host_impl_->DidFinishImplFrame(); | 10693 host_impl_->DidFinishImplFrame(); |
10654 } | 10694 } |
10655 | 10695 |
(...skipping 13 matching lines...) Expand all Loading... |
10669 float page_scale_factor = 2.f; | 10709 float page_scale_factor = 2.f; |
10670 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10710 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10671 page_scale_factor, min_page_scale, max_page_scale); | 10711 page_scale_factor, min_page_scale, max_page_scale); |
10672 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10712 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10673 | 10713 |
10674 // Scroll by a small amount, there should be no bubbling to the outer | 10714 // Scroll by a small amount, there should be no bubbling to the outer |
10675 // viewport. | 10715 // viewport. |
10676 base::TimeTicks start_time = | 10716 base::TimeTicks start_time = |
10677 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10717 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
10678 BeginFrameArgs begin_frame_args = | 10718 BeginFrameArgs begin_frame_args = |
10679 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10719 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10680 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10720 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
10681 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 10721 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
10682 .thread); | 10722 .thread); |
10683 host_impl_->Animate(); | 10723 host_impl_->Animate(); |
10684 host_impl_->UpdateAnimationState(true); | 10724 host_impl_->UpdateAnimationState(true); |
10685 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10725 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
10686 | 10726 |
10687 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10727 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
10688 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10728 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
10689 inner_scroll_layer->CurrentScrollOffset()); | 10729 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; | 10797 float min_page_scale = 1.f, max_page_scale = 4.f; |
10758 float page_scale_factor = 2.f; | 10798 float page_scale_factor = 2.f; |
10759 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10799 host_impl_->active_tree()->PushPageScaleFromMainThread( |
10760 page_scale_factor, min_page_scale, max_page_scale); | 10800 page_scale_factor, min_page_scale, max_page_scale); |
10761 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10801 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
10762 | 10802 |
10763 // Scroll the inner viewport. | 10803 // Scroll the inner viewport. |
10764 base::TimeTicks start_time = | 10804 base::TimeTicks start_time = |
10765 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10805 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
10766 BeginFrameArgs begin_frame_args = | 10806 BeginFrameArgs begin_frame_args = |
10767 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10807 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10768 EXPECT_EQ( | 10808 EXPECT_EQ( |
10769 InputHandler::SCROLL_ON_IMPL_THREAD, | 10809 InputHandler::SCROLL_ON_IMPL_THREAD, |
10770 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); | 10810 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); |
10771 host_impl_->Animate(); | 10811 host_impl_->Animate(); |
10772 host_impl_->UpdateAnimationState(true); | 10812 host_impl_->UpdateAnimationState(true); |
10773 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10813 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
10774 | 10814 |
10775 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10815 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
10776 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); | 10816 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); |
10777 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); | 10817 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); | 10849 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); |
10810 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); | 10850 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); |
10811 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10851 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
10812 | 10852 |
10813 DrawFrame(); | 10853 DrawFrame(); |
10814 | 10854 |
10815 base::TimeTicks start_time = | 10855 base::TimeTicks start_time = |
10816 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10856 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10817 | 10857 |
10818 BeginFrameArgs begin_frame_args = | 10858 BeginFrameArgs begin_frame_args = |
10819 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10859 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10820 | 10860 |
10821 EXPECT_EQ( | 10861 EXPECT_EQ( |
10822 InputHandler::SCROLL_ON_IMPL_THREAD, | 10862 InputHandler::SCROLL_ON_IMPL_THREAD, |
10823 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10863 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
10824 | 10864 |
10825 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10865 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10826 begin_frame_args.frame_time = start_time; | 10866 begin_frame_args.frame_time = start_time; |
| 10867 begin_frame_args.sequence_number++; |
10827 host_impl_->WillBeginImplFrame(begin_frame_args); | 10868 host_impl_->WillBeginImplFrame(begin_frame_args); |
10828 host_impl_->Animate(); | 10869 host_impl_->Animate(); |
10829 host_impl_->UpdateAnimationState(true); | 10870 host_impl_->UpdateAnimationState(true); |
10830 | 10871 |
10831 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10872 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
10832 host_impl_->DidFinishImplFrame(); | 10873 host_impl_->DidFinishImplFrame(); |
10833 | 10874 |
10834 begin_frame_args.frame_time = | 10875 begin_frame_args.frame_time = |
10835 start_time + base::TimeDelta::FromMilliseconds(50); | 10876 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10877 begin_frame_args.sequence_number++; |
10836 host_impl_->WillBeginImplFrame(begin_frame_args); | 10878 host_impl_->WillBeginImplFrame(begin_frame_args); |
10837 host_impl_->Animate(); | 10879 host_impl_->Animate(); |
10838 host_impl_->UpdateAnimationState(true); | 10880 host_impl_->UpdateAnimationState(true); |
10839 | 10881 |
10840 // Should not have scrolled horizontally. | 10882 // Should not have scrolled horizontally. |
10841 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); | 10883 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); |
10842 float y = scrolling_layer->CurrentScrollOffset().y(); | 10884 float y = scrolling_layer->CurrentScrollOffset().y(); |
10843 EXPECT_TRUE(y > 1 && y < 49); | 10885 EXPECT_TRUE(y > 1 && y < 49); |
10844 | 10886 |
10845 // Update target. | 10887 // Update target. |
10846 EXPECT_EQ( | 10888 EXPECT_EQ( |
10847 InputHandler::SCROLL_ON_IMPL_THREAD, | 10889 InputHandler::SCROLL_ON_IMPL_THREAD, |
10848 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10890 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
10849 host_impl_->DidFinishImplFrame(); | 10891 host_impl_->DidFinishImplFrame(); |
10850 | 10892 |
10851 begin_frame_args.frame_time = | 10893 begin_frame_args.frame_time = |
10852 start_time + base::TimeDelta::FromMilliseconds(200); | 10894 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10895 begin_frame_args.sequence_number++; |
10853 host_impl_->WillBeginImplFrame(begin_frame_args); | 10896 host_impl_->WillBeginImplFrame(begin_frame_args); |
10854 host_impl_->Animate(); | 10897 host_impl_->Animate(); |
10855 host_impl_->UpdateAnimationState(true); | 10898 host_impl_->UpdateAnimationState(true); |
10856 | 10899 |
10857 y = scrolling_layer->CurrentScrollOffset().y(); | 10900 y = scrolling_layer->CurrentScrollOffset().y(); |
10858 EXPECT_TRUE(y > 50 && y < 100); | 10901 EXPECT_TRUE(y > 50 && y < 100); |
10859 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10902 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
10860 host_impl_->DidFinishImplFrame(); | 10903 host_impl_->DidFinishImplFrame(); |
10861 | 10904 |
10862 begin_frame_args.frame_time = | 10905 begin_frame_args.frame_time = |
10863 start_time + base::TimeDelta::FromMilliseconds(250); | 10906 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10907 begin_frame_args.sequence_number++; |
10864 host_impl_->WillBeginImplFrame(begin_frame_args); | 10908 host_impl_->WillBeginImplFrame(begin_frame_args); |
10865 host_impl_->Animate(); | 10909 host_impl_->Animate(); |
10866 host_impl_->UpdateAnimationState(true); | 10910 host_impl_->UpdateAnimationState(true); |
10867 | 10911 |
10868 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10912 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
10869 scrolling_layer->CurrentScrollOffset()); | 10913 scrolling_layer->CurrentScrollOffset()); |
10870 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10914 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
10871 host_impl_->DidFinishImplFrame(); | 10915 host_impl_->DidFinishImplFrame(); |
10872 } | 10916 } |
10873 | 10917 |
10874 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10918 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
10875 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10919 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
10876 const gfx::Size old_content_size(1000, 1000); | 10920 const gfx::Size old_content_size(1000, 1000); |
10877 const gfx::Size new_content_size(750, 750); | 10921 const gfx::Size new_content_size(750, 750); |
10878 const gfx::Size viewport_size(500, 500); | 10922 const gfx::Size viewport_size(500, 500); |
10879 | 10923 |
10880 LayerImpl* content_layer = | 10924 LayerImpl* content_layer = |
10881 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10925 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
10882 | 10926 |
10883 DrawFrame(); | 10927 DrawFrame(); |
10884 | 10928 |
10885 base::TimeTicks start_time = | 10929 base::TimeTicks start_time = |
10886 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10930 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
10887 BeginFrameArgs begin_frame_args = | 10931 BeginFrameArgs begin_frame_args = |
10888 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10932 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
10889 | 10933 |
10890 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10934 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
10891 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10935 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
10892 | 10936 |
10893 begin_frame_args.frame_time = start_time; | 10937 begin_frame_args.frame_time = start_time; |
| 10938 begin_frame_args.sequence_number++; |
10894 host_impl_->WillBeginImplFrame(begin_frame_args); | 10939 host_impl_->WillBeginImplFrame(begin_frame_args); |
10895 host_impl_->Animate(); | 10940 host_impl_->Animate(); |
10896 host_impl_->UpdateAnimationState(true); | 10941 host_impl_->UpdateAnimationState(true); |
10897 host_impl_->DidFinishImplFrame(); | 10942 host_impl_->DidFinishImplFrame(); |
10898 | 10943 |
10899 content_layer->SetBounds(new_content_size); | 10944 content_layer->SetBounds(new_content_size); |
10900 scrolling_layer->SetBounds(new_content_size); | 10945 scrolling_layer->SetBounds(new_content_size); |
10901 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10946 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
10902 | 10947 |
10903 DrawFrame(); | 10948 DrawFrame(); |
10904 | 10949 |
10905 begin_frame_args.frame_time = | 10950 begin_frame_args.frame_time = |
10906 start_time + base::TimeDelta::FromMilliseconds(200); | 10951 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10952 begin_frame_args.sequence_number++; |
10907 host_impl_->WillBeginImplFrame(begin_frame_args); | 10953 host_impl_->WillBeginImplFrame(begin_frame_args); |
10908 host_impl_->Animate(); | 10954 host_impl_->Animate(); |
10909 host_impl_->UpdateAnimationState(true); | 10955 host_impl_->UpdateAnimationState(true); |
10910 host_impl_->DidFinishImplFrame(); | 10956 host_impl_->DidFinishImplFrame(); |
10911 | 10957 |
10912 EXPECT_EQ(gfx::ScrollOffset(250, 250), | 10958 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
10913 scrolling_layer->CurrentScrollOffset()); | 10959 scrolling_layer->CurrentScrollOffset()); |
10914 } | 10960 } |
10915 | 10961 |
10916 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 10962 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11186 | 11232 |
11187 bool did_draw_frame() const { return did_draw_frame_; } | 11233 bool did_draw_frame() const { return did_draw_frame_; } |
11188 | 11234 |
11189 private: | 11235 private: |
11190 BeginFrameArgs begin_frame_args_; | 11236 BeginFrameArgs begin_frame_args_; |
11191 bool did_draw_frame_ = false; | 11237 bool did_draw_frame_ = false; |
11192 }; | 11238 }; |
11193 | 11239 |
11194 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { | 11240 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { |
11195 BeginFrameArgs begin_frame_args = | 11241 BeginFrameArgs begin_frame_args = |
11196 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11242 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
11197 FakeVideoFrameController controller; | 11243 FakeVideoFrameController controller; |
11198 | 11244 |
11199 host_impl_->WillBeginImplFrame(begin_frame_args); | 11245 host_impl_->WillBeginImplFrame(begin_frame_args); |
11200 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11246 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11201 host_impl_->AddVideoFrameController(&controller); | 11247 host_impl_->AddVideoFrameController(&controller); |
11202 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11248 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
11203 host_impl_->DidFinishImplFrame(); | 11249 host_impl_->DidFinishImplFrame(); |
11204 | 11250 |
11205 EXPECT_FALSE(controller.did_draw_frame()); | 11251 EXPECT_FALSE(controller.did_draw_frame()); |
11206 LayerTreeHostImpl::FrameData frame; | 11252 LayerTreeHostImpl::FrameData frame; |
11207 host_impl_->DidDrawAllLayers(frame); | 11253 host_impl_->DidDrawAllLayers(frame); |
11208 EXPECT_TRUE(controller.did_draw_frame()); | 11254 EXPECT_TRUE(controller.did_draw_frame()); |
11209 | 11255 |
11210 controller.OnBeginFrame(begin_frame_args); | 11256 controller.OnBeginFrame(begin_frame_args); |
11211 EXPECT_FALSE(controller.did_draw_frame()); | 11257 EXPECT_FALSE(controller.did_draw_frame()); |
11212 host_impl_->RemoveVideoFrameController(&controller); | 11258 host_impl_->RemoveVideoFrameController(&controller); |
11213 host_impl_->DidDrawAllLayers(frame); | 11259 host_impl_->DidDrawAllLayers(frame); |
11214 EXPECT_FALSE(controller.did_draw_frame()); | 11260 EXPECT_FALSE(controller.did_draw_frame()); |
11215 } | 11261 } |
11216 | 11262 |
11217 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { | 11263 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { |
11218 BeginFrameArgs begin_frame_args = | 11264 BeginFrameArgs begin_frame_args = |
11219 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11265 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
11220 FakeVideoFrameController controller; | 11266 FakeVideoFrameController controller; |
11221 | 11267 |
11222 host_impl_->WillBeginImplFrame(begin_frame_args); | 11268 host_impl_->WillBeginImplFrame(begin_frame_args); |
11223 host_impl_->DidFinishImplFrame(); | 11269 host_impl_->DidFinishImplFrame(); |
11224 | 11270 |
11225 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11271 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11226 host_impl_->AddVideoFrameController(&controller); | 11272 host_impl_->AddVideoFrameController(&controller); |
11227 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11273 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11228 | 11274 |
11229 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11275 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3); |
11230 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11276 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
11231 host_impl_->WillBeginImplFrame(begin_frame_args); | 11277 host_impl_->WillBeginImplFrame(begin_frame_args); |
11232 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11278 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
11233 | 11279 |
11234 EXPECT_FALSE(controller.did_draw_frame()); | 11280 EXPECT_FALSE(controller.did_draw_frame()); |
11235 LayerTreeHostImpl::FrameData frame; | 11281 LayerTreeHostImpl::FrameData frame; |
11236 host_impl_->DidDrawAllLayers(frame); | 11282 host_impl_->DidDrawAllLayers(frame); |
11237 EXPECT_TRUE(controller.did_draw_frame()); | 11283 EXPECT_TRUE(controller.did_draw_frame()); |
11238 | 11284 |
11239 controller.OnBeginFrame(begin_frame_args); | 11285 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()); | 11777 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11732 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11778 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11733 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11779 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11734 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11780 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11735 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11781 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11736 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11782 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11737 } | 11783 } |
11738 | 11784 |
11739 } // namespace | 11785 } // namespace |
11740 } // namespace cc | 11786 } // namespace cc |
OLD | NEW |