| 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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 // If we have tiles left to raster for activation, and we don't allow | 1222 // If we have tiles left to raster for activation, and we don't allow |
| 1223 // activating without them, then skip activation and return early. | 1223 // activating without them, then skip activation and return early. |
| 1224 if (wait_for_all_required_tiles) | 1224 if (wait_for_all_required_tiles) |
| 1225 return; | 1225 return; |
| 1226 | 1226 |
| 1227 // Mark any required tiles that have not been been assigned memory after | 1227 // Mark any required tiles that have not been been assigned memory after |
| 1228 // reaching a steady memory state as OOM. This ensures that we activate/draw | 1228 // reaching a steady memory state as OOM. This ensures that we activate/draw |
| 1229 // even when OOM. Note that we can't reuse the queue we used for | 1229 // even when OOM. Note that we can't reuse the queue we used for |
| 1230 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have | 1230 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have |
| 1231 // evicted some tiles that would not be picked up by the old raster queue. | 1231 // evicted some tiles that would not be picked up by the old raster queue. |
| 1232 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1232 MarkTilesOutOfMemory(client_->BuildRasterQueue( |
| 1233 global_state_.tree_priority, | 1233 global_state_.tree_priority, |
| 1234 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 1234 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 1235 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1235 MarkTilesOutOfMemory(client_->BuildRasterQueue( |
| 1236 global_state_.tree_priority, | 1236 global_state_.tree_priority, |
| 1237 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 1237 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 1238 | 1238 |
| 1239 // TODO(vmpstr): Temporary check to debug crbug.com/642927. | 1239 // TODO(vmpstr): Temporary check to debug crbug.com/642927. |
| 1240 CHECK(tile_task_manager_); | 1240 CHECK(tile_task_manager_); |
| 1241 |
| 1241 DCHECK(IsReadyToActivate()); | 1242 DCHECK(IsReadyToActivate()); |
| 1242 DCHECK(IsReadyToDraw()); | 1243 DCHECK(IsReadyToDraw()); |
| 1243 // Signals notifier is already scheduled above in the same function. | 1244 // Signals notifier is already scheduled above in the same function. |
| 1244 signals_.ready_to_activate = need_to_signal_activate; | 1245 signals_.ready_to_activate = true; |
| 1245 signals_.ready_to_draw = need_to_signal_draw; | 1246 signals_.ready_to_draw = true; |
| 1246 } | 1247 } |
| 1247 | 1248 |
| 1248 bool TileManager::MarkTilesOutOfMemory( | 1249 void TileManager::MarkTilesOutOfMemory( |
| 1249 std::unique_ptr<RasterTilePriorityQueue> queue) const { | 1250 std::unique_ptr<RasterTilePriorityQueue> queue) const { |
| 1250 // Mark required tiles as OOM so that we can activate/draw without them. | 1251 // Mark required tiles as OOM so that we can activate/draw without them. |
| 1251 if (queue->IsEmpty()) | |
| 1252 return false; | |
| 1253 | |
| 1254 for (; !queue->IsEmpty(); queue->Pop()) { | 1252 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1255 Tile* tile = queue->Top().tile(); | 1253 Tile* tile = queue->Top().tile(); |
| 1256 if (tile->draw_info().IsReadyToDraw()) | 1254 if (tile->draw_info().IsReadyToDraw()) |
| 1257 continue; | 1255 continue; |
| 1258 tile->draw_info().set_oom(); | 1256 tile->draw_info().set_oom(); |
| 1259 client_->NotifyTileStateChanged(tile); | 1257 client_->NotifyTileStateChanged(tile); |
| 1260 } | 1258 } |
| 1261 return true; | |
| 1262 } | 1259 } |
| 1263 | 1260 |
| 1264 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { | 1261 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
| 1265 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); | 1262 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); |
| 1266 } | 1263 } |
| 1267 | 1264 |
| 1268 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 1265 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
| 1269 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); | 1266 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); |
| 1270 } | 1267 } |
| 1271 | 1268 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 all_tile_tasks_completed = false; | 1368 all_tile_tasks_completed = false; |
| 1372 did_notify_all_tile_tasks_completed = false; | 1369 did_notify_all_tile_tasks_completed = false; |
| 1373 } | 1370 } |
| 1374 | 1371 |
| 1375 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1372 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1376 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1373 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1377 PrioritizedWorkToSchedule&& other) = default; | 1374 PrioritizedWorkToSchedule&& other) = default; |
| 1378 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1375 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1379 | 1376 |
| 1380 } // namespace cc | 1377 } // namespace cc |
| OLD | NEW |