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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 content_layer->SetBounds(content_size); | 369 content_layer->SetBounds(content_size); |
370 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); | 370 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); |
371 | 371 |
372 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); | 372 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); |
373 outer_clip->SetBounds(viewport_size); | 373 outer_clip->SetBounds(viewport_size); |
374 | 374 |
375 LayerImpl* inner_clip_layer = | 375 LayerImpl* inner_clip_layer = |
376 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 376 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
377 inner_clip_layer->SetBounds(viewport_size); | 377 inner_clip_layer->SetBounds(viewport_size); |
378 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 378 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
| 379 |
| 380 // Needs to happen before building property trees as the latter propagates |
| 381 // these element ids to property tree nodes. |
| 382 host_impl_->active_tree()->SetElementIdsForTesting(); |
379 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 383 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
380 | 384 |
381 host_impl_->SetViewportSize(viewport_size); | 385 host_impl_->SetViewportSize(viewport_size); |
382 host_impl_->active_tree()->DidBecomeActive(); | 386 host_impl_->active_tree()->DidBecomeActive(); |
383 | 387 |
384 return content_layer; | 388 return content_layer; |
385 } | 389 } |
386 | 390 |
387 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, | 391 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, |
388 const gfx::Size& size, | 392 const gfx::Size& size, |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1311 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
1308 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1312 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
1309 root->SetBounds(gfx::Size(50, 50)); | 1313 root->SetBounds(gfx::Size(50, 50)); |
1310 root->test_properties()->force_render_surface = true; | 1314 root->test_properties()->force_render_surface = true; |
1311 | 1315 |
1312 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1316 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
1313 LayerImpl* child = root->children()[0]; | 1317 LayerImpl* child = root->children()[0]; |
1314 child->SetBounds(gfx::Size(10, 10)); | 1318 child->SetBounds(gfx::Size(10, 10)); |
1315 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1319 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1316 child->SetDrawsContent(true); | 1320 child->SetDrawsContent(true); |
1317 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1321 |
| 1322 host_impl_->pending_tree()->SetElementIdsForTesting(); |
| 1323 |
| 1324 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1325 3, 0); |
1318 | 1326 |
1319 EXPECT_FALSE(did_request_next_frame_); | 1327 EXPECT_FALSE(did_request_next_frame_); |
1320 EXPECT_FALSE(did_request_redraw_); | 1328 EXPECT_FALSE(did_request_redraw_); |
1321 EXPECT_FALSE(did_request_commit_); | 1329 EXPECT_FALSE(did_request_commit_); |
1322 | 1330 |
1323 host_impl_->AnimatePendingTreeAfterCommit(); | 1331 host_impl_->AnimatePendingTreeAfterCommit(); |
1324 | 1332 |
1325 // An animation exists on the pending layer. Doing | 1333 // An animation exists on the pending layer. Doing |
1326 // AnimatePendingTreeAfterCommit() requests another frame. | 1334 // AnimatePendingTreeAfterCommit() requests another frame. |
1327 // In reality, animations without has_set_start_time() == true do not need to | 1335 // In reality, animations without has_set_start_time() == true do not need to |
(...skipping 30 matching lines...) Expand all Loading... |
1358 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1366 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1359 root->SetBounds(gfx::Size(50, 50)); | 1367 root->SetBounds(gfx::Size(50, 50)); |
1360 root->test_properties()->force_render_surface = true; | 1368 root->test_properties()->force_render_surface = true; |
1361 | 1369 |
1362 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1370 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1363 LayerImpl* child = root->children()[0]; | 1371 LayerImpl* child = root->children()[0]; |
1364 child->SetBounds(gfx::Size(10, 10)); | 1372 child->SetBounds(gfx::Size(10, 10)); |
1365 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1373 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1366 child->SetDrawsContent(true); | 1374 child->SetDrawsContent(true); |
1367 | 1375 |
| 1376 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 1377 |
1368 // Add a translate from 6,7 to 8,9. | 1378 // Add a translate from 6,7 to 8,9. |
1369 TransformOperations start; | 1379 TransformOperations start; |
1370 start.AppendTranslate(6.f, 7.f, 0.f); | 1380 start.AppendTranslate(6.f, 7.f, 0.f); |
1371 TransformOperations end; | 1381 TransformOperations end; |
1372 end.AppendTranslate(8.f, 9.f, 0.f); | 1382 end.AppendTranslate(8.f, 9.f, 0.f); |
1373 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, | 1383 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
1374 end); | 1384 start, end); |
1375 | 1385 |
1376 base::TimeTicks now = base::TimeTicks::Now(); | 1386 base::TimeTicks now = base::TimeTicks::Now(); |
1377 host_impl_->WillBeginImplFrame( | 1387 host_impl_->WillBeginImplFrame( |
1378 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1388 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1379 | 1389 |
1380 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1390 // TODO(crbug.com/551134): We always request a new frame and a draw for |
1381 // animations that are on the pending tree, but we don't need to do that | 1391 // animations that are on the pending tree, but we don't need to do that |
1382 // unless they are waiting for some future time to start. | 1392 // unless they are waiting for some future time to start. |
1383 EXPECT_TRUE(did_request_next_frame_); | 1393 EXPECT_TRUE(did_request_next_frame_); |
1384 EXPECT_TRUE(did_request_redraw_); | 1394 EXPECT_TRUE(did_request_redraw_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1431 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1422 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1432 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1423 root->SetBounds(gfx::Size(50, 50)); | 1433 root->SetBounds(gfx::Size(50, 50)); |
1424 root->SetHasRenderSurface(true); | 1434 root->SetHasRenderSurface(true); |
1425 | 1435 |
1426 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1436 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1427 LayerImpl* child = root->children()[0]; | 1437 LayerImpl* child = root->children()[0]; |
1428 child->SetBounds(gfx::Size(10, 10)); | 1438 child->SetBounds(gfx::Size(10, 10)); |
1429 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1439 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1430 child->SetDrawsContent(true); | 1440 child->SetDrawsContent(true); |
1431 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1441 |
| 1442 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 1443 |
| 1444 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, |
| 1445 3, 0); |
1432 | 1446 |
1433 // Set up the property trees so that UpdateDrawProperties will work in | 1447 // Set up the property trees so that UpdateDrawProperties will work in |
1434 // CommitComplete below. | 1448 // CommitComplete below. |
1435 LayerImplList list; | 1449 LayerImplList list; |
1436 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1450 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1437 root, gfx::Size(50, 50), &list); | 1451 root, gfx::Size(50, 50), &list); |
1438 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1452 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1439 | 1453 |
1440 EXPECT_FALSE(did_request_next_frame_); | 1454 EXPECT_FALSE(did_request_next_frame_); |
1441 EXPECT_FALSE(did_request_redraw_); | 1455 EXPECT_FALSE(did_request_redraw_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 root->SetHasRenderSurface(true); | 1495 root->SetHasRenderSurface(true); |
1482 | 1496 |
1483 root->AddChild(std::unique_ptr<MissingTilesLayer>( | 1497 root->AddChild(std::unique_ptr<MissingTilesLayer>( |
1484 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1498 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
1485 MissingTilesLayer* child = | 1499 MissingTilesLayer* child = |
1486 static_cast<MissingTilesLayer*>(root->children()[0]); | 1500 static_cast<MissingTilesLayer*>(root->children()[0]); |
1487 child->SetBounds(gfx::Size(10, 10)); | 1501 child->SetBounds(gfx::Size(10, 10)); |
1488 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1502 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1489 child->SetDrawsContent(true); | 1503 child->SetDrawsContent(true); |
1490 | 1504 |
| 1505 host_impl_->active_tree()->SetElementIdsForTesting(); |
| 1506 |
1491 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1507 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
1492 | 1508 |
1493 // Add a translate from 6,7 to 8,9. | 1509 // Add a translate from 6,7 to 8,9. |
1494 TransformOperations start; | 1510 TransformOperations start; |
1495 start.AppendTranslate(6.f, 7.f, 0.f); | 1511 start.AppendTranslate(6.f, 7.f, 0.f); |
1496 TransformOperations end; | 1512 TransformOperations end; |
1497 end.AppendTranslate(8.f, 9.f, 0.f); | 1513 end.AppendTranslate(8.f, 9.f, 0.f); |
1498 int animation_id = AddAnimatedTransformToLayerWithPlayer( | 1514 int animation_id = AddAnimatedTransformToElementWithPlayer( |
1499 child->id(), timeline(), 4.0, start, end); | 1515 child->element_id(), timeline(), 4.0, start, end); |
1500 | 1516 |
1501 base::TimeTicks now = base::TimeTicks::Now(); | 1517 base::TimeTicks now = base::TimeTicks::Now(); |
1502 host_impl_->WillBeginImplFrame( | 1518 host_impl_->WillBeginImplFrame( |
1503 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1519 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1504 | 1520 |
1505 host_impl_->ActivateAnimations(); | 1521 host_impl_->ActivateAnimations(); |
1506 host_impl_->Animate(); | 1522 host_impl_->Animate(); |
1507 | 1523 |
1508 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1524 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1509 | 1525 |
(...skipping 10 matching lines...) Expand all Loading... |
1520 child->set_has_missing_tiles(false); | 1536 child->set_has_missing_tiles(false); |
1521 | 1537 |
1522 // Child layer has an animating and no missing tiles. | 1538 // Child layer has an animating and no missing tiles. |
1523 result = host_impl_->PrepareToDraw(&frame); | 1539 result = host_impl_->PrepareToDraw(&frame); |
1524 EXPECT_EQ(DRAW_SUCCESS, result); | 1540 EXPECT_EQ(DRAW_SUCCESS, result); |
1525 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1541 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
1526 host_impl_->DidDrawAllLayers(frame); | 1542 host_impl_->DidDrawAllLayers(frame); |
1527 | 1543 |
1528 // Remove the animation. | 1544 // Remove the animation. |
1529 child->set_has_missing_tiles(true); | 1545 child->set_has_missing_tiles(true); |
1530 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), | 1546 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
1531 animation_id); | 1547 animation_id); |
1532 child->draw_properties().screen_space_transform_is_animating = false; | 1548 child->draw_properties().screen_space_transform_is_animating = false; |
1533 | 1549 |
1534 // Child layer doesn't have an animation, but was never ready since the last | 1550 // Child layer doesn't have an animation, but was never ready since the last |
1535 // time it animated (and has missing tiles). | 1551 // time it animated (and has missing tiles). |
1536 result = host_impl_->PrepareToDraw(&frame); | 1552 result = host_impl_->PrepareToDraw(&frame); |
1537 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1553 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
1538 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1554 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1539 host_impl_->DidDrawAllLayers(frame); | 1555 host_impl_->DidDrawAllLayers(frame); |
1540 | 1556 |
1541 child->set_has_missing_tiles(false); | 1557 child->set_has_missing_tiles(false); |
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, | 3536 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
3521 int id, | 3537 int id, |
3522 bool tile_missing, | 3538 bool tile_missing, |
3523 bool had_incomplete_tile, | 3539 bool had_incomplete_tile, |
3524 bool animating, | 3540 bool animating, |
3525 ResourceProvider* resource_provider, | 3541 ResourceProvider* resource_provider, |
3526 scoped_refptr<AnimationTimeline> timeline) | 3542 scoped_refptr<AnimationTimeline> timeline) |
3527 : DidDrawCheckLayer(tree_impl, id), | 3543 : DidDrawCheckLayer(tree_impl, id), |
3528 tile_missing_(tile_missing), | 3544 tile_missing_(tile_missing), |
3529 had_incomplete_tile_(had_incomplete_tile) { | 3545 had_incomplete_tile_(had_incomplete_tile) { |
3530 if (animating) | 3546 if (animating) { |
3531 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); | 3547 this->SetElementId(LayerIdToElementIdForTesting(id)); |
| 3548 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline, |
| 3549 10.0, 3, 0); |
| 3550 } |
3532 } | 3551 } |
3533 | 3552 |
3534 bool tile_missing_; | 3553 bool tile_missing_; |
3535 bool had_incomplete_tile_; | 3554 bool had_incomplete_tile_; |
3536 }; | 3555 }; |
3537 | 3556 |
3538 struct PrepareToDrawSuccessTestCase { | 3557 struct PrepareToDrawSuccessTestCase { |
3539 struct State { | 3558 struct State { |
3540 bool has_missing_tile = false; | 3559 bool has_missing_tile = false; |
3541 bool has_incomplete_tile = false; | 3560 bool has_incomplete_tile = false; |
(...skipping 6143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9685 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 9704 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
9686 | 9705 |
9687 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9706 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
9688 | 9707 |
9689 begin_frame_args.frame_time = start_time; | 9708 begin_frame_args.frame_time = start_time; |
9690 host_impl_->WillBeginImplFrame(begin_frame_args); | 9709 host_impl_->WillBeginImplFrame(begin_frame_args); |
9691 host_impl_->Animate(); | 9710 host_impl_->Animate(); |
9692 host_impl_->UpdateAnimationState(true); | 9711 host_impl_->UpdateAnimationState(true); |
9693 | 9712 |
9694 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9713 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
9695 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9714 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
9696 | 9715 |
9697 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9716 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
9698 host_impl_->DidFinishImplFrame(); | 9717 host_impl_->DidFinishImplFrame(); |
9699 | 9718 |
9700 begin_frame_args.frame_time = | 9719 begin_frame_args.frame_time = |
9701 start_time + base::TimeDelta::FromMilliseconds(50); | 9720 start_time + base::TimeDelta::FromMilliseconds(50); |
9702 host_impl_->WillBeginImplFrame(begin_frame_args); | 9721 host_impl_->WillBeginImplFrame(begin_frame_args); |
9703 host_impl_->Animate(); | 9722 host_impl_->Animate(); |
9704 host_impl_->UpdateAnimationState(true); | 9723 host_impl_->UpdateAnimationState(true); |
9705 | 9724 |
(...skipping 12 matching lines...) Expand all Loading... |
9718 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 9737 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
9719 InputHandler::WHEEL)); | 9738 InputHandler::WHEEL)); |
9720 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 9739 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
9721 host_impl_->ScrollEnd(scroll_state_end.get()); | 9740 host_impl_->ScrollEnd(scroll_state_end.get()); |
9722 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 9741 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
9723 InputHandler::WHEEL)); | 9742 InputHandler::WHEEL)); |
9724 | 9743 |
9725 // The instant scroll should have marked the smooth scroll animation as | 9744 // The instant scroll should have marked the smooth scroll animation as |
9726 // aborted. | 9745 // aborted. |
9727 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9746 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
9728 scrolling_layer->id())); | 9747 scrolling_layer->element_id())); |
9729 | 9748 |
9730 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9749 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
9731 scrolling_layer->CurrentScrollOffset()); | 9750 scrolling_layer->CurrentScrollOffset()); |
9732 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9751 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
9733 host_impl_->DidFinishImplFrame(); | 9752 host_impl_->DidFinishImplFrame(); |
9734 } | 9753 } |
9735 | 9754 |
9736 // Test that a smooth scroll offset animation is marked finished when aborted | 9755 // Test that a smooth scroll offset animation is marked finished when aborted |
9737 // with the needs_completion flag. The animation is then finished on the | 9756 // with the needs_completion flag. The animation is then finished on the |
9738 // main thread. | 9757 // main thread. |
(...skipping 17 matching lines...) Expand all Loading... |
9756 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 9775 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
9757 | 9776 |
9758 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9777 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
9759 | 9778 |
9760 begin_frame_args.frame_time = start_time; | 9779 begin_frame_args.frame_time = start_time; |
9761 host_impl_->WillBeginImplFrame(begin_frame_args); | 9780 host_impl_->WillBeginImplFrame(begin_frame_args); |
9762 host_impl_->Animate(); | 9781 host_impl_->Animate(); |
9763 host_impl_->UpdateAnimationState(true); | 9782 host_impl_->UpdateAnimationState(true); |
9764 | 9783 |
9765 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9784 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
9766 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9785 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
9767 | 9786 |
9768 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9787 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
9769 host_impl_->DidFinishImplFrame(); | 9788 host_impl_->DidFinishImplFrame(); |
9770 | 9789 |
9771 begin_frame_args.frame_time = | 9790 begin_frame_args.frame_time = |
9772 start_time + base::TimeDelta::FromMilliseconds(50); | 9791 start_time + base::TimeDelta::FromMilliseconds(50); |
9773 host_impl_->WillBeginImplFrame(begin_frame_args); | 9792 host_impl_->WillBeginImplFrame(begin_frame_args); |
9774 host_impl_->Animate(); | 9793 host_impl_->Animate(); |
9775 host_impl_->UpdateAnimationState(true); | 9794 host_impl_->UpdateAnimationState(true); |
9776 | 9795 |
9777 float y = scrolling_layer->CurrentScrollOffset().y(); | 9796 float y = scrolling_layer->CurrentScrollOffset().y(); |
9778 EXPECT_TRUE(y > 1 && y < 49); | 9797 EXPECT_TRUE(y > 1 && y < 49); |
9779 | 9798 |
9780 // Abort animation. | 9799 // Abort animation. |
9781 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); | 9800 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); |
9782 host_impl_->UpdateAnimationState(true); | 9801 host_impl_->UpdateAnimationState(true); |
9783 | 9802 |
9784 // Aborting with the needs completion param should have marked the smooth | 9803 // Aborting with the needs completion param should have marked the smooth |
9785 // scroll animation as finished. | 9804 // scroll animation as finished. |
9786 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9805 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
9787 scrolling_layer->id())); | 9806 scrolling_layer->element_id())); |
9788 EXPECT_TRUE(y > 1 && y < 49); | 9807 EXPECT_TRUE(y > 1 && y < 49); |
9789 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9808 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
9790 host_impl_->DidFinishImplFrame(); | 9809 host_impl_->DidFinishImplFrame(); |
9791 } | 9810 } |
9792 | 9811 |
9793 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9812 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
9794 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9813 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
9795 const gfx::Size content_size(1000, 1000); | 9814 const gfx::Size content_size(1000, 1000); |
9796 const gfx::Size viewport_size(500, 500); | 9815 const gfx::Size viewport_size(500, 500); |
9797 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9816 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9866 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 9885 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
9867 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 9886 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
9868 | 9887 |
9869 // Zoom into the page by a 2X factor | 9888 // Zoom into the page by a 2X factor |
9870 float min_page_scale = 1.f, max_page_scale = 4.f; | 9889 float min_page_scale = 1.f, max_page_scale = 4.f; |
9871 float page_scale_factor = 2.f; | 9890 float page_scale_factor = 2.f; |
9872 RebuildPropertyTrees(); | 9891 RebuildPropertyTrees(); |
9873 host_impl_->active_tree()->PushPageScaleFromMainThread( | 9892 host_impl_->active_tree()->PushPageScaleFromMainThread( |
9874 page_scale_factor, min_page_scale, max_page_scale); | 9893 page_scale_factor, min_page_scale, max_page_scale); |
9875 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 9894 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 9895 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
9876 | 9896 |
9877 // Scroll by a small amount, there should be no bubbling to the outer | 9897 // Scroll by a small amount, there should be no bubbling to the outer |
9878 // viewport. | 9898 // viewport. |
9879 base::TimeTicks start_time = | 9899 base::TimeTicks start_time = |
9880 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 9900 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
9881 BeginFrameArgs begin_frame_args = | 9901 BeginFrameArgs begin_frame_args = |
9882 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 9902 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
9883 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9903 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9884 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 9904 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
9885 .thread); | 9905 .thread); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10746 | 10766 |
10747 // Re-initialize with a software output surface. | 10767 // Re-initialize with a software output surface. |
10748 output_surface_ = FakeOutputSurface::CreateSoftware( | 10768 output_surface_ = FakeOutputSurface::CreateSoftware( |
10749 base::WrapUnique(new SoftwareOutputDevice)); | 10769 base::WrapUnique(new SoftwareOutputDevice)); |
10750 host_impl_->InitializeRenderer(output_surface_.get()); | 10770 host_impl_->InitializeRenderer(output_surface_.get()); |
10751 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10771 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10752 } | 10772 } |
10753 | 10773 |
10754 } // namespace | 10774 } // namespace |
10755 } // namespace cc | 10775 } // namespace cc |
OLD | NEW |