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 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 | 1719 |
1720 void AppendQuads(RenderPass* render_pass, | 1720 void AppendQuads(RenderPass* render_pass, |
1721 AppendQuadsData* append_quads_data) override { | 1721 AppendQuadsData* append_quads_data) override { |
1722 append_quads_data->num_missing_tiles += has_missing_tiles_; | 1722 append_quads_data->num_missing_tiles += has_missing_tiles_; |
1723 } | 1723 } |
1724 | 1724 |
1725 private: | 1725 private: |
1726 bool has_missing_tiles_; | 1726 bool has_missing_tiles_; |
1727 }; | 1727 }; |
1728 | 1728 |
1729 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { | 1729 static bool ReadySinceAnimation(LayerTreeHostImpl* host_impl, |
| 1730 LayerImpl* layer) { |
| 1731 return layer->transform_tree_index() == TransformTree::kInvalidNodeId |
| 1732 ? true |
| 1733 : host_impl->active_tree() |
| 1734 ->property_trees() |
| 1735 ->transform_tree.Node(layer->transform_tree_index()) |
| 1736 ->ready_since_animation; |
| 1737 } |
| 1738 |
| 1739 TEST_F(LayerTreeHostImplTest, AnimationMarksTransformNodeNotReady) { |
1730 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1740 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1731 | 1741 |
1732 host_impl_->active_tree()->SetRootLayerForTesting( | 1742 host_impl_->active_tree()->SetRootLayerForTesting( |
1733 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1743 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1734 LayerImpl* root = *host_impl_->active_tree()->begin(); | 1744 LayerImpl* root = *host_impl_->active_tree()->begin(); |
1735 root->SetBounds(gfx::Size(50, 50)); | 1745 root->SetBounds(gfx::Size(50, 50)); |
1736 | 1746 |
1737 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( | 1747 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( |
1738 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1748 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
1739 MissingTilesLayer* child = | 1749 MissingTilesLayer* child = |
1740 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); | 1750 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); |
1741 child->SetBounds(gfx::Size(10, 10)); | 1751 child->SetBounds(gfx::Size(10, 10)); |
1742 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1752 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1743 child->SetDrawsContent(true); | 1753 child->SetDrawsContent(true); |
1744 | 1754 |
1745 host_impl_->active_tree()->SetElementIdsForTesting(); | 1755 host_impl_->active_tree()->SetElementIdsForTesting(); |
1746 | 1756 |
1747 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1757 EXPECT_TRUE(ReadySinceAnimation(host_impl_.get(), child)); |
1748 | 1758 |
1749 // Add a translate from 6,7 to 8,9. | 1759 // Add a translate from 6,7 to 8,9. |
1750 TransformOperations start; | 1760 TransformOperations start; |
1751 start.AppendTranslate(6.f, 7.f, 0.f); | 1761 start.AppendTranslate(6.f, 7.f, 0.f); |
1752 TransformOperations end; | 1762 TransformOperations end; |
1753 end.AppendTranslate(8.f, 9.f, 0.f); | 1763 end.AppendTranslate(8.f, 9.f, 0.f); |
1754 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1764 int animation_id = AddAnimatedTransformToElementWithPlayer( |
1755 child->element_id(), timeline(), 4.0, start, end); | 1765 child->element_id(), timeline(), 4.0, start, end); |
1756 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1766 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1757 | 1767 |
1758 base::TimeTicks now = base::TimeTicks::Now(); | 1768 base::TimeTicks now = base::TimeTicks::Now(); |
1759 host_impl_->WillBeginImplFrame( | 1769 host_impl_->WillBeginImplFrame( |
1760 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); | 1770 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
1761 | 1771 |
1762 host_impl_->ActivateAnimations(); | 1772 host_impl_->ActivateAnimations(); |
1763 host_impl_->Animate(); | 1773 host_impl_->Animate(); |
1764 | 1774 |
1765 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1775 EXPECT_FALSE(ReadySinceAnimation(host_impl_.get(), child)); |
1766 | 1776 |
1767 host_impl_->ResetRequiresHighResToDraw(); | 1777 host_impl_->ResetRequiresHighResToDraw(); |
1768 | 1778 |
1769 // Child layer has an animating transform but missing tiles. | 1779 // Child layer has an animating transform but missing tiles. |
1770 TestFrameData frame; | 1780 TestFrameData frame; |
1771 DrawResult result = host_impl_->PrepareToDraw(&frame); | 1781 DrawResult result = host_impl_->PrepareToDraw(&frame); |
1772 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1782 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
1773 host_impl_->DidDrawAllLayers(frame); | 1783 host_impl_->DidDrawAllLayers(frame); |
1774 | 1784 |
1775 child->set_has_missing_tiles(false); | 1785 child->set_has_missing_tiles(false); |
1776 | 1786 |
1777 // Child layer has an animating and no missing tiles. | 1787 // Child layer has an animating and no missing tiles. |
1778 result = host_impl_->PrepareToDraw(&frame); | 1788 result = host_impl_->PrepareToDraw(&frame); |
1779 EXPECT_EQ(DRAW_SUCCESS, result); | 1789 EXPECT_EQ(DRAW_SUCCESS, result); |
1780 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1790 EXPECT_TRUE(ReadySinceAnimation(host_impl_.get(), child)); |
1781 host_impl_->DidDrawAllLayers(frame); | 1791 host_impl_->DidDrawAllLayers(frame); |
1782 | 1792 |
1783 // Remove the animation. | 1793 // Remove the animation. |
1784 child->set_has_missing_tiles(true); | 1794 child->set_has_missing_tiles(true); |
1785 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), | 1795 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
1786 animation_id); | 1796 animation_id); |
1787 child->draw_properties().screen_space_transform_is_animating = false; | 1797 child->draw_properties().screen_space_transform_is_animating = false; |
1788 | 1798 |
1789 // Child layer doesn't have an animation, but was never ready since the last | 1799 // Child layer doesn't have an animation, but was never ready since the last |
1790 // time it animated (and has missing tiles). | 1800 // time it animated (and has missing tiles). |
1791 result = host_impl_->PrepareToDraw(&frame); | 1801 result = host_impl_->PrepareToDraw(&frame); |
1792 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); | 1802 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); |
1793 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1803 EXPECT_FALSE(ReadySinceAnimation(host_impl_.get(), child)); |
1794 host_impl_->DidDrawAllLayers(frame); | 1804 host_impl_->DidDrawAllLayers(frame); |
1795 | 1805 |
1796 child->set_has_missing_tiles(false); | 1806 child->set_has_missing_tiles(false); |
1797 | 1807 |
1798 // Child layer doesn't have an animation and all tiles are ready. | 1808 // Child layer doesn't have an animation and all tiles are ready. |
1799 result = host_impl_->PrepareToDraw(&frame); | 1809 result = host_impl_->PrepareToDraw(&frame); |
1800 EXPECT_EQ(DRAW_SUCCESS, result); | 1810 EXPECT_EQ(DRAW_SUCCESS, result); |
1801 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1811 EXPECT_TRUE(ReadySinceAnimation(host_impl_.get(), child)); |
1802 host_impl_->DidDrawAllLayers(frame); | 1812 host_impl_->DidDrawAllLayers(frame); |
1803 | 1813 |
1804 child->set_has_missing_tiles(true); | 1814 child->set_has_missing_tiles(true); |
1805 | 1815 |
1806 // Child layer doesn't have an animation, and was ready at least once since | 1816 // Child layer doesn't have an animation, and was ready at least once since |
1807 // the last time it animated. | 1817 // the last time it animated. |
1808 result = host_impl_->PrepareToDraw(&frame); | 1818 result = host_impl_->PrepareToDraw(&frame); |
1809 EXPECT_EQ(DRAW_SUCCESS, result); | 1819 EXPECT_EQ(DRAW_SUCCESS, result); |
1810 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1820 EXPECT_TRUE(ReadySinceAnimation(host_impl_.get(), child)); |
1811 host_impl_->DidDrawAllLayers(frame); | 1821 host_impl_->DidDrawAllLayers(frame); |
1812 } | 1822 } |
1813 | 1823 |
1814 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 1824 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
1815 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1825 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1816 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1826 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
1817 | 1827 |
1818 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1828 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1819 DrawFrame(); | 1829 DrawFrame(); |
1820 | 1830 |
(...skipping 10642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12463 else | 12473 else |
12464 EXPECT_FALSE(tile->HasRasterTask()); | 12474 EXPECT_FALSE(tile->HasRasterTask()); |
12465 } | 12475 } |
12466 Region expected_invalidation( | 12476 Region expected_invalidation( |
12467 raster_source->GetRectForImage(checkerable_image.stable_id())); | 12477 raster_source->GetRectForImage(checkerable_image.stable_id())); |
12468 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12478 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12469 } | 12479 } |
12470 | 12480 |
12471 } // namespace | 12481 } // namespace |
12472 } // namespace cc | 12482 } // namespace cc |
OLD | NEW |