| 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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "cc/playback/raster_source.h" | 11 #include "cc/playback/raster_source.h" |
| 12 #include "cc/playback/recording_source.h" | 12 #include "cc/playback/recording_source.h" |
| 13 #include "cc/raster/raster_buffer.h" | 13 #include "cc/raster/raster_buffer.h" |
| 14 #include "cc/raster/synchronous_task_graph_runner.h" | 14 #include "cc/raster/synchronous_task_graph_runner.h" |
| 15 #include "cc/resources/resource_pool.h" | 15 #include "cc/resources/resource_pool.h" |
| 16 #include "cc/test/begin_frame_args_test.h" | 16 #include "cc/test/begin_frame_args_test.h" |
| 17 #include "cc/test/fake_impl_task_runner_provider.h" | 17 #include "cc/test/fake_impl_task_runner_provider.h" |
| 18 #include "cc/test/fake_layer_tree_host_impl.h" | 18 #include "cc/test/fake_layer_tree_host_impl.h" |
| 19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
| 20 #include "cc/test/fake_output_surface_client.h" | 20 #include "cc/test/fake_output_surface_client.h" |
| 21 #include "cc/test/fake_picture_layer_impl.h" | 21 #include "cc/test/fake_picture_layer_impl.h" |
| 22 #include "cc/test/fake_picture_layer_tiling_client.h" | 22 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 23 #include "cc/test/fake_raster_source.h" | 23 #include "cc/test/fake_raster_source.h" |
| 24 #include "cc/test/fake_recording_source.h" | 24 #include "cc/test/fake_recording_source.h" |
| 25 #include "cc/test/fake_tile_manager.h" | 25 #include "cc/test/fake_tile_manager.h" |
| 26 #include "cc/test/fake_tile_task_manager.h" | 26 #include "cc/test/fake_tile_task_manager.h" |
| 27 #include "cc/test/test_gpu_memory_buffer_manager.h" | 27 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 28 #include "cc/test/test_layer_tree_host_base.h" | |
| 29 #include "cc/test/test_shared_bitmap_manager.h" | 28 #include "cc/test/test_shared_bitmap_manager.h" |
| 30 #include "cc/test/test_task_graph_runner.h" | 29 #include "cc/test/test_task_graph_runner.h" |
| 31 #include "cc/test/test_tile_priorities.h" | 30 #include "cc/test/test_tile_priorities.h" |
| 32 #include "cc/tiles/eviction_tile_priority_queue.h" | 31 #include "cc/tiles/eviction_tile_priority_queue.h" |
| 33 #include "cc/tiles/raster_tile_priority_queue.h" | 32 #include "cc/tiles/raster_tile_priority_queue.h" |
| 34 #include "cc/tiles/tile.h" | 33 #include "cc/tiles/tile.h" |
| 35 #include "cc/tiles/tile_priority.h" | 34 #include "cc/tiles/tile_priority.h" |
| 36 #include "cc/tiles/tiling_set_raster_queue_all.h" | 35 #include "cc/tiles/tiling_set_raster_queue_all.h" |
| 37 #include "cc/trees/layer_tree_impl.h" | 36 #include "cc/trees/layer_tree_impl.h" |
| 38 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "third_party/skia/include/core/SkRefCnt.h" | 39 #include "third_party/skia/include/core/SkRefCnt.h" |
| 41 #include "third_party/skia/include/core/SkSurface.h" | 40 #include "third_party/skia/include/core/SkSurface.h" |
| 42 | 41 |
| 43 namespace cc { | 42 namespace cc { |
| 44 namespace { | 43 namespace { |
| 45 | 44 |
| 46 class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { | 45 class LowResTilingsSettings : public LayerTreeSettings { |
| 47 public: | 46 public: |
| 48 LayerTreeSettings CreateSettings() override { | 47 LowResTilingsSettings() { |
| 49 LayerTreeSettings settings; | 48 create_low_res_tiling = true; |
| 50 settings.create_low_res_tiling = true; | 49 verify_clip_tree_calculations = true; |
| 51 settings.verify_clip_tree_calculations = true; | 50 } |
| 52 return settings; | 51 }; |
| 52 |
| 53 class TileManagerTilePriorityQueueTest : public testing::Test { |
| 54 public: |
| 55 TileManagerTilePriorityQueueTest() |
| 56 : memory_limit_policy_(ALLOW_ANYTHING), |
| 57 max_tiles_(10000), |
| 58 ready_to_activate_(false), |
| 59 id_(7), |
| 60 task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), |
| 61 output_surface_(FakeOutputSurface::Create3d()), |
| 62 host_impl_(LowResTilingsSettings(), |
| 63 &task_runner_provider_, |
| 64 &shared_bitmap_manager_, |
| 65 &task_graph_runner_, |
| 66 &gpu_memory_buffer_manager_) {} |
| 67 |
| 68 void SetTreePriority(TreePriority tree_priority) { |
| 69 GlobalStateThatImpactsTilePriority state; |
| 70 gfx::Size tile_size(256, 256); |
| 71 |
| 72 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; |
| 73 state.num_resources_limit = max_tiles_; |
| 74 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; |
| 75 state.memory_limit_policy = memory_limit_policy_; |
| 76 state.tree_priority = tree_priority; |
| 77 |
| 78 global_state_ = state; |
| 79 host_impl_.resource_pool()->SetResourceUsageLimits( |
| 80 state.soft_memory_limit_in_bytes, |
| 81 state.num_resources_limit); |
| 82 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
| 53 } | 83 } |
| 54 | 84 |
| 55 TileManager* tile_manager() { return host_impl()->tile_manager(); } | 85 void SetUp() override { |
| 86 InitializeRenderer(); |
| 87 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 88 } |
| 89 |
| 90 virtual void InitializeRenderer() { |
| 91 host_impl_.SetVisible(true); |
| 92 host_impl_.InitializeRenderer(output_surface_.get()); |
| 93 } |
| 94 |
| 95 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 96 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 97 FakeRasterSource::CreateFilled(layer_bounds); |
| 98 scoped_refptr<FakeRasterSource> active_raster_source = |
| 99 FakeRasterSource::CreateFilled(layer_bounds); |
| 100 |
| 101 SetupTrees(pending_raster_source, active_raster_source); |
| 102 } |
| 103 |
| 104 // This matches picture_layer_impl_unittest's ActivateTree. |
| 105 void ActivateTree() { |
| 106 host_impl_.ActivateSyncTree(); |
| 107 CHECK(!host_impl_.pending_tree()); |
| 108 pending_layer_ = NULL; |
| 109 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 110 host_impl_.active_tree()->LayerById(id_)); |
| 111 bool update_lcd_text = false; |
| 112 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 113 } |
| 114 |
| 115 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 116 const gfx::Size& tile_size) { |
| 117 SetupDefaultTrees(layer_bounds); |
| 118 pending_layer_->set_fixed_tile_size(tile_size); |
| 119 active_layer_->set_fixed_tile_size(tile_size); |
| 120 } |
| 121 |
| 122 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, |
| 123 scoped_refptr<RasterSource> active_raster_source) { |
| 124 SetupPendingTree(active_raster_source); |
| 125 ActivateTree(); |
| 126 SetupPendingTree(pending_raster_source); |
| 127 } |
| 128 |
| 129 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 130 host_impl_.CreatePendingTree(); |
| 131 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 132 |
| 133 // Steal from the recycled tree. |
| 134 LayerImpl* old_pending_root = pending_tree->root_layer(); |
| 135 DCHECK(!old_pending_root || old_pending_root->id() == id_); |
| 136 |
| 137 FakePictureLayerImpl* pending_layer = nullptr; |
| 138 if (old_pending_root) { |
| 139 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); |
| 140 pending_layer->SetRasterSourceOnPending(raster_source, Region()); |
| 141 } else { |
| 142 std::unique_ptr<FakePictureLayerImpl> new_root = |
| 143 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 144 raster_source); |
| 145 pending_layer = new_root.get(); |
| 146 pending_tree->SetRootLayer(std::move(new_root)); |
| 147 pending_layer->SetDrawsContent(true); |
| 148 pending_layer->SetHasRenderSurface(true); |
| 149 } |
| 150 // The bounds() just mirror the raster source size. |
| 151 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 152 |
| 153 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 154 host_impl_.pending_tree()->LayerById(id_)); |
| 155 |
| 156 // Add tilings/tiles for the layer. |
| 157 bool update_lcd_text = false; |
| 158 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 159 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 160 } |
| 161 |
| 162 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
| 163 |
| 164 protected: |
| 165 GlobalStateThatImpactsTilePriority global_state_; |
| 166 |
| 167 TestSharedBitmapManager shared_bitmap_manager_; |
| 168 TestTaskGraphRunner task_graph_runner_; |
| 169 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 170 TileMemoryLimitPolicy memory_limit_policy_; |
| 171 int max_tiles_; |
| 172 bool ready_to_activate_; |
| 173 int id_; |
| 174 FakeImplTaskRunnerProvider task_runner_provider_; |
| 175 std::unique_ptr<OutputSurface> output_surface_; |
| 176 FakeLayerTreeHostImpl host_impl_; |
| 177 FakePictureLayerImpl* pending_layer_; |
| 178 FakePictureLayerImpl* active_layer_; |
| 56 }; | 179 }; |
| 57 | 180 |
| 58 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 181 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| 59 const gfx::Size layer_bounds(1000, 1000); | 182 const gfx::Size layer_bounds(1000, 1000); |
| 60 host_impl()->SetViewportSize(layer_bounds); | 183 host_impl_.SetViewportSize(layer_bounds); |
| 61 SetupDefaultTrees(layer_bounds); | 184 SetupDefaultTrees(layer_bounds); |
| 62 | 185 |
| 63 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 186 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 64 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 187 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 65 EXPECT_FALSE(queue->IsEmpty()); | 188 EXPECT_FALSE(queue->IsEmpty()); |
| 66 | 189 |
| 67 size_t tile_count = 0; | 190 size_t tile_count = 0; |
| 68 std::set<Tile*> all_tiles; | 191 std::set<Tile*> all_tiles; |
| 69 while (!queue->IsEmpty()) { | 192 while (!queue->IsEmpty()) { |
| 70 EXPECT_TRUE(queue->Top().tile()); | 193 EXPECT_TRUE(queue->Top().tile()); |
| 71 all_tiles.insert(queue->Top().tile()); | 194 all_tiles.insert(queue->Top().tile()); |
| 72 ++tile_count; | 195 ++tile_count; |
| 73 queue->Pop(); | 196 queue->Pop(); |
| 74 } | 197 } |
| 75 | 198 |
| 76 EXPECT_EQ(tile_count, all_tiles.size()); | 199 EXPECT_EQ(tile_count, all_tiles.size()); |
| 77 EXPECT_EQ(16u, tile_count); | 200 EXPECT_EQ(16u, tile_count); |
| 78 | 201 |
| 79 // Sanity check, all tiles should be visible. | 202 // Sanity check, all tiles should be visible. |
| 80 std::set<Tile*> smoothness_tiles; | 203 std::set<Tile*> smoothness_tiles; |
| 81 queue = host_impl()->BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, | 204 queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, |
| 82 RasterTilePriorityQueue::Type::ALL); | 205 RasterTilePriorityQueue::Type::ALL); |
| 83 bool had_low_res = false; | 206 bool had_low_res = false; |
| 84 while (!queue->IsEmpty()) { | 207 while (!queue->IsEmpty()) { |
| 85 PrioritizedTile prioritized_tile = queue->Top(); | 208 PrioritizedTile prioritized_tile = queue->Top(); |
| 86 EXPECT_TRUE(prioritized_tile.tile()); | 209 EXPECT_TRUE(prioritized_tile.tile()); |
| 87 EXPECT_EQ(TilePriority::NOW, prioritized_tile.priority().priority_bin); | 210 EXPECT_EQ(TilePriority::NOW, prioritized_tile.priority().priority_bin); |
| 88 if (prioritized_tile.priority().resolution == LOW_RESOLUTION) | 211 if (prioritized_tile.priority().resolution == LOW_RESOLUTION) |
| 89 had_low_res = true; | 212 had_low_res = true; |
| 90 else | 213 else |
| 91 smoothness_tiles.insert(prioritized_tile.tile()); | 214 smoothness_tiles.insert(prioritized_tile.tile()); |
| 92 queue->Pop(); | 215 queue->Pop(); |
| 93 } | 216 } |
| 94 EXPECT_EQ(all_tiles, smoothness_tiles); | 217 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 95 EXPECT_TRUE(had_low_res); | 218 EXPECT_TRUE(had_low_res); |
| 96 | 219 |
| 97 // Check that everything is required for activation. | 220 // Check that everything is required for activation. |
| 98 queue = host_impl()->BuildRasterQueue( | 221 queue = host_impl_.BuildRasterQueue( |
| 99 SMOOTHNESS_TAKES_PRIORITY, | 222 SMOOTHNESS_TAKES_PRIORITY, |
| 100 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 223 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 101 std::set<Tile*> required_for_activation_tiles; | 224 std::set<Tile*> required_for_activation_tiles; |
| 102 while (!queue->IsEmpty()) { | 225 while (!queue->IsEmpty()) { |
| 103 PrioritizedTile prioritized_tile = queue->Top(); | 226 PrioritizedTile prioritized_tile = queue->Top(); |
| 104 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); | 227 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
| 105 required_for_activation_tiles.insert(prioritized_tile.tile()); | 228 required_for_activation_tiles.insert(prioritized_tile.tile()); |
| 106 queue->Pop(); | 229 queue->Pop(); |
| 107 } | 230 } |
| 108 EXPECT_EQ(all_tiles, required_for_activation_tiles); | 231 EXPECT_EQ(all_tiles, required_for_activation_tiles); |
| 109 | 232 |
| 110 // Check that everything is required for draw. | 233 // Check that everything is required for draw. |
| 111 queue = host_impl()->BuildRasterQueue( | 234 queue = host_impl_.BuildRasterQueue( |
| 112 SMOOTHNESS_TAKES_PRIORITY, | 235 SMOOTHNESS_TAKES_PRIORITY, |
| 113 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 236 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| 114 std::set<Tile*> required_for_draw_tiles; | 237 std::set<Tile*> required_for_draw_tiles; |
| 115 while (!queue->IsEmpty()) { | 238 while (!queue->IsEmpty()) { |
| 116 PrioritizedTile prioritized_tile = queue->Top(); | 239 PrioritizedTile prioritized_tile = queue->Top(); |
| 117 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); | 240 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); |
| 118 required_for_draw_tiles.insert(prioritized_tile.tile()); | 241 required_for_draw_tiles.insert(prioritized_tile.tile()); |
| 119 queue->Pop(); | 242 queue->Pop(); |
| 120 } | 243 } |
| 121 EXPECT_EQ(all_tiles, required_for_draw_tiles); | 244 EXPECT_EQ(all_tiles, required_for_draw_tiles); |
| 122 | 245 |
| 123 Region invalidation(gfx::Rect(0, 0, 500, 500)); | 246 Region invalidation(gfx::Rect(0, 0, 500, 500)); |
| 124 | 247 |
| 125 // Invalidate the pending tree. | 248 // Invalidate the pending tree. |
| 126 pending_layer()->set_invalidation(invalidation); | 249 pending_layer_->set_invalidation(invalidation); |
| 127 pending_layer()->HighResTiling()->Invalidate(invalidation); | 250 pending_layer_->HighResTiling()->Invalidate(invalidation); |
| 128 | 251 |
| 129 // Renew all of the tile priorities. | 252 // Renew all of the tile priorities. |
| 130 gfx::Rect viewport(50, 50, 100, 100); | 253 gfx::Rect viewport(50, 50, 100, 100); |
| 131 pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 254 pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 132 viewport, 1.0f, 1.0, Occlusion(), true); | 255 viewport, 1.0f, 1.0, Occlusion(), true); |
| 133 active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 256 active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 134 viewport, 1.0f, 1.0, Occlusion(), true); | 257 viewport, 1.0f, 1.0, Occlusion(), true); |
| 135 | 258 |
| 136 // Populate all tiles directly from the tilings. | 259 // Populate all tiles directly from the tilings. |
| 137 all_tiles.clear(); | 260 all_tiles.clear(); |
| 138 std::set<Tile*> high_res_tiles; | 261 std::set<Tile*> high_res_tiles; |
| 139 std::vector<Tile*> pending_high_res_tiles = | 262 std::vector<Tile*> pending_high_res_tiles = |
| 140 pending_layer()->HighResTiling()->AllTilesForTesting(); | 263 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 141 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) { | 264 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) { |
| 142 all_tiles.insert(pending_high_res_tiles[i]); | 265 all_tiles.insert(pending_high_res_tiles[i]); |
| 143 high_res_tiles.insert(pending_high_res_tiles[i]); | 266 high_res_tiles.insert(pending_high_res_tiles[i]); |
| 144 } | 267 } |
| 145 | 268 |
| 146 std::vector<Tile*> active_high_res_tiles = | 269 std::vector<Tile*> active_high_res_tiles = |
| 147 active_layer()->HighResTiling()->AllTilesForTesting(); | 270 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 148 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) { | 271 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) { |
| 149 all_tiles.insert(active_high_res_tiles[i]); | 272 all_tiles.insert(active_high_res_tiles[i]); |
| 150 high_res_tiles.insert(active_high_res_tiles[i]); | 273 high_res_tiles.insert(active_high_res_tiles[i]); |
| 151 } | 274 } |
| 152 | 275 |
| 153 std::vector<Tile*> active_low_res_tiles = | 276 std::vector<Tile*> active_low_res_tiles = |
| 154 active_layer()->LowResTiling()->AllTilesForTesting(); | 277 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 155 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 278 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 156 all_tiles.insert(active_low_res_tiles[i]); | 279 all_tiles.insert(active_low_res_tiles[i]); |
| 157 | 280 |
| 158 PrioritizedTile last_tile; | 281 PrioritizedTile last_tile; |
| 159 smoothness_tiles.clear(); | 282 smoothness_tiles.clear(); |
| 160 tile_count = 0; | 283 tile_count = 0; |
| 161 size_t correct_order_tiles = 0u; | 284 size_t correct_order_tiles = 0u; |
| 162 // Here we expect to get increasing ACTIVE_TREE priority_bin. | 285 // Here we expect to get increasing ACTIVE_TREE priority_bin. |
| 163 queue = host_impl()->BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, | 286 queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, |
| 164 RasterTilePriorityQueue::Type::ALL); | 287 RasterTilePriorityQueue::Type::ALL); |
| 165 std::set<Tile*> expected_required_for_draw_tiles; | 288 std::set<Tile*> expected_required_for_draw_tiles; |
| 166 std::set<Tile*> expected_required_for_activation_tiles; | 289 std::set<Tile*> expected_required_for_activation_tiles; |
| 167 while (!queue->IsEmpty()) { | 290 while (!queue->IsEmpty()) { |
| 168 PrioritizedTile prioritized_tile = queue->Top(); | 291 PrioritizedTile prioritized_tile = queue->Top(); |
| 169 EXPECT_TRUE(prioritized_tile.tile()); | 292 EXPECT_TRUE(prioritized_tile.tile()); |
| 170 | 293 |
| 171 if (!last_tile.tile()) | 294 if (!last_tile.tile()) |
| 172 last_tile = prioritized_tile; | 295 last_tile = prioritized_tile; |
| 173 | 296 |
| 174 EXPECT_LE(last_tile.priority().priority_bin, | 297 EXPECT_LE(last_tile.priority().priority_bin, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 203 queue->Pop(); | 326 queue->Pop(); |
| 204 } | 327 } |
| 205 | 328 |
| 206 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 329 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 207 EXPECT_EQ(all_tiles, smoothness_tiles); | 330 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 208 // Since we don't guarantee increasing distance due to spiral iterator, we | 331 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 209 // should check that we're _mostly_ right. | 332 // should check that we're _mostly_ right. |
| 210 EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); | 333 EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); |
| 211 | 334 |
| 212 // Check that we have consistent required_for_activation tiles. | 335 // Check that we have consistent required_for_activation tiles. |
| 213 queue = host_impl()->BuildRasterQueue( | 336 queue = host_impl_.BuildRasterQueue( |
| 214 SMOOTHNESS_TAKES_PRIORITY, | 337 SMOOTHNESS_TAKES_PRIORITY, |
| 215 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 338 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 216 required_for_activation_tiles.clear(); | 339 required_for_activation_tiles.clear(); |
| 217 while (!queue->IsEmpty()) { | 340 while (!queue->IsEmpty()) { |
| 218 PrioritizedTile prioritized_tile = queue->Top(); | 341 PrioritizedTile prioritized_tile = queue->Top(); |
| 219 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); | 342 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
| 220 required_for_activation_tiles.insert(prioritized_tile.tile()); | 343 required_for_activation_tiles.insert(prioritized_tile.tile()); |
| 221 queue->Pop(); | 344 queue->Pop(); |
| 222 } | 345 } |
| 223 EXPECT_EQ(expected_required_for_activation_tiles, | 346 EXPECT_EQ(expected_required_for_activation_tiles, |
| 224 required_for_activation_tiles); | 347 required_for_activation_tiles); |
| 225 EXPECT_NE(all_tiles, required_for_activation_tiles); | 348 EXPECT_NE(all_tiles, required_for_activation_tiles); |
| 226 | 349 |
| 227 // Check that we have consistent required_for_draw tiles. | 350 // Check that we have consistent required_for_draw tiles. |
| 228 queue = host_impl()->BuildRasterQueue( | 351 queue = host_impl_.BuildRasterQueue( |
| 229 SMOOTHNESS_TAKES_PRIORITY, | 352 SMOOTHNESS_TAKES_PRIORITY, |
| 230 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 353 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| 231 required_for_draw_tiles.clear(); | 354 required_for_draw_tiles.clear(); |
| 232 while (!queue->IsEmpty()) { | 355 while (!queue->IsEmpty()) { |
| 233 PrioritizedTile prioritized_tile = queue->Top(); | 356 PrioritizedTile prioritized_tile = queue->Top(); |
| 234 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); | 357 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); |
| 235 required_for_draw_tiles.insert(prioritized_tile.tile()); | 358 required_for_draw_tiles.insert(prioritized_tile.tile()); |
| 236 queue->Pop(); | 359 queue->Pop(); |
| 237 } | 360 } |
| 238 EXPECT_EQ(expected_required_for_draw_tiles, required_for_draw_tiles); | 361 EXPECT_EQ(expected_required_for_draw_tiles, required_for_draw_tiles); |
| 239 EXPECT_NE(all_tiles, required_for_draw_tiles); | 362 EXPECT_NE(all_tiles, required_for_draw_tiles); |
| 240 | 363 |
| 241 std::set<Tile*> new_content_tiles; | 364 std::set<Tile*> new_content_tiles; |
| 242 last_tile = PrioritizedTile(); | 365 last_tile = PrioritizedTile(); |
| 243 size_t increasing_distance_tiles = 0u; | 366 size_t increasing_distance_tiles = 0u; |
| 244 // Here we expect to get increasing PENDING_TREE priority_bin. | 367 // Here we expect to get increasing PENDING_TREE priority_bin. |
| 245 queue = host_impl()->BuildRasterQueue(NEW_CONTENT_TAKES_PRIORITY, | 368 queue = host_impl_.BuildRasterQueue(NEW_CONTENT_TAKES_PRIORITY, |
| 246 RasterTilePriorityQueue::Type::ALL); | 369 RasterTilePriorityQueue::Type::ALL); |
| 247 tile_count = 0; | 370 tile_count = 0; |
| 248 while (!queue->IsEmpty()) { | 371 while (!queue->IsEmpty()) { |
| 249 PrioritizedTile prioritized_tile = queue->Top(); | 372 PrioritizedTile prioritized_tile = queue->Top(); |
| 250 EXPECT_TRUE(prioritized_tile.tile()); | 373 EXPECT_TRUE(prioritized_tile.tile()); |
| 251 | 374 |
| 252 if (!last_tile.tile()) | 375 if (!last_tile.tile()) |
| 253 last_tile = prioritized_tile; | 376 last_tile = prioritized_tile; |
| 254 | 377 |
| 255 EXPECT_LE(last_tile.priority().priority_bin, | 378 EXPECT_LE(last_tile.priority().priority_bin, |
| 256 prioritized_tile.priority().priority_bin); | 379 prioritized_tile.priority().priority_bin); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 274 queue->Pop(); | 397 queue->Pop(); |
| 275 } | 398 } |
| 276 | 399 |
| 277 EXPECT_EQ(tile_count, new_content_tiles.size()); | 400 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 278 EXPECT_EQ(high_res_tiles, new_content_tiles); | 401 EXPECT_EQ(high_res_tiles, new_content_tiles); |
| 279 // Since we don't guarantee increasing distance due to spiral iterator, we | 402 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 280 // should check that we're _mostly_ right. | 403 // should check that we're _mostly_ right. |
| 281 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); | 404 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); |
| 282 | 405 |
| 283 // Check that we have consistent required_for_activation tiles. | 406 // Check that we have consistent required_for_activation tiles. |
| 284 queue = host_impl()->BuildRasterQueue( | 407 queue = host_impl_.BuildRasterQueue( |
| 285 NEW_CONTENT_TAKES_PRIORITY, | 408 NEW_CONTENT_TAKES_PRIORITY, |
| 286 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 409 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 287 required_for_activation_tiles.clear(); | 410 required_for_activation_tiles.clear(); |
| 288 while (!queue->IsEmpty()) { | 411 while (!queue->IsEmpty()) { |
| 289 PrioritizedTile prioritized_tile = queue->Top(); | 412 PrioritizedTile prioritized_tile = queue->Top(); |
| 290 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); | 413 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
| 291 required_for_activation_tiles.insert(prioritized_tile.tile()); | 414 required_for_activation_tiles.insert(prioritized_tile.tile()); |
| 292 queue->Pop(); | 415 queue->Pop(); |
| 293 } | 416 } |
| 294 EXPECT_EQ(expected_required_for_activation_tiles, | 417 EXPECT_EQ(expected_required_for_activation_tiles, |
| 295 required_for_activation_tiles); | 418 required_for_activation_tiles); |
| 296 EXPECT_NE(new_content_tiles, required_for_activation_tiles); | 419 EXPECT_NE(new_content_tiles, required_for_activation_tiles); |
| 297 | 420 |
| 298 // Check that we have consistent required_for_draw tiles. | 421 // Check that we have consistent required_for_draw tiles. |
| 299 queue = host_impl()->BuildRasterQueue( | 422 queue = host_impl_.BuildRasterQueue( |
| 300 NEW_CONTENT_TAKES_PRIORITY, | 423 NEW_CONTENT_TAKES_PRIORITY, |
| 301 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 424 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| 302 required_for_draw_tiles.clear(); | 425 required_for_draw_tiles.clear(); |
| 303 while (!queue->IsEmpty()) { | 426 while (!queue->IsEmpty()) { |
| 304 PrioritizedTile prioritized_tile = queue->Top(); | 427 PrioritizedTile prioritized_tile = queue->Top(); |
| 305 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); | 428 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); |
| 306 required_for_draw_tiles.insert(prioritized_tile.tile()); | 429 required_for_draw_tiles.insert(prioritized_tile.tile()); |
| 307 queue->Pop(); | 430 queue->Pop(); |
| 308 } | 431 } |
| 309 EXPECT_EQ(expected_required_for_draw_tiles, required_for_draw_tiles); | 432 EXPECT_EQ(expected_required_for_draw_tiles, required_for_draw_tiles); |
| 310 EXPECT_NE(new_content_tiles, required_for_draw_tiles); | 433 EXPECT_NE(new_content_tiles, required_for_draw_tiles); |
| 311 } | 434 } |
| 312 | 435 |
| 313 TEST_F(TileManagerTilePriorityQueueTest, | 436 TEST_F(TileManagerTilePriorityQueueTest, |
| 314 RasterTilePriorityQueueHighNonIdealTilings) { | 437 RasterTilePriorityQueueHighNonIdealTilings) { |
| 315 const gfx::Size layer_bounds(1000, 1000); | 438 const gfx::Size layer_bounds(1000, 1000); |
| 316 const gfx::Size viewport(800, 800); | 439 const gfx::Size viewport(800, 800); |
| 317 host_impl()->SetViewportSize(viewport); | 440 host_impl_.SetViewportSize(viewport); |
| 318 SetupDefaultTrees(layer_bounds); | 441 SetupDefaultTrees(layer_bounds); |
| 319 | 442 |
| 320 pending_layer()->tilings()->AddTiling(1.5f, pending_layer()->raster_source()); | 443 pending_layer_->tilings()->AddTiling(1.5f, pending_layer_->raster_source()); |
| 321 active_layer()->tilings()->AddTiling(1.5f, active_layer()->raster_source()); | 444 active_layer_->tilings()->AddTiling(1.5f, active_layer_->raster_source()); |
| 322 pending_layer()->tilings()->AddTiling(1.7f, pending_layer()->raster_source()); | 445 pending_layer_->tilings()->AddTiling(1.7f, pending_layer_->raster_source()); |
| 323 active_layer()->tilings()->AddTiling(1.7f, active_layer()->raster_source()); | 446 active_layer_->tilings()->AddTiling(1.7f, active_layer_->raster_source()); |
| 324 | 447 |
| 325 pending_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, | 448 pending_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, |
| 326 5.0, Occlusion(), true); | |
| 327 active_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, | |
| 328 Occlusion(), true); | 449 Occlusion(), true); |
| 450 active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, |
| 451 Occlusion(), true); |
| 329 | 452 |
| 330 std::set<Tile*> all_expected_tiles; | 453 std::set<Tile*> all_expected_tiles; |
| 331 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { | 454 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 332 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); | 455 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 333 if (tiling->contents_scale() == 1.f) { | 456 if (tiling->contents_scale() == 1.f) { |
| 334 tiling->set_resolution(HIGH_RESOLUTION); | 457 tiling->set_resolution(HIGH_RESOLUTION); |
| 335 const auto& all_tiles = tiling->AllTilesForTesting(); | 458 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 336 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 459 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 337 } else { | 460 } else { |
| 338 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 461 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 339 } | 462 } |
| 340 } | 463 } |
| 341 | 464 |
| 342 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { | 465 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 343 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); | 466 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 344 if (tiling->contents_scale() == 1.5f) { | 467 if (tiling->contents_scale() == 1.5f) { |
| 345 tiling->set_resolution(HIGH_RESOLUTION); | 468 tiling->set_resolution(HIGH_RESOLUTION); |
| 346 const auto& all_tiles = tiling->AllTilesForTesting(); | 469 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 347 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 470 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 348 } else { | 471 } else { |
| 349 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 472 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 350 // Non ideal tilings with a high res pending twin have to be processed | 473 // Non ideal tilings with a high res pending twin have to be processed |
| 351 // because of possible activation tiles. | 474 // because of possible activation tiles. |
| 352 if (tiling->contents_scale() == 1.f) { | 475 if (tiling->contents_scale() == 1.f) { |
| 353 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 476 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 354 const auto& all_tiles = tiling->AllTilesForTesting(); | 477 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 355 for (auto* tile : all_tiles) | 478 for (auto* tile : all_tiles) |
| 356 EXPECT_TRUE(tile->required_for_activation()); | 479 EXPECT_TRUE(tile->required_for_activation()); |
| 357 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 480 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 358 } | 481 } |
| 359 } | 482 } |
| 360 } | 483 } |
| 361 | 484 |
| 362 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 485 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 363 SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); | 486 SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); |
| 364 EXPECT_FALSE(queue->IsEmpty()); | 487 EXPECT_FALSE(queue->IsEmpty()); |
| 365 | 488 |
| 366 size_t tile_count = 0; | 489 size_t tile_count = 0; |
| 367 std::set<Tile*> all_actual_tiles; | 490 std::set<Tile*> all_actual_tiles; |
| 368 while (!queue->IsEmpty()) { | 491 while (!queue->IsEmpty()) { |
| 369 EXPECT_TRUE(queue->Top().tile()); | 492 EXPECT_TRUE(queue->Top().tile()); |
| 370 all_actual_tiles.insert(queue->Top().tile()); | 493 all_actual_tiles.insert(queue->Top().tile()); |
| 371 ++tile_count; | 494 ++tile_count; |
| 372 queue->Pop(); | 495 queue->Pop(); |
| 373 } | 496 } |
| 374 | 497 |
| 375 EXPECT_EQ(tile_count, all_actual_tiles.size()); | 498 EXPECT_EQ(tile_count, all_actual_tiles.size()); |
| 376 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size()); | 499 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size()); |
| 377 EXPECT_EQ(all_expected_tiles, all_actual_tiles); | 500 EXPECT_EQ(all_expected_tiles, all_actual_tiles); |
| 378 } | 501 } |
| 379 | 502 |
| 380 TEST_F(TileManagerTilePriorityQueueTest, | 503 TEST_F(TileManagerTilePriorityQueueTest, |
| 381 RasterTilePriorityQueueHighLowTilings) { | 504 RasterTilePriorityQueueHighLowTilings) { |
| 382 const gfx::Size layer_bounds(1000, 1000); | 505 const gfx::Size layer_bounds(1000, 1000); |
| 383 const gfx::Size viewport(800, 800); | 506 const gfx::Size viewport(800, 800); |
| 384 host_impl()->SetViewportSize(viewport); | 507 host_impl_.SetViewportSize(viewport); |
| 385 SetupDefaultTrees(layer_bounds); | 508 SetupDefaultTrees(layer_bounds); |
| 386 | 509 |
| 387 pending_layer()->tilings()->AddTiling(1.5f, pending_layer()->raster_source()); | 510 pending_layer_->tilings()->AddTiling(1.5f, pending_layer_->raster_source()); |
| 388 active_layer()->tilings()->AddTiling(1.5f, active_layer()->raster_source()); | 511 active_layer_->tilings()->AddTiling(1.5f, active_layer_->raster_source()); |
| 389 pending_layer()->tilings()->AddTiling(1.7f, pending_layer()->raster_source()); | 512 pending_layer_->tilings()->AddTiling(1.7f, pending_layer_->raster_source()); |
| 390 active_layer()->tilings()->AddTiling(1.7f, active_layer()->raster_source()); | 513 active_layer_->tilings()->AddTiling(1.7f, active_layer_->raster_source()); |
| 391 | 514 |
| 392 pending_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, | 515 pending_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, |
| 393 5.0, Occlusion(), true); | |
| 394 active_layer()->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, | |
| 395 Occlusion(), true); | 516 Occlusion(), true); |
| 517 active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0, |
| 518 Occlusion(), true); |
| 396 | 519 |
| 397 std::set<Tile*> all_expected_tiles; | 520 std::set<Tile*> all_expected_tiles; |
| 398 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { | 521 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
| 399 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); | 522 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 400 if (tiling->contents_scale() == 1.f) { | 523 if (tiling->contents_scale() == 1.f) { |
| 401 tiling->set_resolution(HIGH_RESOLUTION); | 524 tiling->set_resolution(HIGH_RESOLUTION); |
| 402 const auto& all_tiles = tiling->AllTilesForTesting(); | 525 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 403 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 526 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 404 } else { | 527 } else { |
| 405 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 528 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
| 406 } | 529 } |
| 407 } | 530 } |
| 408 | 531 |
| 409 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { | 532 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
| 410 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); | 533 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
| 411 if (tiling->contents_scale() == 1.5f) { | 534 if (tiling->contents_scale() == 1.5f) { |
| 412 tiling->set_resolution(HIGH_RESOLUTION); | 535 tiling->set_resolution(HIGH_RESOLUTION); |
| 413 const auto& all_tiles = tiling->AllTilesForTesting(); | 536 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 414 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 537 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 415 } else { | 538 } else { |
| 416 tiling->set_resolution(LOW_RESOLUTION); | 539 tiling->set_resolution(LOW_RESOLUTION); |
| 417 // Low res tilings with a high res pending twin have to be processed | 540 // Low res tilings with a high res pending twin have to be processed |
| 418 // because of possible activation tiles. | 541 // because of possible activation tiles. |
| 419 if (tiling->contents_scale() == 1.f) { | 542 if (tiling->contents_scale() == 1.f) { |
| 420 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 543 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 421 const auto& all_tiles = tiling->AllTilesForTesting(); | 544 const auto& all_tiles = tiling->AllTilesForTesting(); |
| 422 for (auto* tile : all_tiles) | 545 for (auto* tile : all_tiles) |
| 423 EXPECT_TRUE(tile->required_for_activation()); | 546 EXPECT_TRUE(tile->required_for_activation()); |
| 424 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); | 547 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end()); |
| 425 } | 548 } |
| 426 } | 549 } |
| 427 } | 550 } |
| 428 | 551 |
| 429 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 552 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 430 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 553 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 431 EXPECT_FALSE(queue->IsEmpty()); | 554 EXPECT_FALSE(queue->IsEmpty()); |
| 432 | 555 |
| 433 size_t tile_count = 0; | 556 size_t tile_count = 0; |
| 434 std::set<Tile*> all_actual_tiles; | 557 std::set<Tile*> all_actual_tiles; |
| 435 while (!queue->IsEmpty()) { | 558 while (!queue->IsEmpty()) { |
| 436 EXPECT_TRUE(queue->Top().tile()); | 559 EXPECT_TRUE(queue->Top().tile()); |
| 437 all_actual_tiles.insert(queue->Top().tile()); | 560 all_actual_tiles.insert(queue->Top().tile()); |
| 438 ++tile_count; | 561 ++tile_count; |
| 439 queue->Pop(); | 562 queue->Pop(); |
| 440 } | 563 } |
| 441 | 564 |
| 442 EXPECT_EQ(tile_count, all_actual_tiles.size()); | 565 EXPECT_EQ(tile_count, all_actual_tiles.size()); |
| 443 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size()); | 566 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size()); |
| 444 EXPECT_EQ(all_expected_tiles, all_actual_tiles); | 567 EXPECT_EQ(all_expected_tiles, all_actual_tiles); |
| 445 } | 568 } |
| 446 | 569 |
| 447 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { | 570 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { |
| 448 const gfx::Size layer_bounds(1000, 1000); | 571 const gfx::Size layer_bounds(1000, 1000); |
| 449 host_impl()->SetViewportSize(gfx::Size(500, 500)); | 572 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
| 450 SetupDefaultTrees(layer_bounds); | 573 SetupDefaultTrees(layer_bounds); |
| 451 | 574 |
| 452 // Use a tile's content rect as an invalidation. We should inset it a bit to | 575 // Use a tile's content rect as an invalidation. We should inset it a bit to |
| 453 // ensure that border math doesn't invalidate neighbouring tiles. | 576 // ensure that border math doesn't invalidate neighbouring tiles. |
| 454 gfx::Rect invalidation = | 577 gfx::Rect invalidation = |
| 455 active_layer()->HighResTiling()->TileAt(1, 0)->content_rect(); | 578 active_layer_->HighResTiling()->TileAt(1, 0)->content_rect(); |
| 456 invalidation.Inset(2, 2); | 579 invalidation.Inset(2, 2); |
| 457 | 580 |
| 458 pending_layer()->set_invalidation(invalidation); | 581 pending_layer_->set_invalidation(invalidation); |
| 459 pending_layer()->HighResTiling()->Invalidate(invalidation); | 582 pending_layer_->HighResTiling()->Invalidate(invalidation); |
| 460 pending_layer()->HighResTiling()->CreateMissingTilesInLiveTilesRect(); | 583 pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect(); |
| 461 | 584 |
| 462 // Sanity checks: Tile at 0, 0 not exist on the pending tree (it's not | 585 // Sanity checks: Tile at 0, 0 not exist on the pending tree (it's not |
| 463 // invalidated). Tile 1, 0 should exist on both. | 586 // invalidated). Tile 1, 0 should exist on both. |
| 464 EXPECT_FALSE(pending_layer()->HighResTiling()->TileAt(0, 0)); | 587 EXPECT_FALSE(pending_layer_->HighResTiling()->TileAt(0, 0)); |
| 465 EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(0, 0)); | 588 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(0, 0)); |
| 466 EXPECT_TRUE(pending_layer()->HighResTiling()->TileAt(1, 0)); | 589 EXPECT_TRUE(pending_layer_->HighResTiling()->TileAt(1, 0)); |
| 467 EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(1, 0)); | 590 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(1, 0)); |
| 468 EXPECT_NE(pending_layer()->HighResTiling()->TileAt(1, 0), | 591 EXPECT_NE(pending_layer_->HighResTiling()->TileAt(1, 0), |
| 469 active_layer()->HighResTiling()->TileAt(1, 0)); | 592 active_layer_->HighResTiling()->TileAt(1, 0)); |
| 470 | 593 |
| 471 std::set<Tile*> expected_now_tiles; | 594 std::set<Tile*> expected_now_tiles; |
| 472 std::set<Tile*> expected_required_for_draw_tiles; | 595 std::set<Tile*> expected_required_for_draw_tiles; |
| 473 std::set<Tile*> expected_required_for_activation_tiles; | 596 std::set<Tile*> expected_required_for_activation_tiles; |
| 474 for (int i = 0; i <= 1; ++i) { | 597 for (int i = 0; i <= 1; ++i) { |
| 475 for (int j = 0; j <= 1; ++j) { | 598 for (int j = 0; j <= 1; ++j) { |
| 476 bool have_pending_tile = false; | 599 bool have_pending_tile = false; |
| 477 if (pending_layer()->HighResTiling()->TileAt(i, j)) { | 600 if (pending_layer_->HighResTiling()->TileAt(i, j)) { |
| 478 expected_now_tiles.insert( | 601 expected_now_tiles.insert( |
| 479 pending_layer()->HighResTiling()->TileAt(i, j)); | 602 pending_layer_->HighResTiling()->TileAt(i, j)); |
| 480 expected_required_for_activation_tiles.insert( | 603 expected_required_for_activation_tiles.insert( |
| 481 pending_layer()->HighResTiling()->TileAt(i, j)); | 604 pending_layer_->HighResTiling()->TileAt(i, j)); |
| 482 have_pending_tile = true; | 605 have_pending_tile = true; |
| 483 } | 606 } |
| 484 Tile* active_tile = active_layer()->HighResTiling()->TileAt(i, j); | 607 Tile* active_tile = active_layer_->HighResTiling()->TileAt(i, j); |
| 485 EXPECT_TRUE(active_tile); | 608 EXPECT_TRUE(active_tile); |
| 486 expected_now_tiles.insert(active_tile); | 609 expected_now_tiles.insert(active_tile); |
| 487 expected_required_for_draw_tiles.insert(active_tile); | 610 expected_required_for_draw_tiles.insert(active_tile); |
| 488 if (!have_pending_tile) | 611 if (!have_pending_tile) |
| 489 expected_required_for_activation_tiles.insert(active_tile); | 612 expected_required_for_activation_tiles.insert(active_tile); |
| 490 } | 613 } |
| 491 } | 614 } |
| 492 // Expect 3 shared tiles and 1 unshared tile in total. | 615 // Expect 3 shared tiles and 1 unshared tile in total. |
| 493 EXPECT_EQ(5u, expected_now_tiles.size()); | 616 EXPECT_EQ(5u, expected_now_tiles.size()); |
| 494 // Expect 4 tiles for each draw and activation, but not all the same. | 617 // Expect 4 tiles for each draw and activation, but not all the same. |
| 495 EXPECT_EQ(4u, expected_required_for_activation_tiles.size()); | 618 EXPECT_EQ(4u, expected_required_for_activation_tiles.size()); |
| 496 EXPECT_EQ(4u, expected_required_for_draw_tiles.size()); | 619 EXPECT_EQ(4u, expected_required_for_draw_tiles.size()); |
| 497 EXPECT_NE(expected_required_for_draw_tiles, | 620 EXPECT_NE(expected_required_for_draw_tiles, |
| 498 expected_required_for_activation_tiles); | 621 expected_required_for_activation_tiles); |
| 499 | 622 |
| 500 std::set<Tile*> expected_all_tiles; | 623 std::set<Tile*> expected_all_tiles; |
| 501 for (int i = 0; i <= 3; ++i) { | 624 for (int i = 0; i <= 3; ++i) { |
| 502 for (int j = 0; j <= 3; ++j) { | 625 for (int j = 0; j <= 3; ++j) { |
| 503 if (pending_layer()->HighResTiling()->TileAt(i, j)) | 626 if (pending_layer_->HighResTiling()->TileAt(i, j)) |
| 504 expected_all_tiles.insert( | 627 expected_all_tiles.insert( |
| 505 pending_layer()->HighResTiling()->TileAt(i, j)); | 628 pending_layer_->HighResTiling()->TileAt(i, j)); |
| 506 EXPECT_TRUE(active_layer()->HighResTiling()->TileAt(i, j)); | 629 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(i, j)); |
| 507 expected_all_tiles.insert(active_layer()->HighResTiling()->TileAt(i, j)); | 630 expected_all_tiles.insert(active_layer_->HighResTiling()->TileAt(i, j)); |
| 508 } | 631 } |
| 509 } | 632 } |
| 510 // Expect 15 shared tiles and 1 unshared tile. | 633 // Expect 15 shared tiles and 1 unshared tile. |
| 511 EXPECT_EQ(17u, expected_all_tiles.size()); | 634 EXPECT_EQ(17u, expected_all_tiles.size()); |
| 512 | 635 |
| 513 // The actual test will now build different queues and verify that the queues | 636 // The actual test will now build different queues and verify that the queues |
| 514 // return the same information as computed manually above. | 637 // return the same information as computed manually above. |
| 515 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 638 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 516 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 639 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 517 std::set<Tile*> actual_now_tiles; | 640 std::set<Tile*> actual_now_tiles; |
| 518 std::set<Tile*> actual_all_tiles; | 641 std::set<Tile*> actual_all_tiles; |
| 519 while (!queue->IsEmpty()) { | 642 while (!queue->IsEmpty()) { |
| 520 PrioritizedTile prioritized_tile = queue->Top(); | 643 PrioritizedTile prioritized_tile = queue->Top(); |
| 521 queue->Pop(); | 644 queue->Pop(); |
| 522 if (prioritized_tile.priority().priority_bin == TilePriority::NOW) | 645 if (prioritized_tile.priority().priority_bin == TilePriority::NOW) |
| 523 actual_now_tiles.insert(prioritized_tile.tile()); | 646 actual_now_tiles.insert(prioritized_tile.tile()); |
| 524 actual_all_tiles.insert(prioritized_tile.tile()); | 647 actual_all_tiles.insert(prioritized_tile.tile()); |
| 525 } | 648 } |
| 526 EXPECT_EQ(expected_now_tiles, actual_now_tiles); | 649 EXPECT_EQ(expected_now_tiles, actual_now_tiles); |
| 527 EXPECT_EQ(expected_all_tiles, actual_all_tiles); | 650 EXPECT_EQ(expected_all_tiles, actual_all_tiles); |
| 528 | 651 |
| 529 queue = host_impl()->BuildRasterQueue( | 652 queue = host_impl_.BuildRasterQueue( |
| 530 SAME_PRIORITY_FOR_BOTH_TREES, | 653 SAME_PRIORITY_FOR_BOTH_TREES, |
| 531 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 654 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| 532 std::set<Tile*> actual_required_for_draw_tiles; | 655 std::set<Tile*> actual_required_for_draw_tiles; |
| 533 while (!queue->IsEmpty()) { | 656 while (!queue->IsEmpty()) { |
| 534 PrioritizedTile prioritized_tile = queue->Top(); | 657 PrioritizedTile prioritized_tile = queue->Top(); |
| 535 queue->Pop(); | 658 queue->Pop(); |
| 536 actual_required_for_draw_tiles.insert(prioritized_tile.tile()); | 659 actual_required_for_draw_tiles.insert(prioritized_tile.tile()); |
| 537 } | 660 } |
| 538 EXPECT_EQ(expected_required_for_draw_tiles, actual_required_for_draw_tiles); | 661 EXPECT_EQ(expected_required_for_draw_tiles, actual_required_for_draw_tiles); |
| 539 | 662 |
| 540 queue = host_impl()->BuildRasterQueue( | 663 queue = host_impl_.BuildRasterQueue( |
| 541 SAME_PRIORITY_FOR_BOTH_TREES, | 664 SAME_PRIORITY_FOR_BOTH_TREES, |
| 542 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 665 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 543 std::set<Tile*> actual_required_for_activation_tiles; | 666 std::set<Tile*> actual_required_for_activation_tiles; |
| 544 while (!queue->IsEmpty()) { | 667 while (!queue->IsEmpty()) { |
| 545 Tile* tile = queue->Top().tile(); | 668 Tile* tile = queue->Top().tile(); |
| 546 queue->Pop(); | 669 queue->Pop(); |
| 547 actual_required_for_activation_tiles.insert(tile); | 670 actual_required_for_activation_tiles.insert(tile); |
| 548 } | 671 } |
| 549 EXPECT_EQ(expected_required_for_activation_tiles, | 672 EXPECT_EQ(expected_required_for_activation_tiles, |
| 550 actual_required_for_activation_tiles); | 673 actual_required_for_activation_tiles); |
| 551 } | 674 } |
| 552 | 675 |
| 553 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { | 676 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { |
| 554 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 677 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 555 | 678 |
| 556 gfx::Size layer_bounds(1000, 1000); | 679 gfx::Size layer_bounds(1000, 1000); |
| 557 SetupDefaultTrees(layer_bounds); | 680 SetupDefaultTrees(layer_bounds); |
| 558 | 681 |
| 559 // Create a pending child layer. | 682 // Create a pending child layer. |
| 560 scoped_refptr<FakeRasterSource> pending_raster_source = | 683 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 561 FakeRasterSource::CreateFilled(layer_bounds); | 684 FakeRasterSource::CreateFilled(layer_bounds); |
| 562 std::unique_ptr<FakePictureLayerImpl> pending_child = | 685 std::unique_ptr<FakePictureLayerImpl> pending_child = |
| 563 FakePictureLayerImpl::CreateWithRasterSource( | 686 FakePictureLayerImpl::CreateWithRasterSource( |
| 564 host_impl()->pending_tree(), layer_id() + 1, pending_raster_source); | 687 host_impl_.pending_tree(), id_ + 1, pending_raster_source); |
| 565 FakePictureLayerImpl* pending_child_raw = pending_child.get(); | 688 FakePictureLayerImpl* pending_child_raw = pending_child.get(); |
| 566 pending_child_raw->SetDrawsContent(true); | 689 pending_child_raw->SetDrawsContent(true); |
| 567 pending_layer()->AddChild(std::move(pending_child)); | 690 pending_layer_->AddChild(std::move(pending_child)); |
| 568 | 691 |
| 569 // Set a small viewport, so we have soon and eventually tiles. | 692 // Set a small viewport, so we have soon and eventually tiles. |
| 570 host_impl()->SetViewportSize(gfx::Size(200, 200)); | 693 host_impl_.SetViewportSize(gfx::Size(200, 200)); |
| 571 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 694 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 572 bool update_lcd_text = false; | 695 bool update_lcd_text = false; |
| 573 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; | 696 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; |
| 574 host_impl()->pending_tree()->BuildPropertyTreesForTesting(); | 697 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 575 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 698 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 576 | 699 |
| 577 host_impl()->SetRequiresHighResToDraw(); | 700 host_impl_.SetRequiresHighResToDraw(); |
| 578 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 701 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 579 SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); | 702 SMOOTHNESS_TAKES_PRIORITY, RasterTilePriorityQueue::Type::ALL)); |
| 580 EXPECT_FALSE(queue->IsEmpty()); | 703 EXPECT_FALSE(queue->IsEmpty()); |
| 581 | 704 |
| 582 // Get all the tiles that are NOW or SOON and make sure they are ready to | 705 // Get all the tiles that are NOW or SOON and make sure they are ready to |
| 583 // draw. | 706 // draw. |
| 584 std::vector<Tile*> all_tiles; | 707 std::vector<Tile*> all_tiles; |
| 585 while (!queue->IsEmpty()) { | 708 while (!queue->IsEmpty()) { |
| 586 PrioritizedTile prioritized_tile = queue->Top(); | 709 PrioritizedTile prioritized_tile = queue->Top(); |
| 587 if (prioritized_tile.priority().priority_bin >= TilePriority::EVENTUALLY) | 710 if (prioritized_tile.priority().priority_bin >= TilePriority::EVENTUALLY) |
| 588 break; | 711 break; |
| 589 | 712 |
| 590 all_tiles.push_back(prioritized_tile.tile()); | 713 all_tiles.push_back(prioritized_tile.tile()); |
| 591 queue->Pop(); | 714 queue->Pop(); |
| 592 } | 715 } |
| 593 | 716 |
| 594 tile_manager()->InitializeTilesWithResourcesForTesting( | 717 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 595 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 718 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 596 | 719 |
| 597 // Ensure we can activate. | 720 // Ensure we can activate. |
| 598 EXPECT_TRUE(tile_manager()->IsReadyToActivate()); | 721 EXPECT_TRUE(tile_manager()->IsReadyToActivate()); |
| 599 } | 722 } |
| 600 | 723 |
| 601 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { | 724 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { |
| 602 const gfx::Size layer_bounds(1000, 1000); | 725 const gfx::Size layer_bounds(1000, 1000); |
| 603 host_impl()->SetViewportSize(layer_bounds); | 726 host_impl_.SetViewportSize(layer_bounds); |
| 604 SetupDefaultTrees(layer_bounds); | 727 SetupDefaultTrees(layer_bounds); |
| 605 ASSERT_TRUE(active_layer()->HighResTiling()); | 728 ASSERT_TRUE(active_layer_->HighResTiling()); |
| 606 ASSERT_TRUE(active_layer()->LowResTiling()); | 729 ASSERT_TRUE(active_layer_->LowResTiling()); |
| 607 ASSERT_TRUE(pending_layer()->HighResTiling()); | 730 ASSERT_TRUE(pending_layer_->HighResTiling()); |
| 608 EXPECT_FALSE(pending_layer()->LowResTiling()); | 731 EXPECT_FALSE(pending_layer_->LowResTiling()); |
| 609 | 732 |
| 610 std::unique_ptr<EvictionTilePriorityQueue> empty_queue( | 733 std::unique_ptr<EvictionTilePriorityQueue> empty_queue( |
| 611 host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); | 734 host_impl_.BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); |
| 612 EXPECT_TRUE(empty_queue->IsEmpty()); | 735 EXPECT_TRUE(empty_queue->IsEmpty()); |
| 613 std::set<Tile*> all_tiles; | 736 std::set<Tile*> all_tiles; |
| 614 size_t tile_count = 0; | 737 size_t tile_count = 0; |
| 615 | 738 |
| 616 std::unique_ptr<RasterTilePriorityQueue> raster_queue( | 739 std::unique_ptr<RasterTilePriorityQueue> raster_queue( |
| 617 host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, | 740 host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, |
| 618 RasterTilePriorityQueue::Type::ALL)); | 741 RasterTilePriorityQueue::Type::ALL)); |
| 619 while (!raster_queue->IsEmpty()) { | 742 while (!raster_queue->IsEmpty()) { |
| 620 ++tile_count; | 743 ++tile_count; |
| 621 EXPECT_TRUE(raster_queue->Top().tile()); | 744 EXPECT_TRUE(raster_queue->Top().tile()); |
| 622 all_tiles.insert(raster_queue->Top().tile()); | 745 all_tiles.insert(raster_queue->Top().tile()); |
| 623 raster_queue->Pop(); | 746 raster_queue->Pop(); |
| 624 } | 747 } |
| 625 | 748 |
| 626 EXPECT_EQ(tile_count, all_tiles.size()); | 749 EXPECT_EQ(tile_count, all_tiles.size()); |
| 627 EXPECT_EQ(16u, tile_count); | 750 EXPECT_EQ(16u, tile_count); |
| 628 | 751 |
| 629 tile_manager()->InitializeTilesWithResourcesForTesting( | 752 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 630 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 753 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 631 | 754 |
| 632 std::unique_ptr<EvictionTilePriorityQueue> queue( | 755 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 633 host_impl()->BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); | 756 host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); |
| 634 EXPECT_FALSE(queue->IsEmpty()); | 757 EXPECT_FALSE(queue->IsEmpty()); |
| 635 | 758 |
| 636 // Sanity check, all tiles should be visible. | 759 // Sanity check, all tiles should be visible. |
| 637 std::set<Tile*> smoothness_tiles; | 760 std::set<Tile*> smoothness_tiles; |
| 638 while (!queue->IsEmpty()) { | 761 while (!queue->IsEmpty()) { |
| 639 PrioritizedTile prioritized_tile = queue->Top(); | 762 PrioritizedTile prioritized_tile = queue->Top(); |
| 640 EXPECT_TRUE(prioritized_tile.tile()); | 763 EXPECT_TRUE(prioritized_tile.tile()); |
| 641 EXPECT_EQ(TilePriority::NOW, prioritized_tile.priority().priority_bin); | 764 EXPECT_EQ(TilePriority::NOW, prioritized_tile.priority().priority_bin); |
| 642 EXPECT_TRUE(prioritized_tile.tile()->draw_info().has_resource()); | 765 EXPECT_TRUE(prioritized_tile.tile()->draw_info().has_resource()); |
| 643 smoothness_tiles.insert(prioritized_tile.tile()); | 766 smoothness_tiles.insert(prioritized_tile.tile()); |
| 644 queue->Pop(); | 767 queue->Pop(); |
| 645 } | 768 } |
| 646 EXPECT_EQ(all_tiles, smoothness_tiles); | 769 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 647 | 770 |
| 648 tile_manager()->ReleaseTileResourcesForTesting( | 771 tile_manager()->ReleaseTileResourcesForTesting( |
| 649 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 772 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 650 | 773 |
| 651 Region invalidation(gfx::Rect(0, 0, 500, 500)); | 774 Region invalidation(gfx::Rect(0, 0, 500, 500)); |
| 652 | 775 |
| 653 // Invalidate the pending tree. | 776 // Invalidate the pending tree. |
| 654 pending_layer()->set_invalidation(invalidation); | 777 pending_layer_->set_invalidation(invalidation); |
| 655 pending_layer()->HighResTiling()->Invalidate(invalidation); | 778 pending_layer_->HighResTiling()->Invalidate(invalidation); |
| 656 pending_layer()->HighResTiling()->CreateMissingTilesInLiveTilesRect(); | 779 pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect(); |
| 657 EXPECT_FALSE(pending_layer()->LowResTiling()); | 780 EXPECT_FALSE(pending_layer_->LowResTiling()); |
| 658 | 781 |
| 659 // Renew all of the tile priorities. | 782 // Renew all of the tile priorities. |
| 660 gfx::Rect viewport(50, 50, 100, 100); | 783 gfx::Rect viewport(50, 50, 100, 100); |
| 661 pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 784 pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 662 viewport, 1.0f, 1.0, Occlusion(), true); | 785 viewport, 1.0f, 1.0, Occlusion(), true); |
| 663 active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 786 active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 664 viewport, 1.0f, 1.0, Occlusion(), true); | 787 viewport, 1.0f, 1.0, Occlusion(), true); |
| 665 | 788 |
| 666 // Populate all tiles directly from the tilings. | 789 // Populate all tiles directly from the tilings. |
| 667 all_tiles.clear(); | 790 all_tiles.clear(); |
| 668 std::vector<Tile*> pending_high_res_tiles = | 791 std::vector<Tile*> pending_high_res_tiles = |
| 669 pending_layer()->HighResTiling()->AllTilesForTesting(); | 792 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 670 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) | 793 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) |
| 671 all_tiles.insert(pending_high_res_tiles[i]); | 794 all_tiles.insert(pending_high_res_tiles[i]); |
| 672 | 795 |
| 673 std::vector<Tile*> active_high_res_tiles = | 796 std::vector<Tile*> active_high_res_tiles = |
| 674 active_layer()->HighResTiling()->AllTilesForTesting(); | 797 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 675 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) | 798 for (size_t i = 0; i < active_high_res_tiles.size(); ++i) |
| 676 all_tiles.insert(active_high_res_tiles[i]); | 799 all_tiles.insert(active_high_res_tiles[i]); |
| 677 | 800 |
| 678 std::vector<Tile*> active_low_res_tiles = | 801 std::vector<Tile*> active_low_res_tiles = |
| 679 active_layer()->LowResTiling()->AllTilesForTesting(); | 802 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 680 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 803 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 681 all_tiles.insert(active_low_res_tiles[i]); | 804 all_tiles.insert(active_low_res_tiles[i]); |
| 682 | 805 |
| 683 tile_manager()->InitializeTilesWithResourcesForTesting( | 806 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 684 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 807 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 685 | 808 |
| 686 PrioritizedTile last_tile; | 809 PrioritizedTile last_tile; |
| 687 smoothness_tiles.clear(); | 810 smoothness_tiles.clear(); |
| 688 tile_count = 0; | 811 tile_count = 0; |
| 689 // Here we expect to get increasing combined priority_bin. | 812 // Here we expect to get increasing combined priority_bin. |
| 690 queue = host_impl()->BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); | 813 queue = host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); |
| 691 int distance_increasing = 0; | 814 int distance_increasing = 0; |
| 692 int distance_decreasing = 0; | 815 int distance_decreasing = 0; |
| 693 while (!queue->IsEmpty()) { | 816 while (!queue->IsEmpty()) { |
| 694 PrioritizedTile prioritized_tile = queue->Top(); | 817 PrioritizedTile prioritized_tile = queue->Top(); |
| 695 Tile* tile = prioritized_tile.tile(); | 818 Tile* tile = prioritized_tile.tile(); |
| 696 EXPECT_TRUE(tile); | 819 EXPECT_TRUE(tile); |
| 697 EXPECT_TRUE(tile->draw_info().has_resource()); | 820 EXPECT_TRUE(tile->draw_info().has_resource()); |
| 698 | 821 |
| 699 if (!last_tile.tile()) | 822 if (!last_tile.tile()) |
| 700 last_tile = prioritized_tile; | 823 last_tile = prioritized_tile; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 723 | 846 |
| 724 // Ensure that the distance is decreasing many more times than increasing. | 847 // Ensure that the distance is decreasing many more times than increasing. |
| 725 EXPECT_EQ(3, distance_increasing); | 848 EXPECT_EQ(3, distance_increasing); |
| 726 EXPECT_EQ(16, distance_decreasing); | 849 EXPECT_EQ(16, distance_decreasing); |
| 727 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 850 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 728 EXPECT_EQ(all_tiles, smoothness_tiles); | 851 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 729 | 852 |
| 730 std::set<Tile*> new_content_tiles; | 853 std::set<Tile*> new_content_tiles; |
| 731 last_tile = PrioritizedTile(); | 854 last_tile = PrioritizedTile(); |
| 732 // Again, we expect to get increasing combined priority_bin. | 855 // Again, we expect to get increasing combined priority_bin. |
| 733 queue = host_impl()->BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); | 856 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); |
| 734 distance_decreasing = 0; | 857 distance_decreasing = 0; |
| 735 distance_increasing = 0; | 858 distance_increasing = 0; |
| 736 while (!queue->IsEmpty()) { | 859 while (!queue->IsEmpty()) { |
| 737 PrioritizedTile prioritized_tile = queue->Top(); | 860 PrioritizedTile prioritized_tile = queue->Top(); |
| 738 Tile* tile = prioritized_tile.tile(); | 861 Tile* tile = prioritized_tile.tile(); |
| 739 EXPECT_TRUE(tile); | 862 EXPECT_TRUE(tile); |
| 740 | 863 |
| 741 if (!last_tile.tile()) | 864 if (!last_tile.tile()) |
| 742 last_tile = prioritized_tile; | 865 last_tile = prioritized_tile; |
| 743 | 866 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 764 | 887 |
| 765 // Ensure that the distance is decreasing many more times than increasing. | 888 // Ensure that the distance is decreasing many more times than increasing. |
| 766 EXPECT_EQ(3, distance_increasing); | 889 EXPECT_EQ(3, distance_increasing); |
| 767 EXPECT_EQ(16, distance_decreasing); | 890 EXPECT_EQ(16, distance_decreasing); |
| 768 EXPECT_EQ(tile_count, new_content_tiles.size()); | 891 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 769 EXPECT_EQ(all_tiles, new_content_tiles); | 892 EXPECT_EQ(all_tiles, new_content_tiles); |
| 770 } | 893 } |
| 771 | 894 |
| 772 TEST_F(TileManagerTilePriorityQueueTest, | 895 TEST_F(TileManagerTilePriorityQueueTest, |
| 773 EvictionTilePriorityQueueWithOcclusion) { | 896 EvictionTilePriorityQueueWithOcclusion) { |
| 774 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 897 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 775 | 898 |
| 776 gfx::Size layer_bounds(1000, 1000); | 899 gfx::Size layer_bounds(1000, 1000); |
| 777 | 900 |
| 778 host_impl()->SetViewportSize(layer_bounds); | 901 host_impl_.SetViewportSize(layer_bounds); |
| 779 | 902 |
| 780 scoped_refptr<FakeRasterSource> pending_raster_source = | 903 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 781 FakeRasterSource::CreateFilled(layer_bounds); | 904 FakeRasterSource::CreateFilled(layer_bounds); |
| 782 SetupPendingTree(pending_raster_source); | 905 SetupPendingTree(pending_raster_source); |
| 783 | 906 |
| 784 std::unique_ptr<FakePictureLayerImpl> pending_child = | 907 std::unique_ptr<FakePictureLayerImpl> pending_child = |
| 785 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), | 908 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 786 2, pending_raster_source); | 909 pending_raster_source); |
| 787 pending_layer()->AddChild(std::move(pending_child)); | 910 pending_layer_->AddChild(std::move(pending_child)); |
| 788 | 911 |
| 789 FakePictureLayerImpl* pending_child_layer = | 912 FakePictureLayerImpl* pending_child_layer = |
| 790 static_cast<FakePictureLayerImpl*>(pending_layer()->children()[0]); | 913 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 791 pending_child_layer->SetDrawsContent(true); | 914 pending_child_layer->SetDrawsContent(true); |
| 792 | 915 |
| 793 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 916 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 794 bool update_lcd_text = false; | 917 bool update_lcd_text = false; |
| 795 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; | 918 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; |
| 796 host_impl()->pending_tree()->BuildPropertyTreesForTesting(); | 919 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 797 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 920 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 798 | 921 |
| 799 ActivateTree(); | 922 ActivateTree(); |
| 800 SetupPendingTree(pending_raster_source); | 923 SetupPendingTree(pending_raster_source); |
| 801 | 924 |
| 802 FakePictureLayerImpl* active_child_layer = | 925 FakePictureLayerImpl* active_child_layer = |
| 803 static_cast<FakePictureLayerImpl*>(active_layer()->children()[0]); | 926 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); |
| 804 | 927 |
| 805 std::set<Tile*> all_tiles; | 928 std::set<Tile*> all_tiles; |
| 806 size_t tile_count = 0; | 929 size_t tile_count = 0; |
| 807 std::unique_ptr<RasterTilePriorityQueue> raster_queue( | 930 std::unique_ptr<RasterTilePriorityQueue> raster_queue( |
| 808 host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, | 931 host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, |
| 809 RasterTilePriorityQueue::Type::ALL)); | 932 RasterTilePriorityQueue::Type::ALL)); |
| 810 while (!raster_queue->IsEmpty()) { | 933 while (!raster_queue->IsEmpty()) { |
| 811 ++tile_count; | 934 ++tile_count; |
| 812 EXPECT_TRUE(raster_queue->Top().tile()); | 935 EXPECT_TRUE(raster_queue->Top().tile()); |
| 813 all_tiles.insert(raster_queue->Top().tile()); | 936 all_tiles.insert(raster_queue->Top().tile()); |
| 814 raster_queue->Pop(); | 937 raster_queue->Pop(); |
| 815 } | 938 } |
| 816 EXPECT_EQ(tile_count, all_tiles.size()); | 939 EXPECT_EQ(tile_count, all_tiles.size()); |
| 817 EXPECT_EQ(32u, tile_count); | 940 EXPECT_EQ(32u, tile_count); |
| 818 | 941 |
| 819 // Renew all of the tile priorities. | 942 // Renew all of the tile priorities. |
| 820 gfx::Rect viewport(layer_bounds); | 943 gfx::Rect viewport(layer_bounds); |
| 821 pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 944 pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 822 viewport, 1.0f, 1.0, Occlusion(), true); | 945 viewport, 1.0f, 1.0, Occlusion(), true); |
| 823 pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( | 946 pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( |
| 824 viewport, 1.0f, 1.0, Occlusion(), true); | 947 viewport, 1.0f, 1.0, Occlusion(), true); |
| 825 | 948 |
| 826 active_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 949 active_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 827 viewport, 1.0f, 1.0, Occlusion(), true); | 950 viewport, 1.0f, 1.0, Occlusion(), true); |
| 828 active_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( | 951 active_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( |
| 829 viewport, 1.0f, 1.0, Occlusion(), true); | 952 viewport, 1.0f, 1.0, Occlusion(), true); |
| 830 | 953 |
| 831 // Populate all tiles directly from the tilings. | 954 // Populate all tiles directly from the tilings. |
| 832 all_tiles.clear(); | 955 all_tiles.clear(); |
| 833 std::vector<Tile*> pending_high_res_tiles = | 956 std::vector<Tile*> pending_high_res_tiles = |
| 834 pending_layer()->HighResTiling()->AllTilesForTesting(); | 957 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 835 all_tiles.insert(pending_high_res_tiles.begin(), | 958 all_tiles.insert(pending_high_res_tiles.begin(), |
| 836 pending_high_res_tiles.end()); | 959 pending_high_res_tiles.end()); |
| 837 | 960 |
| 838 // Set all tiles on the pending_child_layer as occluded on the pending tree. | 961 // Set all tiles on the pending_child_layer as occluded on the pending tree. |
| 839 std::vector<Tile*> pending_child_high_res_tiles = | 962 std::vector<Tile*> pending_child_high_res_tiles = |
| 840 pending_child_layer->HighResTiling()->AllTilesForTesting(); | 963 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 841 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); | 964 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 842 active_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); | 965 active_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 843 active_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); | 966 active_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 844 | 967 |
| 845 tile_manager()->InitializeTilesWithResourcesForTesting( | 968 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 846 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 969 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 847 | 970 |
| 848 // Verify occlusion is considered by EvictionTilePriorityQueue. | 971 // Verify occlusion is considered by EvictionTilePriorityQueue. |
| 849 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; | 972 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 850 size_t occluded_count = 0u; | 973 size_t occluded_count = 0u; |
| 851 PrioritizedTile last_tile; | 974 PrioritizedTile last_tile; |
| 852 std::unique_ptr<EvictionTilePriorityQueue> queue( | 975 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 853 host_impl()->BuildEvictionQueue(tree_priority)); | 976 host_impl_.BuildEvictionQueue(tree_priority)); |
| 854 while (!queue->IsEmpty()) { | 977 while (!queue->IsEmpty()) { |
| 855 PrioritizedTile prioritized_tile = queue->Top(); | 978 PrioritizedTile prioritized_tile = queue->Top(); |
| 856 if (!last_tile.tile()) | 979 if (!last_tile.tile()) |
| 857 last_tile = prioritized_tile; | 980 last_tile = prioritized_tile; |
| 858 | 981 |
| 859 bool tile_is_occluded = prioritized_tile.is_occluded(); | 982 bool tile_is_occluded = prioritized_tile.is_occluded(); |
| 860 | 983 |
| 861 // The only way we will encounter an occluded tile after an unoccluded | 984 // The only way we will encounter an occluded tile after an unoccluded |
| 862 // tile is if the priorty bin decreased, the tile is required for | 985 // tile is if the priorty bin decreased, the tile is required for |
| 863 // activation, or the scale changed. | 986 // activation, or the scale changed. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 879 } | 1002 } |
| 880 last_tile = prioritized_tile; | 1003 last_tile = prioritized_tile; |
| 881 queue->Pop(); | 1004 queue->Pop(); |
| 882 } | 1005 } |
| 883 size_t expected_occluded_count = pending_child_high_res_tiles.size(); | 1006 size_t expected_occluded_count = pending_child_high_res_tiles.size(); |
| 884 EXPECT_EQ(expected_occluded_count, occluded_count); | 1007 EXPECT_EQ(expected_occluded_count, occluded_count); |
| 885 } | 1008 } |
| 886 | 1009 |
| 887 TEST_F(TileManagerTilePriorityQueueTest, | 1010 TEST_F(TileManagerTilePriorityQueueTest, |
| 888 EvictionTilePriorityQueueWithTransparentLayer) { | 1011 EvictionTilePriorityQueueWithTransparentLayer) { |
| 889 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1012 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 890 | 1013 |
| 891 gfx::Size layer_bounds(1000, 1000); | 1014 gfx::Size layer_bounds(1000, 1000); |
| 892 | 1015 |
| 893 scoped_refptr<FakeRasterSource> pending_raster_source = | 1016 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 894 FakeRasterSource::CreateFilled(layer_bounds); | 1017 FakeRasterSource::CreateFilled(layer_bounds); |
| 895 SetupPendingTree(pending_raster_source); | 1018 SetupPendingTree(pending_raster_source); |
| 896 | 1019 |
| 897 std::unique_ptr<FakePictureLayerImpl> pending_child = | 1020 std::unique_ptr<FakePictureLayerImpl> pending_child = |
| 898 FakePictureLayerImpl::CreateWithRasterSource(host_impl()->pending_tree(), | 1021 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 899 2, pending_raster_source); | 1022 pending_raster_source); |
| 900 FakePictureLayerImpl* pending_child_layer = pending_child.get(); | 1023 FakePictureLayerImpl* pending_child_layer = pending_child.get(); |
| 901 pending_layer()->AddChild(std::move(pending_child)); | 1024 pending_layer_->AddChild(std::move(pending_child)); |
| 902 | 1025 |
| 903 // Create a fully transparent child layer so that its tile priorities are not | 1026 // Create a fully transparent child layer so that its tile priorities are not |
| 904 // considered to be valid. | 1027 // considered to be valid. |
| 905 pending_child_layer->SetDrawsContent(true); | 1028 pending_child_layer->SetDrawsContent(true); |
| 906 pending_child_layer->test_properties()->force_render_surface = true; | 1029 pending_child_layer->test_properties()->force_render_surface = true; |
| 907 | 1030 |
| 908 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1031 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 909 bool update_lcd_text = false; | 1032 bool update_lcd_text = false; |
| 910 host_impl()->pending_tree()->property_trees()->needs_rebuild = true; | 1033 host_impl_.pending_tree()->property_trees()->needs_rebuild = true; |
| 911 host_impl()->pending_tree()->BuildPropertyTreesForTesting(); | 1034 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); |
| 912 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1035 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 913 | 1036 |
| 914 pending_child_layer->OnOpacityAnimated(0.0); | 1037 pending_child_layer->OnOpacityAnimated(0.0); |
| 915 | 1038 |
| 916 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1039 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 917 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1040 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 918 | 1041 |
| 919 // Renew all of the tile priorities. | 1042 // Renew all of the tile priorities. |
| 920 gfx::Rect viewport(layer_bounds); | 1043 gfx::Rect viewport(layer_bounds); |
| 921 pending_layer()->picture_layer_tiling_set()->UpdateTilePriorities( | 1044 pending_layer_->picture_layer_tiling_set()->UpdateTilePriorities( |
| 922 viewport, 1.0f, 1.0, Occlusion(), true); | 1045 viewport, 1.0f, 1.0, Occlusion(), true); |
| 923 pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( | 1046 pending_child_layer->picture_layer_tiling_set()->UpdateTilePriorities( |
| 924 viewport, 1.0f, 1.0, Occlusion(), true); | 1047 viewport, 1.0f, 1.0, Occlusion(), true); |
| 925 | 1048 |
| 926 // Populate all tiles directly from the tilings. | 1049 // Populate all tiles directly from the tilings. |
| 927 std::set<Tile*> all_pending_tiles; | 1050 std::set<Tile*> all_pending_tiles; |
| 928 std::vector<Tile*> pending_high_res_tiles = | 1051 std::vector<Tile*> pending_high_res_tiles = |
| 929 pending_layer()->HighResTiling()->AllTilesForTesting(); | 1052 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 930 all_pending_tiles.insert(pending_high_res_tiles.begin(), | 1053 all_pending_tiles.insert(pending_high_res_tiles.begin(), |
| 931 pending_high_res_tiles.end()); | 1054 pending_high_res_tiles.end()); |
| 932 EXPECT_EQ(16u, pending_high_res_tiles.size()); | 1055 EXPECT_EQ(16u, pending_high_res_tiles.size()); |
| 933 | 1056 |
| 934 std::set<Tile*> all_pending_child_tiles; | 1057 std::set<Tile*> all_pending_child_tiles; |
| 935 std::vector<Tile*> pending_child_high_res_tiles = | 1058 std::vector<Tile*> pending_child_high_res_tiles = |
| 936 pending_child_layer->HighResTiling()->AllTilesForTesting(); | 1059 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 937 all_pending_child_tiles.insert(pending_child_high_res_tiles.begin(), | 1060 all_pending_child_tiles.insert(pending_child_high_res_tiles.begin(), |
| 938 pending_child_high_res_tiles.end()); | 1061 pending_child_high_res_tiles.end()); |
| 939 EXPECT_EQ(16u, pending_child_high_res_tiles.size()); | 1062 EXPECT_EQ(16u, pending_child_high_res_tiles.size()); |
| 940 | 1063 |
| 941 std::set<Tile*> all_tiles = all_pending_tiles; | 1064 std::set<Tile*> all_tiles = all_pending_tiles; |
| 942 all_tiles.insert(all_pending_child_tiles.begin(), | 1065 all_tiles.insert(all_pending_child_tiles.begin(), |
| 943 all_pending_child_tiles.end()); | 1066 all_pending_child_tiles.end()); |
| 944 | 1067 |
| 945 tile_manager()->InitializeTilesWithResourcesForTesting( | 1068 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 946 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 1069 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 947 | 1070 |
| 948 EXPECT_TRUE(pending_layer()->HasValidTilePriorities()); | 1071 EXPECT_TRUE(pending_layer_->HasValidTilePriorities()); |
| 949 EXPECT_FALSE(pending_child_layer->HasValidTilePriorities()); | 1072 EXPECT_FALSE(pending_child_layer->HasValidTilePriorities()); |
| 950 | 1073 |
| 951 // Verify that eviction queue returns tiles also from layers without valid | 1074 // Verify that eviction queue returns tiles also from layers without valid |
| 952 // tile priorities and that the tile priority bin of those tiles is (at most) | 1075 // tile priorities and that the tile priority bin of those tiles is (at most) |
| 953 // EVENTUALLY. | 1076 // EVENTUALLY. |
| 954 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; | 1077 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 955 std::set<Tile*> new_content_tiles; | 1078 std::set<Tile*> new_content_tiles; |
| 956 size_t tile_count = 0; | 1079 size_t tile_count = 0; |
| 957 std::unique_ptr<EvictionTilePriorityQueue> queue( | 1080 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 958 host_impl()->BuildEvictionQueue(tree_priority)); | 1081 host_impl_.BuildEvictionQueue(tree_priority)); |
| 959 while (!queue->IsEmpty()) { | 1082 while (!queue->IsEmpty()) { |
| 960 PrioritizedTile prioritized_tile = queue->Top(); | 1083 PrioritizedTile prioritized_tile = queue->Top(); |
| 961 Tile* tile = prioritized_tile.tile(); | 1084 Tile* tile = prioritized_tile.tile(); |
| 962 const TilePriority& pending_priority = prioritized_tile.priority(); | 1085 const TilePriority& pending_priority = prioritized_tile.priority(); |
| 963 EXPECT_NE(std::numeric_limits<float>::infinity(), | 1086 EXPECT_NE(std::numeric_limits<float>::infinity(), |
| 964 pending_priority.distance_to_visible); | 1087 pending_priority.distance_to_visible); |
| 965 if (all_pending_child_tiles.find(tile) != all_pending_child_tiles.end()) | 1088 if (all_pending_child_tiles.find(tile) != all_pending_child_tiles.end()) |
| 966 EXPECT_EQ(TilePriority::EVENTUALLY, pending_priority.priority_bin); | 1089 EXPECT_EQ(TilePriority::EVENTUALLY, pending_priority.priority_bin); |
| 967 else | 1090 else |
| 968 EXPECT_EQ(TilePriority::NOW, pending_priority.priority_bin); | 1091 EXPECT_EQ(TilePriority::NOW, pending_priority.priority_bin); |
| 969 new_content_tiles.insert(tile); | 1092 new_content_tiles.insert(tile); |
| 970 ++tile_count; | 1093 ++tile_count; |
| 971 queue->Pop(); | 1094 queue->Pop(); |
| 972 } | 1095 } |
| 973 EXPECT_EQ(tile_count, new_content_tiles.size()); | 1096 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 974 EXPECT_EQ(all_tiles, new_content_tiles); | 1097 EXPECT_EQ(all_tiles, new_content_tiles); |
| 975 } | 1098 } |
| 976 | 1099 |
| 977 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { | 1100 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { |
| 978 const gfx::Size layer_bounds(1000, 1000); | 1101 const gfx::Size layer_bounds(1000, 1000); |
| 979 host_impl()->SetViewportSize(layer_bounds); | 1102 host_impl_.SetViewportSize(layer_bounds); |
| 980 SetupDefaultTrees(layer_bounds); | 1103 SetupDefaultTrees(layer_bounds); |
| 981 | 1104 |
| 982 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 1105 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 983 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1106 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 984 EXPECT_FALSE(queue->IsEmpty()); | 1107 EXPECT_FALSE(queue->IsEmpty()); |
| 985 | 1108 |
| 986 size_t tile_count = 0; | 1109 size_t tile_count = 0; |
| 987 std::set<Tile*> all_tiles; | 1110 std::set<Tile*> all_tiles; |
| 988 while (!queue->IsEmpty()) { | 1111 while (!queue->IsEmpty()) { |
| 989 EXPECT_TRUE(queue->Top().tile()); | 1112 EXPECT_TRUE(queue->Top().tile()); |
| 990 all_tiles.insert(queue->Top().tile()); | 1113 all_tiles.insert(queue->Top().tile()); |
| 991 ++tile_count; | 1114 ++tile_count; |
| 992 queue->Pop(); | 1115 queue->Pop(); |
| 993 } | 1116 } |
| 994 | 1117 |
| 995 EXPECT_EQ(tile_count, all_tiles.size()); | 1118 EXPECT_EQ(tile_count, all_tiles.size()); |
| 996 EXPECT_EQ(16u, tile_count); | 1119 EXPECT_EQ(16u, tile_count); |
| 997 | 1120 |
| 998 for (int i = 1; i < 10; ++i) { | 1121 for (int i = 1; i < 10; ++i) { |
| 999 std::unique_ptr<FakePictureLayerImpl> pending_child_layer = | 1122 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 1000 FakePictureLayerImpl::Create(host_impl()->pending_tree(), | 1123 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); |
| 1001 layer_id() + i); | 1124 pending_layer->SetDrawsContent(true); |
| 1002 pending_child_layer->SetDrawsContent(true); | 1125 pending_layer->set_has_valid_tile_priorities(true); |
| 1003 pending_child_layer->set_has_valid_tile_priorities(true); | 1126 pending_layer_->AddChild(std::move(pending_layer)); |
| 1004 pending_layer()->AddChild(std::move(pending_child_layer)); | |
| 1005 } | 1127 } |
| 1006 | 1128 |
| 1007 queue = host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, | 1129 queue = host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, |
| 1008 RasterTilePriorityQueue::Type::ALL); | 1130 RasterTilePriorityQueue::Type::ALL); |
| 1009 EXPECT_FALSE(queue->IsEmpty()); | 1131 EXPECT_FALSE(queue->IsEmpty()); |
| 1010 | 1132 |
| 1011 tile_count = 0; | 1133 tile_count = 0; |
| 1012 all_tiles.clear(); | 1134 all_tiles.clear(); |
| 1013 while (!queue->IsEmpty()) { | 1135 while (!queue->IsEmpty()) { |
| 1014 EXPECT_TRUE(queue->Top().tile()); | 1136 EXPECT_TRUE(queue->Top().tile()); |
| 1015 all_tiles.insert(queue->Top().tile()); | 1137 all_tiles.insert(queue->Top().tile()); |
| 1016 ++tile_count; | 1138 ++tile_count; |
| 1017 queue->Pop(); | 1139 queue->Pop(); |
| 1018 } | 1140 } |
| 1019 EXPECT_EQ(tile_count, all_tiles.size()); | 1141 EXPECT_EQ(tile_count, all_tiles.size()); |
| 1020 EXPECT_EQ(16u, tile_count); | 1142 EXPECT_EQ(16u, tile_count); |
| 1021 } | 1143 } |
| 1022 | 1144 |
| 1023 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { | 1145 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { |
| 1024 const gfx::Size layer_bounds(1000, 1000); | 1146 const gfx::Size layer_bounds(1000, 1000); |
| 1025 host_impl()->SetViewportSize(layer_bounds); | 1147 host_impl_.SetViewportSize(layer_bounds); |
| 1026 SetupDefaultTrees(layer_bounds); | 1148 SetupDefaultTrees(layer_bounds); |
| 1027 | 1149 |
| 1028 std::unique_ptr<RasterTilePriorityQueue> raster_queue( | 1150 std::unique_ptr<RasterTilePriorityQueue> raster_queue( |
| 1029 host_impl()->BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, | 1151 host_impl_.BuildRasterQueue(SAME_PRIORITY_FOR_BOTH_TREES, |
| 1030 RasterTilePriorityQueue::Type::ALL)); | 1152 RasterTilePriorityQueue::Type::ALL)); |
| 1031 EXPECT_FALSE(raster_queue->IsEmpty()); | 1153 EXPECT_FALSE(raster_queue->IsEmpty()); |
| 1032 | 1154 |
| 1033 size_t tile_count = 0; | 1155 size_t tile_count = 0; |
| 1034 std::set<Tile*> all_tiles; | 1156 std::set<Tile*> all_tiles; |
| 1035 while (!raster_queue->IsEmpty()) { | 1157 while (!raster_queue->IsEmpty()) { |
| 1036 EXPECT_TRUE(raster_queue->Top().tile()); | 1158 EXPECT_TRUE(raster_queue->Top().tile()); |
| 1037 all_tiles.insert(raster_queue->Top().tile()); | 1159 all_tiles.insert(raster_queue->Top().tile()); |
| 1038 ++tile_count; | 1160 ++tile_count; |
| 1039 raster_queue->Pop(); | 1161 raster_queue->Pop(); |
| 1040 } | 1162 } |
| 1041 EXPECT_EQ(tile_count, all_tiles.size()); | 1163 EXPECT_EQ(tile_count, all_tiles.size()); |
| 1042 EXPECT_EQ(16u, tile_count); | 1164 EXPECT_EQ(16u, tile_count); |
| 1043 | 1165 |
| 1044 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); | 1166 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); |
| 1045 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 1167 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 1046 | 1168 |
| 1047 for (int i = 1; i < 10; ++i) { | 1169 for (int i = 1; i < 10; ++i) { |
| 1048 std::unique_ptr<FakePictureLayerImpl> pending_child_layer = | 1170 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 1049 FakePictureLayerImpl::Create(host_impl()->pending_tree(), | 1171 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); |
| 1050 layer_id() + i); | 1172 pending_layer->SetDrawsContent(true); |
| 1051 pending_child_layer->SetDrawsContent(true); | 1173 pending_layer->set_has_valid_tile_priorities(true); |
| 1052 pending_child_layer->set_has_valid_tile_priorities(true); | 1174 pending_layer_->AddChild(std::move(pending_layer)); |
| 1053 pending_layer()->AddChild(std::move(pending_child_layer)); | |
| 1054 } | 1175 } |
| 1055 | 1176 |
| 1056 std::unique_ptr<EvictionTilePriorityQueue> queue( | 1177 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 1057 host_impl()->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); | 1178 host_impl_.BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); |
| 1058 EXPECT_FALSE(queue->IsEmpty()); | 1179 EXPECT_FALSE(queue->IsEmpty()); |
| 1059 | 1180 |
| 1060 tile_count = 0; | 1181 tile_count = 0; |
| 1061 all_tiles.clear(); | 1182 all_tiles.clear(); |
| 1062 while (!queue->IsEmpty()) { | 1183 while (!queue->IsEmpty()) { |
| 1063 EXPECT_TRUE(queue->Top().tile()); | 1184 EXPECT_TRUE(queue->Top().tile()); |
| 1064 all_tiles.insert(queue->Top().tile()); | 1185 all_tiles.insert(queue->Top().tile()); |
| 1065 ++tile_count; | 1186 ++tile_count; |
| 1066 queue->Pop(); | 1187 queue->Pop(); |
| 1067 } | 1188 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 EXPECT_GT(eventually_bin_order_correct_count, | 1374 EXPECT_GT(eventually_bin_order_correct_count, |
| 1254 eventually_bin_order_incorrect_count); | 1375 eventually_bin_order_incorrect_count); |
| 1255 | 1376 |
| 1256 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1377 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1257 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1378 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1258 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1379 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1259 } | 1380 } |
| 1260 | 1381 |
| 1261 TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADraw) { | 1382 TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADraw) { |
| 1262 const gfx::Size layer_bounds(1000, 1000); | 1383 const gfx::Size layer_bounds(1000, 1000); |
| 1263 host_impl()->SetViewportSize(layer_bounds); | 1384 host_impl_.SetViewportSize(layer_bounds); |
| 1264 SetupDefaultTrees(layer_bounds); | 1385 SetupDefaultTrees(layer_bounds); |
| 1265 | 1386 |
| 1266 // Verify that the queue has a required for draw tile at Top. | 1387 // Verify that the queue has a required for draw tile at Top. |
| 1267 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 1388 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1268 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1389 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1269 EXPECT_FALSE(queue->IsEmpty()); | 1390 EXPECT_FALSE(queue->IsEmpty()); |
| 1270 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1391 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1271 | 1392 |
| 1272 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1393 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1273 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1394 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1274 EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); | 1395 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); |
| 1275 } | 1396 } |
| 1276 | 1397 |
| 1277 TEST_F(TileManagerTilePriorityQueueTest, | 1398 TEST_F(TileManagerTilePriorityQueueTest, |
| 1278 SetIsLikelyToRequireADrawOnZeroMemoryBudget) { | 1399 SetIsLikelyToRequireADrawOnZeroMemoryBudget) { |
| 1279 const gfx::Size layer_bounds(1000, 1000); | 1400 const gfx::Size layer_bounds(1000, 1000); |
| 1280 host_impl()->SetViewportSize(layer_bounds); | 1401 host_impl_.SetViewportSize(layer_bounds); |
| 1281 SetupDefaultTrees(layer_bounds); | 1402 SetupDefaultTrees(layer_bounds); |
| 1282 | 1403 |
| 1283 // Verify that the queue has a required for draw tile at Top. | 1404 // Verify that the queue has a required for draw tile at Top. |
| 1284 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 1405 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1285 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1406 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1286 EXPECT_FALSE(queue->IsEmpty()); | 1407 EXPECT_FALSE(queue->IsEmpty()); |
| 1287 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1408 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1288 | 1409 |
| 1289 ManagedMemoryPolicy policy = host_impl()->ActualManagedMemoryPolicy(); | 1410 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); |
| 1290 policy.bytes_limit_when_visible = 0; | 1411 policy.bytes_limit_when_visible = 0; |
| 1291 host_impl()->SetMemoryPolicy(policy); | 1412 host_impl_.SetMemoryPolicy(policy); |
| 1292 | 1413 |
| 1293 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1414 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1294 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1415 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1295 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1416 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1296 } | 1417 } |
| 1297 | 1418 |
| 1298 TEST_F(TileManagerTilePriorityQueueTest, | 1419 TEST_F(TileManagerTilePriorityQueueTest, |
| 1299 SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { | 1420 SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { |
| 1300 const gfx::Size layer_bounds(1000, 1000); | 1421 const gfx::Size layer_bounds(1000, 1000); |
| 1301 host_impl()->SetViewportSize(layer_bounds); | 1422 host_impl_.SetViewportSize(layer_bounds); |
| 1302 SetupDefaultTrees(layer_bounds); | 1423 SetupDefaultTrees(layer_bounds); |
| 1303 | 1424 |
| 1304 // Verify that the queue has a required for draw tile at Top. | 1425 // Verify that the queue has a required for draw tile at Top. |
| 1305 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 1426 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1306 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1427 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1307 EXPECT_FALSE(queue->IsEmpty()); | 1428 EXPECT_FALSE(queue->IsEmpty()); |
| 1308 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1429 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1309 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); | 1430 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); |
| 1310 EXPECT_EQ(RGBA_8888, host_impl()->resource_provider()->best_texture_format()); | 1431 EXPECT_EQ(RGBA_8888, host_impl_.resource_provider()->best_texture_format()); |
| 1311 | 1432 |
| 1312 ManagedMemoryPolicy policy = host_impl()->ActualManagedMemoryPolicy(); | 1433 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); |
| 1313 policy.bytes_limit_when_visible = ResourceUtil::UncheckedSizeInBytes<size_t>( | 1434 policy.bytes_limit_when_visible = ResourceUtil::UncheckedSizeInBytes<size_t>( |
| 1314 gfx::Size(256, 256), RGBA_8888); | 1435 gfx::Size(256, 256), RGBA_8888); |
| 1315 host_impl()->SetMemoryPolicy(policy); | 1436 host_impl_.SetMemoryPolicy(policy); |
| 1316 | 1437 |
| 1317 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1438 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1318 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1439 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1319 EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); | 1440 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); |
| 1320 | 1441 |
| 1321 Resource* resource = host_impl()->resource_pool()->AcquireResource( | 1442 Resource* resource = host_impl_.resource_pool()->AcquireResource( |
| 1322 gfx::Size(256, 256), RGBA_8888); | 1443 gfx::Size(256, 256), RGBA_8888); |
| 1323 | 1444 |
| 1324 host_impl()->tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); | 1445 host_impl_.tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); |
| 1325 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1446 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1326 | 1447 |
| 1327 host_impl()->resource_pool()->ReleaseResource(resource, 0); | 1448 host_impl_.resource_pool()->ReleaseResource(resource, 0); |
| 1328 } | 1449 } |
| 1329 | 1450 |
| 1330 TEST_F(TileManagerTilePriorityQueueTest, DefaultMemoryPolicy) { | 1451 TEST_F(TileManagerTilePriorityQueueTest, DefaultMemoryPolicy) { |
| 1331 const gfx::Size layer_bounds(1000, 1000); | 1452 const gfx::Size layer_bounds(1000, 1000); |
| 1332 host_impl()->SetViewportSize(layer_bounds); | 1453 host_impl_.SetViewportSize(layer_bounds); |
| 1333 SetupDefaultTrees(layer_bounds); | 1454 SetupDefaultTrees(layer_bounds); |
| 1334 | 1455 |
| 1335 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1456 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1336 | 1457 |
| 1337 // 64MB is the default mem limit. | 1458 // 64MB is the default mem limit. |
| 1338 EXPECT_EQ(67108864u, | 1459 EXPECT_EQ(67108864u, |
| 1339 host_impl()->global_tile_state().hard_memory_limit_in_bytes); | 1460 host_impl_.global_tile_state().hard_memory_limit_in_bytes); |
| 1340 EXPECT_EQ(TileMemoryLimitPolicy::ALLOW_ANYTHING, | 1461 EXPECT_EQ(TileMemoryLimitPolicy::ALLOW_ANYTHING, |
| 1341 host_impl()->global_tile_state().memory_limit_policy); | 1462 host_impl_.global_tile_state().memory_limit_policy); |
| 1342 EXPECT_EQ(ManagedMemoryPolicy::kDefaultNumResourcesLimit, | 1463 EXPECT_EQ(ManagedMemoryPolicy::kDefaultNumResourcesLimit, |
| 1343 host_impl()->global_tile_state().num_resources_limit); | 1464 host_impl_.global_tile_state().num_resources_limit); |
| 1344 } | 1465 } |
| 1345 | 1466 |
| 1346 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { | 1467 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { |
| 1347 // Verify that we use the real tile bounds when advancing phases during the | 1468 // Verify that we use the real tile bounds when advancing phases during the |
| 1348 // tile iteration. | 1469 // tile iteration. |
| 1349 gfx::Size layer_bounds(1, 1); | 1470 gfx::Size layer_bounds(1, 1); |
| 1350 | 1471 |
| 1351 scoped_refptr<FakeRasterSource> raster_source = | 1472 scoped_refptr<FakeRasterSource> raster_source = |
| 1352 FakeRasterSource::CreateFilled(layer_bounds); | 1473 FakeRasterSource::CreateFilled(layer_bounds); |
| 1353 | 1474 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 non_solid_paint); | 1545 non_solid_paint); |
| 1425 recording_source->Rerecord(); | 1546 recording_source->Rerecord(); |
| 1426 | 1547 |
| 1427 scoped_refptr<RasterSource> raster_source = | 1548 scoped_refptr<RasterSource> raster_source = |
| 1428 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 1549 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
| 1429 | 1550 |
| 1430 FakePictureLayerTilingClient tiling_client; | 1551 FakePictureLayerTilingClient tiling_client; |
| 1431 tiling_client.SetTileSize(size); | 1552 tiling_client.SetTileSize(size); |
| 1432 | 1553 |
| 1433 std::unique_ptr<PictureLayerImpl> layer_impl = | 1554 std::unique_ptr<PictureLayerImpl> layer_impl = |
| 1434 PictureLayerImpl::Create(host_impl()->active_tree(), 1, false); | 1555 PictureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1435 layer_impl->set_is_drawn_render_surface_layer_list_member(true); | 1556 layer_impl->set_is_drawn_render_surface_layer_list_member(true); |
| 1436 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set(); | 1557 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set(); |
| 1437 | 1558 |
| 1438 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); | 1559 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); |
| 1439 tiling->set_resolution(HIGH_RESOLUTION); | 1560 tiling->set_resolution(HIGH_RESOLUTION); |
| 1440 tiling->CreateAllTilesForTesting(); | 1561 tiling->CreateAllTilesForTesting(); |
| 1441 tiling->SetTilePriorityRectsForTesting( | 1562 tiling->SetTilePriorityRectsForTesting( |
| 1442 gfx::Rect(layer_bounds), // Visible rect. | 1563 gfx::Rect(layer_bounds), // Visible rect. |
| 1443 gfx::Rect(layer_bounds), // Skewport rect. | 1564 gfx::Rect(layer_bounds), // Skewport rect. |
| 1444 gfx::Rect(layer_bounds), // Soon rect. | 1565 gfx::Rect(layer_bounds), // Soon rect. |
| 1445 gfx::Rect(layer_bounds)); // Eventually rect. | 1566 gfx::Rect(layer_bounds)); // Eventually rect. |
| 1446 | 1567 |
| 1447 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1568 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1448 | 1569 |
| 1449 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 1570 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 1450 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { | 1571 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { |
| 1451 Tile* tile = tiles[tile_idx]; | 1572 Tile* tile = tiles[tile_idx]; |
| 1452 if (tile->id() == 1) { | 1573 if (tile->id() == 1) { |
| 1453 // Non-solid tile. | 1574 // Non-solid tile. |
| 1454 EXPECT_TRUE(tile->HasRasterTask()); | 1575 EXPECT_TRUE(tile->HasRasterTask()); |
| 1455 EXPECT_EQ(TileDrawInfo::RESOURCE_MODE, tile->draw_info().mode()); | 1576 EXPECT_EQ(TileDrawInfo::RESOURCE_MODE, tile->draw_info().mode()); |
| 1456 } else { | 1577 } else { |
| 1457 EXPECT_FALSE(tile->HasRasterTask()); | 1578 EXPECT_FALSE(tile->HasRasterTask()); |
| 1458 EXPECT_EQ(TileDrawInfo::SOLID_COLOR_MODE, tile->draw_info().mode()); | 1579 EXPECT_EQ(TileDrawInfo::SOLID_COLOR_MODE, tile->draw_info().mode()); |
| 1459 EXPECT_EQ(solid_color, tile->draw_info().solid_color()); | 1580 EXPECT_EQ(solid_color, tile->draw_info().solid_color()); |
| 1460 } | 1581 } |
| 1461 } | 1582 } |
| 1462 } | 1583 } |
| 1463 | 1584 |
| 1464 class TileManagerTest : public TestLayerTreeHostBase { | 1585 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest. |
| 1586 class TileManagerTest : public testing::Test { |
| 1465 public: | 1587 public: |
| 1588 void SetUp() override { |
| 1589 LayerTreeSettings settings; |
| 1590 settings.verify_clip_tree_calculations = true; |
| 1591 |
| 1592 CustomizeSettings(&settings); |
| 1593 output_surface_ = GetOutputSurface(); |
| 1594 task_graph_runner_ = GetTaskGraphRunner(); |
| 1595 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_, |
| 1596 &shared_bitmap_manager_, |
| 1597 task_graph_runner_.get())); |
| 1598 host_impl_->SetVisible(true); |
| 1599 host_impl_->InitializeRenderer(output_surface_.get()); |
| 1600 } |
| 1601 |
| 1602 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 1603 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1604 FakeRasterSource::CreateFilled(layer_bounds); |
| 1605 scoped_refptr<FakeRasterSource> active_raster_source = |
| 1606 FakeRasterSource::CreateFilled(layer_bounds); |
| 1607 |
| 1608 SetupTrees(pending_raster_source, active_raster_source); |
| 1609 } |
| 1610 |
| 1611 // This matches picture_layer_impl_unittest's ActivateTree. |
| 1612 void ActivateTree() { |
| 1613 host_impl_->ActivateSyncTree(); |
| 1614 CHECK(!host_impl_->pending_tree()); |
| 1615 bool update_lcd_text = false; |
| 1616 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 1617 } |
| 1618 |
| 1619 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, |
| 1620 scoped_refptr<RasterSource> active_raster_source) { |
| 1621 SetupPendingTree(active_raster_source); |
| 1622 ActivateTree(); |
| 1623 SetupPendingTree(pending_raster_source); |
| 1624 } |
| 1625 |
| 1626 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 1627 host_impl_->CreatePendingTree(); |
| 1628 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 1629 |
| 1630 // Steal from the recycled tree. |
| 1631 LayerImpl* old_pending_root = pending_tree->root_layer(); |
| 1632 FakePictureLayerImpl* pending_layer = nullptr; |
| 1633 if (old_pending_root) { |
| 1634 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); |
| 1635 pending_layer->SetRasterSourceOnPending(raster_source, Region()); |
| 1636 } else { |
| 1637 int id = 7; |
| 1638 std::unique_ptr<FakePictureLayerImpl> new_root = |
| 1639 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id, |
| 1640 raster_source); |
| 1641 pending_layer = new_root.get(); |
| 1642 pending_layer->SetDrawsContent(true); |
| 1643 pending_layer->SetHasRenderSurface(true); |
| 1644 pending_tree->SetRootLayer(std::move(new_root)); |
| 1645 } |
| 1646 |
| 1647 // The bounds() just mirror the raster source size. |
| 1648 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 1649 |
| 1650 // Add tilings/tiles for the layer. |
| 1651 bool update_lcd_text = false; |
| 1652 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 1653 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1654 } |
| 1655 |
| 1656 protected: |
| 1466 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. | 1657 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. |
| 1467 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { | 1658 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { |
| 1468 public: | 1659 public: |
| 1469 MockLayerTreeHostImpl( | 1660 MockLayerTreeHostImpl(const LayerTreeSettings& settings, |
| 1470 const LayerTreeSettings& settings, | 1661 TaskRunnerProvider* task_runner_provider, |
| 1471 TaskRunnerProvider* task_runner_provider, | 1662 SharedBitmapManager* manager, |
| 1472 SharedBitmapManager* manager, | 1663 TaskGraphRunner* task_graph_runner) |
| 1473 TaskGraphRunner* task_graph_runner, | |
| 1474 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) | |
| 1475 : FakeLayerTreeHostImpl(settings, | 1664 : FakeLayerTreeHostImpl(settings, |
| 1476 task_runner_provider, | 1665 task_runner_provider, |
| 1477 manager, | 1666 manager, |
| 1478 task_graph_runner, | 1667 task_graph_runner) {} |
| 1479 gpu_memory_buffer_manager) {} | |
| 1480 | 1668 |
| 1481 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); | 1669 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
| 1482 MOCK_METHOD0(NotifyReadyToDraw, void()); | 1670 MOCK_METHOD0(NotifyReadyToDraw, void()); |
| 1483 }; | 1671 }; |
| 1484 | 1672 |
| 1485 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( | 1673 // By default do no customization. |
| 1486 const LayerTreeSettings& settings, | 1674 virtual void CustomizeSettings(LayerTreeSettings* settings) {} |
| 1487 TaskRunnerProvider* task_runner_provider, | 1675 |
| 1488 SharedBitmapManager* shared_bitmap_manager, | 1676 // By default use TestTaskGraphRunner. |
| 1489 TaskGraphRunner* task_graph_runner, | 1677 virtual std::unique_ptr<TaskGraphRunner> GetTaskGraphRunner() const { |
| 1490 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) override { | 1678 return base::WrapUnique(new TestTaskGraphRunner()); |
| 1491 return base::WrapUnique(new MockLayerTreeHostImpl( | |
| 1492 settings, task_runner_provider, shared_bitmap_manager, | |
| 1493 task_graph_runner, gpu_memory_buffer_manager)); | |
| 1494 } | 1679 } |
| 1495 | 1680 |
| 1496 // By default use SoftwareOutputSurface. | 1681 // By default use SoftwareOutputSurface. |
| 1497 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 1682 virtual std::unique_ptr<OutputSurface> GetOutputSurface() const { |
| 1498 return FakeOutputSurface::CreateSoftware( | 1683 return FakeOutputSurface::CreateSoftware( |
| 1499 base::WrapUnique(new SoftwareOutputDevice)); | 1684 base::WrapUnique(new SoftwareOutputDevice)); |
| 1500 } | 1685 } |
| 1501 | 1686 |
| 1502 MockLayerTreeHostImpl& MockHostImpl() { | 1687 TestSharedBitmapManager shared_bitmap_manager_; |
| 1503 return *static_cast<MockLayerTreeHostImpl*>(host_impl()); | 1688 std::unique_ptr<TaskGraphRunner> task_graph_runner_; |
| 1504 } | 1689 FakeImplTaskRunnerProvider task_runner_provider_; |
| 1690 std::unique_ptr<OutputSurface> output_surface_; |
| 1691 std::unique_ptr<MockLayerTreeHostImpl> host_impl_; |
| 1505 }; | 1692 }; |
| 1506 | 1693 |
| 1507 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is | 1694 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is |
| 1508 // called. | 1695 // called. |
| 1509 TEST_F(TileManagerTest, AllWorkFinishedTest) { | 1696 TEST_F(TileManagerTest, AllWorkFinishedTest) { |
| 1510 // Check with no tile work enqueued. | 1697 // Check with no tile work enqueued. |
| 1511 { | 1698 { |
| 1512 base::RunLoop run_loop; | 1699 base::RunLoop run_loop; |
| 1513 EXPECT_FALSE( | 1700 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1514 host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1701 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
| 1515 EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) | |
| 1516 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1702 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1517 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1703 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); |
| 1518 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1704 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1519 run_loop.Run(); | 1705 run_loop.Run(); |
| 1520 } | 1706 } |
| 1521 | 1707 |
| 1522 // Check that the "schedule more work" path also triggers the expected | 1708 // Check that the "schedule more work" path also triggers the expected |
| 1523 // callback. | 1709 // callback. |
| 1524 { | 1710 { |
| 1525 base::RunLoop run_loop; | 1711 base::RunLoop run_loop; |
| 1526 EXPECT_FALSE( | 1712 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1527 host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1713 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
| 1528 EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) | |
| 1529 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1714 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1530 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1715 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); |
| 1531 host_impl()->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); | 1716 host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); |
| 1532 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1717 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1533 run_loop.Run(); | 1718 run_loop.Run(); |
| 1534 } | 1719 } |
| 1535 } | 1720 } |
| 1536 | 1721 |
| 1537 TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) { | 1722 TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) { |
| 1538 SetupDefaultTrees(gfx::Size(1000, 1000)); | 1723 SetupDefaultTrees(gfx::Size(1000, 1000)); |
| 1539 | 1724 |
| 1540 auto global_state = host_impl()->global_tile_state(); | 1725 auto global_state = host_impl_->global_tile_state(); |
| 1541 global_state.hard_memory_limit_in_bytes = 1u; | 1726 global_state.hard_memory_limit_in_bytes = 1u; |
| 1542 global_state.soft_memory_limit_in_bytes = 1u; | 1727 global_state.soft_memory_limit_in_bytes = 1u; |
| 1543 | 1728 |
| 1544 { | 1729 { |
| 1545 base::RunLoop run_loop; | 1730 base::RunLoop run_loop; |
| 1546 EXPECT_FALSE( | 1731 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1547 host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1732 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
| 1548 EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) | |
| 1549 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1733 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1550 host_impl()->tile_manager()->PrepareTiles(global_state); | 1734 host_impl_->tile_manager()->PrepareTiles(global_state); |
| 1551 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 1735 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
| 1552 run_loop.Run(); | 1736 run_loop.Run(); |
| 1553 } | 1737 } |
| 1554 | 1738 |
| 1555 EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToDraw()); | 1739 EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToDraw()); |
| 1556 EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); | 1740 EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToActivate()); |
| 1557 EXPECT_TRUE(host_impl()->notify_tile_state_changed_called()); | 1741 EXPECT_TRUE(host_impl_->notify_tile_state_changed_called()); |
| 1558 | 1742 |
| 1559 // Next PrepareTiles should skip NotifyTileStateChanged since all tiles | 1743 // Next PrepareTiles should skip NotifyTileStateChanged since all tiles |
| 1560 // are marked oom already. | 1744 // are marked oom already. |
| 1561 { | 1745 { |
| 1562 base::RunLoop run_loop; | 1746 base::RunLoop run_loop; |
| 1563 host_impl()->set_notify_tile_state_changed_called(false); | 1747 host_impl_->set_notify_tile_state_changed_called(false); |
| 1564 EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) | 1748 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
| 1565 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1749 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1566 host_impl()->tile_manager()->PrepareTiles(global_state); | 1750 host_impl_->tile_manager()->PrepareTiles(global_state); |
| 1567 run_loop.Run(); | 1751 run_loop.Run(); |
| 1568 EXPECT_FALSE(host_impl()->notify_tile_state_changed_called()); | 1752 EXPECT_FALSE(host_impl_->notify_tile_state_changed_called()); |
| 1569 } | 1753 } |
| 1570 } | 1754 } |
| 1571 | 1755 |
| 1572 TEST_F(TileManagerTest, LowResHasNoImage) { | 1756 TEST_F(TileManagerTest, LowResHasNoImage) { |
| 1573 gfx::Size size(10, 12); | 1757 gfx::Size size(10, 12); |
| 1574 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION}; | 1758 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION}; |
| 1575 | 1759 |
| 1576 for (size_t i = 0; i < arraysize(resolutions); ++i) { | 1760 for (size_t i = 0; i < arraysize(resolutions); ++i) { |
| 1577 SCOPED_TRACE(resolutions[i]); | 1761 SCOPED_TRACE(resolutions[i]); |
| 1578 | 1762 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1593 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); | 1777 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); |
| 1594 recording_source->add_draw_image(std::move(blue_image), gfx::Point()); | 1778 recording_source->add_draw_image(std::move(blue_image), gfx::Point()); |
| 1595 recording_source->Rerecord(); | 1779 recording_source->Rerecord(); |
| 1596 scoped_refptr<RasterSource> raster = | 1780 scoped_refptr<RasterSource> raster = |
| 1597 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 1781 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
| 1598 | 1782 |
| 1599 FakePictureLayerTilingClient tiling_client; | 1783 FakePictureLayerTilingClient tiling_client; |
| 1600 tiling_client.SetTileSize(size); | 1784 tiling_client.SetTileSize(size); |
| 1601 | 1785 |
| 1602 std::unique_ptr<PictureLayerImpl> layer = | 1786 std::unique_ptr<PictureLayerImpl> layer = |
| 1603 PictureLayerImpl::Create(host_impl()->active_tree(), 1, false); | 1787 PictureLayerImpl::Create(host_impl_->active_tree(), 1, false); |
| 1604 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); | 1788 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); |
| 1605 layer->set_is_drawn_render_surface_layer_list_member(true); | 1789 layer->set_is_drawn_render_surface_layer_list_member(true); |
| 1606 | 1790 |
| 1607 auto* tiling = tiling_set->AddTiling(1.0f, raster); | 1791 auto* tiling = tiling_set->AddTiling(1.0f, raster); |
| 1608 tiling->set_resolution(resolutions[i]); | 1792 tiling->set_resolution(resolutions[i]); |
| 1609 tiling->CreateAllTilesForTesting(); | 1793 tiling->CreateAllTilesForTesting(); |
| 1610 tiling->SetTilePriorityRectsForTesting( | 1794 tiling->SetTilePriorityRectsForTesting( |
| 1611 gfx::Rect(size), // Visible rect. | 1795 gfx::Rect(size), // Visible rect. |
| 1612 gfx::Rect(size), // Skewport rect. | 1796 gfx::Rect(size), // Skewport rect. |
| 1613 gfx::Rect(size), // Soon rect. | 1797 gfx::Rect(size), // Soon rect. |
| 1614 gfx::Rect(size)); // Eventually rect. | 1798 gfx::Rect(size)); // Eventually rect. |
| 1615 | 1799 |
| 1616 // SMOOTHNESS_TAKES_PRIORITY ensures that we will actually raster | 1800 // SMOOTHNESS_TAKES_PRIORITY ensures that we will actually raster |
| 1617 // LOW_RESOLUTION tiles, otherwise they are skipped. | 1801 // LOW_RESOLUTION tiles, otherwise they are skipped. |
| 1618 host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); | 1802 host_impl_->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); |
| 1619 | 1803 |
| 1620 // Call PrepareTiles and wait for it to complete. | 1804 // Call PrepareTiles and wait for it to complete. |
| 1621 auto* tile_manager = host_impl()->tile_manager(); | 1805 auto* tile_manager = host_impl_->tile_manager(); |
| 1622 base::RunLoop run_loop; | 1806 base::RunLoop run_loop; |
| 1623 EXPECT_CALL(MockHostImpl(), NotifyAllTileTasksCompleted()) | 1807 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
| 1624 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1808 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1625 tile_manager->PrepareTiles(host_impl()->global_tile_state()); | 1809 tile_manager->PrepareTiles(host_impl_->global_tile_state()); |
| 1626 run_loop.Run(); | 1810 run_loop.Run(); |
| 1627 tile_manager->Flush(); | 1811 tile_manager->Flush(); |
| 1628 | 1812 |
| 1629 Tile* tile = tiling->TileAt(0, 0); | 1813 Tile* tile = tiling->TileAt(0, 0); |
| 1630 // The tile in the tiling was rastered. | 1814 // The tile in the tiling was rastered. |
| 1631 EXPECT_EQ(TileDrawInfo::RESOURCE_MODE, tile->draw_info().mode()); | 1815 EXPECT_EQ(TileDrawInfo::RESOURCE_MODE, tile->draw_info().mode()); |
| 1632 EXPECT_TRUE(tile->draw_info().IsReadyToDraw()); | 1816 EXPECT_TRUE(tile->draw_info().IsReadyToDraw()); |
| 1633 | 1817 |
| 1634 ResourceProvider::ScopedReadLockSoftware lock( | 1818 ResourceProvider::ScopedReadLockSoftware lock( |
| 1635 host_impl()->resource_provider(), tile->draw_info().resource_id()); | 1819 host_impl_->resource_provider(), tile->draw_info().resource_id()); |
| 1636 const SkBitmap* bitmap = lock.sk_bitmap(); | 1820 const SkBitmap* bitmap = lock.sk_bitmap(); |
| 1637 for (int x = 0; x < size.width(); ++x) { | 1821 for (int x = 0; x < size.width(); ++x) { |
| 1638 for (int y = 0; y < size.height(); ++y) { | 1822 for (int y = 0; y < size.height(); ++y) { |
| 1639 SCOPED_TRACE(y); | 1823 SCOPED_TRACE(y); |
| 1640 SCOPED_TRACE(x); | 1824 SCOPED_TRACE(x); |
| 1641 if (resolutions[i] == LOW_RESOLUTION) { | 1825 if (resolutions[i] == LOW_RESOLUTION) { |
| 1642 // Since it's low res, the bitmap was not drawn, and the background | 1826 // Since it's low res, the bitmap was not drawn, and the background |
| 1643 // (green) is visible instead. | 1827 // (green) is visible instead. |
| 1644 ASSERT_EQ(SK_ColorGREEN, bitmap->getColor(x, y)); | 1828 ASSERT_EQ(SK_ColorGREEN, bitmap->getColor(x, y)); |
| 1645 } else { | 1829 } else { |
| 1646 EXPECT_EQ(HIGH_RESOLUTION, resolutions[i]); | 1830 EXPECT_EQ(HIGH_RESOLUTION, resolutions[i]); |
| 1647 // Since it's high res, the bitmap (blue) was drawn, and the | 1831 // Since it's high res, the bitmap (blue) was drawn, and the |
| 1648 // background is not visible. | 1832 // background is not visible. |
| 1649 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); | 1833 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); |
| 1650 } | 1834 } |
| 1651 } | 1835 } |
| 1652 } | 1836 } |
| 1653 } | 1837 } |
| 1654 } | 1838 } |
| 1655 | 1839 |
| 1656 class ActivationTasksDoNotBlockReadyToDrawTest : public TileManagerTest { | 1840 class ActivationTasksDoNotBlockReadyToDrawTest : public TileManagerTest { |
| 1657 protected: | 1841 protected: |
| 1658 std::unique_ptr<TaskGraphRunner> CreateTaskGraphRunner() override { | 1842 std::unique_ptr<TaskGraphRunner> GetTaskGraphRunner() const override { |
| 1659 return base::WrapUnique(new SynchronousTaskGraphRunner()); | 1843 return base::WrapUnique(new SynchronousTaskGraphRunner()); |
| 1660 } | 1844 } |
| 1661 | 1845 |
| 1662 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 1846 std::unique_ptr<OutputSurface> GetOutputSurface() const override { |
| 1663 return FakeOutputSurface::Create3d(); | 1847 return FakeOutputSurface::Create3d(); |
| 1664 } | 1848 } |
| 1665 | 1849 |
| 1666 LayerTreeSettings CreateSettings() override { | 1850 void CustomizeSettings(LayerTreeSettings* settings) override { |
| 1667 LayerTreeSettings settings = TileManagerTest::CreateSettings(); | 1851 settings->gpu_rasterization_forced = true; |
| 1668 settings.gpu_rasterization_forced = true; | 1852 } |
| 1669 return settings; | 1853 |
| 1854 SynchronousTaskGraphRunner* GetSynchronousTaskGraphRunner() const { |
| 1855 return static_cast<SynchronousTaskGraphRunner*>(task_graph_runner_.get()); |
| 1670 } | 1856 } |
| 1671 }; | 1857 }; |
| 1672 | 1858 |
| 1673 TEST_F(ActivationTasksDoNotBlockReadyToDrawTest, | 1859 TEST_F(ActivationTasksDoNotBlockReadyToDrawTest, |
| 1674 ActivationTasksDoNotBlockReadyToDraw) { | 1860 ActivationTasksDoNotBlockReadyToDraw) { |
| 1675 const gfx::Size layer_bounds(1000, 1000); | 1861 const gfx::Size layer_bounds(1000, 1000); |
| 1676 | 1862 |
| 1677 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); | 1863 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 1678 | 1864 |
| 1679 // Active tree has no non-solid tiles, so it will generate no tile tasks. | 1865 // Active tree has no non-solid tiles, so it will generate no tile tasks. |
| 1680 std::unique_ptr<FakeRecordingSource> active_tree_recording_source = | 1866 std::unique_ptr<FakeRecordingSource> active_tree_recording_source = |
| 1681 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 1867 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 1682 | 1868 |
| 1683 SkPaint solid_paint; | 1869 SkPaint solid_paint; |
| 1684 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 1870 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 1685 solid_paint.setColor(solid_color); | 1871 solid_paint.setColor(solid_color); |
| 1686 active_tree_recording_source->add_draw_rect_with_paint( | 1872 active_tree_recording_source->add_draw_rect_with_paint( |
| 1687 gfx::Rect(layer_bounds), solid_paint); | 1873 gfx::Rect(layer_bounds), solid_paint); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1700 pending_tree_recording_source->Rerecord(); | 1886 pending_tree_recording_source->Rerecord(); |
| 1701 | 1887 |
| 1702 scoped_refptr<RasterSource> active_tree_raster_source = | 1888 scoped_refptr<RasterSource> active_tree_raster_source = |
| 1703 RasterSource::CreateFromRecordingSource( | 1889 RasterSource::CreateFromRecordingSource( |
| 1704 active_tree_recording_source.get(), false); | 1890 active_tree_recording_source.get(), false); |
| 1705 scoped_refptr<RasterSource> pending_tree_raster_source = | 1891 scoped_refptr<RasterSource> pending_tree_raster_source = |
| 1706 RasterSource::CreateFromRecordingSource( | 1892 RasterSource::CreateFromRecordingSource( |
| 1707 pending_tree_recording_source.get(), false); | 1893 pending_tree_recording_source.get(), false); |
| 1708 | 1894 |
| 1709 SetupTrees(pending_tree_raster_source, active_tree_raster_source); | 1895 SetupTrees(pending_tree_raster_source, active_tree_raster_source); |
| 1710 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1896 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); |
| 1711 | 1897 |
| 1712 // The first task to run should be ReadyToDraw (this should not be blocked by | 1898 // The first task to run should be ReadyToDraw (this should not be blocked by |
| 1713 // the tasks required for activation). | 1899 // the tasks required for activation). |
| 1714 base::RunLoop run_loop; | 1900 base::RunLoop run_loop; |
| 1715 EXPECT_CALL(MockHostImpl(), NotifyReadyToDraw()) | 1901 EXPECT_CALL(*host_impl_, NotifyReadyToDraw()) |
| 1716 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1902 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1717 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner()) | 1903 GetSynchronousTaskGraphRunner()->RunSingleTaskForTesting(); |
| 1718 ->RunSingleTaskForTesting(); | |
| 1719 run_loop.Run(); | 1904 run_loop.Run(); |
| 1720 } | 1905 } |
| 1721 | 1906 |
| 1722 // Fake TileTaskManager that just cancels all scheduled tasks immediately. | 1907 // Fake TileTaskManager that just cancels all scheduled tasks immediately. |
| 1723 class CancellingTileTaskManager : public FakeTileTaskManagerImpl { | 1908 class CancellingTileTaskManager : public FakeTileTaskManagerImpl { |
| 1724 public: | 1909 public: |
| 1725 CancellingTileTaskManager() {} | 1910 CancellingTileTaskManager() {} |
| 1726 ~CancellingTileTaskManager() override {} | 1911 ~CancellingTileTaskManager() override {} |
| 1727 | 1912 |
| 1728 void ScheduleTasks(TaskGraph* graph) override { | 1913 void ScheduleTasks(TaskGraph* graph) override { |
| 1729 // Just call CompleteOnOriginThread on each item in the queue. As none of | 1914 // Just call CompleteOnOriginThread on each item in the queue. As none of |
| 1730 // these items have run yet, they will be treated as cancelled tasks. | 1915 // these items have run yet, they will be treated as cancelled tasks. |
| 1731 for (const auto& node : graph->nodes) { | 1916 for (const auto& node : graph->nodes) { |
| 1732 static_cast<TileTask*>(node.task)->CompleteOnOriginThread( | 1917 static_cast<TileTask*>(node.task)->CompleteOnOriginThread( |
| 1733 raster_buffer_provider_.get()); | 1918 raster_buffer_provider_.get()); |
| 1734 } | 1919 } |
| 1735 } | 1920 } |
| 1736 void CheckForCompletedTasks() override {} | 1921 void CheckForCompletedTasks() override {} |
| 1737 }; | 1922 }; |
| 1738 | 1923 |
| 1739 class PartialRasterTileManagerTest : public TileManagerTest { | 1924 class PartialRasterTileManagerTest : public TileManagerTest { |
| 1740 public: | 1925 public: |
| 1741 LayerTreeSettings CreateSettings() override { | 1926 void CustomizeSettings(LayerTreeSettings* settings) override { |
| 1742 LayerTreeSettings settings = TileManagerTest::CreateSettings(); | 1927 settings->use_partial_raster = true; |
| 1743 settings.use_partial_raster = true; | |
| 1744 return settings; | |
| 1745 } | 1928 } |
| 1746 }; | 1929 }; |
| 1747 | 1930 |
| 1748 // Ensures that if a raster task is cancelled, it gets returned to the resource | 1931 // Ensures that if a raster task is cancelled, it gets returned to the resource |
| 1749 // pool with an invalid content ID, not with its invalidated content ID. | 1932 // pool with an invalid content ID, not with its invalidated content ID. |
| 1750 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) { | 1933 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) { |
| 1751 // Create a CancellingTaskRunner and set it on the tile manager so that all | 1934 // Create a CancellingTaskRunner and set it on the tile manager so that all |
| 1752 // scheduled work is immediately cancelled. | 1935 // scheduled work is immediately cancelled. |
| 1753 CancellingTileTaskManager cancelling_task_manager; | 1936 CancellingTileTaskManager cancelling_task_manager; |
| 1754 host_impl()->tile_manager()->SetTileTaskManagerForTesting( | 1937 host_impl_->tile_manager()->SetTileTaskManagerForTesting( |
| 1755 &cancelling_task_manager); | 1938 &cancelling_task_manager); |
| 1756 | 1939 |
| 1757 // Pick arbitrary IDs - they don't really matter as long as they're constant. | 1940 // Pick arbitrary IDs - they don't really matter as long as they're constant. |
| 1758 const int kLayerId = 7; | 1941 const int kLayerId = 7; |
| 1759 const uint64_t kInvalidatedId = 43; | 1942 const uint64_t kInvalidatedId = 43; |
| 1760 const gfx::Size kTileSize(128, 128); | 1943 const gfx::Size kTileSize(128, 128); |
| 1761 | 1944 |
| 1762 scoped_refptr<FakeRasterSource> pending_raster_source = | 1945 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1763 FakeRasterSource::CreateFilled(kTileSize); | 1946 FakeRasterSource::CreateFilled(kTileSize); |
| 1764 host_impl()->CreatePendingTree(); | 1947 host_impl_->CreatePendingTree(); |
| 1765 LayerTreeImpl* pending_tree = host_impl()->pending_tree(); | 1948 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 1766 | 1949 |
| 1767 // Steal from the recycled tree. | 1950 // Steal from the recycled tree. |
| 1768 std::unique_ptr<FakePictureLayerImpl> pending_layer = | 1951 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 1769 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, | 1952 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, |
| 1770 pending_raster_source); | 1953 pending_raster_source); |
| 1771 pending_layer->SetDrawsContent(true); | 1954 pending_layer->SetDrawsContent(true); |
| 1772 pending_layer->SetHasRenderSurface(true); | 1955 pending_layer->SetHasRenderSurface(true); |
| 1773 | 1956 |
| 1774 // The bounds() just mirror the raster source size. | 1957 // The bounds() just mirror the raster source size. |
| 1775 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 1958 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 1776 pending_tree->SetRootLayer(std::move(pending_layer)); | 1959 pending_tree->SetRootLayer(std::move(pending_layer)); |
| 1777 | 1960 |
| 1778 // Add tilings/tiles for the layer. | 1961 // Add tilings/tiles for the layer. |
| 1779 host_impl()->pending_tree()->BuildPropertyTreesForTesting(); | 1962 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 1780 host_impl()->pending_tree()->UpdateDrawProperties( | 1963 host_impl_->pending_tree()->UpdateDrawProperties(false /* update_lcd_text */); |
| 1781 false /* update_lcd_text */); | |
| 1782 | 1964 |
| 1783 // Build the raster queue and invalidate the top tile. | 1965 // Build the raster queue and invalidate the top tile. |
| 1784 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl()->BuildRasterQueue( | 1966 std::unique_ptr<RasterTilePriorityQueue> queue(host_impl_->BuildRasterQueue( |
| 1785 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1967 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1786 EXPECT_FALSE(queue->IsEmpty()); | 1968 EXPECT_FALSE(queue->IsEmpty()); |
| 1787 queue->Top().tile()->SetInvalidated(gfx::Rect(), kInvalidatedId); | 1969 queue->Top().tile()->SetInvalidated(gfx::Rect(), kInvalidatedId); |
| 1788 | 1970 |
| 1789 // PrepareTiles to schedule tasks. Due to the CancellingTileTaskManager, | 1971 // PrepareTiles to schedule tasks. Due to the CancellingTileTaskManager, |
| 1790 // these tasks will immediately be canceled. | 1972 // these tasks will immediately be canceled. |
| 1791 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1973 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); |
| 1792 | 1974 |
| 1793 // Make sure that the tile we invalidated above was not returned to the pool | 1975 // Make sure that the tile we invalidated above was not returned to the pool |
| 1794 // with its invalidated resource ID. | 1976 // with its invalidated resource ID. |
| 1795 host_impl()->resource_pool()->CheckBusyResources(); | 1977 host_impl_->resource_pool()->CheckBusyResources(); |
| 1796 EXPECT_FALSE(host_impl()->resource_pool()->TryAcquireResourceWithContentId( | 1978 EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( |
| 1797 kInvalidatedId)); | 1979 kInvalidatedId)); |
| 1798 | 1980 |
| 1799 // Free our host_impl_ before the cancelling_task_manager we passed it, as it | 1981 // Free our host_impl_ before the cancelling_task_manager we passed it, as it |
| 1800 // will use that class in clean up. | 1982 // will use that class in clean up. |
| 1801 TakeHostImpl(); | 1983 host_impl_ = nullptr; |
| 1802 } | 1984 } |
| 1803 | 1985 |
| 1804 // FakeRasterBufferProviderImpl that verifies the resource content ID of raster | 1986 // FakeRasterBufferProviderImpl that verifies the resource content ID of raster |
| 1805 // tasks. | 1987 // tasks. |
| 1806 class VerifyResourceContentIdRasterBufferProvider | 1988 class VerifyResourceContentIdRasterBufferProvider |
| 1807 : public FakeRasterBufferProviderImpl { | 1989 : public FakeRasterBufferProviderImpl { |
| 1808 public: | 1990 public: |
| 1809 explicit VerifyResourceContentIdRasterBufferProvider( | 1991 explicit VerifyResourceContentIdRasterBufferProvider( |
| 1810 uint64_t expected_resource_id) | 1992 uint64_t expected_resource_id) |
| 1811 : expected_resource_id_(expected_resource_id) {} | 1993 : expected_resource_id_(expected_resource_id) {} |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 host_impl->tile_manager()->PrepareTiles(host_impl->global_tile_state()); | 2081 host_impl->tile_manager()->PrepareTiles(host_impl->global_tile_state()); |
| 1900 | 2082 |
| 1901 // Free our host_impl before the verifying_task_manager we passed it, as it | 2083 // Free our host_impl before the verifying_task_manager we passed it, as it |
| 1902 // will use that class in clean up. | 2084 // will use that class in clean up. |
| 1903 host_impl = nullptr; | 2085 host_impl = nullptr; |
| 1904 } | 2086 } |
| 1905 | 2087 |
| 1906 // Ensures that the tile manager successfully reuses tiles when partial | 2088 // Ensures that the tile manager successfully reuses tiles when partial |
| 1907 // raster is enabled. | 2089 // raster is enabled. |
| 1908 TEST_F(PartialRasterTileManagerTest, PartialRasterSuccessfullyEnabled) { | 2090 TEST_F(PartialRasterTileManagerTest, PartialRasterSuccessfullyEnabled) { |
| 1909 RunPartialRasterCheck(TakeHostImpl(), true /* partial_raster_enabled */); | 2091 RunPartialRasterCheck(std::move(host_impl_), |
| 2092 true /* partial_raster_enabled */); |
| 1910 } | 2093 } |
| 1911 | 2094 |
| 1912 // Ensures that the tile manager does not attempt to reuse tiles when partial | 2095 // Ensures that the tile manager does not attempt to reuse tiles when partial |
| 1913 // raster is disabled. | 2096 // raster is disabled. |
| 1914 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 2097 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| 1915 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); | 2098 RunPartialRasterCheck(std::move(host_impl_), |
| 2099 false /* partial_raster_enabled */); |
| 1916 } | 2100 } |
| 1917 | 2101 |
| 1918 } // namespace | 2102 } // namespace |
| 1919 } // namespace cc | 2103 } // namespace cc |
| OLD | NEW |