| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/playback/display_list_raster_source.h" | 10 #include "cc/playback/display_list_raster_source.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 SetupPendingTree(active_raster_source); | 119 SetupPendingTree(active_raster_source); |
| 120 ActivateTree(); | 120 ActivateTree(); |
| 121 SetupPendingTree(pending_raster_source); | 121 SetupPendingTree(pending_raster_source); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { | 124 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { |
| 125 host_impl_.CreatePendingTree(); | 125 host_impl_.CreatePendingTree(); |
| 126 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 126 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 127 | 127 |
| 128 // Steal from the recycled tree. | 128 // Steal from the recycled tree. |
| 129 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 129 LayerImpl* old_pending_root = pending_tree->root_layer(); |
| 130 DCHECK(!old_pending_root || old_pending_root->id() == id_); | 130 DCHECK(!old_pending_root || old_pending_root->id() == id_); |
| 131 | 131 |
| 132 scoped_ptr<FakePictureLayerImpl> pending_layer; | 132 FakePictureLayerImpl* pending_layer = nullptr; |
| 133 if (old_pending_root) { | 133 if (old_pending_root) { |
| 134 pending_layer.reset( | 134 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); |
| 135 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | |
| 136 pending_layer->SetRasterSourceOnPending(raster_source, Region()); | 135 pending_layer->SetRasterSourceOnPending(raster_source, Region()); |
| 137 } else { | 136 } else { |
| 138 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( | 137 scoped_ptr<FakePictureLayerImpl> new_root = |
| 139 pending_tree, id_, raster_source); | 138 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 139 raster_source); |
| 140 pending_layer = new_root.get(); |
| 141 pending_tree->SetRootLayer(std::move(new_root)); |
| 140 pending_layer->SetDrawsContent(true); | 142 pending_layer->SetDrawsContent(true); |
| 141 pending_layer->SetHasRenderSurface(true); | 143 pending_layer->SetHasRenderSurface(true); |
| 142 } | 144 } |
| 143 // The bounds() just mirror the raster source size. | 145 // The bounds() just mirror the raster source size. |
| 144 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 146 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 145 pending_tree->SetRootLayer(std::move(pending_layer)); | |
| 146 | 147 |
| 147 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 148 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 148 host_impl_.pending_tree()->LayerById(id_)); | 149 host_impl_.pending_tree()->LayerById(id_)); |
| 149 | 150 |
| 150 // Add tilings/tiles for the layer. | 151 // Add tilings/tiles for the layer. |
| 151 bool update_lcd_text = false; | 152 bool update_lcd_text = false; |
| 152 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); | 153 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 153 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 154 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 154 } | 155 } |
| 155 | 156 |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 901 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 901 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 902 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 902 SetupPendingTree(pending_raster_source); | 903 SetupPendingTree(pending_raster_source); |
| 903 | 904 |
| 904 scoped_ptr<FakePictureLayerImpl> pending_child = | 905 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 905 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, | 906 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 906 pending_raster_source); | 907 pending_raster_source); |
| 907 pending_layer_->AddChild(std::move(pending_child)); | 908 pending_layer_->AddChild(std::move(pending_child)); |
| 908 | 909 |
| 909 FakePictureLayerImpl* pending_child_layer = | 910 FakePictureLayerImpl* pending_child_layer = |
| 910 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0].get()); | 911 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 911 pending_child_layer->SetDrawsContent(true); | 912 pending_child_layer->SetDrawsContent(true); |
| 912 | 913 |
| 913 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 914 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 914 bool update_lcd_text = false; | 915 bool update_lcd_text = false; |
| 915 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; | 916 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; |
| 916 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); | 917 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 917 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 918 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 918 | 919 |
| 919 ActivateTree(); | 920 ActivateTree(); |
| 920 SetupPendingTree(pending_raster_source); | 921 SetupPendingTree(pending_raster_source); |
| 921 | 922 |
| 922 FakePictureLayerImpl* active_child_layer = | 923 FakePictureLayerImpl* active_child_layer = |
| 923 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0].get()); | 924 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); |
| 924 | 925 |
| 925 std::set<Tile*> all_tiles; | 926 std::set<Tile*> all_tiles; |
| 926 size_t tile_count = 0; | 927 size_t tile_count = 0; |
| 927 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( | 928 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( |
| 928 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 929 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 929 while (!raster_queue->IsEmpty()) { | 930 while (!raster_queue->IsEmpty()) { |
| 930 ++tile_count; | 931 ++tile_count; |
| 931 EXPECT_TRUE(raster_queue->Top().tile()); | 932 EXPECT_TRUE(raster_queue->Top().tile()); |
| 932 all_tiles.insert(raster_queue->Top().tile()); | 933 all_tiles.insert(raster_queue->Top().tile()); |
| 933 raster_queue->Pop(); | 934 raster_queue->Pop(); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 SetupPendingTree(active_raster_source); | 1616 SetupPendingTree(active_raster_source); |
| 1616 ActivateTree(); | 1617 ActivateTree(); |
| 1617 SetupPendingTree(pending_raster_source); | 1618 SetupPendingTree(pending_raster_source); |
| 1618 } | 1619 } |
| 1619 | 1620 |
| 1620 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { | 1621 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { |
| 1621 host_impl_->CreatePendingTree(); | 1622 host_impl_->CreatePendingTree(); |
| 1622 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 1623 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 1623 | 1624 |
| 1624 // Steal from the recycled tree. | 1625 // Steal from the recycled tree. |
| 1625 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 1626 LayerImpl* old_pending_root = pending_tree->root_layer(); |
| 1626 scoped_ptr<FakePictureLayerImpl> pending_layer; | 1627 FakePictureLayerImpl* pending_layer = nullptr; |
| 1627 if (old_pending_root) { | 1628 if (old_pending_root) { |
| 1628 pending_layer.reset( | 1629 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); |
| 1629 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | |
| 1630 pending_layer->SetRasterSourceOnPending(raster_source, Region()); | 1630 pending_layer->SetRasterSourceOnPending(raster_source, Region()); |
| 1631 } else { | 1631 } else { |
| 1632 int id = 7; | 1632 int id = 7; |
| 1633 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( | 1633 scoped_ptr<FakePictureLayerImpl> new_root = |
| 1634 pending_tree, id, raster_source); | 1634 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id, |
| 1635 raster_source); |
| 1636 pending_layer = new_root.get(); |
| 1635 pending_layer->SetDrawsContent(true); | 1637 pending_layer->SetDrawsContent(true); |
| 1636 pending_layer->SetHasRenderSurface(true); | 1638 pending_layer->SetHasRenderSurface(true); |
| 1639 pending_tree->SetRootLayer(std::move(new_root)); |
| 1637 } | 1640 } |
| 1641 |
| 1638 // The bounds() just mirror the raster source size. | 1642 // The bounds() just mirror the raster source size. |
| 1639 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 1643 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 1640 pending_tree->SetRootLayer(std::move(pending_layer)); | |
| 1641 | 1644 |
| 1642 // Add tilings/tiles for the layer. | 1645 // Add tilings/tiles for the layer. |
| 1643 bool update_lcd_text = false; | 1646 bool update_lcd_text = false; |
| 1644 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 1647 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 1645 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1648 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1646 } | 1649 } |
| 1647 | 1650 |
| 1648 protected: | 1651 protected: |
| 1649 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. | 1652 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. |
| 1650 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { | 1653 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 | 2023 |
| 2021 // Ensures that the tile manager does not attempt to reuse tiles when partial | 2024 // Ensures that the tile manager does not attempt to reuse tiles when partial |
| 2022 // raster is disabled. | 2025 // raster is disabled. |
| 2023 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 2026 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| 2024 RunPartialRasterCheck(std::move(host_impl_), | 2027 RunPartialRasterCheck(std::move(host_impl_), |
| 2025 false /* partial_raster_enabled */); | 2028 false /* partial_raster_enabled */); |
| 2026 } | 2029 } |
| 2027 | 2030 |
| 2028 } // namespace | 2031 } // namespace |
| 2029 } // namespace cc | 2032 } // namespace cc |
| OLD | NEW |