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

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: rebase 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 root->SetBounds(gfx::Size(50, 50)); 1306 root->SetBounds(gfx::Size(50, 50));
1303 root->test_properties()->force_render_surface = true; 1307 root->test_properties()->force_render_surface = true;
1304 1308
1305 root->test_properties()->AddChild( 1309 root->test_properties()->AddChild(
1306 LayerImpl::Create(host_impl_->pending_tree(), 2)); 1310 LayerImpl::Create(host_impl_->pending_tree(), 2));
1307 host_impl_->pending_tree()->BuildLayerListForTesting(); 1311 host_impl_->pending_tree()->BuildLayerListForTesting();
1308 LayerImpl* child = root->test_properties()->children[0]; 1312 LayerImpl* child = root->test_properties()->children[0];
1309 child->SetBounds(gfx::Size(10, 10)); 1313 child->SetBounds(gfx::Size(10, 10));
1310 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1314 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1311 child->SetDrawsContent(true); 1315 child->SetDrawsContent(true);
1312 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1316
1317 host_impl_->pending_tree()->SetElementIdsForTesting();
1318
1319 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
1320 3, 0);
1313 1321
1314 EXPECT_FALSE(did_request_next_frame_); 1322 EXPECT_FALSE(did_request_next_frame_);
1315 EXPECT_FALSE(did_request_redraw_); 1323 EXPECT_FALSE(did_request_redraw_);
1316 EXPECT_FALSE(did_request_commit_); 1324 EXPECT_FALSE(did_request_commit_);
1317 1325
1318 host_impl_->AnimatePendingTreeAfterCommit(); 1326 host_impl_->AnimatePendingTreeAfterCommit();
1319 1327
1320 // An animation exists on the pending layer. Doing 1328 // An animation exists on the pending layer. Doing
1321 // AnimatePendingTreeAfterCommit() requests another frame. 1329 // AnimatePendingTreeAfterCommit() requests another frame.
1322 // In reality, animations without has_set_start_time() == true do not need to 1330 // 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
1354 root->SetBounds(gfx::Size(50, 50)); 1362 root->SetBounds(gfx::Size(50, 50));
1355 root->test_properties()->force_render_surface = true; 1363 root->test_properties()->force_render_surface = true;
1356 1364
1357 root->test_properties()->AddChild( 1365 root->test_properties()->AddChild(
1358 LayerImpl::Create(host_impl_->active_tree(), 2)); 1366 LayerImpl::Create(host_impl_->active_tree(), 2));
1359 LayerImpl* child = root->test_properties()->children[0]; 1367 LayerImpl* child = root->test_properties()->children[0];
1360 child->SetBounds(gfx::Size(10, 10)); 1368 child->SetBounds(gfx::Size(10, 10));
1361 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1369 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1362 child->SetDrawsContent(true); 1370 child->SetDrawsContent(true);
1363 1371
1372 host_impl_->active_tree()->SetElementIdsForTesting();
1373
1364 // Add a translate from 6,7 to 8,9. 1374 // Add a translate from 6,7 to 8,9.
1365 TransformOperations start; 1375 TransformOperations start;
1366 start.AppendTranslate(6.f, 7.f, 0.f); 1376 start.AppendTranslate(6.f, 7.f, 0.f);
1367 TransformOperations end; 1377 TransformOperations end;
1368 end.AppendTranslate(8.f, 9.f, 0.f); 1378 end.AppendTranslate(8.f, 9.f, 0.f);
1369 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1379 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1370 end); 1380 start, end);
1371 1381
1372 base::TimeTicks now = base::TimeTicks::Now(); 1382 base::TimeTicks now = base::TimeTicks::Now();
1373 host_impl_->WillBeginImplFrame( 1383 host_impl_->WillBeginImplFrame(
1374 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1384 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1375 1385
1376 // TODO(crbug.com/551134): We always request a new frame and a draw for 1386 // TODO(crbug.com/551134): We always request a new frame and a draw for
1377 // animations that are on the pending tree, but we don't need to do that 1387 // animations that are on the pending tree, but we don't need to do that
1378 // unless they are waiting for some future time to start. 1388 // unless they are waiting for some future time to start.
1379 EXPECT_TRUE(did_request_next_frame_); 1389 EXPECT_TRUE(did_request_next_frame_);
1380 EXPECT_TRUE(did_request_redraw_); 1390 EXPECT_TRUE(did_request_redraw_);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 1428 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
1419 root->SetBounds(gfx::Size(50, 50)); 1429 root->SetBounds(gfx::Size(50, 50));
1420 root->SetHasRenderSurface(true); 1430 root->SetHasRenderSurface(true);
1421 1431
1422 root->test_properties()->AddChild( 1432 root->test_properties()->AddChild(
1423 LayerImpl::Create(host_impl_->active_tree(), 2)); 1433 LayerImpl::Create(host_impl_->active_tree(), 2));
1424 LayerImpl* child = root->test_properties()->children[0]; 1434 LayerImpl* child = root->test_properties()->children[0];
1425 child->SetBounds(gfx::Size(10, 10)); 1435 child->SetBounds(gfx::Size(10, 10));
1426 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1436 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1427 child->SetDrawsContent(true); 1437 child->SetDrawsContent(true);
1428 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1438
1439 host_impl_->active_tree()->SetElementIdsForTesting();
1440
1441 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
1442 3, 0);
1429 1443
1430 // Set up the property trees so that UpdateDrawProperties will work in 1444 // Set up the property trees so that UpdateDrawProperties will work in
1431 // CommitComplete below. 1445 // CommitComplete below.
1432 LayerImplList list; 1446 LayerImplList list;
1433 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1447 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1434 root, gfx::Size(50, 50), &list); 1448 root, gfx::Size(50, 50), &list);
1435 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1449 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1436 1450
1437 EXPECT_FALSE(did_request_next_frame_); 1451 EXPECT_FALSE(did_request_next_frame_);
1438 EXPECT_FALSE(did_request_redraw_); 1452 EXPECT_FALSE(did_request_redraw_);
(...skipping 19 matching lines...) Expand all
1458 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 1472 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
1459 root->SetBounds(gfx::Size(50, 50)); 1473 root->SetBounds(gfx::Size(50, 50));
1460 1474
1461 root->test_properties()->AddChild( 1475 root->test_properties()->AddChild(
1462 LayerImpl::Create(host_impl_->active_tree(), 2)); 1476 LayerImpl::Create(host_impl_->active_tree(), 2));
1463 LayerImpl* child = root->test_properties()->children[0]; 1477 LayerImpl* child = root->test_properties()->children[0];
1464 child->SetBounds(gfx::Size(10, 10)); 1478 child->SetBounds(gfx::Size(10, 10));
1465 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1479 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1466 child->SetDrawsContent(true); 1480 child->SetDrawsContent(true);
1467 1481
1482 host_impl_->active_tree()->SetElementIdsForTesting();
1483
1468 // Add a translate animation. 1484 // Add a translate animation.
1469 TransformOperations start; 1485 TransformOperations start;
1470 start.AppendTranslate(6.f, 7.f, 0.f); 1486 start.AppendTranslate(6.f, 7.f, 0.f);
1471 TransformOperations end; 1487 TransformOperations end;
1472 end.AppendTranslate(8.f, 9.f, 0.f); 1488 end.AppendTranslate(8.f, 9.f, 0.f);
1473 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1489 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1474 end); 1490 start, end);
1475 1491
1476 base::TimeTicks now = base::TimeTicks::Now(); 1492 base::TimeTicks now = base::TimeTicks::Now();
1477 host_impl_->WillBeginImplFrame( 1493 host_impl_->WillBeginImplFrame(
1478 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1494 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1479 EXPECT_TRUE(did_request_next_frame_); 1495 EXPECT_TRUE(did_request_next_frame_);
1480 did_request_next_frame_ = false; 1496 did_request_next_frame_ = false;
1481 1497
1482 host_impl_->ActivateAnimations(); 1498 host_impl_->ActivateAnimations();
1483 // On activating an animation, we should request another frame so that we'll 1499 // On activating an animation, we should request another frame so that we'll
1484 // continue ticking the animation. 1500 // continue ticking the animation.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 root->SetHasRenderSurface(true); 1549 root->SetHasRenderSurface(true);
1534 1550
1535 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( 1551 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>(
1536 new MissingTilesLayer(host_impl_->active_tree(), 2))); 1552 new MissingTilesLayer(host_impl_->active_tree(), 2)));
1537 MissingTilesLayer* child = 1553 MissingTilesLayer* child =
1538 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); 1554 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]);
1539 child->SetBounds(gfx::Size(10, 10)); 1555 child->SetBounds(gfx::Size(10, 10));
1540 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1556 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1541 child->SetDrawsContent(true); 1557 child->SetDrawsContent(true);
1542 1558
1559 host_impl_->active_tree()->SetElementIdsForTesting();
1560
1543 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1561 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1544 1562
1545 // Add a translate from 6,7 to 8,9. 1563 // Add a translate from 6,7 to 8,9.
1546 TransformOperations start; 1564 TransformOperations start;
1547 start.AppendTranslate(6.f, 7.f, 0.f); 1565 start.AppendTranslate(6.f, 7.f, 0.f);
1548 TransformOperations end; 1566 TransformOperations end;
1549 end.AppendTranslate(8.f, 9.f, 0.f); 1567 end.AppendTranslate(8.f, 9.f, 0.f);
1550 int animation_id = AddAnimatedTransformToLayerWithPlayer( 1568 int animation_id = AddAnimatedTransformToElementWithPlayer(
1551 child->id(), timeline(), 4.0, start, end); 1569 child->element_id(), timeline(), 4.0, start, end);
1552 1570
1553 base::TimeTicks now = base::TimeTicks::Now(); 1571 base::TimeTicks now = base::TimeTicks::Now();
1554 host_impl_->WillBeginImplFrame( 1572 host_impl_->WillBeginImplFrame(
1555 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); 1573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now));
1556 1574
1557 host_impl_->ActivateAnimations(); 1575 host_impl_->ActivateAnimations();
1558 host_impl_->Animate(); 1576 host_impl_->Animate();
1559 1577
1560 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); 1578 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation());
1561 1579
(...skipping 10 matching lines...) Expand all
1572 child->set_has_missing_tiles(false); 1590 child->set_has_missing_tiles(false);
1573 1591
1574 // Child layer has an animating and no missing tiles. 1592 // Child layer has an animating and no missing tiles.
1575 result = host_impl_->PrepareToDraw(&frame); 1593 result = host_impl_->PrepareToDraw(&frame);
1576 EXPECT_EQ(DRAW_SUCCESS, result); 1594 EXPECT_EQ(DRAW_SUCCESS, result);
1577 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1595 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1578 host_impl_->DidDrawAllLayers(frame); 1596 host_impl_->DidDrawAllLayers(frame);
1579 1597
1580 // Remove the animation. 1598 // Remove the animation.
1581 child->set_has_missing_tiles(true); 1599 child->set_has_missing_tiles(true);
1582 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), 1600 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(),
1583 animation_id); 1601 animation_id);
1584 child->draw_properties().screen_space_transform_is_animating = false; 1602 child->draw_properties().screen_space_transform_is_animating = false;
1585 1603
1586 // Child layer doesn't have an animation, but was never ready since the last 1604 // Child layer doesn't have an animation, but was never ready since the last
1587 // time it animated (and has missing tiles). 1605 // time it animated (and has missing tiles).
1588 result = host_impl_->PrepareToDraw(&frame); 1606 result = host_impl_->PrepareToDraw(&frame);
1589 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); 1607 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result);
1590 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); 1608 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation());
1591 host_impl_->DidDrawAllLayers(frame); 1609 host_impl_->DidDrawAllLayers(frame);
1592 1610
1593 child->set_has_missing_tiles(false); 1611 child->set_has_missing_tiles(false);
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3595 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, 3613 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl,
3596 int id, 3614 int id,
3597 bool tile_missing, 3615 bool tile_missing,
3598 bool had_incomplete_tile, 3616 bool had_incomplete_tile,
3599 bool animating, 3617 bool animating,
3600 ResourceProvider* resource_provider, 3618 ResourceProvider* resource_provider,
3601 scoped_refptr<AnimationTimeline> timeline) 3619 scoped_refptr<AnimationTimeline> timeline)
3602 : DidDrawCheckLayer(tree_impl, id), 3620 : DidDrawCheckLayer(tree_impl, id),
3603 tile_missing_(tile_missing), 3621 tile_missing_(tile_missing),
3604 had_incomplete_tile_(had_incomplete_tile) { 3622 had_incomplete_tile_(had_incomplete_tile) {
3605 if (animating) 3623 if (animating) {
3606 AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); 3624 this->SetElementId(LayerIdToElementIdForTesting(id));
3625 AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline,
3626 10.0, 3, 0);
3627 }
3607 } 3628 }
3608 3629
3609 bool tile_missing_; 3630 bool tile_missing_;
3610 bool had_incomplete_tile_; 3631 bool had_incomplete_tile_;
3611 }; 3632 };
3612 3633
3613 struct PrepareToDrawSuccessTestCase { 3634 struct PrepareToDrawSuccessTestCase {
3614 struct State { 3635 struct State {
3615 bool has_missing_tile = false; 3636 bool has_missing_tile = false;
3616 bool has_incomplete_tile = false; 3637 bool has_incomplete_tile = false;
(...skipping 6224 matching lines...) Expand 10 before | Expand all | Expand 10 after
9841 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); 9862 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread);
9842 9863
9843 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 9864 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
9844 9865
9845 begin_frame_args.frame_time = start_time; 9866 begin_frame_args.frame_time = start_time;
9846 host_impl_->WillBeginImplFrame(begin_frame_args); 9867 host_impl_->WillBeginImplFrame(begin_frame_args);
9847 host_impl_->Animate(); 9868 host_impl_->Animate();
9848 host_impl_->UpdateAnimationState(true); 9869 host_impl_->UpdateAnimationState(true);
9849 9870
9850 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( 9871 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
9851 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); 9872 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
9852 9873
9853 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 9874 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
9854 host_impl_->DidFinishImplFrame(); 9875 host_impl_->DidFinishImplFrame();
9855 9876
9856 begin_frame_args.frame_time = 9877 begin_frame_args.frame_time =
9857 start_time + base::TimeDelta::FromMilliseconds(50); 9878 start_time + base::TimeDelta::FromMilliseconds(50);
9858 host_impl_->WillBeginImplFrame(begin_frame_args); 9879 host_impl_->WillBeginImplFrame(begin_frame_args);
9859 host_impl_->Animate(); 9880 host_impl_->Animate();
9860 host_impl_->UpdateAnimationState(true); 9881 host_impl_->UpdateAnimationState(true);
9861 9882
(...skipping 12 matching lines...) Expand all
9874 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), 9895 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50),
9875 InputHandler::WHEEL)); 9896 InputHandler::WHEEL));
9876 std::unique_ptr<ScrollState> scroll_state_end = EndState(); 9897 std::unique_ptr<ScrollState> scroll_state_end = EndState();
9877 host_impl_->ScrollEnd(scroll_state_end.get()); 9898 host_impl_->ScrollEnd(scroll_state_end.get());
9878 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 9899 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
9879 InputHandler::WHEEL)); 9900 InputHandler::WHEEL));
9880 9901
9881 // The instant scroll should have marked the smooth scroll animation as 9902 // The instant scroll should have marked the smooth scroll animation as
9882 // aborted. 9903 // aborted.
9883 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( 9904 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
9884 scrolling_layer->id())); 9905 scrolling_layer->element_id()));
9885 9906
9886 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), 9907 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50),
9887 scrolling_layer->CurrentScrollOffset()); 9908 scrolling_layer->CurrentScrollOffset());
9888 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 9909 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
9889 host_impl_->DidFinishImplFrame(); 9910 host_impl_->DidFinishImplFrame();
9890 } 9911 }
9891 9912
9892 // Test that a smooth scroll offset animation is marked finished when aborted 9913 // Test that a smooth scroll offset animation is marked finished when aborted
9893 // with the needs_completion flag. The animation is then finished on the 9914 // with the needs_completion flag. The animation is then finished on the
9894 // main thread. 9915 // main thread.
(...skipping 17 matching lines...) Expand all
9912 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); 9933 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread);
9913 9934
9914 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 9935 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
9915 9936
9916 begin_frame_args.frame_time = start_time; 9937 begin_frame_args.frame_time = start_time;
9917 host_impl_->WillBeginImplFrame(begin_frame_args); 9938 host_impl_->WillBeginImplFrame(begin_frame_args);
9918 host_impl_->Animate(); 9939 host_impl_->Animate();
9919 host_impl_->UpdateAnimationState(true); 9940 host_impl_->UpdateAnimationState(true);
9920 9941
9921 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( 9942 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
9922 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); 9943 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
9923 9944
9924 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 9945 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
9925 host_impl_->DidFinishImplFrame(); 9946 host_impl_->DidFinishImplFrame();
9926 9947
9927 begin_frame_args.frame_time = 9948 begin_frame_args.frame_time =
9928 start_time + base::TimeDelta::FromMilliseconds(50); 9949 start_time + base::TimeDelta::FromMilliseconds(50);
9929 host_impl_->WillBeginImplFrame(begin_frame_args); 9950 host_impl_->WillBeginImplFrame(begin_frame_args);
9930 host_impl_->Animate(); 9951 host_impl_->Animate();
9931 host_impl_->UpdateAnimationState(true); 9952 host_impl_->UpdateAnimationState(true);
9932 9953
9933 float y = scrolling_layer->CurrentScrollOffset().y(); 9954 float y = scrolling_layer->CurrentScrollOffset().y();
9934 EXPECT_TRUE(y > 1 && y < 49); 9955 EXPECT_TRUE(y > 1 && y < 49);
9935 9956
9936 // Abort animation. 9957 // Abort animation.
9937 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); 9958 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/);
9938 host_impl_->UpdateAnimationState(true); 9959 host_impl_->UpdateAnimationState(true);
9939 9960
9940 // Aborting with the needs completion param should have marked the smooth 9961 // Aborting with the needs completion param should have marked the smooth
9941 // scroll animation as finished. 9962 // scroll animation as finished.
9942 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( 9963 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
9943 scrolling_layer->id())); 9964 scrolling_layer->element_id()));
9944 EXPECT_TRUE(y > 1 && y < 49); 9965 EXPECT_TRUE(y > 1 && y < 49);
9945 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 9966 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
9946 host_impl_->DidFinishImplFrame(); 9967 host_impl_->DidFinishImplFrame();
9947 } 9968 }
9948 9969
9949 // Evolved from LayerTreeHostImplTest.ScrollAnimated. 9970 // Evolved from LayerTreeHostImplTest.ScrollAnimated.
9950 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { 9971 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
9951 const gfx::Size content_size(1000, 1000); 9972 const gfx::Size content_size(1000, 1000);
9952 const gfx::Size viewport_size(500, 500); 9973 const gfx::Size viewport_size(500, 500);
9953 CreateBasicVirtualViewportLayers(viewport_size, content_size); 9974 CreateBasicVirtualViewportLayers(viewport_size, content_size);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
10022 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); 10043 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer();
10023 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); 10044 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer();
10024 10045
10025 // Zoom into the page by a 2X factor 10046 // Zoom into the page by a 2X factor
10026 float min_page_scale = 1.f, max_page_scale = 4.f; 10047 float min_page_scale = 1.f, max_page_scale = 4.f;
10027 float page_scale_factor = 2.f; 10048 float page_scale_factor = 2.f;
10028 RebuildPropertyTrees(); 10049 RebuildPropertyTrees();
10029 host_impl_->active_tree()->PushPageScaleFromMainThread( 10050 host_impl_->active_tree()->PushPageScaleFromMainThread(
10030 page_scale_factor, min_page_scale, max_page_scale); 10051 page_scale_factor, min_page_scale, max_page_scale);
10031 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 10052 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
10053 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
10032 10054
10033 // Scroll by a small amount, there should be no bubbling to the outer 10055 // Scroll by a small amount, there should be no bubbling to the outer
10034 // viewport. 10056 // viewport.
10035 base::TimeTicks start_time = 10057 base::TimeTicks start_time =
10036 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); 10058 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250);
10037 BeginFrameArgs begin_frame_args = 10059 BeginFrameArgs begin_frame_args =
10038 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 10060 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
10039 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10061 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10040 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) 10062 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f))
10041 .thread); 10063 .thread);
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
10913 10935
10914 // Re-initialize with a software output surface. 10936 // Re-initialize with a software output surface.
10915 output_surface_ = FakeOutputSurface::CreateSoftware( 10937 output_surface_ = FakeOutputSurface::CreateSoftware(
10916 base::WrapUnique(new SoftwareOutputDevice)); 10938 base::WrapUnique(new SoftwareOutputDevice));
10917 host_impl_->InitializeRenderer(output_surface_.get()); 10939 host_impl_->InitializeRenderer(output_surface_.get());
10918 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10940 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10919 } 10941 }
10920 10942
10921 } // namespace 10943 } // namespace
10922 } // namespace cc 10944 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698