| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 | 269 |
| 270 void TileManager::CleanUpReleasedTiles() { | 270 void TileManager::CleanUpReleasedTiles() { |
| 271 std::vector<Tile*> tiles_to_retain; | 271 std::vector<Tile*> tiles_to_retain; |
| 272 for (auto* tile : released_tiles_) { | 272 for (auto* tile : released_tiles_) { |
| 273 if (tile->HasRasterTask()) { | 273 if (tile->HasRasterTask()) { |
| 274 tiles_to_retain.push_back(tile); | 274 tiles_to_retain.push_back(tile); |
| 275 continue; | 275 continue; |
| 276 } | 276 } |
| 277 | 277 |
| 278 DCHECK(!tile->HasResource()); | 278 DCHECK(!tile->draw_info().has_resource()); |
| 279 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 279 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 280 tiles_.erase(tile->id()); | 280 tiles_.erase(tile->id()); |
| 281 | 281 |
| 282 LayerCountMap::iterator layer_it = | 282 LayerCountMap::iterator layer_it = |
| 283 used_layer_counts_.find(tile->layer_id()); | 283 used_layer_counts_.find(tile->layer_id()); |
| 284 DCHECK_GT(layer_it->second, 0); | 284 DCHECK_GT(layer_it->second, 0); |
| 285 if (--layer_it->second == 0) { | 285 if (--layer_it->second == 0) { |
| 286 used_layer_counts_.erase(layer_it); | 286 used_layer_counts_.erase(layer_it); |
| 287 image_decode_tasks_.erase(tile->layer_id()); | 287 image_decode_tasks_.erase(tile->layer_id()); |
| 288 } | 288 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 | 576 |
| 577 void TileManager::FreeResourcesForTile(Tile* tile) { | 577 void TileManager::FreeResourcesForTile(Tile* tile) { |
| 578 TileDrawInfo& draw_info = tile->draw_info(); | 578 TileDrawInfo& draw_info = tile->draw_info(); |
| 579 if (draw_info.resource_) | 579 if (draw_info.resource_) |
| 580 resource_pool_->ReleaseResource(draw_info.resource_.Pass()); | 580 resource_pool_->ReleaseResource(draw_info.resource_.Pass()); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( | 583 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( |
| 584 Tile* tile) { | 584 Tile* tile) { |
| 585 bool was_ready_to_draw = tile->IsReadyToDraw(); | 585 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); |
| 586 FreeResourcesForTile(tile); | 586 FreeResourcesForTile(tile); |
| 587 if (was_ready_to_draw) | 587 if (was_ready_to_draw) |
| 588 client_->NotifyTileStateChanged(tile); | 588 client_->NotifyTileStateChanged(tile); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void TileManager::ScheduleTasks( | 591 void TileManager::ScheduleTasks( |
| 592 const PrioritizedTileVector& tiles_that_need_to_be_rasterized) { | 592 const PrioritizedTileVector& tiles_that_need_to_be_rasterized) { |
| 593 TRACE_EVENT1("cc", | 593 TRACE_EVENT1("cc", |
| 594 "TileManager::ScheduleTasks", | 594 "TileManager::ScheduleTasks", |
| 595 "count", | 595 "count", |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 bool TileManager::AreRequiredTilesReadyToDraw( | 776 bool TileManager::AreRequiredTilesReadyToDraw( |
| 777 RasterTilePriorityQueue::Type type) const { | 777 RasterTilePriorityQueue::Type type) const { |
| 778 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 778 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 779 client_->BuildRasterQueue(global_state_.tree_priority, type)); | 779 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 780 // It is insufficient to check whether the raster queue we constructed is | 780 // It is insufficient to check whether the raster queue we constructed is |
| 781 // empty. The reason for this is that there are situations (rasterize on | 781 // empty. The reason for this is that there are situations (rasterize on |
| 782 // demand) when the tile both needs raster and it's ready to draw. Hence, we | 782 // demand) when the tile both needs raster and it's ready to draw. Hence, we |
| 783 // have to iterate the queue to check whether the required tiles are ready to | 783 // have to iterate the queue to check whether the required tiles are ready to |
| 784 // draw. | 784 // draw. |
| 785 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 785 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 786 if (!raster_priority_queue->Top().tile()->IsReadyToDraw()) | 786 if (!raster_priority_queue->Top().tile()->draw_info().IsReadyToDraw()) |
| 787 return false; | 787 return false; |
| 788 } | 788 } |
| 789 | 789 |
| 790 #if DCHECK_IS_ON() | 790 #if DCHECK_IS_ON() |
| 791 scoped_ptr<RasterTilePriorityQueue> all_queue( | 791 scoped_ptr<RasterTilePriorityQueue> all_queue( |
| 792 client_->BuildRasterQueue(global_state_.tree_priority, type)); | 792 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 793 for (; !all_queue->IsEmpty(); all_queue->Pop()) { | 793 for (; !all_queue->IsEmpty(); all_queue->Pop()) { |
| 794 Tile* tile = all_queue->Top().tile(); | 794 Tile* tile = all_queue->Top().tile(); |
| 795 DCHECK_IMPLIES(tile->required_for_activation(), tile->IsReadyToDraw()); | 795 DCHECK_IMPLIES(tile->required_for_activation(), |
| 796 tile->draw_info().IsReadyToDraw()); |
| 796 } | 797 } |
| 797 #endif | 798 #endif |
| 798 return true; | 799 return true; |
| 799 } | 800 } |
| 800 bool TileManager::IsReadyToActivate() const { | 801 bool TileManager::IsReadyToActivate() const { |
| 801 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); | 802 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
| 802 return AreRequiredTilesReadyToDraw( | 803 return AreRequiredTilesReadyToDraw( |
| 803 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 804 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 804 } | 805 } |
| 805 | 806 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 result -= other; | 966 result -= other; |
| 966 return result; | 967 return result; |
| 967 } | 968 } |
| 968 | 969 |
| 969 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 970 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 970 return memory_bytes_ > limit.memory_bytes_ || | 971 return memory_bytes_ > limit.memory_bytes_ || |
| 971 resource_count_ > limit.resource_count_; | 972 resource_count_ > limit.resource_count_; |
| 972 } | 973 } |
| 973 | 974 |
| 974 } // namespace cc | 975 } // namespace cc |
| OLD | NEW |