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