Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 LayerImpl* outer_clip = 374 LayerImpl* outer_clip =
375 host_impl_->OuterViewportScrollLayer()->test_properties()->parent; 375 host_impl_->OuterViewportScrollLayer()->test_properties()->parent;
376 outer_clip->SetBounds(viewport_size); 376 outer_clip->SetBounds(viewport_size);
377 377
378 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer() 378 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer()
379 ->test_properties() 379 ->test_properties()
380 ->parent->test_properties() 380 ->parent->test_properties()
381 ->parent; 381 ->parent;
382 inner_clip_layer->SetBounds(viewport_size); 382 inner_clip_layer->SetBounds(viewport_size);
383 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); 383 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size);
384
385 // Needs to happen before building property trees as the latter propagates
386 // these element ids to property tree nodes.
387 host_impl_->active_tree()->SetElementIdsForTesting();
384 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 388 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
385 389
386 host_impl_->SetViewportSize(viewport_size); 390 host_impl_->SetViewportSize(viewport_size);
387 host_impl_->active_tree()->DidBecomeActive(); 391 host_impl_->active_tree()->DidBecomeActive();
388 392
389 return content_layer; 393 return content_layer;
390 } 394 }
391 395
392 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id, 396 std::unique_ptr<LayerImpl> CreateScrollableLayer(int id,
393 const gfx::Size& size, 397 const gfx::Size& size,
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 root->SetBounds(gfx::Size(50, 50)); 1304 root->SetBounds(gfx::Size(50, 50));
1301 root->test_properties()->force_render_surface = true; 1305 root->test_properties()->force_render_surface = true;
1302 1306
1303 root->test_properties()->AddChild( 1307 root->test_properties()->AddChild(
1304 LayerImpl::Create(host_impl_->pending_tree(), 2)); 1308 LayerImpl::Create(host_impl_->pending_tree(), 2));
1305 host_impl_->pending_tree()->BuildLayerListForTesting(); 1309 host_impl_->pending_tree()->BuildLayerListForTesting();
1306 LayerImpl* child = root->test_properties()->children[0]; 1310 LayerImpl* child = root->test_properties()->children[0];
1307 child->SetBounds(gfx::Size(10, 10)); 1311 child->SetBounds(gfx::Size(10, 10));
1308 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1312 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1309 child->SetDrawsContent(true); 1313 child->SetDrawsContent(true);
1310 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1314
1315 host_impl_->pending_tree()->SetElementIdsForTesting();
1316
1317 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
1318 3, 0);
1311 1319
1312 EXPECT_FALSE(did_request_next_frame_); 1320 EXPECT_FALSE(did_request_next_frame_);
1313 EXPECT_FALSE(did_request_redraw_); 1321 EXPECT_FALSE(did_request_redraw_);
1314 EXPECT_FALSE(did_request_commit_); 1322 EXPECT_FALSE(did_request_commit_);
1315 1323
1316 host_impl_->AnimatePendingTreeAfterCommit(); 1324 host_impl_->AnimatePendingTreeAfterCommit();
1317 1325
1318 // An animation exists on the pending layer. Doing 1326 // An animation exists on the pending layer. Doing
1319 // AnimatePendingTreeAfterCommit() requests another frame. 1327 // AnimatePendingTreeAfterCommit() requests another frame.
1320 // In reality, animations without has_set_start_time() == true do not need to 1328 // In reality, animations without has_set_start_time() == true do not need to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 root->SetBounds(gfx::Size(50, 50)); 1360 root->SetBounds(gfx::Size(50, 50));
1353 root->test_properties()->force_render_surface = true; 1361 root->test_properties()->force_render_surface = true;
1354 1362
1355 root->test_properties()->AddChild( 1363 root->test_properties()->AddChild(
1356 LayerImpl::Create(host_impl_->active_tree(), 2)); 1364 LayerImpl::Create(host_impl_->active_tree(), 2));
1357 LayerImpl* child = root->test_properties()->children[0]; 1365 LayerImpl* child = root->test_properties()->children[0];
1358 child->SetBounds(gfx::Size(10, 10)); 1366 child->SetBounds(gfx::Size(10, 10));
1359 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1367 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1360 child->SetDrawsContent(true); 1368 child->SetDrawsContent(true);
1361 1369
1370 host_impl_->active_tree()->SetElementIdsForTesting();
1371
1362 // Add a translate from 6,7 to 8,9. 1372 // Add a translate from 6,7 to 8,9.
1363 TransformOperations start; 1373 TransformOperations start;
1364 start.AppendTranslate(6.f, 7.f, 0.f); 1374 start.AppendTranslate(6.f, 7.f, 0.f);
1365 TransformOperations end; 1375 TransformOperations end;
1366 end.AppendTranslate(8.f, 9.f, 0.f); 1376 end.AppendTranslate(8.f, 9.f, 0.f);
1367 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1377 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1368 end); 1378 start, end);
1369 1379
1370 base::TimeTicks now = base::TimeTicks::Now(); 1380 base::TimeTicks now = base::TimeTicks::Now();
1371 host_impl_->WillBeginImplFrame( 1381 host_impl_->WillBeginImplFrame(
1372 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1382 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1373 1383
1374 // TODO(crbug.com/551134): We always request a new frame and a draw for 1384 // TODO(crbug.com/551134): We always request a new frame and a draw for
1375 // animations that are on the pending tree, but we don't need to do that 1385 // animations that are on the pending tree, but we don't need to do that
1376 // unless they are waiting for some future time to start. 1386 // unless they are waiting for some future time to start.
1377 EXPECT_TRUE(did_request_next_frame_); 1387 EXPECT_TRUE(did_request_next_frame_);
1378 EXPECT_TRUE(did_request_redraw_); 1388 EXPECT_TRUE(did_request_redraw_);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1426 LayerImpl* root = host_impl_->active_tree()->root_layer();
1417 root->SetBounds(gfx::Size(50, 50)); 1427 root->SetBounds(gfx::Size(50, 50));
1418 root->SetHasRenderSurface(true); 1428 root->SetHasRenderSurface(true);
1419 1429
1420 root->test_properties()->AddChild( 1430 root->test_properties()->AddChild(
1421 LayerImpl::Create(host_impl_->active_tree(), 2)); 1431 LayerImpl::Create(host_impl_->active_tree(), 2));
1422 LayerImpl* child = root->test_properties()->children[0]; 1432 LayerImpl* child = root->test_properties()->children[0];
1423 child->SetBounds(gfx::Size(10, 10)); 1433 child->SetBounds(gfx::Size(10, 10));
1424 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1434 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1425 child->SetDrawsContent(true); 1435 child->SetDrawsContent(true);
1426 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1436
1437 host_impl_->active_tree()->SetElementIdsForTesting();
1438
1439 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
1440 3, 0);
1427 1441
1428 // Set up the property trees so that UpdateDrawProperties will work in 1442 // Set up the property trees so that UpdateDrawProperties will work in
1429 // CommitComplete below. 1443 // CommitComplete below.
1430 LayerImplList list; 1444 LayerImplList list;
1431 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1445 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1432 root, gfx::Size(50, 50), &list); 1446 root, gfx::Size(50, 50), &list);
1433 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1447 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1434 1448
1435 EXPECT_FALSE(did_request_next_frame_); 1449 EXPECT_FALSE(did_request_next_frame_);
1436 EXPECT_FALSE(did_request_redraw_); 1450 EXPECT_FALSE(did_request_redraw_);
(...skipping 19 matching lines...) Expand all
1456 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1470 LayerImpl* root = host_impl_->active_tree()->root_layer();
1457 root->SetBounds(gfx::Size(50, 50)); 1471 root->SetBounds(gfx::Size(50, 50));
1458 1472
1459 root->test_properties()->AddChild( 1473 root->test_properties()->AddChild(
1460 LayerImpl::Create(host_impl_->active_tree(), 2)); 1474 LayerImpl::Create(host_impl_->active_tree(), 2));
1461 LayerImpl* child = root->test_properties()->children[0]; 1475 LayerImpl* child = root->test_properties()->children[0];
1462 child->SetBounds(gfx::Size(10, 10)); 1476 child->SetBounds(gfx::Size(10, 10));
1463 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1477 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1464 child->SetDrawsContent(true); 1478 child->SetDrawsContent(true);
1465 1479
1480 host_impl_->active_tree()->SetElementIdsForTesting();
1481
1466 // Add a translate animation. 1482 // Add a translate animation.
1467 TransformOperations start; 1483 TransformOperations start;
1468 start.AppendTranslate(6.f, 7.f, 0.f); 1484 start.AppendTranslate(6.f, 7.f, 0.f);
1469 TransformOperations end; 1485 TransformOperations end;
1470 end.AppendTranslate(8.f, 9.f, 0.f); 1486 end.AppendTranslate(8.f, 9.f, 0.f);
1471 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1487 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1472 end); 1488 start, end);
1473 1489
1474 base::TimeTicks now = base::TimeTicks::Now(); 1490 base::TimeTicks now = base::TimeTicks::Now();
1475 host_impl_->WillBeginImplFrame( 1491 host_impl_->WillBeginImplFrame(
1476 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1492 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1477 EXPECT_TRUE(did_request_next_frame_); 1493 EXPECT_TRUE(did_request_next_frame_);
1478 did_request_next_frame_ = false; 1494 did_request_next_frame_ = false;
1479 1495
1480 host_impl_->ActivateAnimations(); 1496 host_impl_->ActivateAnimations();
1481 // On activating an animation, we should request another frame so that we'll 1497 // On activating an animation, we should request another frame so that we'll
1482 // continue ticking the animation. 1498 // continue ticking the animation.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 root->SetHasRenderSurface(true); 1547 root->SetHasRenderSurface(true);
1532 1548
1533 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( 1549 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>(
1534 new MissingTilesLayer(host_impl_->active_tree(), 2))); 1550 new MissingTilesLayer(host_impl_->active_tree(), 2)));
1535 MissingTilesLayer* child = 1551 MissingTilesLayer* child =
1536 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); 1552 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]);
1537 child->SetBounds(gfx::Size(10, 10)); 1553 child->SetBounds(gfx::Size(10, 10));
1538 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1554 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1539 child->SetDrawsContent(true); 1555 child->SetDrawsContent(true);
1540 1556
1557 host_impl_->active_tree()->SetElementIdsForTesting();
1558
1541 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1559 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1542 1560
1543 // Add a translate from 6,7 to 8,9. 1561 // Add a translate from 6,7 to 8,9.
1544 TransformOperations start; 1562 TransformOperations start;
1545 start.AppendTranslate(6.f, 7.f, 0.f); 1563 start.AppendTranslate(6.f, 7.f, 0.f);
1546 TransformOperations end; 1564 TransformOperations end;
1547 end.AppendTranslate(8.f, 9.f, 0.f); 1565 end.AppendTranslate(8.f, 9.f, 0.f);
1548 int animation_id = AddAnimatedTransformToLayerWithPlayer( 1566 int animation_id = AddAnimatedTransformToElementWithPlayer(
1549 child->id(), timeline(), 4.0, start, end); 1567 child->element_id(), timeline(), 4.0, start, end);
1550 1568
1551 base::TimeTicks now = base::TimeTicks::Now(); 1569 base::TimeTicks now = base::TimeTicks::Now();
1552 host_impl_->WillBeginImplFrame( 1570 host_impl_->WillBeginImplFrame(
1553 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1571 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1554 1572
1555 host_impl_->ActivateAnimations(); 1573 host_impl_->ActivateAnimations();
1556 host_impl_->Animate(); 1574 host_impl_->Animate();
1557 1575
1558 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); 1576 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation());
1559 1577
(...skipping 10 matching lines...) Expand all
1570 child->set_has_missing_tiles(false); 1588 child->set_has_missing_tiles(false);
1571 1589
1572 // Child layer has an animating and no missing tiles. 1590 // Child layer has an animating and no missing tiles.
1573 result = host_impl_->PrepareToDraw(&frame); 1591 result = host_impl_->PrepareToDraw(&frame);
1574 EXPECT_EQ(DRAW_SUCCESS, result); 1592 EXPECT_EQ(DRAW_SUCCESS, result);
1575 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1593 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1576 host_impl_->DidDrawAllLayers(frame); 1594 host_impl_->DidDrawAllLayers(frame);
1577 1595
1578 // Remove the animation. 1596 // Remove the animation.
1579 child->set_has_missing_tiles(true); 1597 child->set_has_missing_tiles(true);
1580 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), 1598 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(),
1581 animation_id); 1599 animation_id);
1582 child->draw_properties().screen_space_transform_is_animating = false; 1600 child->draw_properties().screen_space_transform_is_animating = false;
1583 1601
1584 // Child layer doesn't have an animation, but was never ready since the last 1602 // Child layer doesn't have an animation, but was never ready since the last
1585 // time it animated (and has missing tiles). 1603 // time it animated (and has missing tiles).
1586 result = host_impl_->PrepareToDraw(&frame); 1604 result = host_impl_->PrepareToDraw(&frame);
1587 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); 1605 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result);
1588 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); 1606 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation());
1589 host_impl_->DidDrawAllLayers(frame); 1607 host_impl_->DidDrawAllLayers(frame);
1590 1608
1591 child->set_has_missing_tiles(false); 1609 child->set_has_missing_tiles(false);
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, 3610 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl,
3593 int id, 3611 int id,
3594 bool tile_missing, 3612 bool tile_missing,
3595 bool had_incomplete_tile, 3613 bool had_incomplete_tile,
3596 bool animating, 3614 bool animating,
3597 ResourceProvider* resource_provider, 3615 ResourceProvider* resource_provider,
3598 scoped_refptr<AnimationTimeline> timeline) 3616 scoped_refptr<AnimationTimeline> timeline)
3599 : DidDrawCheckLayer(tree_impl, id), 3617 : DidDrawCheckLayer(tree_impl, id),
3600 tile_missing_(tile_missing), 3618 tile_missing_(tile_missing),
3601 had_incomplete_tile_(had_incomplete_tile) { 3619 had_incomplete_tile_(had_incomplete_tile) {
3602 if (animating) 3620 if (animating) {
3603 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); 3621 this->SetElementId(LayerIdToElementIdForTesting(id));
3622 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline,
3623 10.0, 3, 0);
3624 }
3604 } 3625 }
3605 3626
3606 bool tile_missing_; 3627 bool tile_missing_;
3607 bool had_incomplete_tile_; 3628 bool had_incomplete_tile_;
3608 }; 3629 };
3609 3630
3610 struct PrepareToDrawSuccessTestCase { 3631 struct PrepareToDrawSuccessTestCase {
3611 struct State { 3632 struct State {
3612 bool has_missing_tile = false; 3633 bool has_missing_tile = false;
3613 bool has_incomplete_tile = false; 3634 bool has_incomplete_tile = false;
(...skipping 6211 matching lines...) Expand 10 before | Expand all | Expand 10 after
9825 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); 9846 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread);
9826 9847
9827 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 9848 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
9828 9849
9829 begin_frame_args.frame_time = start_time; 9850 begin_frame_args.frame_time = start_time;
9830 host_impl_->WillBeginImplFrame(begin_frame_args); 9851 host_impl_->WillBeginImplFrame(begin_frame_args);
9831 host_impl_->Animate(); 9852 host_impl_->Animate();
9832 host_impl_->UpdateAnimationState(true); 9853 host_impl_->UpdateAnimationState(true);
9833 9854
9834 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( 9855 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
9835 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); 9856 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
9836 9857
9837 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 9858 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
9838 host_impl_->DidFinishImplFrame(); 9859 host_impl_->DidFinishImplFrame();
9839 9860
9840 begin_frame_args.frame_time = 9861 begin_frame_args.frame_time =
9841 start_time + base::TimeDelta::FromMilliseconds(50); 9862 start_time + base::TimeDelta::FromMilliseconds(50);
9842 host_impl_->WillBeginImplFrame(begin_frame_args); 9863 host_impl_->WillBeginImplFrame(begin_frame_args);
9843 host_impl_->Animate(); 9864 host_impl_->Animate();
9844 host_impl_->UpdateAnimationState(true); 9865 host_impl_->UpdateAnimationState(true);
9845 9866
(...skipping 12 matching lines...) Expand all
9858 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), 9879 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50),
9859 InputHandler::WHEEL)); 9880 InputHandler::WHEEL));
9860 std::unique_ptr<ScrollState> scroll_state_end = EndState(); 9881 std::unique_ptr<ScrollState> scroll_state_end = EndState();
9861 host_impl_->ScrollEnd(scroll_state_end.get()); 9882 host_impl_->ScrollEnd(scroll_state_end.get());
9862 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 9883 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
9863 InputHandler::WHEEL)); 9884 InputHandler::WHEEL));
9864 9885
9865 // The instant scroll should have marked the smooth scroll animation as 9886 // The instant scroll should have marked the smooth scroll animation as
9866 // aborted. 9887 // aborted.
9867 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( 9888 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
9868 scrolling_layer->id())); 9889 scrolling_layer->element_id()));
9869 9890
9870 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), 9891 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50),
9871 scrolling_layer->CurrentScrollOffset()); 9892 scrolling_layer->CurrentScrollOffset());
9872 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 9893 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
9873 host_impl_->DidFinishImplFrame(); 9894 host_impl_->DidFinishImplFrame();
9874 } 9895 }
9875 9896
9876 // Test that a smooth scroll offset animation is marked finished when aborted 9897 // Test that a smooth scroll offset animation is marked finished when aborted
9877 // with the needs_completion flag. The animation is then finished on the 9898 // with the needs_completion flag. The animation is then finished on the
9878 // main thread. 9899 // main thread.
(...skipping 17 matching lines...) Expand all
9896 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); 9917 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread);
9897 9918
9898 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 9919 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
9899 9920
9900 begin_frame_args.frame_time = start_time; 9921 begin_frame_args.frame_time = start_time;
9901 host_impl_->WillBeginImplFrame(begin_frame_args); 9922 host_impl_->WillBeginImplFrame(begin_frame_args);
9902 host_impl_->Animate(); 9923 host_impl_->Animate();
9903 host_impl_->UpdateAnimationState(true); 9924 host_impl_->UpdateAnimationState(true);
9904 9925
9905 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( 9926 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
9906 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); 9927 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
9907 9928
9908 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 9929 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
9909 host_impl_->DidFinishImplFrame(); 9930 host_impl_->DidFinishImplFrame();
9910 9931
9911 begin_frame_args.frame_time = 9932 begin_frame_args.frame_time =
9912 start_time + base::TimeDelta::FromMilliseconds(50); 9933 start_time + base::TimeDelta::FromMilliseconds(50);
9913 host_impl_->WillBeginImplFrame(begin_frame_args); 9934 host_impl_->WillBeginImplFrame(begin_frame_args);
9914 host_impl_->Animate(); 9935 host_impl_->Animate();
9915 host_impl_->UpdateAnimationState(true); 9936 host_impl_->UpdateAnimationState(true);
9916 9937
9917 float y = scrolling_layer->CurrentScrollOffset().y(); 9938 float y = scrolling_layer->CurrentScrollOffset().y();
9918 EXPECT_TRUE(y > 1 && y < 49); 9939 EXPECT_TRUE(y > 1 && y < 49);
9919 9940
9920 // Abort animation. 9941 // Abort animation.
9921 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); 9942 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/);
9922 host_impl_->UpdateAnimationState(true); 9943 host_impl_->UpdateAnimationState(true);
9923 9944
9924 // Aborting with the needs completion param should have marked the smooth 9945 // Aborting with the needs completion param should have marked the smooth
9925 // scroll animation as finished. 9946 // scroll animation as finished.
9926 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( 9947 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
9927 scrolling_layer->id())); 9948 scrolling_layer->element_id()));
9928 EXPECT_TRUE(y > 1 && y < 49); 9949 EXPECT_TRUE(y > 1 && y < 49);
9929 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 9950 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
9930 host_impl_->DidFinishImplFrame(); 9951 host_impl_->DidFinishImplFrame();
9931 } 9952 }
9932 9953
9933 // Evolved from LayerTreeHostImplTest.ScrollAnimated. 9954 // Evolved from LayerTreeHostImplTest.ScrollAnimated.
9934 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { 9955 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
9935 const gfx::Size content_size(1000, 1000); 9956 const gfx::Size content_size(1000, 1000);
9936 const gfx::Size viewport_size(500, 500); 9957 const gfx::Size viewport_size(500, 500);
9937 CreateBasicVirtualViewportLayers(viewport_size, content_size); 9958 CreateBasicVirtualViewportLayers(viewport_size, content_size);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
10006 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 10027 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
10007 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 10028 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
10008 10029
10009 // Zoom into the page by a 2X factor 10030 // Zoom into the page by a 2X factor
10010 float min_page_scale = 1.f, max_page_scale = 4.f; 10031 float min_page_scale = 1.f, max_page_scale = 4.f;
10011 float page_scale_factor = 2.f; 10032 float page_scale_factor = 2.f;
10012 RebuildPropertyTrees(); 10033 RebuildPropertyTrees();
10013 host_impl_->active_tree()->PushPageScaleFromMainThread( 10034 host_impl_->active_tree()->PushPageScaleFromMainThread(
10014 page_scale_factor, min_page_scale, max_page_scale); 10035 page_scale_factor, min_page_scale, max_page_scale);
10015 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 10036 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
10037 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
10016 10038
10017 // Scroll by a small amount, there should be no bubbling to the outer 10039 // Scroll by a small amount, there should be no bubbling to the outer
10018 // viewport. 10040 // viewport.
10019 base::TimeTicks start_time = 10041 base::TimeTicks start_time =
10020 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); 10042 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250);
10021 BeginFrameArgs begin_frame_args = 10043 BeginFrameArgs begin_frame_args =
10022 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 10044 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
10023 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10045 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10024 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) 10046 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f))
10025 .thread); 10047 .thread);
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
10896 10918
10897 // Re-initialize with a software output surface. 10919 // Re-initialize with a software output surface.
10898 output_surface_ = FakeOutputSurface::CreateSoftware( 10920 output_surface_ = FakeOutputSurface::CreateSoftware(
10899 base::WrapUnique(new SoftwareOutputDevice)); 10921 base::WrapUnique(new SoftwareOutputDevice));
10900 host_impl_->InitializeRenderer(output_surface_.get()); 10922 host_impl_->InitializeRenderer(output_surface_.get());
10901 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10923 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10902 } 10924 }
10903 10925
10904 } // namespace 10926 } // namespace
10905 } // namespace cc 10927 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698