| 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/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/debug/lap_timer.h" | 12 #include "cc/debug/lap_timer.h" |
| 13 #include "cc/raster/raster_buffer.h" | 13 #include "cc/raster/raster_buffer.h" |
| 14 #include "cc/test/begin_frame_args_test.h" | 14 #include "cc/test/begin_frame_args_test.h" |
| 15 #include "cc/test/fake_display_list_raster_source.h" | |
| 16 #include "cc/test/fake_impl_task_runner_provider.h" | 15 #include "cc/test/fake_impl_task_runner_provider.h" |
| 17 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
| 18 #include "cc/test/fake_output_surface.h" | 17 #include "cc/test/fake_output_surface.h" |
| 19 #include "cc/test/fake_output_surface_client.h" | 18 #include "cc/test/fake_output_surface_client.h" |
| 20 #include "cc/test/fake_picture_layer_impl.h" | 19 #include "cc/test/fake_picture_layer_impl.h" |
| 20 #include "cc/test/fake_raster_source.h" |
| 21 #include "cc/test/fake_tile_manager.h" | 21 #include "cc/test/fake_tile_manager.h" |
| 22 #include "cc/test/fake_tile_manager_client.h" | 22 #include "cc/test/fake_tile_manager_client.h" |
| 23 #include "cc/test/test_shared_bitmap_manager.h" | 23 #include "cc/test/test_shared_bitmap_manager.h" |
| 24 #include "cc/test/test_task_graph_runner.h" | 24 #include "cc/test/test_task_graph_runner.h" |
| 25 #include "cc/test/test_tile_priorities.h" | 25 #include "cc/test/test_tile_priorities.h" |
| 26 #include "cc/tiles/tile.h" | 26 #include "cc/tiles/tile.h" |
| 27 #include "cc/tiles/tile_priority.h" | 27 #include "cc/tiles/tile_priority.h" |
| 28 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
| 29 | 29 |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual void InitializeRenderer() { | 125 virtual void InitializeRenderer() { |
| 126 host_impl_.SetVisible(true); | 126 host_impl_.SetVisible(true); |
| 127 host_impl_.InitializeRenderer(output_surface_.get()); | 127 host_impl_.InitializeRenderer(output_surface_.get()); |
| 128 tile_manager()->SetTileTaskRunnerForTesting( | 128 tile_manager()->SetTileTaskRunnerForTesting( |
| 129 g_fake_tile_task_runner.Pointer()); | 129 g_fake_tile_task_runner.Pointer()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 132 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 133 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 133 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 134 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 134 FakeRasterSource::CreateFilled(layer_bounds); |
| 135 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | 135 scoped_refptr<FakeRasterSource> active_raster_source = |
| 136 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 136 FakeRasterSource::CreateFilled(layer_bounds); |
| 137 | 137 |
| 138 SetupTrees(pending_raster_source, active_raster_source); | 138 SetupTrees(pending_raster_source, active_raster_source); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ActivateTree() { | 141 void ActivateTree() { |
| 142 host_impl_.ActivateSyncTree(); | 142 host_impl_.ActivateSyncTree(); |
| 143 CHECK(!host_impl_.pending_tree()); | 143 CHECK(!host_impl_.pending_tree()); |
| 144 pending_root_layer_ = NULL; | 144 pending_root_layer_ = NULL; |
| 145 active_root_layer_ = static_cast<FakePictureLayerImpl*>( | 145 active_root_layer_ = static_cast<FakePictureLayerImpl*>( |
| 146 host_impl_.active_tree()->LayerById(id_)); | 146 host_impl_.active_tree()->LayerById(id_)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 149 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 150 const gfx::Size& tile_size) { | 150 const gfx::Size& tile_size) { |
| 151 SetupDefaultTrees(layer_bounds); | 151 SetupDefaultTrees(layer_bounds); |
| 152 pending_root_layer_->set_fixed_tile_size(tile_size); | 152 pending_root_layer_->set_fixed_tile_size(tile_size); |
| 153 active_root_layer_->set_fixed_tile_size(tile_size); | 153 active_root_layer_->set_fixed_tile_size(tile_size); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source, | 156 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, |
| 157 scoped_refptr<DisplayListRasterSource> active_raster_source) { | 157 scoped_refptr<RasterSource> active_raster_source) { |
| 158 SetupPendingTree(active_raster_source); | 158 SetupPendingTree(active_raster_source); |
| 159 ActivateTree(); | 159 ActivateTree(); |
| 160 SetupPendingTree(pending_raster_source); | 160 SetupPendingTree(pending_raster_source); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { | 163 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 164 host_impl_.CreatePendingTree(); | 164 host_impl_.CreatePendingTree(); |
| 165 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 165 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 166 // Clear recycled tree. | 166 // Clear recycled tree. |
| 167 pending_tree->ClearLayers(); | 167 pending_tree->ClearLayers(); |
| 168 | 168 |
| 169 scoped_ptr<FakePictureLayerImpl> pending_layer = | 169 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 170 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, | 170 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 171 raster_source); | 171 raster_source); |
| 172 pending_layer->SetDrawsContent(true); | 172 pending_layer->SetDrawsContent(true); |
| 173 pending_layer->SetForceRenderSurface(true); | 173 pending_layer->SetForceRenderSurface(true); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 SetupDefaultTreesWithFixedTileSize(layer_bounds, | 340 SetupDefaultTreesWithFixedTileSize(layer_bounds, |
| 341 settings_.default_tile_size); | 341 settings_.default_tile_size); |
| 342 | 342 |
| 343 std::vector<FakePictureLayerImpl*> layers; | 343 std::vector<FakePictureLayerImpl*> layers; |
| 344 | 344 |
| 345 // Pending layer counts as one layer. | 345 // Pending layer counts as one layer. |
| 346 layers.push_back(pending_root_layer_); | 346 layers.push_back(pending_root_layer_); |
| 347 int next_id = id_ + 1; | 347 int next_id = id_ + 1; |
| 348 | 348 |
| 349 // Create the rest of the layers as children of the root layer. | 349 // Create the rest of the layers as children of the root layer. |
| 350 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 350 scoped_refptr<FakeRasterSource> raster_source = |
| 351 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 351 FakeRasterSource::CreateFilled(layer_bounds); |
| 352 while (static_cast<int>(layers.size()) < layer_count) { | 352 while (static_cast<int>(layers.size()) < layer_count) { |
| 353 scoped_ptr<FakePictureLayerImpl> layer = | 353 scoped_ptr<FakePictureLayerImpl> layer = |
| 354 FakePictureLayerImpl::CreateWithRasterSource( | 354 FakePictureLayerImpl::CreateWithRasterSource( |
| 355 host_impl_.pending_tree(), next_id, raster_source); | 355 host_impl_.pending_tree(), next_id, raster_source); |
| 356 layer->SetBounds(layer_bounds); | 356 layer->SetBounds(layer_bounds); |
| 357 layer->SetDrawsContent(true); | 357 layer->SetDrawsContent(true); |
| 358 layers.push_back(layer.get()); | 358 layers.push_back(layer.get()); |
| 359 pending_root_layer_->AddChild(std::move(layer)); | 359 pending_root_layer_->AddChild(std::move(layer)); |
| 360 ++next_id; | 360 ++next_id; |
| 361 } | 361 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); | 474 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); |
| 475 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); | 475 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
| 476 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); | 476 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
| 477 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); | 477 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
| 478 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); | 478 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
| 479 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); | 479 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace | 482 } // namespace |
| 483 } // namespace cc | 483 } // namespace cc |
| OLD | NEW |