| 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 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3533 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, | 3549 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
| 3534 int id, | 3550 int id, |
| 3535 bool tile_missing, | 3551 bool tile_missing, |
| 3536 bool had_incomplete_tile, | 3552 bool had_incomplete_tile, |
| 3537 bool animating, | 3553 bool animating, |
| 3538 ResourceProvider* resource_provider, | 3554 ResourceProvider* resource_provider, |
| 3539 scoped_refptr<AnimationTimeline> timeline) | 3555 scoped_refptr<AnimationTimeline> timeline) |
| 3540 : DidDrawCheckLayer(tree_impl, id), | 3556 : DidDrawCheckLayer(tree_impl, id), |
| 3541 tile_missing_(tile_missing), | 3557 tile_missing_(tile_missing), |
| 3542 had_incomplete_tile_(had_incomplete_tile) { | 3558 had_incomplete_tile_(had_incomplete_tile) { |
| 3543 if (animating) | 3559 if (animating) { |
| 3544 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); | 3560 this->SetElementId(LayerIdToElementIdForTesting(id)); |
| 3561 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline, |
| 3562 10.0, 3, 0); |
| 3563 } |
| 3545 } | 3564 } |
| 3546 | 3565 |
| 3547 bool tile_missing_; | 3566 bool tile_missing_; |
| 3548 bool had_incomplete_tile_; | 3567 bool had_incomplete_tile_; |
| 3549 }; | 3568 }; |
| 3550 | 3569 |
| 3551 struct PrepareToDrawSuccessTestCase { | 3570 struct PrepareToDrawSuccessTestCase { |
| 3552 struct State { | 3571 struct State { |
| 3553 bool has_missing_tile = false; | 3572 bool has_missing_tile = false; |
| 3554 bool has_incomplete_tile = false; | 3573 bool has_incomplete_tile = false; |
| (...skipping 6143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9698 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 9717 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 9699 | 9718 |
| 9700 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9719 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 9701 | 9720 |
| 9702 begin_frame_args.frame_time = start_time; | 9721 begin_frame_args.frame_time = start_time; |
| 9703 host_impl_->WillBeginImplFrame(begin_frame_args); | 9722 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9704 host_impl_->Animate(); | 9723 host_impl_->Animate(); |
| 9705 host_impl_->UpdateAnimationState(true); | 9724 host_impl_->UpdateAnimationState(true); |
| 9706 | 9725 |
| 9707 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9726 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
| 9708 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9727 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 9709 | 9728 |
| 9710 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9729 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 9711 host_impl_->DidFinishImplFrame(); | 9730 host_impl_->DidFinishImplFrame(); |
| 9712 | 9731 |
| 9713 begin_frame_args.frame_time = | 9732 begin_frame_args.frame_time = |
| 9714 start_time + base::TimeDelta::FromMilliseconds(50); | 9733 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9715 host_impl_->WillBeginImplFrame(begin_frame_args); | 9734 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9716 host_impl_->Animate(); | 9735 host_impl_->Animate(); |
| 9717 host_impl_->UpdateAnimationState(true); | 9736 host_impl_->UpdateAnimationState(true); |
| 9718 | 9737 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9731 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 9750 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
| 9732 InputHandler::WHEEL)); | 9751 InputHandler::WHEEL)); |
| 9733 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 9752 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
| 9734 host_impl_->ScrollEnd(scroll_state_end.get()); | 9753 host_impl_->ScrollEnd(scroll_state_end.get()); |
| 9735 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 9754 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 9736 InputHandler::WHEEL)); | 9755 InputHandler::WHEEL)); |
| 9737 | 9756 |
| 9738 // The instant scroll should have marked the smooth scroll animation as | 9757 // The instant scroll should have marked the smooth scroll animation as |
| 9739 // aborted. | 9758 // aborted. |
| 9740 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9759 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 9741 scrolling_layer->id())); | 9760 scrolling_layer->element_id())); |
| 9742 | 9761 |
| 9743 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9762 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 9744 scrolling_layer->CurrentScrollOffset()); | 9763 scrolling_layer->CurrentScrollOffset()); |
| 9745 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9764 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9746 host_impl_->DidFinishImplFrame(); | 9765 host_impl_->DidFinishImplFrame(); |
| 9747 } | 9766 } |
| 9748 | 9767 |
| 9749 // Test that a smooth scroll offset animation is marked finished when aborted | 9768 // Test that a smooth scroll offset animation is marked finished when aborted |
| 9750 // with the needs_completion flag. The animation is then finished on the | 9769 // with the needs_completion flag. The animation is then finished on the |
| 9751 // main thread. | 9770 // main thread. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9769 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 9788 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
| 9770 | 9789 |
| 9771 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9790 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 9772 | 9791 |
| 9773 begin_frame_args.frame_time = start_time; | 9792 begin_frame_args.frame_time = start_time; |
| 9774 host_impl_->WillBeginImplFrame(begin_frame_args); | 9793 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9775 host_impl_->Animate(); | 9794 host_impl_->Animate(); |
| 9776 host_impl_->UpdateAnimationState(true); | 9795 host_impl_->UpdateAnimationState(true); |
| 9777 | 9796 |
| 9778 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9797 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
| 9779 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); | 9798 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 9780 | 9799 |
| 9781 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9800 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 9782 host_impl_->DidFinishImplFrame(); | 9801 host_impl_->DidFinishImplFrame(); |
| 9783 | 9802 |
| 9784 begin_frame_args.frame_time = | 9803 begin_frame_args.frame_time = |
| 9785 start_time + base::TimeDelta::FromMilliseconds(50); | 9804 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9786 host_impl_->WillBeginImplFrame(begin_frame_args); | 9805 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9787 host_impl_->Animate(); | 9806 host_impl_->Animate(); |
| 9788 host_impl_->UpdateAnimationState(true); | 9807 host_impl_->UpdateAnimationState(true); |
| 9789 | 9808 |
| 9790 float y = scrolling_layer->CurrentScrollOffset().y(); | 9809 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 9791 EXPECT_TRUE(y > 1 && y < 49); | 9810 EXPECT_TRUE(y > 1 && y < 49); |
| 9792 | 9811 |
| 9793 // Abort animation. | 9812 // Abort animation. |
| 9794 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); | 9813 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); |
| 9795 host_impl_->UpdateAnimationState(true); | 9814 host_impl_->UpdateAnimationState(true); |
| 9796 | 9815 |
| 9797 // Aborting with the needs completion param should have marked the smooth | 9816 // Aborting with the needs completion param should have marked the smooth |
| 9798 // scroll animation as finished. | 9817 // scroll animation as finished. |
| 9799 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9818 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 9800 scrolling_layer->id())); | 9819 scrolling_layer->element_id())); |
| 9801 EXPECT_TRUE(y > 1 && y < 49); | 9820 EXPECT_TRUE(y > 1 && y < 49); |
| 9802 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9821 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9803 host_impl_->DidFinishImplFrame(); | 9822 host_impl_->DidFinishImplFrame(); |
| 9804 } | 9823 } |
| 9805 | 9824 |
| 9806 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9825 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
| 9807 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9826 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
| 9808 const gfx::Size content_size(1000, 1000); | 9827 const gfx::Size content_size(1000, 1000); |
| 9809 const gfx::Size viewport_size(500, 500); | 9828 const gfx::Size viewport_size(500, 500); |
| 9810 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9829 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9879 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 9898 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 9880 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 9899 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 9881 | 9900 |
| 9882 // Zoom into the page by a 2X factor | 9901 // Zoom into the page by a 2X factor |
| 9883 float min_page_scale = 1.f, max_page_scale = 4.f; | 9902 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 9884 float page_scale_factor = 2.f; | 9903 float page_scale_factor = 2.f; |
| 9885 RebuildPropertyTrees(); | 9904 RebuildPropertyTrees(); |
| 9886 host_impl_->active_tree()->PushPageScaleFromMainThread( | 9905 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 9887 page_scale_factor, min_page_scale, max_page_scale); | 9906 page_scale_factor, min_page_scale, max_page_scale); |
| 9888 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 9907 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 9908 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9889 | 9909 |
| 9890 // Scroll by a small amount, there should be no bubbling to the outer | 9910 // Scroll by a small amount, there should be no bubbling to the outer |
| 9891 // viewport. | 9911 // viewport. |
| 9892 base::TimeTicks start_time = | 9912 base::TimeTicks start_time = |
| 9893 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 9913 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
| 9894 BeginFrameArgs begin_frame_args = | 9914 BeginFrameArgs begin_frame_args = |
| 9895 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 9915 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 9896 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9916 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9897 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 9917 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
| 9898 .thread); | 9918 .thread); |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10759 | 10779 |
| 10760 // Re-initialize with a software output surface. | 10780 // Re-initialize with a software output surface. |
| 10761 output_surface_ = FakeOutputSurface::CreateSoftware( | 10781 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10762 base::WrapUnique(new SoftwareOutputDevice)); | 10782 base::WrapUnique(new SoftwareOutputDevice)); |
| 10763 host_impl_->InitializeRenderer(output_surface_.get()); | 10783 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10764 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10784 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10765 } | 10785 } |
| 10766 | 10786 |
| 10767 } // namespace | 10787 } // namespace |
| 10768 } // namespace cc | 10788 } // namespace cc |
| OLD | NEW |