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(); | |
383 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 379 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
384 | 380 |
385 host_impl_->SetViewportSize(viewport_size); | 381 host_impl_->SetViewportSize(viewport_size); |
386 host_impl_->active_tree()->DidBecomeActive(); | 382 host_impl_->active_tree()->DidBecomeActive(); |
387 | 383 |
388 return content_layer; | 384 return content_layer; |
389 } | 385 } |
390 | 386 |
391 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, | 387 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, |
392 const gfx::Size& size, | 388 const gfx::Size& size, |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1307 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
1312 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1308 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
1313 root->SetBounds(gfx::Size(50, 50)); | 1309 root->SetBounds(gfx::Size(50, 50)); |
1314 root->test_properties()->force_render_surface = true; | 1310 root->test_properties()->force_render_surface = true; |
1315 | 1311 |
1316 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1312 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
1317 LayerImpl* child = root->children()[0]; | 1313 LayerImpl* child = root->children()[0]; |
1318 child->SetBounds(gfx::Size(10, 10)); | 1314 child->SetBounds(gfx::Size(10, 10)); |
1319 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1315 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1320 child->SetDrawsContent(true); | 1316 child->SetDrawsContent(true); |
1321 | 1317 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
1322 host_impl_->pending_tree()->SetElementIdsForTesting(); | |
1323 | |
1324 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, | |
1325 3, 0); | |
1326 | 1318 |
1327 EXPECT_FALSE(did_request_next_frame_); | 1319 EXPECT_FALSE(did_request_next_frame_); |
1328 EXPECT_FALSE(did_request_redraw_); | 1320 EXPECT_FALSE(did_request_redraw_); |
1329 EXPECT_FALSE(did_request_commit_); | 1321 EXPECT_FALSE(did_request_commit_); |
1330 | 1322 |
1331 host_impl_->AnimatePendingTreeAfterCommit(); | 1323 host_impl_->AnimatePendingTreeAfterCommit(); |
1332 | 1324 |
1333 // An animation exists on the pending layer. Doing | 1325 // An animation exists on the pending layer. Doing |
1334 // AnimatePendingTreeAfterCommit() requests another frame. | 1326 // AnimatePendingTreeAfterCommit() requests another frame. |
1335 // In reality, animations without has_set_start_time() == true do not need to | 1327 // In reality, animations without has_set_start_time() == true do not need to |
(...skipping 30 matching lines...) Expand all Loading... |
1366 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1358 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1367 root->SetBounds(gfx::Size(50, 50)); | 1359 root->SetBounds(gfx::Size(50, 50)); |
1368 root->test_properties()->force_render_surface = true; | 1360 root->test_properties()->force_render_surface = true; |
1369 | 1361 |
1370 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1362 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1371 LayerImpl* child = root->children()[0]; | 1363 LayerImpl* child = root->children()[0]; |
1372 child->SetBounds(gfx::Size(10, 10)); | 1364 child->SetBounds(gfx::Size(10, 10)); |
1373 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1365 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1374 child->SetDrawsContent(true); | 1366 child->SetDrawsContent(true); |
1375 | 1367 |
1376 host_impl_->active_tree()->SetElementIdsForTesting(); | |
1377 | |
1378 // Add a translate from 6,7 to 8,9. | 1368 // Add a translate from 6,7 to 8,9. |
1379 TransformOperations start; | 1369 TransformOperations start; |
1380 start.AppendTranslate(6.f, 7.f, 0.f); | 1370 start.AppendTranslate(6.f, 7.f, 0.f); |
1381 TransformOperations end; | 1371 TransformOperations end; |
1382 end.AppendTranslate(8.f, 9.f, 0.f); | 1372 end.AppendTranslate(8.f, 9.f, 0.f); |
1383 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1373 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
1384 start, end); | 1374 end); |
1385 | 1375 |
1386 base::TimeTicks now = base::TimeTicks::Now(); | 1376 base::TimeTicks now = base::TimeTicks::Now(); |
1387 host_impl_->WillBeginImplFrame( | 1377 host_impl_->WillBeginImplFrame( |
1388 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1378 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1389 | 1379 |
1390 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1380 // TODO(crbug.com/551134): We always request a new frame and a draw for |
1391 // animations that are on the pending tree, but we don't need to do that | 1381 // animations that are on the pending tree, but we don't need to do that |
1392 // unless they are waiting for some future time to start. | 1382 // unless they are waiting for some future time to start. |
1393 EXPECT_TRUE(did_request_next_frame_); | 1383 EXPECT_TRUE(did_request_next_frame_); |
1394 EXPECT_TRUE(did_request_redraw_); | 1384 EXPECT_TRUE(did_request_redraw_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1421 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1432 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1422 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1433 root->SetBounds(gfx::Size(50, 50)); | 1423 root->SetBounds(gfx::Size(50, 50)); |
1434 root->SetHasRenderSurface(true); | 1424 root->SetHasRenderSurface(true); |
1435 | 1425 |
1436 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1426 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1437 LayerImpl* child = root->children()[0]; | 1427 LayerImpl* child = root->children()[0]; |
1438 child->SetBounds(gfx::Size(10, 10)); | 1428 child->SetBounds(gfx::Size(10, 10)); |
1439 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1429 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1440 child->SetDrawsContent(true); | 1430 child->SetDrawsContent(true); |
1441 | 1431 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
1442 host_impl_->active_tree()->SetElementIdsForTesting(); | |
1443 | |
1444 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0, | |
1445 3, 0); | |
1446 | 1432 |
1447 // Set up the property trees so that UpdateDrawProperties will work in | 1433 // Set up the property trees so that UpdateDrawProperties will work in |
1448 // CommitComplete below. | 1434 // CommitComplete below. |
1449 LayerImplList list; | 1435 LayerImplList list; |
1450 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1436 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1451 root, gfx::Size(50, 50), &list); | 1437 root, gfx::Size(50, 50), &list); |
1452 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1438 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1453 | 1439 |
1454 EXPECT_FALSE(did_request_next_frame_); | 1440 EXPECT_FALSE(did_request_next_frame_); |
1455 EXPECT_FALSE(did_request_redraw_); | 1441 EXPECT_FALSE(did_request_redraw_); |
(...skipping 18 matching lines...) Expand all Loading... |
1474 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1460 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1475 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1461 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1476 root->SetBounds(gfx::Size(50, 50)); | 1462 root->SetBounds(gfx::Size(50, 50)); |
1477 | 1463 |
1478 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1464 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1479 LayerImpl* child = root->children()[0]; | 1465 LayerImpl* child = root->children()[0]; |
1480 child->SetBounds(gfx::Size(10, 10)); | 1466 child->SetBounds(gfx::Size(10, 10)); |
1481 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1467 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1482 child->SetDrawsContent(true); | 1468 child->SetDrawsContent(true); |
1483 | 1469 |
1484 host_impl_->active_tree()->SetElementIdsForTesting(); | |
1485 | |
1486 // Add a translate animation. | 1470 // Add a translate animation. |
1487 TransformOperations start; | 1471 TransformOperations start; |
1488 start.AppendTranslate(6.f, 7.f, 0.f); | 1472 start.AppendTranslate(6.f, 7.f, 0.f); |
1489 TransformOperations end; | 1473 TransformOperations end; |
1490 end.AppendTranslate(8.f, 9.f, 0.f); | 1474 end.AppendTranslate(8.f, 9.f, 0.f); |
1491 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1475 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
1492 start, end); | 1476 end); |
1493 | 1477 |
1494 base::TimeTicks now = base::TimeTicks::Now(); | 1478 base::TimeTicks now = base::TimeTicks::Now(); |
1495 host_impl_->WillBeginImplFrame( | 1479 host_impl_->WillBeginImplFrame( |
1496 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1480 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1497 EXPECT_TRUE(did_request_next_frame_); | 1481 EXPECT_TRUE(did_request_next_frame_); |
1498 did_request_next_frame_ = false; | 1482 did_request_next_frame_ = false; |
1499 | 1483 |
1500 host_impl_->ActivateAnimations(); | 1484 host_impl_->ActivateAnimations(); |
1501 // On activating an animation, we should request another frame so that we'll | 1485 // On activating an animation, we should request another frame so that we'll |
1502 // continue ticking the animation. | 1486 // continue ticking the animation. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 root->SetHasRenderSurface(true); | 1535 root->SetHasRenderSurface(true); |
1552 | 1536 |
1553 root->AddChild(std::unique_ptr<MissingTilesLayer>( | 1537 root->AddChild(std::unique_ptr<MissingTilesLayer>( |
1554 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1538 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
1555 MissingTilesLayer* child = | 1539 MissingTilesLayer* child = |
1556 static_cast<MissingTilesLayer*>(root->children()[0]); | 1540 static_cast<MissingTilesLayer*>(root->children()[0]); |
1557 child->SetBounds(gfx::Size(10, 10)); | 1541 child->SetBounds(gfx::Size(10, 10)); |
1558 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1542 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1559 child->SetDrawsContent(true); | 1543 child->SetDrawsContent(true); |
1560 | 1544 |
1561 host_impl_->active_tree()->SetElementIdsForTesting(); | |
1562 | |
1563 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1545 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
1564 | 1546 |
1565 // Add a translate from 6,7 to 8,9. | 1547 // Add a translate from 6,7 to 8,9. |
1566 TransformOperations start; | 1548 TransformOperations start; |
1567 start.AppendTranslate(6.f, 7.f, 0.f); | 1549 start.AppendTranslate(6.f, 7.f, 0.f); |
1568 TransformOperations end; | 1550 TransformOperations end; |
1569 end.AppendTranslate(8.f, 9.f, 0.f); | 1551 end.AppendTranslate(8.f, 9.f, 0.f); |
1570 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1552 int animation_id = AddAnimatedTransformToLayerWithPlayer( |
1571 child->element_id(), timeline(), 4.0, start, end); | 1553 child->id(), timeline(), 4.0, start, end); |
1572 | 1554 |
1573 base::TimeTicks now = base::TimeTicks::Now(); | 1555 base::TimeTicks now = base::TimeTicks::Now(); |
1574 host_impl_->WillBeginImplFrame( | 1556 host_impl_->WillBeginImplFrame( |
1575 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1557 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
1576 | 1558 |
1577 host_impl_->ActivateAnimations(); | 1559 host_impl_->ActivateAnimations(); |
1578 host_impl_->Animate(); | 1560 host_impl_->Animate(); |
1579 | 1561 |
1580 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1562 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1581 | 1563 |
(...skipping 10 matching lines...) Expand all Loading... |
1592 child->set_has_missing_tiles(false); | 1574 child->set_has_missing_tiles(false); |
1593 | 1575 |
1594 // Child layer has an animating and no missing tiles. | 1576 // Child layer has an animating and no missing tiles. |
1595 result = host_impl_->PrepareToDraw(&frame); | 1577 result = host_impl_->PrepareToDraw(&frame); |
1596 EXPECT_EQ(DRAW_SUCCESS, result); | 1578 EXPECT_EQ(DRAW_SUCCESS, result); |
1597 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1579 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
1598 host_impl_->DidDrawAllLayers(frame); | 1580 host_impl_->DidDrawAllLayers(frame); |
1599 | 1581 |
1600 // Remove the animation. | 1582 // Remove the animation. |
1601 child->set_has_missing_tiles(true); | 1583 child->set_has_missing_tiles(true); |
1602 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), | 1584 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), |
1603 animation_id); | 1585 animation_id); |
1604 child->draw_properties().screen_space_transform_is_animating = false; | 1586 child->draw_properties().screen_space_transform_is_animating = false; |
1605 | 1587 |
1606 // Child layer doesn't have an animation, but was never ready since the last | 1588 // Child layer doesn't have an animation, but was never ready since the last |
1607 // time it animated (and has missing tiles). | 1589 // time it animated (and has missing tiles). |
1608 result = host_impl_->PrepareToDraw(&frame); | 1590 result = host_impl_->PrepareToDraw(&frame); |
1609 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1591 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
1610 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1592 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
1611 host_impl_->DidDrawAllLayers(frame); | 1593 host_impl_->DidDrawAllLayers(frame); |
1612 | 1594 |
1613 child->set_has_missing_tiles(false); | 1595 child->set_has_missing_tiles(false); |
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, | 3587 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
3606 int id, | 3588 int id, |
3607 bool tile_missing, | 3589 bool tile_missing, |
3608 bool had_incomplete_tile, | 3590 bool had_incomplete_tile, |
3609 bool animating, | 3591 bool animating, |
3610 ResourceProvider* resource_provider, | 3592 ResourceProvider* resource_provider, |
3611 scoped_refptr<AnimationTimeline> timeline) | 3593 scoped_refptr<AnimationTimeline> timeline) |
3612 : DidDrawCheckLayer(tree_impl, id), | 3594 : DidDrawCheckLayer(tree_impl, id), |
3613 tile_missing_(tile_missing), | 3595 tile_missing_(tile_missing), |
3614 had_incomplete_tile_(had_incomplete_tile) { | 3596 had_incomplete_tile_(had_incomplete_tile) { |
3615 if (animating) { | 3597 if (animating) |
3616 this->SetElementId(LayerIdToElementIdForTesting(id)); | 3598 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); |
3617 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline, | |
3618 10.0, 3, 0); | |
3619 } | |
3620 } | 3599 } |
3621 | 3600 |
3622 bool tile_missing_; | 3601 bool tile_missing_; |
3623 bool had_incomplete_tile_; | 3602 bool had_incomplete_tile_; |
3624 }; | 3603 }; |
3625 | 3604 |
3626 struct PrepareToDrawSuccessTestCase { | 3605 struct PrepareToDrawSuccessTestCase { |
3627 struct State { | 3606 struct State { |
3628 bool has_missing_tile = false; | 3607 bool has_missing_tile = false; |
3629 bool has_incomplete_tile = false; | 3608 bool has_incomplete_tile = false; |
(...skipping 6145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9775 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 9754 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
9776 | 9755 |
9777 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9756 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
9778 | 9757 |
9779 begin_frame_args.frame_time = start_time; | 9758 begin_frame_args.frame_time = start_time; |
9780 host_impl_->WillBeginImplFrame(begin_frame_args); | 9759 host_impl_->WillBeginImplFrame(begin_frame_args); |
9781 host_impl_->Animate(); | 9760 host_impl_->Animate(); |
9782 host_impl_->UpdateAnimationState(true); | 9761 host_impl_->UpdateAnimationState(true); |
9783 | 9762 |
9784 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9763 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
9785 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 9764 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); |
9786 | 9765 |
9787 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9766 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
9788 host_impl_->DidFinishImplFrame(); | 9767 host_impl_->DidFinishImplFrame(); |
9789 | 9768 |
9790 begin_frame_args.frame_time = | 9769 begin_frame_args.frame_time = |
9791 start_time + base::TimeDelta::FromMilliseconds(50); | 9770 start_time + base::TimeDelta::FromMilliseconds(50); |
9792 host_impl_->WillBeginImplFrame(begin_frame_args); | 9771 host_impl_->WillBeginImplFrame(begin_frame_args); |
9793 host_impl_->Animate(); | 9772 host_impl_->Animate(); |
9794 host_impl_->UpdateAnimationState(true); | 9773 host_impl_->UpdateAnimationState(true); |
9795 | 9774 |
(...skipping 12 matching lines...) Expand all Loading... |
9808 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 9787 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
9809 InputHandler::WHEEL)); | 9788 InputHandler::WHEEL)); |
9810 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 9789 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
9811 host_impl_->ScrollEnd(scroll_state_end.get()); | 9790 host_impl_->ScrollEnd(scroll_state_end.get()); |
9812 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 9791 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
9813 InputHandler::WHEEL)); | 9792 InputHandler::WHEEL)); |
9814 | 9793 |
9815 // The instant scroll should have marked the smooth scroll animation as | 9794 // The instant scroll should have marked the smooth scroll animation as |
9816 // aborted. | 9795 // aborted. |
9817 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9796 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
9818 scrolling_layer->element_id())); | 9797 scrolling_layer->id())); |
9819 | 9798 |
9820 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9799 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
9821 scrolling_layer->CurrentScrollOffset()); | 9800 scrolling_layer->CurrentScrollOffset()); |
9822 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9801 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
9823 host_impl_->DidFinishImplFrame(); | 9802 host_impl_->DidFinishImplFrame(); |
9824 } | 9803 } |
9825 | 9804 |
9826 // Test that a smooth scroll offset animation is marked finished when aborted | 9805 // Test that a smooth scroll offset animation is marked finished when aborted |
9827 // with the needs_completion flag. The animation is then finished on the | 9806 // with the needs_completion flag. The animation is then finished on the |
9828 // main thread. | 9807 // main thread. |
(...skipping 17 matching lines...) Expand all Loading... |
9846 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 9825 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
9847 | 9826 |
9848 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 9827 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
9849 | 9828 |
9850 begin_frame_args.frame_time = start_time; | 9829 begin_frame_args.frame_time = start_time; |
9851 host_impl_->WillBeginImplFrame(begin_frame_args); | 9830 host_impl_->WillBeginImplFrame(begin_frame_args); |
9852 host_impl_->Animate(); | 9831 host_impl_->Animate(); |
9853 host_impl_->UpdateAnimationState(true); | 9832 host_impl_->UpdateAnimationState(true); |
9854 | 9833 |
9855 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( | 9834 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
9856 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 9835 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); |
9857 | 9836 |
9858 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 9837 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
9859 host_impl_->DidFinishImplFrame(); | 9838 host_impl_->DidFinishImplFrame(); |
9860 | 9839 |
9861 begin_frame_args.frame_time = | 9840 begin_frame_args.frame_time = |
9862 start_time + base::TimeDelta::FromMilliseconds(50); | 9841 start_time + base::TimeDelta::FromMilliseconds(50); |
9863 host_impl_->WillBeginImplFrame(begin_frame_args); | 9842 host_impl_->WillBeginImplFrame(begin_frame_args); |
9864 host_impl_->Animate(); | 9843 host_impl_->Animate(); |
9865 host_impl_->UpdateAnimationState(true); | 9844 host_impl_->UpdateAnimationState(true); |
9866 | 9845 |
9867 float y = scrolling_layer->CurrentScrollOffset().y(); | 9846 float y = scrolling_layer->CurrentScrollOffset().y(); |
9868 EXPECT_TRUE(y > 1 && y < 49); | 9847 EXPECT_TRUE(y > 1 && y < 49); |
9869 | 9848 |
9870 // Abort animation. | 9849 // Abort animation. |
9871 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); | 9850 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); |
9872 host_impl_->UpdateAnimationState(true); | 9851 host_impl_->UpdateAnimationState(true); |
9873 | 9852 |
9874 // Aborting with the needs completion param should have marked the smooth | 9853 // Aborting with the needs completion param should have marked the smooth |
9875 // scroll animation as finished. | 9854 // scroll animation as finished. |
9876 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9855 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
9877 scrolling_layer->element_id())); | 9856 scrolling_layer->id())); |
9878 EXPECT_TRUE(y > 1 && y < 49); | 9857 EXPECT_TRUE(y > 1 && y < 49); |
9879 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9858 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
9880 host_impl_->DidFinishImplFrame(); | 9859 host_impl_->DidFinishImplFrame(); |
9881 } | 9860 } |
9882 | 9861 |
9883 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9862 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
9884 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9863 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
9885 const gfx::Size content_size(1000, 1000); | 9864 const gfx::Size content_size(1000, 1000); |
9886 const gfx::Size viewport_size(500, 500); | 9865 const gfx::Size viewport_size(500, 500); |
9887 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9866 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9956 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 9935 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
9957 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 9936 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
9958 | 9937 |
9959 // Zoom into the page by a 2X factor | 9938 // Zoom into the page by a 2X factor |
9960 float min_page_scale = 1.f, max_page_scale = 4.f; | 9939 float min_page_scale = 1.f, max_page_scale = 4.f; |
9961 float page_scale_factor = 2.f; | 9940 float page_scale_factor = 2.f; |
9962 RebuildPropertyTrees(); | 9941 RebuildPropertyTrees(); |
9963 host_impl_->active_tree()->PushPageScaleFromMainThread( | 9942 host_impl_->active_tree()->PushPageScaleFromMainThread( |
9964 page_scale_factor, min_page_scale, max_page_scale); | 9943 page_scale_factor, min_page_scale, max_page_scale); |
9965 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 9944 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
9966 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | |
9967 | 9945 |
9968 // Scroll by a small amount, there should be no bubbling to the outer | 9946 // Scroll by a small amount, there should be no bubbling to the outer |
9969 // viewport. | 9947 // viewport. |
9970 base::TimeTicks start_time = | 9948 base::TimeTicks start_time = |
9971 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 9949 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
9972 BeginFrameArgs begin_frame_args = | 9950 BeginFrameArgs begin_frame_args = |
9973 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 9951 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
9974 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9952 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
9975 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 9953 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
9976 .thread); | 9954 .thread); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10837 | 10815 |
10838 // Re-initialize with a software output surface. | 10816 // Re-initialize with a software output surface. |
10839 output_surface_ = FakeOutputSurface::CreateSoftware( | 10817 output_surface_ = FakeOutputSurface::CreateSoftware( |
10840 base::WrapUnique(new SoftwareOutputDevice)); | 10818 base::WrapUnique(new SoftwareOutputDevice)); |
10841 host_impl_->InitializeRenderer(output_surface_.get()); | 10819 host_impl_->InitializeRenderer(output_surface_.get()); |
10842 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10820 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10843 } | 10821 } |
10844 | 10822 |
10845 } // namespace | 10823 } // namespace |
10846 } // namespace cc | 10824 } // namespace cc |
OLD | NEW |