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 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 // Animations on the active tree should be started and ticked, and a new frame | 1446 // Animations on the active tree should be started and ticked, and a new frame |
1447 // should be requested to continue ticking them. | 1447 // should be requested to continue ticking them. |
1448 EXPECT_TRUE(did_request_next_frame_); | 1448 EXPECT_TRUE(did_request_next_frame_); |
1449 EXPECT_TRUE(did_request_redraw_); | 1449 EXPECT_TRUE(did_request_redraw_); |
1450 EXPECT_FALSE(did_request_commit_); | 1450 EXPECT_FALSE(did_request_commit_); |
1451 | 1451 |
1452 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. | 1452 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
1453 host_impl_ = nullptr; | 1453 host_impl_ = nullptr; |
1454 } | 1454 } |
1455 | 1455 |
| 1456 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
| 1457 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1458 |
| 1459 host_impl_->active_tree()->SetRootLayer( |
| 1460 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1461 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1462 root->SetBounds(gfx::Size(50, 50)); |
| 1463 |
| 1464 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1465 LayerImpl* child = root->children()[0]; |
| 1466 child->SetBounds(gfx::Size(10, 10)); |
| 1467 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1468 child->SetDrawsContent(true); |
| 1469 |
| 1470 // Add a translate animation. |
| 1471 TransformOperations start; |
| 1472 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1473 TransformOperations end; |
| 1474 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1475 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
| 1476 end); |
| 1477 |
| 1478 base::TimeTicks now = base::TimeTicks::Now(); |
| 1479 host_impl_->WillBeginImplFrame( |
| 1480 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); |
| 1481 EXPECT_TRUE(did_request_next_frame_); |
| 1482 did_request_next_frame_ = false; |
| 1483 |
| 1484 host_impl_->ActivateAnimations(); |
| 1485 // On activating an animation, we should request another frame so that we'll |
| 1486 // continue ticking the animation. |
| 1487 EXPECT_TRUE(did_request_next_frame_); |
| 1488 did_request_next_frame_ = false; |
| 1489 |
| 1490 // The next frame after activating, we'll tick the animation again. |
| 1491 host_impl_->Animate(); |
| 1492 // An animation exists on the active layer. Doing Animate() requests another |
| 1493 // frame after the current one. |
| 1494 EXPECT_TRUE(did_request_next_frame_); |
| 1495 did_request_next_frame_ = false; |
| 1496 |
| 1497 // Destroy layer, unregister animation target (element). |
| 1498 child->SetParent(nullptr); |
| 1499 root->RemoveChildForTesting(child); |
| 1500 child = nullptr; |
| 1501 |
| 1502 // Doing Animate() doesn't request another frame after the current one. |
| 1503 host_impl_->Animate(); |
| 1504 EXPECT_FALSE(did_request_next_frame_); |
| 1505 |
| 1506 host_impl_->Animate(); |
| 1507 EXPECT_FALSE(did_request_next_frame_); |
| 1508 } |
| 1509 |
1456 class MissingTilesLayer : public LayerImpl { | 1510 class MissingTilesLayer : public LayerImpl { |
1457 public: | 1511 public: |
1458 MissingTilesLayer(LayerTreeImpl* layer_tree_impl, int id) | 1512 MissingTilesLayer(LayerTreeImpl* layer_tree_impl, int id) |
1459 : LayerImpl(layer_tree_impl, id), has_missing_tiles_(true) {} | 1513 : LayerImpl(layer_tree_impl, id), has_missing_tiles_(true) {} |
1460 | 1514 |
1461 void set_has_missing_tiles(bool has_missing_tiles) { | 1515 void set_has_missing_tiles(bool has_missing_tiles) { |
1462 has_missing_tiles_ = has_missing_tiles; | 1516 has_missing_tiles_ = has_missing_tiles; |
1463 } | 1517 } |
1464 | 1518 |
1465 void AppendQuads(RenderPass* render_pass, | 1519 void AppendQuads(RenderPass* render_pass, |
(...skipping 9295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10761 | 10815 |
10762 // Re-initialize with a software output surface. | 10816 // Re-initialize with a software output surface. |
10763 output_surface_ = FakeOutputSurface::CreateSoftware( | 10817 output_surface_ = FakeOutputSurface::CreateSoftware( |
10764 base::WrapUnique(new SoftwareOutputDevice)); | 10818 base::WrapUnique(new SoftwareOutputDevice)); |
10765 host_impl_->InitializeRenderer(output_surface_.get()); | 10819 host_impl_->InitializeRenderer(output_surface_.get()); |
10766 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10820 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10767 } | 10821 } |
10768 | 10822 |
10769 } // namespace | 10823 } // namespace |
10770 } // namespace cc | 10824 } // namespace cc |
OLD | NEW |