| 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/tile_manager.h" | 5 #include "cc/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const int kNumPendingRasterTasksPerThread = 2; | 32 const int kNumPendingRasterTasksPerThread = 2; |
| 33 | 33 |
| 34 // Determine bin based on three categories of tiles: things we need now, | 34 // Determine bin based on three categories of tiles: things we need now, |
| 35 // things we need soon, and eventually. | 35 // things we need soon, and eventually. |
| 36 cc::TileManagerBin BinFromTilePriority(const cc::TilePriority& prio) { | 36 cc::TileManagerBin BinFromTilePriority(const cc::TilePriority& prio) { |
| 37 | 37 |
| 38 // The amount of time for which we want to have prepainting coverage. | 38 // The amount of time for which we want to have prepainting coverage. |
| 39 const double prepainting_window_time_seconds = 1.0; | 39 const double prepainting_window_time_seconds = 1.0; |
| 40 const double backfling_guard_distance_pixels = 314.0; | 40 const double backfling_guard_distance_pixels = 314.0; |
| 41 | 41 |
| 42 // Explicitly limit how far ahead we will prepaint for low and non-low res. |
| 43 const double max_lores_paint_distance_pixels = 8192.0; |
| 44 const double max_hires_paint_distance_pixels = 4096.0; |
| 45 if (prio.resolution == cc::LOW_RESOLUTION) { |
| 46 if (prio.distance_to_visible_in_pixels > max_lores_paint_distance_pixels) |
| 47 return cc::NEVER_BIN; |
| 48 } |
| 49 else { |
| 50 if (prio.distance_to_visible_in_pixels > max_hires_paint_distance_pixels) |
| 51 return cc::NEVER_BIN; |
| 52 } |
| 53 |
| 42 if (prio.time_to_needed_in_seconds() == std::numeric_limits<float>::max()) | 54 if (prio.time_to_needed_in_seconds() == std::numeric_limits<float>::max()) |
| 43 return cc::NEVER_BIN; | 55 return cc::NEVER_BIN; |
| 44 | 56 |
| 45 if (prio.resolution == cc::NON_IDEAL_RESOLUTION) | 57 if (prio.resolution == cc::NON_IDEAL_RESOLUTION) |
| 46 return cc::EVENTUALLY_BIN; | 58 return cc::EVENTUALLY_BIN; |
| 47 | 59 |
| 48 if (prio.time_to_needed_in_seconds() == 0 || | 60 if (prio.time_to_needed_in_seconds() == 0 || |
| 49 prio.distance_to_visible_in_pixels < backfling_guard_distance_pixels) | 61 prio.distance_to_visible_in_pixels < backfling_guard_distance_pixels) |
| 50 return cc::NOW_BIN; | 62 return cc::NOW_BIN; |
| 51 | 63 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 int num_pending_tasks_; | 152 int num_pending_tasks_; |
| 141 | 153 |
| 142 DISALLOW_COPY_AND_ASSIGN(RasterThread); | 154 DISALLOW_COPY_AND_ASSIGN(RasterThread); |
| 143 }; | 155 }; |
| 144 | 156 |
| 145 ManagedTileState::ManagedTileState() | 157 ManagedTileState::ManagedTileState() |
| 146 : can_use_gpu_memory(false), | 158 : can_use_gpu_memory(false), |
| 147 can_be_freed(true), | 159 can_be_freed(true), |
| 148 resource_is_being_initialized(false), | 160 resource_is_being_initialized(false), |
| 149 contents_swizzled(false), | 161 contents_swizzled(false), |
| 150 need_to_gather_pixel_refs(true) { | 162 need_to_gather_pixel_refs(true), |
| 163 gpu_memmgr_stats_bin(NEVER_BIN) { |
| 151 } | 164 } |
| 152 | 165 |
| 153 ManagedTileState::~ManagedTileState() { | 166 ManagedTileState::~ManagedTileState() { |
| 154 DCHECK(!resource); | 167 DCHECK(!resource); |
| 155 DCHECK(!resource_is_being_initialized); | 168 DCHECK(!resource_is_being_initialized); |
| 156 } | 169 } |
| 157 | 170 |
| 158 TileManager::TileManager( | 171 TileManager::TileManager( |
| 159 TileManagerClient* client, | 172 TileManagerClient* client, |
| 160 ResourceProvider* resource_provider, | 173 ResourceProvider* resource_provider, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 292 |
| 280 TilePriority prio; | 293 TilePriority prio; |
| 281 if (smoothness_takes_priority) | 294 if (smoothness_takes_priority) |
| 282 prio = tile->priority(ACTIVE_TREE); | 295 prio = tile->priority(ACTIVE_TREE); |
| 283 else | 296 else |
| 284 prio = tile->combined_priority(); | 297 prio = tile->combined_priority(); |
| 285 | 298 |
| 286 mts.resolution = prio.resolution; | 299 mts.resolution = prio.resolution; |
| 287 mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds(); | 300 mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds(); |
| 288 mts.raster_bin = BinFromTilePriority(prio); | 301 mts.raster_bin = BinFromTilePriority(prio); |
| 302 mts.gpu_memmgr_stats_bin = BinFromTilePriority(tile->combined_priority()); |
| 289 } | 303 } |
| 290 | 304 |
| 291 // Memory limit policy works by mapping some bin states to the NEVER bin. | 305 // Memory limit policy works by mapping some bin states to the NEVER bin. |
| 292 TileManagerBin bin_map[NUM_BINS]; | 306 TileManagerBin bin_map[NUM_BINS]; |
| 293 if (global_state_.memory_limit_policy == ALLOW_NOTHING) { | 307 if (global_state_.memory_limit_policy == ALLOW_NOTHING) { |
| 294 bin_map[NOW_BIN] = NEVER_BIN; | 308 bin_map[NOW_BIN] = NEVER_BIN; |
| 295 bin_map[SOON_BIN] = NEVER_BIN; | 309 bin_map[SOON_BIN] = NEVER_BIN; |
| 296 bin_map[EVENTUALLY_BIN] = NEVER_BIN; | 310 bin_map[EVENTUALLY_BIN] = NEVER_BIN; |
| 297 bin_map[NEVER_BIN] = NEVER_BIN; | 311 bin_map[NEVER_BIN] = NEVER_BIN; |
| 298 } else if (global_state_.memory_limit_policy == ALLOW_ABSOLUTE_MINIMUM) { | 312 } else if (global_state_.memory_limit_policy == ALLOW_ABSOLUTE_MINIMUM) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 406 |
| 393 int TileManager::GetDrawableTilesInBinCount( | 407 int TileManager::GetDrawableTilesInBinCount( |
| 394 TileManagerBin bin, WhichTree tree) { | 408 TileManagerBin bin, WhichTree tree) { |
| 395 DCHECK(bin >= 0); | 409 DCHECK(bin >= 0); |
| 396 DCHECK(bin < NUM_BINS); | 410 DCHECK(bin < NUM_BINS); |
| 397 DCHECK(tree >= 0); | 411 DCHECK(tree >= 0); |
| 398 DCHECK(tree < NUM_TREES); | 412 DCHECK(tree < NUM_TREES); |
| 399 return drawable_tiles_in_bin_count_[bin][tree]; | 413 return drawable_tiles_in_bin_count_[bin][tree]; |
| 400 } | 414 } |
| 401 | 415 |
| 416 void TileManager::GetMemoryStats( |
| 417 size_t* memoryRequiredBytes, |
| 418 size_t* memoryNiceToHaveBytes, |
| 419 size_t* memoryUsedBytes) { |
| 420 *memoryRequiredBytes = 0; |
| 421 *memoryNiceToHaveBytes = 0; |
| 422 *memoryUsedBytes = 0; |
| 423 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 424 Tile* tile = *it; |
| 425 ManagedTileState& mts = tile->managed_state(); |
| 426 size_t tile_bytes = tile->bytes_consumed_if_allocated(); |
| 427 if (mts.gpu_memmgr_stats_bin == NOW_BIN) |
| 428 *memoryRequiredBytes += tile_bytes; |
| 429 if (mts.gpu_memmgr_stats_bin != NEVER_BIN) |
| 430 *memoryNiceToHaveBytes += tile_bytes; |
| 431 if (mts.can_use_gpu_memory) |
| 432 *memoryUsedBytes += tile_bytes; |
| 433 } |
| 434 } |
| 435 |
| 402 void TileManager::ResetBinCounts() { | 436 void TileManager::ResetBinCounts() { |
| 403 for (int i = 0; i < NUM_BINS; ++i) | 437 for (int i = 0; i < NUM_BINS; ++i) |
| 404 for (int j = 0; j < NUM_TREES; ++j) | 438 for (int j = 0; j < NUM_TREES; ++j) |
| 405 tiles_in_bin_count_[i][j] = drawable_tiles_in_bin_count_[i][j] = 0; | 439 tiles_in_bin_count_[i][j] = drawable_tiles_in_bin_count_[i][j] = 0; |
| 406 } | 440 } |
| 407 | 441 |
| 408 void TileManager::AssignGpuMemoryToTiles() { | 442 void TileManager::AssignGpuMemoryToTiles() { |
| 409 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); | 443 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); |
| 410 // Some memory cannot be released. Figure out which. | 444 // Some memory cannot be released. Figure out which. |
| 411 size_t unreleasable_bytes = 0; | 445 size_t unreleasable_bytes = 0; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 void TileManager::DidFinishTileInitialization(Tile* tile) { | 719 void TileManager::DidFinishTileInitialization(Tile* tile) { |
| 686 ManagedTileState& managed_tile_state = tile->managed_state(); | 720 ManagedTileState& managed_tile_state = tile->managed_state(); |
| 687 DCHECK(managed_tile_state.resource); | 721 DCHECK(managed_tile_state.resource); |
| 688 managed_tile_state.resource_is_being_initialized = false; | 722 managed_tile_state.resource_is_being_initialized = false; |
| 689 managed_tile_state.can_be_freed = true; | 723 managed_tile_state.can_be_freed = true; |
| 690 for (int i = 0; i < NUM_TREES; ++i) | 724 for (int i = 0; i < NUM_TREES; ++i) |
| 691 drawable_tiles_in_bin_count_[managed_tile_state.bin[i]][i]++; | 725 drawable_tiles_in_bin_count_[managed_tile_state.bin[i]][i]++; |
| 692 } | 726 } |
| 693 | 727 |
| 694 } | 728 } |
| OLD | NEW |