Chromium Code Reviews| 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 "cc/resources/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
| 6 #include "cc/resources/raster_tile_priority_queue.h" | 6 #include "cc/resources/raster_tile_priority_queue.h" |
| 7 #include "cc/resources/tile.h" | 7 #include "cc/resources/tile.h" |
| 8 #include "cc/resources/tile_priority.h" | 8 #include "cc/resources/tile_priority.h" |
| 9 #include "cc/resources/tiling_set_raster_queue_all.h" | |
| 9 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/fake_output_surface_client.h" | 14 #include "cc/test/fake_output_surface_client.h" |
| 14 #include "cc/test/fake_picture_layer_impl.h" | 15 #include "cc/test/fake_picture_layer_impl.h" |
| 15 #include "cc/test/fake_picture_layer_tiling_client.h" | 16 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 16 #include "cc/test/fake_picture_pile_impl.h" | 17 #include "cc/test/fake_picture_pile_impl.h" |
| 17 #include "cc/test/fake_tile_manager.h" | 18 #include "cc/test/fake_tile_manager.h" |
| 18 #include "cc/test/impl_side_painting_settings.h" | 19 #include "cc/test/impl_side_painting_settings.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 FakePictureLayerImpl* pending_layer_; | 145 FakePictureLayerImpl* pending_layer_; |
| 145 FakePictureLayerImpl* active_layer_; | 146 FakePictureLayerImpl* active_layer_; |
| 146 }; | 147 }; |
| 147 | 148 |
| 148 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 149 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| 149 const gfx::Size layer_bounds(1000, 1000); | 150 const gfx::Size layer_bounds(1000, 1000); |
| 150 host_impl_.SetViewportSize(layer_bounds); | 151 host_impl_.SetViewportSize(layer_bounds); |
| 151 SetupDefaultTrees(layer_bounds); | 152 SetupDefaultTrees(layer_bounds); |
| 152 | 153 |
| 153 RasterTilePriorityQueue queue; | 154 RasterTilePriorityQueue queue; |
| 154 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 155 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 156 RasterTilePriorityQueue::Type::ALL); | |
| 155 EXPECT_FALSE(queue.IsEmpty()); | 157 EXPECT_FALSE(queue.IsEmpty()); |
| 156 | 158 |
| 157 size_t tile_count = 0; | 159 size_t tile_count = 0; |
| 158 std::set<Tile*> all_tiles; | 160 std::set<Tile*> all_tiles; |
| 159 while (!queue.IsEmpty()) { | 161 while (!queue.IsEmpty()) { |
| 160 EXPECT_TRUE(queue.Top()); | 162 EXPECT_TRUE(queue.Top()); |
| 161 all_tiles.insert(queue.Top()); | 163 all_tiles.insert(queue.Top()); |
| 162 ++tile_count; | 164 ++tile_count; |
| 163 queue.Pop(); | 165 queue.Pop(); |
| 164 } | 166 } |
| 165 | 167 |
| 166 EXPECT_EQ(tile_count, all_tiles.size()); | 168 EXPECT_EQ(tile_count, all_tiles.size()); |
| 167 EXPECT_EQ(16u, tile_count); | 169 EXPECT_EQ(16u, tile_count); |
| 168 | 170 |
| 169 // Sanity check, all tiles should be visible. | 171 // Sanity check, all tiles should be visible. |
| 170 std::set<Tile*> smoothness_tiles; | 172 std::set<Tile*> smoothness_tiles; |
| 171 queue.Reset(); | 173 queue.Reset(); |
| 172 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); | 174 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| 175 RasterTilePriorityQueue::Type::ALL); | |
| 173 bool had_low_res = false; | 176 bool had_low_res = false; |
| 174 while (!queue.IsEmpty()) { | 177 while (!queue.IsEmpty()) { |
| 175 Tile* tile = queue.Top(); | 178 Tile* tile = queue.Top(); |
| 176 EXPECT_TRUE(tile); | 179 EXPECT_TRUE(tile); |
| 177 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 180 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
| 178 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin); | 181 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin); |
| 179 if (tile->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) | 182 if (tile->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) |
| 180 had_low_res = true; | 183 had_low_res = true; |
| 181 else | 184 else |
| 182 smoothness_tiles.insert(tile); | 185 smoothness_tiles.insert(tile); |
| 183 queue.Pop(); | 186 queue.Pop(); |
| 184 } | 187 } |
| 185 EXPECT_EQ(all_tiles, smoothness_tiles); | 188 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 186 EXPECT_TRUE(had_low_res); | 189 EXPECT_TRUE(had_low_res); |
| 187 | 190 |
| 191 // Check that everything is required for activation. | |
| 192 queue.Reset(); | |
| 193 host_impl_.BuildRasterQueue( | |
| 194 &queue, SMOOTHNESS_TAKES_PRIORITY, | |
| 195 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | |
| 196 std::set<Tile*> required_for_activation_tiles; | |
| 197 while (!queue.IsEmpty()) { | |
| 198 Tile* tile = queue.Top(); | |
| 199 EXPECT_TRUE(tile->required_for_activation()); | |
| 200 required_for_activation_tiles.insert(tile); | |
| 201 queue.Pop(); | |
| 202 } | |
| 203 EXPECT_EQ(all_tiles, required_for_activation_tiles); | |
|
danakj
2015/01/08 23:24:41
this test is just checking that all tiles are requ
vmpstr
2015/01/09 20:21:40
Well it's testing that these tiles are all shared
| |
| 204 | |
| 205 // Check that everything is required for draw. | |
| 206 queue.Reset(); | |
| 207 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, | |
| 208 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | |
| 209 std::set<Tile*> required_for_draw_tiles; | |
| 210 while (!queue.IsEmpty()) { | |
| 211 Tile* tile = queue.Top(); | |
| 212 EXPECT_TRUE(tile->required_for_draw()); | |
| 213 required_for_draw_tiles.insert(tile); | |
| 214 queue.Pop(); | |
| 215 } | |
| 216 EXPECT_EQ(all_tiles, required_for_draw_tiles); | |
|
danakj
2015/01/08 23:24:40
ditto?
vmpstr
2015/01/09 20:21:40
Ditto!
| |
| 217 | |
| 188 Region invalidation(gfx::Rect(0, 0, 500, 500)); | 218 Region invalidation(gfx::Rect(0, 0, 500, 500)); |
| 189 | 219 |
| 190 // Invalidate the pending tree. | 220 // Invalidate the pending tree. |
| 191 pending_layer_->set_invalidation(invalidation); | 221 pending_layer_->set_invalidation(invalidation); |
| 192 pending_layer_->HighResTiling()->Invalidate(invalidation); | 222 pending_layer_->HighResTiling()->Invalidate(invalidation); |
| 193 pending_layer_->LowResTiling()->Invalidate(invalidation); | 223 pending_layer_->LowResTiling()->Invalidate(invalidation); |
| 194 | 224 |
| 195 active_layer_->ResetAllTilesPriorities(); | 225 active_layer_->ResetAllTilesPriorities(); |
| 196 pending_layer_->ResetAllTilesPriorities(); | 226 pending_layer_->ResetAllTilesPriorities(); |
| 197 | 227 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 active_layer_->LowResTiling()->AllTilesForTesting(); | 262 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 233 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 263 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 234 all_tiles.insert(active_low_res_tiles[i]); | 264 all_tiles.insert(active_low_res_tiles[i]); |
| 235 | 265 |
| 236 Tile* last_tile = NULL; | 266 Tile* last_tile = NULL; |
| 237 smoothness_tiles.clear(); | 267 smoothness_tiles.clear(); |
| 238 tile_count = 0; | 268 tile_count = 0; |
| 239 size_t correct_order_tiles = 0u; | 269 size_t correct_order_tiles = 0u; |
| 240 // Here we expect to get increasing ACTIVE_TREE priority_bin. | 270 // Here we expect to get increasing ACTIVE_TREE priority_bin. |
| 241 queue.Reset(); | 271 queue.Reset(); |
| 242 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); | 272 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| 273 RasterTilePriorityQueue::Type::ALL); | |
| 274 std::set<Tile*> actual_required_for_draw_tiles; | |
| 275 std::set<Tile*> actual_required_for_activation_tiles; | |
| 243 while (!queue.IsEmpty()) { | 276 while (!queue.IsEmpty()) { |
| 244 Tile* tile = queue.Top(); | 277 Tile* tile = queue.Top(); |
| 245 EXPECT_TRUE(tile); | 278 EXPECT_TRUE(tile); |
| 246 | 279 |
| 247 if (!last_tile) | 280 if (!last_tile) |
| 248 last_tile = tile; | 281 last_tile = tile; |
| 249 | 282 |
| 250 EXPECT_LE(last_tile->priority(ACTIVE_TREE).priority_bin, | 283 EXPECT_LE(last_tile->priority(ACTIVE_TREE).priority_bin, |
| 251 tile->priority(ACTIVE_TREE).priority_bin); | 284 tile->priority(ACTIVE_TREE).priority_bin); |
| 252 bool skip_updating_last_tile = false; | 285 bool skip_updating_last_tile = false; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 268 last_tile->priority(ACTIVE_TREE).resolution != | 301 last_tile->priority(ACTIVE_TREE).resolution != |
| 269 tile->priority(ACTIVE_TREE).resolution) { | 302 tile->priority(ACTIVE_TREE).resolution) { |
| 270 // Low resolution should come first. | 303 // Low resolution should come first. |
| 271 EXPECT_EQ(LOW_RESOLUTION, last_tile->priority(ACTIVE_TREE).resolution); | 304 EXPECT_EQ(LOW_RESOLUTION, last_tile->priority(ACTIVE_TREE).resolution); |
| 272 } | 305 } |
| 273 | 306 |
| 274 if (!skip_updating_last_tile) | 307 if (!skip_updating_last_tile) |
| 275 last_tile = tile; | 308 last_tile = tile; |
| 276 ++tile_count; | 309 ++tile_count; |
| 277 smoothness_tiles.insert(tile); | 310 smoothness_tiles.insert(tile); |
| 311 if (tile->required_for_draw()) | |
| 312 actual_required_for_draw_tiles.insert(tile); | |
| 313 if (tile->required_for_activation()) | |
| 314 actual_required_for_activation_tiles.insert(tile); | |
| 278 queue.Pop(); | 315 queue.Pop(); |
| 279 } | 316 } |
| 280 | 317 |
| 281 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 318 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 282 EXPECT_EQ(all_tiles, smoothness_tiles); | 319 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 283 // Since we don't guarantee increasing distance due to spiral iterator, we | 320 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 284 // should check that we're _mostly_ right. | 321 // should check that we're _mostly_ right. |
| 285 EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); | 322 EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); |
| 286 | 323 |
| 324 // Check that we have consistent required_for_activation tiles. | |
| 325 queue.Reset(); | |
| 326 host_impl_.BuildRasterQueue( | |
| 327 &queue, SMOOTHNESS_TAKES_PRIORITY, | |
| 328 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | |
| 329 required_for_activation_tiles.clear(); | |
| 330 while (!queue.IsEmpty()) { | |
| 331 Tile* tile = queue.Top(); | |
| 332 EXPECT_TRUE(tile->required_for_activation()); | |
| 333 required_for_activation_tiles.insert(tile); | |
| 334 queue.Pop(); | |
| 335 } | |
| 336 EXPECT_EQ(actual_required_for_activation_tiles, | |
|
danakj
2015/01/08 23:24:41
Can you EXPECT_NE(required_for_activation, all_til
vmpstr
2015/01/09 20:21:40
Done.
| |
| 337 required_for_activation_tiles); | |
| 338 | |
| 339 // Check that we have consistent required_for_draw tiles. | |
| 340 queue.Reset(); | |
| 341 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, | |
| 342 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | |
| 343 required_for_draw_tiles.clear(); | |
| 344 while (!queue.IsEmpty()) { | |
| 345 Tile* tile = queue.Top(); | |
| 346 EXPECT_TRUE(tile->required_for_draw()); | |
| 347 required_for_draw_tiles.insert(tile); | |
| 348 queue.Pop(); | |
| 349 } | |
| 350 EXPECT_EQ(actual_required_for_draw_tiles, required_for_draw_tiles); | |
|
danakj
2015/01/08 23:24:41
Can you EXPECT_NE(required_for_draw, all_tiles) ?
vmpstr
2015/01/09 20:21:40
Done.
| |
| 351 | |
| 287 std::set<Tile*> new_content_tiles; | 352 std::set<Tile*> new_content_tiles; |
| 288 last_tile = NULL; | 353 last_tile = NULL; |
| 289 size_t increasing_distance_tiles = 0u; | 354 size_t increasing_distance_tiles = 0u; |
| 290 // Here we expect to get increasing PENDING_TREE priority_bin. | 355 // Here we expect to get increasing PENDING_TREE priority_bin. |
| 291 queue.Reset(); | 356 queue.Reset(); |
| 292 host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); | 357 host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY, |
| 358 RasterTilePriorityQueue::Type::ALL); | |
| 293 tile_count = 0; | 359 tile_count = 0; |
| 294 while (!queue.IsEmpty()) { | 360 while (!queue.IsEmpty()) { |
| 295 Tile* tile = queue.Top(); | 361 Tile* tile = queue.Top(); |
| 296 EXPECT_TRUE(tile); | 362 EXPECT_TRUE(tile); |
| 297 | 363 |
| 298 if (!last_tile) | 364 if (!last_tile) |
| 299 last_tile = tile; | 365 last_tile = tile; |
| 300 | 366 |
| 301 EXPECT_LE(last_tile->priority(PENDING_TREE).priority_bin, | 367 EXPECT_LE(last_tile->priority(PENDING_TREE).priority_bin, |
| 302 tile->priority(PENDING_TREE).priority_bin); | 368 tile->priority(PENDING_TREE).priority_bin); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 318 new_content_tiles.insert(tile); | 384 new_content_tiles.insert(tile); |
| 319 ++tile_count; | 385 ++tile_count; |
| 320 queue.Pop(); | 386 queue.Pop(); |
| 321 } | 387 } |
| 322 | 388 |
| 323 EXPECT_EQ(tile_count, new_content_tiles.size()); | 389 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 324 EXPECT_EQ(high_res_tiles, new_content_tiles); | 390 EXPECT_EQ(high_res_tiles, new_content_tiles); |
| 325 // Since we don't guarantee increasing distance due to spiral iterator, we | 391 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 326 // should check that we're _mostly_ right. | 392 // should check that we're _mostly_ right. |
| 327 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); | 393 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); |
| 394 | |
| 395 // Check that we have consistent required_for_activation tiles. | |
| 396 queue.Reset(); | |
| 397 host_impl_.BuildRasterQueue( | |
| 398 &queue, NEW_CONTENT_TAKES_PRIORITY, | |
| 399 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | |
| 400 required_for_activation_tiles.clear(); | |
| 401 while (!queue.IsEmpty()) { | |
| 402 Tile* tile = queue.Top(); | |
| 403 EXPECT_TRUE(tile->required_for_activation()); | |
| 404 required_for_activation_tiles.insert(tile); | |
| 405 queue.Pop(); | |
| 406 } | |
| 407 EXPECT_EQ(actual_required_for_activation_tiles, | |
| 408 required_for_activation_tiles); | |
|
danakj
2015/01/08 23:24:40
ditto?
vmpstr
2015/01/09 20:21:40
Done.
| |
| 409 | |
| 410 // Check that we have consistent required_for_draw tiles. | |
| 411 queue.Reset(); | |
| 412 host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY, | |
| 413 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | |
| 414 required_for_draw_tiles.clear(); | |
| 415 while (!queue.IsEmpty()) { | |
| 416 Tile* tile = queue.Top(); | |
| 417 EXPECT_TRUE(tile->required_for_draw()); | |
| 418 required_for_draw_tiles.insert(tile); | |
| 419 queue.Pop(); | |
| 420 } | |
| 421 EXPECT_EQ(actual_required_for_draw_tiles, required_for_draw_tiles); | |
|
danakj
2015/01/08 23:24:40
moar ditto?
vmpstr
2015/01/09 20:21:40
Done.
| |
| 328 } | 422 } |
| 329 | 423 |
| 330 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { | 424 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { |
| 331 base::TimeTicks time_ticks; | 425 base::TimeTicks time_ticks; |
| 332 time_ticks += base::TimeDelta::FromMilliseconds(1); | 426 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 333 host_impl_.SetCurrentBeginFrameArgs( | 427 host_impl_.SetCurrentBeginFrameArgs( |
| 334 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 428 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 335 | 429 |
| 336 gfx::Size layer_bounds(1000, 1000); | 430 gfx::Size layer_bounds(1000, 1000); |
| 337 SetupDefaultTrees(layer_bounds); | 431 SetupDefaultTrees(layer_bounds); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 349 | 443 |
| 350 // Set a small viewport, so we have soon and eventually tiles. | 444 // Set a small viewport, so we have soon and eventually tiles. |
| 351 host_impl_.SetViewportSize(gfx::Size(200, 200)); | 445 host_impl_.SetViewportSize(gfx::Size(200, 200)); |
| 352 time_ticks += base::TimeDelta::FromMilliseconds(1); | 446 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 353 host_impl_.SetCurrentBeginFrameArgs( | 447 host_impl_.SetCurrentBeginFrameArgs( |
| 354 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 448 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 355 host_impl_.pending_tree()->UpdateDrawProperties(); | 449 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 356 | 450 |
| 357 RasterTilePriorityQueue queue; | 451 RasterTilePriorityQueue queue; |
| 358 host_impl_.SetRequiresHighResToDraw(); | 452 host_impl_.SetRequiresHighResToDraw(); |
| 359 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); | 453 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| 454 RasterTilePriorityQueue::Type::ALL); | |
| 360 EXPECT_FALSE(queue.IsEmpty()); | 455 EXPECT_FALSE(queue.IsEmpty()); |
| 361 | 456 |
| 362 // Get all the tiles that are NOW or SOON and make sure they are ready to | 457 // Get all the tiles that are NOW or SOON and make sure they are ready to |
| 363 // draw. | 458 // draw. |
| 364 std::vector<Tile*> all_tiles; | 459 std::vector<Tile*> all_tiles; |
| 365 while (!queue.IsEmpty()) { | 460 while (!queue.IsEmpty()) { |
| 366 Tile* tile = queue.Top(); | 461 Tile* tile = queue.Top(); |
| 367 if (tile->combined_priority().priority_bin >= TilePriority::EVENTUALLY) | 462 if (tile->combined_priority().priority_bin >= TilePriority::EVENTUALLY) |
| 368 break; | 463 break; |
| 369 | 464 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 384 host_impl_.SetViewportSize(layer_bounds); | 479 host_impl_.SetViewportSize(layer_bounds); |
| 385 SetupDefaultTrees(layer_bounds); | 480 SetupDefaultTrees(layer_bounds); |
| 386 | 481 |
| 387 EvictionTilePriorityQueue empty_queue; | 482 EvictionTilePriorityQueue empty_queue; |
| 388 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES); | 483 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| 389 EXPECT_TRUE(empty_queue.IsEmpty()); | 484 EXPECT_TRUE(empty_queue.IsEmpty()); |
| 390 std::set<Tile*> all_tiles; | 485 std::set<Tile*> all_tiles; |
| 391 size_t tile_count = 0; | 486 size_t tile_count = 0; |
| 392 | 487 |
| 393 RasterTilePriorityQueue raster_queue; | 488 RasterTilePriorityQueue raster_queue; |
| 394 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); | 489 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 490 RasterTilePriorityQueue::Type::ALL); | |
| 395 while (!raster_queue.IsEmpty()) { | 491 while (!raster_queue.IsEmpty()) { |
| 396 ++tile_count; | 492 ++tile_count; |
| 397 EXPECT_TRUE(raster_queue.Top()); | 493 EXPECT_TRUE(raster_queue.Top()); |
| 398 all_tiles.insert(raster_queue.Top()); | 494 all_tiles.insert(raster_queue.Top()); |
| 399 raster_queue.Pop(); | 495 raster_queue.Pop(); |
| 400 } | 496 } |
| 401 | 497 |
| 402 EXPECT_EQ(tile_count, all_tiles.size()); | 498 EXPECT_EQ(tile_count, all_tiles.size()); |
| 403 EXPECT_EQ(16u, tile_count); | 499 EXPECT_EQ(16u, tile_count); |
| 404 | 500 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 pending_child_layer->SetDrawsContent(true); | 677 pending_child_layer->SetDrawsContent(true); |
| 582 | 678 |
| 583 time_ticks += base::TimeDelta::FromMilliseconds(1); | 679 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 584 host_impl_.SetCurrentBeginFrameArgs( | 680 host_impl_.SetCurrentBeginFrameArgs( |
| 585 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 681 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 586 host_impl_.pending_tree()->UpdateDrawProperties(); | 682 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 587 | 683 |
| 588 std::set<Tile*> all_tiles; | 684 std::set<Tile*> all_tiles; |
| 589 size_t tile_count = 0; | 685 size_t tile_count = 0; |
| 590 RasterTilePriorityQueue raster_queue; | 686 RasterTilePriorityQueue raster_queue; |
| 591 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); | 687 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 688 RasterTilePriorityQueue::Type::ALL); | |
| 592 while (!raster_queue.IsEmpty()) { | 689 while (!raster_queue.IsEmpty()) { |
| 593 ++tile_count; | 690 ++tile_count; |
| 594 EXPECT_TRUE(raster_queue.Top()); | 691 EXPECT_TRUE(raster_queue.Top()); |
| 595 all_tiles.insert(raster_queue.Top()); | 692 all_tiles.insert(raster_queue.Top()); |
| 596 raster_queue.Pop(); | 693 raster_queue.Pop(); |
| 597 } | 694 } |
| 598 EXPECT_EQ(tile_count, all_tiles.size()); | 695 EXPECT_EQ(tile_count, all_tiles.size()); |
| 599 EXPECT_EQ(32u, tile_count); | 696 EXPECT_EQ(32u, tile_count); |
| 600 | 697 |
| 601 pending_layer_->ResetAllTilesPriorities(); | 698 pending_layer_->ResetAllTilesPriorities(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 EXPECT_EQ(tile_count, new_content_tiles.size()); | 883 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 787 EXPECT_EQ(all_tiles, new_content_tiles); | 884 EXPECT_EQ(all_tiles, new_content_tiles); |
| 788 } | 885 } |
| 789 | 886 |
| 790 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { | 887 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { |
| 791 const gfx::Size layer_bounds(1000, 1000); | 888 const gfx::Size layer_bounds(1000, 1000); |
| 792 host_impl_.SetViewportSize(layer_bounds); | 889 host_impl_.SetViewportSize(layer_bounds); |
| 793 SetupDefaultTrees(layer_bounds); | 890 SetupDefaultTrees(layer_bounds); |
| 794 | 891 |
| 795 RasterTilePriorityQueue queue; | 892 RasterTilePriorityQueue queue; |
| 796 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 893 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 894 RasterTilePriorityQueue::Type::ALL); | |
| 797 EXPECT_FALSE(queue.IsEmpty()); | 895 EXPECT_FALSE(queue.IsEmpty()); |
| 798 | 896 |
| 799 size_t tile_count = 0; | 897 size_t tile_count = 0; |
| 800 std::set<Tile*> all_tiles; | 898 std::set<Tile*> all_tiles; |
| 801 while (!queue.IsEmpty()) { | 899 while (!queue.IsEmpty()) { |
| 802 EXPECT_TRUE(queue.Top()); | 900 EXPECT_TRUE(queue.Top()); |
| 803 all_tiles.insert(queue.Top()); | 901 all_tiles.insert(queue.Top()); |
| 804 ++tile_count; | 902 ++tile_count; |
| 805 queue.Pop(); | 903 queue.Pop(); |
| 806 } | 904 } |
| 807 | 905 |
| 808 EXPECT_EQ(tile_count, all_tiles.size()); | 906 EXPECT_EQ(tile_count, all_tiles.size()); |
| 809 EXPECT_EQ(16u, tile_count); | 907 EXPECT_EQ(16u, tile_count); |
| 810 | 908 |
| 811 queue.Reset(); | 909 queue.Reset(); |
| 812 for (int i = 1; i < 10; ++i) { | 910 for (int i = 1; i < 10; ++i) { |
| 813 scoped_ptr<FakePictureLayerImpl> pending_layer = | 911 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 814 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); | 912 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); |
| 815 pending_layer->SetDrawsContent(true); | 913 pending_layer->SetDrawsContent(true); |
| 816 pending_layer->set_has_valid_tile_priorities(true); | 914 pending_layer->set_has_valid_tile_priorities(true); |
| 817 pending_layer_->AddChild(pending_layer.Pass()); | 915 pending_layer_->AddChild(pending_layer.Pass()); |
| 818 } | 916 } |
| 819 | 917 |
| 820 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 918 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 919 RasterTilePriorityQueue::Type::ALL); | |
| 821 EXPECT_FALSE(queue.IsEmpty()); | 920 EXPECT_FALSE(queue.IsEmpty()); |
| 822 | 921 |
| 823 tile_count = 0; | 922 tile_count = 0; |
| 824 all_tiles.clear(); | 923 all_tiles.clear(); |
| 825 while (!queue.IsEmpty()) { | 924 while (!queue.IsEmpty()) { |
| 826 EXPECT_TRUE(queue.Top()); | 925 EXPECT_TRUE(queue.Top()); |
| 827 all_tiles.insert(queue.Top()); | 926 all_tiles.insert(queue.Top()); |
| 828 ++tile_count; | 927 ++tile_count; |
| 829 queue.Pop(); | 928 queue.Pop(); |
| 830 } | 929 } |
| 831 EXPECT_EQ(tile_count, all_tiles.size()); | 930 EXPECT_EQ(tile_count, all_tiles.size()); |
| 832 EXPECT_EQ(16u, tile_count); | 931 EXPECT_EQ(16u, tile_count); |
| 833 } | 932 } |
| 834 | 933 |
| 835 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { | 934 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { |
| 836 const gfx::Size layer_bounds(1000, 1000); | 935 const gfx::Size layer_bounds(1000, 1000); |
| 837 host_impl_.SetViewportSize(layer_bounds); | 936 host_impl_.SetViewportSize(layer_bounds); |
| 838 SetupDefaultTrees(layer_bounds); | 937 SetupDefaultTrees(layer_bounds); |
| 839 | 938 |
| 840 RasterTilePriorityQueue raster_queue; | 939 RasterTilePriorityQueue raster_queue; |
| 841 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); | 940 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| 941 RasterTilePriorityQueue::Type::ALL); | |
| 842 EXPECT_FALSE(raster_queue.IsEmpty()); | 942 EXPECT_FALSE(raster_queue.IsEmpty()); |
| 843 | 943 |
| 844 size_t tile_count = 0; | 944 size_t tile_count = 0; |
| 845 std::set<Tile*> all_tiles; | 945 std::set<Tile*> all_tiles; |
| 846 while (!raster_queue.IsEmpty()) { | 946 while (!raster_queue.IsEmpty()) { |
| 847 EXPECT_TRUE(raster_queue.Top()); | 947 EXPECT_TRUE(raster_queue.Top()); |
| 848 all_tiles.insert(raster_queue.Top()); | 948 all_tiles.insert(raster_queue.Top()); |
| 849 ++tile_count; | 949 ++tile_count; |
| 850 raster_queue.Pop(); | 950 raster_queue.Pop(); |
| 851 } | 951 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 &client, settings.max_tiles_for_interest_area, | 998 &client, settings.max_tiles_for_interest_area, |
| 899 settings.skewport_target_time_in_seconds, | 999 settings.skewport_target_time_in_seconds, |
| 900 settings.skewport_extrapolation_limit_in_content_pixels); | 1000 settings.skewport_extrapolation_limit_in_content_pixels); |
| 901 | 1001 |
| 902 scoped_refptr<FakePicturePileImpl> pile = | 1002 scoped_refptr<FakePicturePileImpl> pile = |
| 903 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1003 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 904 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); | 1004 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); |
| 905 tiling->set_resolution(HIGH_RESOLUTION); | 1005 tiling->set_resolution(HIGH_RESOLUTION); |
| 906 | 1006 |
| 907 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); | 1007 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| 908 | |
| 909 TilingSetRasterQueue empty_queue; | |
| 910 EXPECT_TRUE(empty_queue.IsEmpty()); | |
| 911 | |
| 912 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1008 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 913 | |
| 914 // Sanity check. | 1009 // Sanity check. |
| 915 EXPECT_EQ(841u, all_tiles.size()); | 1010 EXPECT_EQ(841u, all_tiles.size()); |
| 916 | 1011 |
| 917 // The explanation of each iteration is as follows: | 1012 // The explanation of each iteration is as follows: |
| 918 // 1. First iteration tests that we can get all of the tiles correctly. | 1013 // 1. First iteration tests that we can get all of the tiles correctly. |
| 919 // 2. Second iteration ensures that we can get all of the tiles again (first | 1014 // 2. Second iteration ensures that we can get all of the tiles again (first |
| 920 // iteration didn't change any tiles), as well set all tiles to be ready to | 1015 // iteration didn't change any tiles), as well set all tiles to be ready to |
| 921 // draw. | 1016 // draw. |
| 922 // 3. Third iteration ensures that no tiles are returned, since they were all | 1017 // 3. Third iteration ensures that no tiles are returned, since they were all |
| 923 // marked as ready to draw. | 1018 // marked as ready to draw. |
| 924 for (int i = 0; i < 3; ++i) { | 1019 for (int i = 0; i < 3; ++i) { |
| 925 TilingSetRasterQueue queue(tiling_set.get(), false); | 1020 scoped_ptr<TilingSetRasterQueue> queue( |
| 1021 new TilingSetRasterQueueAll(tiling_set.get(), false)); | |
| 926 | 1022 |
| 927 // There are 3 bins in TilePriority. | 1023 // There are 3 bins in TilePriority. |
| 928 bool have_tiles[3] = {}; | 1024 bool have_tiles[3] = {}; |
| 929 | 1025 |
| 930 // On the third iteration, we should get no tiles since everything was | 1026 // On the third iteration, we should get no tiles since everything was |
| 931 // marked as ready to draw. | 1027 // marked as ready to draw. |
| 932 if (i == 2) { | 1028 if (i == 2) { |
| 933 EXPECT_TRUE(queue.IsEmpty()); | 1029 EXPECT_TRUE(queue->IsEmpty()); |
| 934 continue; | 1030 continue; |
| 935 } | 1031 } |
| 936 | 1032 |
| 937 EXPECT_FALSE(queue.IsEmpty()); | 1033 EXPECT_FALSE(queue->IsEmpty()); |
| 938 std::set<Tile*> unique_tiles; | 1034 std::set<Tile*> unique_tiles; |
| 939 unique_tiles.insert(queue.Top()); | 1035 unique_tiles.insert(queue->Top()); |
| 940 Tile* last_tile = queue.Top(); | 1036 Tile* last_tile = queue->Top(); |
| 941 have_tiles[last_tile->priority(ACTIVE_TREE).priority_bin] = true; | 1037 have_tiles[last_tile->priority(ACTIVE_TREE).priority_bin] = true; |
| 942 | 1038 |
| 943 // On the second iteration, mark everything as ready to draw (solid color). | 1039 // On the second iteration, mark everything as ready to draw (solid color). |
| 944 if (i == 1) { | 1040 if (i == 1) { |
| 945 TileDrawInfo& draw_info = last_tile->draw_info(); | 1041 TileDrawInfo& draw_info = last_tile->draw_info(); |
| 946 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1042 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 947 } | 1043 } |
| 948 queue.Pop(); | 1044 queue->Pop(); |
| 949 int eventually_bin_order_correct_count = 0; | 1045 int eventually_bin_order_correct_count = 0; |
| 950 int eventually_bin_order_incorrect_count = 0; | 1046 int eventually_bin_order_incorrect_count = 0; |
| 951 while (!queue.IsEmpty()) { | 1047 while (!queue->IsEmpty()) { |
| 952 Tile* new_tile = queue.Top(); | 1048 Tile* new_tile = queue->Top(); |
| 953 queue.Pop(); | 1049 queue->Pop(); |
| 954 unique_tiles.insert(new_tile); | 1050 unique_tiles.insert(new_tile); |
| 955 | 1051 |
| 956 TilePriority last_priority = last_tile->priority(ACTIVE_TREE); | 1052 TilePriority last_priority = last_tile->priority(ACTIVE_TREE); |
| 957 TilePriority new_priority = new_tile->priority(ACTIVE_TREE); | 1053 TilePriority new_priority = new_tile->priority(ACTIVE_TREE); |
| 958 EXPECT_LE(last_priority.priority_bin, new_priority.priority_bin); | 1054 EXPECT_LE(last_priority.priority_bin, new_priority.priority_bin); |
| 959 if (last_priority.priority_bin == new_priority.priority_bin) { | 1055 if (last_priority.priority_bin == new_priority.priority_bin) { |
| 960 if (last_priority.priority_bin == TilePriority::EVENTUALLY) { | 1056 if (last_priority.priority_bin == TilePriority::EVENTUALLY) { |
| 961 bool order_correct = last_priority.distance_to_visible <= | 1057 bool order_correct = last_priority.distance_to_visible <= |
| 962 new_priority.distance_to_visible; | 1058 new_priority.distance_to_visible; |
| 963 eventually_bin_order_correct_count += order_correct; | 1059 eventually_bin_order_correct_count += order_correct; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 true); | 1120 true); |
| 1025 | 1121 |
| 1026 gfx::Rect soon_rect = moved_viewport; | 1122 gfx::Rect soon_rect = moved_viewport; |
| 1027 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1123 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1028 | 1124 |
| 1029 // There are 3 bins in TilePriority. | 1125 // There are 3 bins in TilePriority. |
| 1030 bool have_tiles[3] = {}; | 1126 bool have_tiles[3] = {}; |
| 1031 Tile* last_tile = NULL; | 1127 Tile* last_tile = NULL; |
| 1032 int eventually_bin_order_correct_count = 0; | 1128 int eventually_bin_order_correct_count = 0; |
| 1033 int eventually_bin_order_incorrect_count = 0; | 1129 int eventually_bin_order_incorrect_count = 0; |
| 1034 for (TilingSetRasterQueue queue(tiling_set.get(), false); !queue.IsEmpty(); | 1130 scoped_ptr<TilingSetRasterQueue> queue( |
| 1035 queue.Pop()) { | 1131 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
| 1132 for (; !queue->IsEmpty(); queue->Pop()) { | |
| 1036 if (!last_tile) | 1133 if (!last_tile) |
| 1037 last_tile = queue.Top(); | 1134 last_tile = queue->Top(); |
| 1038 | 1135 |
| 1039 Tile* new_tile = queue.Top(); | 1136 Tile* new_tile = queue->Top(); |
| 1040 | 1137 |
| 1041 TilePriority last_priority = last_tile->priority(ACTIVE_TREE); | 1138 TilePriority last_priority = last_tile->priority(ACTIVE_TREE); |
| 1042 TilePriority new_priority = new_tile->priority(ACTIVE_TREE); | 1139 TilePriority new_priority = new_tile->priority(ACTIVE_TREE); |
| 1043 | 1140 |
| 1044 have_tiles[new_priority.priority_bin] = true; | 1141 have_tiles[new_priority.priority_bin] = true; |
| 1045 | 1142 |
| 1046 EXPECT_LE(last_priority.priority_bin, new_priority.priority_bin); | 1143 EXPECT_LE(last_priority.priority_bin, new_priority.priority_bin); |
| 1047 if (last_priority.priority_bin == new_priority.priority_bin) { | 1144 if (last_priority.priority_bin == new_priority.priority_bin) { |
| 1048 if (last_priority.priority_bin == TilePriority::EVENTUALLY) { | 1145 if (last_priority.priority_bin == TilePriority::EVENTUALLY) { |
| 1049 bool order_correct = last_priority.distance_to_visible <= | 1146 bool order_correct = last_priority.distance_to_visible <= |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1064 EXPECT_GT(eventually_bin_order_correct_count, | 1161 EXPECT_GT(eventually_bin_order_correct_count, |
| 1065 eventually_bin_order_incorrect_count); | 1162 eventually_bin_order_incorrect_count); |
| 1066 | 1163 |
| 1067 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1164 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1068 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1165 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1069 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1166 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1070 } | 1167 } |
| 1071 | 1168 |
| 1072 } // namespace | 1169 } // namespace |
| 1073 } // namespace cc | 1170 } // namespace cc |
| OLD | NEW |