| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // Adjust bin state based on if ready to draw. | 372 // Adjust bin state based on if ready to draw. |
| 373 active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin]; | 373 active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin]; |
| 374 pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin]; | 374 pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin]; |
| 375 combined_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][combined_bin]; | 375 combined_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][combined_bin]; |
| 376 | 376 |
| 377 // Adjust bin state based on if active. | 377 // Adjust bin state based on if active. |
| 378 active_bin = kBinIsActiveMap[tile_is_active][active_bin]; | 378 active_bin = kBinIsActiveMap[tile_is_active][active_bin]; |
| 379 pending_bin = kBinIsActiveMap[tile_is_active][pending_bin]; | 379 pending_bin = kBinIsActiveMap[tile_is_active][pending_bin]; |
| 380 combined_bin = kBinIsActiveMap[tile_is_active][combined_bin]; | 380 combined_bin = kBinIsActiveMap[tile_is_active][combined_bin]; |
| 381 | 381 |
| 382 mts.tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; | 382 ManagedTileBin tree_bin[NUM_TREES]; |
| 383 mts.tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; | 383 tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; |
| 384 tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; |
| 384 | 385 |
| 385 // The bin that the tile would have if the GPU memory manager had | 386 // The bin that the tile would have if the GPU memory manager had |
| 386 // a maximally permissive policy, send to the GPU memory manager | 387 // a maximally permissive policy, send to the GPU memory manager |
| 387 // to determine policy. | 388 // to determine policy. |
| 388 ManagedTileBin gpu_memmgr_stats_bin = NEVER_BIN; | 389 ManagedTileBin gpu_memmgr_stats_bin = NEVER_BIN; |
| 389 TilePriority tile_priority; | 390 TilePriority tile_priority; |
| 390 | 391 |
| 391 switch (tree_priority) { | 392 switch (tree_priority) { |
| 392 case SAME_PRIORITY_FOR_BOTH_TREES: | 393 case SAME_PRIORITY_FOR_BOTH_TREES: |
| 393 mts.bin = kBinPolicyMap[memory_policy][combined_bin]; | 394 mts.bin = kBinPolicyMap[memory_policy][combined_bin]; |
| 394 gpu_memmgr_stats_bin = combined_bin; | 395 gpu_memmgr_stats_bin = combined_bin; |
| 395 tile_priority = tile->combined_priority(); | 396 tile_priority = tile->combined_priority(); |
| 396 break; | 397 break; |
| 397 case SMOOTHNESS_TAKES_PRIORITY: | 398 case SMOOTHNESS_TAKES_PRIORITY: |
| 398 mts.bin = mts.tree_bin[ACTIVE_TREE]; | 399 mts.bin = tree_bin[ACTIVE_TREE]; |
| 399 gpu_memmgr_stats_bin = active_bin; | 400 gpu_memmgr_stats_bin = active_bin; |
| 400 tile_priority = active_priority; | 401 tile_priority = active_priority; |
| 401 break; | 402 break; |
| 402 case NEW_CONTENT_TAKES_PRIORITY: | 403 case NEW_CONTENT_TAKES_PRIORITY: |
| 403 mts.bin = mts.tree_bin[PENDING_TREE]; | 404 mts.bin = tree_bin[PENDING_TREE]; |
| 404 gpu_memmgr_stats_bin = pending_bin; | 405 gpu_memmgr_stats_bin = pending_bin; |
| 405 tile_priority = pending_priority; | 406 tile_priority = pending_priority; |
| 406 break; | 407 break; |
| 407 } | 408 } |
| 408 | 409 |
| 409 if (!tile_is_ready_to_draw || tile_version.requires_resource()) { | 410 if (!tile_is_ready_to_draw || tile_version.requires_resource()) { |
| 410 if ((gpu_memmgr_stats_bin == NOW_BIN) || | 411 if ((gpu_memmgr_stats_bin == NOW_BIN) || |
| 411 (gpu_memmgr_stats_bin == NOW_AND_READY_TO_DRAW_BIN)) | 412 (gpu_memmgr_stats_bin == NOW_AND_READY_TO_DRAW_BIN)) |
| 412 memory_required_bytes_ += BytesConsumedIfAllocated(tile); | 413 memory_required_bytes_ += BytesConsumedIfAllocated(tile); |
| 413 if (gpu_memmgr_stats_bin != NEVER_BIN) | 414 if (gpu_memmgr_stats_bin != NEVER_BIN) |
| 414 memory_nice_to_have_bytes_ += BytesConsumedIfAllocated(tile); | 415 memory_nice_to_have_bytes_ += BytesConsumedIfAllocated(tile); |
| 415 } | 416 } |
| 416 | 417 |
| 417 // Bump up the priority if we determined it's NEVER_BIN on one tree, | 418 // Bump up the priority if we determined it's NEVER_BIN on one tree, |
| 418 // but is still required on the other tree. | 419 // but is still required on the other tree. |
| 419 bool is_in_never_bin_on_both_trees = | 420 bool is_in_never_bin_on_both_trees = |
| 420 mts.tree_bin[ACTIVE_TREE] == NEVER_BIN && | 421 tree_bin[ACTIVE_TREE] == NEVER_BIN && |
| 421 mts.tree_bin[PENDING_TREE] == NEVER_BIN; | 422 tree_bin[PENDING_TREE] == NEVER_BIN; |
| 422 | 423 |
| 423 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) | 424 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) |
| 424 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; | 425 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; |
| 425 | 426 |
| 426 mts.resolution = tile_priority.resolution; | 427 mts.resolution = tile_priority.resolution; |
| 427 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; | 428 mts.time_to_needed_in_seconds = tile_priority.time_to_visible_in_seconds; |
| 428 mts.distance_to_visible_in_pixels = | 429 mts.distance_to_visible_in_pixels = |
| 429 tile_priority.distance_to_visible_in_pixels; | 430 tile_priority.distance_to_visible_in_pixels; |
| 430 mts.required_for_activation = tile_priority.required_for_activation; | 431 mts.required_for_activation = tile_priority.required_for_activation; |
| 431 | 432 |
| 432 mts.visible_and_ready_to_draw = | 433 mts.visible_and_ready_to_draw = |
| 433 mts.tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; | 434 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; |
| 434 | 435 |
| 435 if (mts.bin == NEVER_BIN) { | 436 if (mts.bin == NEVER_BIN) { |
| 436 FreeResourcesForTile(tile); | 437 FreeResourcesForTile(tile); |
| 437 continue; | 438 continue; |
| 438 } | 439 } |
| 439 | 440 |
| 440 // Note that if the tile is visible_and_ready_to_draw, then we always want | 441 // Note that if the tile is visible_and_ready_to_draw, then we always want |
| 441 // the priority to be NOW_AND_READY_TO_DRAW_BIN, even if HIGH_PRIORITY_BIN | 442 // the priority to be NOW_AND_READY_TO_DRAW_BIN, even if HIGH_PRIORITY_BIN |
| 442 // is something different. The reason for this is that if we're prioritizing | 443 // is something different. The reason for this is that if we're prioritizing |
| 443 // the pending tree, we still want visible tiles to take the highest | 444 // the pending tree, we still want visible tiles to take the highest |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 decode_tasks.Insert(decode_task); | 829 decode_tasks.Insert(decode_task); |
| 829 existing_pixel_refs[id] = decode_task; | 830 existing_pixel_refs[id] = decode_task; |
| 830 } | 831 } |
| 831 | 832 |
| 832 return RasterWorkerPool::CreateRasterTask( | 833 return RasterWorkerPool::CreateRasterTask( |
| 833 const_resource, | 834 const_resource, |
| 834 tile->picture_pile(), | 835 tile->picture_pile(), |
| 835 tile->content_rect(), | 836 tile->content_rect(), |
| 836 tile->contents_scale(), | 837 tile->contents_scale(), |
| 837 mts.raster_mode, | 838 mts.raster_mode, |
| 838 mts.tree_bin[PENDING_TREE] == NOW_BIN, | |
| 839 mts.resolution, | 839 mts.resolution, |
| 840 tile->layer_id(), | 840 tile->layer_id(), |
| 841 static_cast<const void *>(tile), | 841 static_cast<const void *>(tile), |
| 842 tile->source_frame_number(), | 842 tile->source_frame_number(), |
| 843 rendering_stats_instrumentation_, | 843 rendering_stats_instrumentation_, |
| 844 base::Bind(&TileManager::OnRasterTaskCompleted, | 844 base::Bind(&TileManager::OnRasterTaskCompleted, |
| 845 base::Unretained(this), | 845 base::Unretained(this), |
| 846 tile->id(), | 846 tile->id(), |
| 847 base::Passed(&resource), | 847 base::Passed(&resource), |
| 848 mts.raster_mode), | 848 mts.raster_mode), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 can_use_lcd_text)); | 936 can_use_lcd_text)); |
| 937 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 937 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
| 938 | 938 |
| 939 tiles_[tile->id()] = tile; | 939 tiles_[tile->id()] = tile; |
| 940 used_layer_counts_[tile->layer_id()]++; | 940 used_layer_counts_[tile->layer_id()]++; |
| 941 prioritized_tiles_dirty_ = true; | 941 prioritized_tiles_dirty_ = true; |
| 942 return tile; | 942 return tile; |
| 943 } | 943 } |
| 944 | 944 |
| 945 } // namespace cc | 945 } // namespace cc |
| OLD | NEW |